If libvirtd terminates while event-test.py has an open connection to it, it will crash with the following traceback:
> myConnectionCloseCallback: qemu:///session: Error > Exception in thread libvirtEventLoop: > Traceback (most recent call last): > File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner > self.run() > File "/usr/lib/python2.7/threading.py", line 754, in run > self.__target(*self.__args, **self.__kwargs) > File "examples/event-test.py", line 424, in virEventLoopPollRun > eventLoop.run_loop() > File "examples/event-test.py", line 242, in run_loop > self.run_once() > File "examples/event-test.py", line 187, in run_once > libvirt.virEventInvokeFreeCallback(opaque) > AttributeError: 'module' object has no attribute 'virEventInvokeFreeCallback' > > libvirt: XML-RPC error : internal error: client socket is closed > Traceback (most recent call last): > File "examples/event-test.py", line 872, in <module> > main() > File "examples/event-test.py", line 854, in main > vc.secretEventDeregisterAny(id) > File "/usr/lib/python2.7/dist-packages/libvirt.py", line 4987, in > secretEventDeregisterAny > if ret == -1: raise libvirtError ('virConnectSecretEventDeregisterAny() > failed', conn=self) > libvirt.libvirtError: internal error: client socket is closed > Closing qemu:///session Skip unregistering the event callbacks and closing the connection if the connection is already broken / closed. Signed-off-by: Philipp Hahn <h...@univention.de> --- examples/event-test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/event-test.py b/examples/event-test.py index 04310e1..c17d2bb 100755 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -716,7 +716,8 @@ def main(): old_exitfunc = getattr(sys, 'exitfunc', None) def exit(): print("Closing " + vc.getURI()) - vc.close() + if run: + vc.close() if (old_exitfunc): old_exitfunc() sys.exitfunc = exit @@ -777,6 +778,11 @@ def main(): count = count + 1 time.sleep(1) + # If the connection was closed, we cannot unregister anything. + # Just abort now. + if not run: + return + vc.domainEventDeregister(myDomainEventCallback1) for id in seccallbacks: -- 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list