1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-07-29 19:41:52 +03:00
Commit Graph

743 Commits

Author SHA1 Message Date
bedc937cce Don't hardcode interpreter path
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>
2017-11-30 08:48:36 +01:00
8018f0aa7e Release of libvirt-python-3.9.0 v3.9.0 2017-11-02 18:00:45 +01:00
9a93051c16 Unify whitespace around *_ALLOW_THREADS macros
Most of the code treats libvirt API calls as separate block, keeping one
blank line before the LIBVIRT_BEGIN_ALLOW_THREAD, and one blank line
after LIBVIRT_END_ALLOW_THREADS. Unify the whitespace so all calls
wrapped with these macros are treated as a separate block.
v3.8.0
2017-09-29 10:49:32 +01:00
7af7450b0a Release the GIL during virDomainGetMemoryStats & virDomainGetDiskErrors
We discovered that the entire python process get stuck for about 30
seconds when calling virDomain.getMemoryStats() if libvirt is stuck in
virConnect.getAllDomainStats() on inaccessible storage. This blocking
cause a horrible mess in oVirt.

This patches adds the standard *_ALLOW_THREADS around the call to avoid
this unwanted blocking.

Signed-off-by: Nir Soffer <nirsof@gmail.com>
2017-09-27 16:07:13 +01:00
ac8faf417e Avoid implicit treatment of an arithmetic result as a boolean
Latest GCC versions are unhappy with us treating an integer
arithmetic result as a boolean:

libvirt-utils.c: In function ‘virReallocN’:
libvirt-utils.c:111:23: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context]
     if (!tmp && (size * count)) {
                 ~~~~~~^~~~~~~~

Add an explicit comparison '!= 0' to keep it happy, since its
suggestion to use '&&' is nonsense.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-26 11:14:03 +01:00
75ec2acb61 Fix comparisons between signed & unsigned integers
When python3 builds C modules, it adds the -Wsign-compare flag to GCC.
This creates lots of warnings where we compare a 'size_t' value against
an 'int' value due to signed/unsigned difference.  Change all the size_t
types to ssize_t to address this.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-26 11:12:18 +01:00
f70939fc3e libvirtaio: add .drain() coroutine
The intended use is to ensure that the implementation is empty, which is
one way to ensure that all connections were properly closed and file
descriptors reclaimed.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
7f1994ff46 libvirtaio: keep track of the current implementation
Since 7534c19 it is not possible to register event implementation twice.
Instead, allow for retrieving the current one, should it be needed
afterwards.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
fc482fc868 libvirtaio: fix closing of the objects
- Descriptor.close() was a dead code, never used.
- TimeoutCallback.close(), as a cleanup function, should have called
    super() as last statement, not first

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
cc82a94528 libvirtaio: do not double-add callbacks
This was a harmless bug, without any impact, but it is wrong to manage
the collection of callbacks from it's members.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
a5cc6da2c8 libvirtaio: cache the list of callbacks when calling
When the callback causes something that results in changes wrt
registered handles, python aborts iteration.

Relevant error message:

    Exception in callback None()
    handle: <Handle cancelled>
    Traceback (most recent call last):
      File "/usr/lib64/python3.5/asyncio/events.py", line 126, in _run
        self._callback(*self._args)
      File "/usr/lib64/python3.5/site-packages/libvirtaio.py", line 99, in _handle
        for callback in self.callbacks.values():
    RuntimeError: dictionary changed size during iteration

QubesOS/qubes-issues#2805
Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
f7e5a9a085 libvirtaio: add more debug logging
This logging is helpful for tracing problems with unclosed connections
and leaking file descriptors.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-09-26 11:01:33 +01:00
6ee87778ab Add travis build config
Enable builds on several python versions, and against several versions
of libvirt. Ideally we would build all the way back to 0.9.11, since
that is the min supported libvirt for python binding. It is not possible
to build this old libvirt version on modern distros though, so using
1.2.0 as the oldest for now.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-19 16:11:23 +01:00
13b4283d58 Skip sparseRecvAll / sparseSendAll in sanity test
The sanity test check aims to ensure that every function listed in
the Python code maps to a corresponding C function. The Sparse
send/recv methods are special though - we're never calling the
corresponding C APIs, instead we have a pure python impl.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-18 12:59:42 +01:00
c1a8c6c105 Post-release version bump to 3.8.0
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-06 11:48:09 +01:00
7534c19a71 Report an error if registering an event loop twice
The C library will now ignore an attempt to register an event
loop twice. It is unable to report an error in this case though
due to the C API returning 'void'. To improve this we must
manually report an error at the python level.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-06 11:47:11 +01:00
57a160b524 Remove unused variables for event callbacks
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-06 11:47:02 +01:00
abce5971b2 Change Obsoletes to an explicit version
We only want to obsolete versions which actually had the
original name, not all future versions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-04 13:13:53 +01:00
4ed61cae8f Release of libvirt-python 3.7.0
* setup.py: updated for release
v3.7.0
2017-09-04 12:19:20 +02:00
213ee4d7ae Implement virDomainMigrateGetMaxDowntime
Add override code for virDomainMigrateGetMaxDowntime
2017-08-26 08:59:24 -04:00
100177c3dc Introduce virDomainMigrateGetMaxDowntime API
Introduce wrapper for virDomainMigrateGetMaxDowntime
2017-08-26 08:58:41 -04:00
49cb00a5eb Fix package name in description of sub-RPMs
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-08-10 12:12:24 +01:00
a2e3bb8ea7 Revert "rpm: assume python3 is always available"
This reverts commit b302b6d884.

Only drop the Fedora 18 test - RHEL must still build without
python 3
2017-08-10 12:11:40 +01:00
bbfea06114 rpm: rename packages to python2-libvirt / python3-libvirt
This complies with Fedora naming policy for python packages

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-08-10 10:36:26 +01:00
b302b6d884 rpm: assume python3 is always available
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-08-10 10:36:19 +01:00
a0e8d37e66 virDomainMemoryStats: include usable memory and last update
We've forgot to include VIR_DOMAIN_MEMORY_STAT_USABLE and
VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE constants.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-08-02 12:46:16 +02:00
853c1c85d5 Release of libvirt-python-3.6.0
virtually identical to 3.5.0 except for the bump of version in setup.py
v3.6.0
2017-08-02 10:05:27 +08:00
d736d3f5ea Release of libvirt-python-3.5.0
* setup.py: bump version number
v3.5.0
2017-07-04 22:39:03 +02:00
36430e115d Add details for shutdown event
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>
2017-06-20 16:31:14 +02:00
ecde5e5cd3 Release of libvirt-python-3.4.0 v3.4.0 2017-06-02 09:05:17 +02:00
ae94a895e4 Fix error check for virDomainGetTime method
The virDomainGetTime returns either a dict or None, but the python
glue layer for checking for '-1'. Thus it failed to raise an
exception on error.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-05-24 15:14:50 +01:00
9b98fe2d6f examples: Introduce sparsestream.py
Sparse streams are not that straight forward to use for the very
first time. Especially the sparseRecvAll() and sparseSendAll()
methods which expects callbacks. What we can do to make it easier
for developers is to have an example where they can take an
inspiration from.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-24 13:32:41 +02:00
d7e1c976f4 virStream: Introduce virStreamSparse{Recv,Send}All
Yet again, our parser is not capable of generating proper
wrapper. To be fair, this one wold be really tough anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-24 13:32:37 +02:00
2e4cb22122 virStream: Introduce virStreamRecvFlags
Yet again, we need a custom wrapper over virStreamRecvFlags
because our generator is not capable of generating it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-23 13:43:15 +02:00
1f42d8629f Implement virStreamSendHole/virStreamRecvHole
The return value for virStreamRecvHole is slightly different to
its C counterpart. In python, either it returns the hole size or
None if C API fails.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-23 13:43:12 +02:00
d8c880a10e Use better comparison in virStream.sendAll for Python 3
In Python 3, if the file is open in binary mode, @got will end up
being equal to b"" and b"" != "" in Python 3.
2017-05-17 09:33:46 +02:00
7695aa5a3b spec: Install egg-info with rpm package
This was being done due to now deprecated policy and that file should
be installed so that pip can recognize that the packages is already
installed in the system.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-15 17:58:25 +02:00
16e0892841 Release of libvirt-python-3.3.0 v3.3.0 2017-05-05 21:48:36 +02:00
58c4c12ce6 event-test: add ability to run the asyncio event loop
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>
2017-04-04 15:28:50 +01:00
1c6503b800 event-test: rename example event loop impl
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>
2017-04-04 15:28:50 +01:00
4cb0508048 event-test: unregister callbacks & close conn on exit
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>
2017-04-04 15:28:50 +01:00
6c8d625676 event-test: add timeout to exit event loop
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-04-04 15:28:50 +01:00
1770fa45b4 event-test: free opaque data when removing callbacks
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>
2017-04-04 15:28:50 +01:00
e985010674 Add asyncio event loop implementation
This is usable only on python >= 3.4 (or 3.3 with out-of-tree asyncio),
however it should be harmless for anyone with older python versions.

In simplest case, to have the callbacks queued on the default loop:

    >>> import libvirtaio
    >>> libvirtaio.virEventRegisterAsyncIOImpl()

The function is not present on non-compatible platforms.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
2017-04-04 15:28:50 +01:00
72e237f7b9 Allow for ff callbacks to be called by custom event implementations
The documentation says:
> If the opaque user data requires free'ing when the handle is
> unregistered, then a 2nd callback can be supplied for this purpose.
> This callback needs to be invoked from a clean stack. If 'ff'
> callbacks are invoked directly from the virEventRemoveHandleFunc they
> will likely deadlock in libvirt.

And they did deadlock. In removeTimeout too. Now we supply a custom
function to pick it from the opaque blob and fire.

Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-04-04 15:00:27 +01:00
069269e896 Release of libvirt-python-3.2.0
* setup.py: bumped version
v3.2.0
2017-04-02 17:08:59 +02:00
a927799334 event: Add handler for block threshold event
Unfortunately python doesn't generate those.
2017-03-29 16:59:39 +02:00
f261fd3e3c event: fix comment for _dispatchDomainEventMetadataChangeCallback
The comment was copied from the device removal failed event.
2017-03-29 16:58:59 +02:00
405f537bd0 Removed unused 'functions_list_exception_test' code from generator
The 'functions_list_exception_test' data structure and associated code
in the generator is inherited from libxml. This has never
been used in libvirt, so delete it to simplify the generator.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
v3.1.0
2017-01-27 09:58:40 +00:00
60f71591b9 Removed unused 'converter_type' code from generator
The 'converter_type' data structure and associated code
in the generator is inherited from libxml. This has never
been used in libvirt, so delete it to simplify the generator.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-01-27 09:58:40 +00:00