| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
In Python 3.10 the setDaemon method was deprecated. It is redundant
since the 'daemon' parameter can be given when creating the thread,
or the 'daemon' attribute can be set after it was created.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
|
| |
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
|
| |
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
|
|
|
|
| |
The remove function are supposed to return 0 on success and -1 on failure.
<https://libvirt.org/html/libvirt-libvirt-event.html#virEventRemoveTimeoutFunc>
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
| |
Replace getopt() and hand-rolled-parser with argparse.ArgumentParser.
Fix wrong header comments copy-pasted from domstart.py
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
| |
Assigning sys.exitfunc no longer works with Python 3.
Use atexit.register() instead.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
It only needed when a value is assigned.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
|
| |
python2 will be end of life by the time of the next
libvirt release. All our supported build targets, including
CentOS7, have a python3 build available.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
|
|
|
| |
Add the support to work with libvirt commit 66a85cb13.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
| |
VIR_DOMAIN_EVENT_ID_IO_ERROR and VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
callbacks receive the same 'action' parameter, so also translate that
numeric action to a descriptive text for the first callback.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ERROR_EVENTS translates the numeric 'action' argument to a description,
not the 'reason' argument which already contains a descriptive string
like 'enospc'.
> Traceback (most recent call last):
> File "/usr/lib/python2.7/dist-packages/libvirt.py", line 4661, in _dispatchDomainEventIOErrorReasonCallback
> reason, opaque)
> File "libvirt-python/examples/event-test.py", line 536, in myDomainEventIOErrorReasonCallback
> dom.name(), dom.ID(), srcpath, devalias, action, ERROR_EVENTS[reason]))
> File "libvirt-python/examples/event-test.py", line 474, in __getitem__
> data = self.args[item]
> TypeError: tuple indices must be integers, not str
Fixes: f5928c6711654f1496707ca77f626b3192843d57
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
Closer to pep8
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
| |
by directly building the list with the IDs instead of appending them
explicitly.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Registering the same function twice using the old domainEventRegister()
interface would not work, as the function reference is used for
un-registering.
But it is not a problem with the new interface domainEventRegisterAny(),
as that returns a unique ID.
While at it also demonstrate the 'opaque' mechanism.
Signed-off-by: Philipp Hahn <hahn@univention.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
|
|
|
| |
instead of sys.argv[0]
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
to fix loop termination on exit.
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
| |
variable is unused
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
| |
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 <hahn@univention.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add new events to prevent crash:
> Traceback (most recent call last):
> File "/usr/lib/python2.7/dist-packages/libvirt.py", line 4601, in _dispatchDomainEventCallbacks
> cb(self, virDomain(self, _obj=dom), event, detail, opaque)
> File "libvirt-python/examples/event-test.py", line 505, in myDomainEventCallback1
> domDetailToString(event, detail)))
> File "libvirt-python/examples/event-test.py", line 484, in domDetailToString
> return domEventStrings[event][detail]
> IndexError: tuple index out of range
Signed-off-by: Philipp Hahn <hahn@univention.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
https://bugzilla.redhat.com/show_bug.cgi?id=1578337
Since libvirt 3.8.0 we have 6 events: defined, undefined,
started, stopped, created, deleted. However, the last two were
missing in a string list that translates libvirt events (int)
into human readable strings.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
|
| |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
|
|
|
|
|
| |
This is particularly useful on operating systems that don't ship
Python as part of the base system (eg. FreeBSD) while still working
just as well as it did before on Linux.
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
|
|
|
| |
In commit a8eba5036cb4b0e2ec827e9e6e019ce70e451377, libvirt added
support for two more details. In python bindings it all worked fine
automagically except an example that was not updated.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1463188
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
|
|
|
|
| |
The event test program '--loop' arg is modified to take the name
of an event loop impl to run. eg 'event-test.py --loop asyncio'
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
| |
Use the name 'Poll' instead of 'Pure' for the event loop demo,
since there's now a second pure python loop impl available.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
|
|
| |
In order to test cleanup code paths we must unregister all callbacks
and close the connection on shutdown. Since cleanup happens in the
background, we do a short sleep to allow the main loop to run its
cleanup too.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
| |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
|
|
|
| |
The pure python event loop impl has to call
libvirt.virEventInvokeFreeCallback
to free the event opaque data from a clean stack context
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
| |
Unfortunately python doesn't generate those.
|
|
|
|
|
|
|
| |
With recent changes there are new events known to libvirt.
Reflect those changes in our event-test.py example script.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
Fixes copy-paste typo introduced by commit cb84e36c.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1354271
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
|
| |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|