1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-07-17 00:59:36 +03:00
Commit Graph

885 Commits

Author SHA1 Message Date
e27528204c libvirtaio: Fix compat with python 3.7
In python 3.7, async is now a keyword, so this throws a syntax error:

  File "/usr/lib64/python3.7/site-packages/libvirtaio.py", line 49
    from asyncio import async as ensure_future
                            ^
  SyntaxError: invalid syntax

Switch to getattr trickery to accomplish the same goal

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-06-27 10:07:39 -04:00
6c136b8150 Add support for virNodeGetSEVInfo
This binding allows to query the AMD's SEV firmware for various platform
specific things, like a PDH certificate and a certificate chain to
establish a trusted connection with the firmware. Because the API uses
typed params, it's exempted from generation.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-14 17:23:19 +02:00
dbae262811 Add support for virDomainGetLaunchSecurityInfo
Libvirt recently introduced support for getting launch security
parameters, most notably AMD SEV VM memory measurement. This API can't
be generated as it's using typed parameters which we need to allocate.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-14 17:22:59 +02:00
a950b08317 libvirt_charPtrUnwrap: remove unnecessary check of returned string
Function libvirt_charPtrUnwrap() either fails or always sets the
unwrapped string so there is no need to check it explicitly.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2018-06-12 10:27:38 +02:00
0c2d0c9be9 libvirt-override: Reset exception if the error is ignored
In virConnectCredCallbackWrapper() we ignore the error case of
libvirt_charPtrUnwrap() function so we should also reset the exception.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2018-06-12 10:27:36 +02:00
181a30867a typewrappers: Fix libvirt_charPtrUnwrap to set an exception if it fails
If the function fails it should always set an exception.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2018-06-12 10:27:33 +02:00
fb70ad1599 libvirt-utils: remove unused py_str function
Commit <57a160b5248ba47d4e1c9d22d95847dad8e0524f> removed last usage
but did not remove the function itself.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2018-06-12 10:27:14 +02:00
c682257e6f Blacklist virGetLastError{Code,Domain}
These methods will not be exposed to apps, since we auto raise
all errors.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-06 16:49:32 +01:00
8099ca5ecb Release of libvirt-python-4.4.0
* setup.py: update for release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
v4.4.0
2018-06-04 22:35:30 +02:00
0f3f82e8be Add support for virConnectBaselineHypervisorCPU
The python bindings for this API cannot be generated because are
generator is not capable of handling string arrays (char **) parameters.

https://bugzilla.redhat.com/show_bug.cgi?id=1584676

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-01 08:16:48 +02:00
bae22e3eb7 event-test.py: Sync list of storage lifecycle events
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>
2018-05-22 14:22:46 +02:00
d23f8bc3a3 Allow virConnect to be used as a context manager
The libvirt python bindings are now more 'pythonic' as virConnect can
now be used as a context manager.

For example, it's possible to write the following code:

with libvirt.open() as conn:
    # do something with the connection...
    print(conn.listAllDomains())

At the end of this with-block the connection will be closed
automatically.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2018-05-16 10:40:46 +02:00
6f0456cdbc libvirt-override.py: remove unused import
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2018-05-16 10:40:46 +02:00
c84192fbd4 libvirt-override.py: fix sparseSendAll
Variable ret is used before assignment.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
2018-05-16 10:40:46 +02:00
318e305512 libvirt_qemu/lxc: fix a namespace issue
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2018-05-16 10:40:46 +02:00
0a07908e69 libvirt_qemu/lxc: import 'sys' package
This fixes the pylint [1] warning "E: 25,16: Undefined variable
'sys' (undefined-variable)".

[1] https://www.pylint.org/

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2018-05-16 10:40:46 +02:00
9bf6f3d46f maint: Drop autobuild.sh
The Test-AutoBuild project, that this script is supposed
to be used with, hasn't seen any activity in ~7 years;
these days, libvirt-python CI builds are happening on the
Jenkins-based CentOS CI environment under the libvirt
umbrella[1], and in that context the script is not used
at all.

[1] https://ci.centos.org/view/libvirt/

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 17:54:16 +02:00
41e0a95f50 git: add config file telling git-publish how to send patches
The "git-publish" tool is a useful git extension for sending patch
series for code review. It automatically creates versioned tags
each time code on a branch is sent, so that there is a record of
each version. It also remembers the cover letter so it does not
need re-entering each time the series is reposted.

With this config file present it is now sufficient[1] to run

  $ git publish

to send all patches in a branch to the list for review, with the
correct subject prefix added for this non-core libvirt module.

[1] Assuming your $HOME/.gitconfig has an SMTP server listed
at least e.g.

   [sendemail]
        smtpserver = smtp.example.com

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
v4.3.0
2018-04-24 10:46:59 +01:00
c99ed22847 Fix build with older libvirt versions
The libvirt python module is supposed to build with historical versions
of the API back to 0.9.1, which means all constants / methods must be
wrapped in conditionals. This was accidentally forgotten in:

  commit 314b2346df
  Author: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com>
  Date:   Wed Feb 7 17:49:30 2018 +0300

    Set hints for virPyDictToTypedParams

    Predefine hints for all parameters possible to avoid wrong type
    convert.

This broke the build against any libvirt < 2.0.0

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-19 16:07:19 +01:00
899dc23352 Post-release version bump to 4.3.0
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-03 14:27:25 +01:00
74eab13a2b Disable Python 2 on future RHEL and Fedora > 29
The end of Python 2 is nearing, so declare when it will be removed
from libvirt Python binding RPMs.

NB, this doesn't imply we'll be removing py2 support from upstream
libvirt-python on the same timeframe - we'll consider what todo
wrt that when upstream Python 2 finally goes EOL.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
v4.2.0
2018-03-23 15:18:51 +00:00
f9695b9b01 Post-release version bump to 4.2.0
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-05 15:09:24 +00:00
cdb2dcb4ea Release of libvirt-python 4.1.0
Signed-off-by: Daniel Veillard <veillard@redhat.com>
v4.1.0
2018-03-05 11:51:51 +01:00
b3f1a3adb0 Fix virPyDictToTypedParams type hint for block copy params
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2018-02-19 15:55:51 +01:00
7c43a863e9 Add missing virPyDictToTypedParams hint for migration params
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2018-02-19 15:55:48 +01:00
1d8852d9c4 Fix order of virPyDictToTypedParams hints
This corresponds to the order in libvirt-domain.h header file.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2018-02-19 15:55:45 +01:00
920be92397 Use static variables to store virPyDictToTypedParams hints
There is no need to have dynamic allocation every time the API
is called.  Rewrites commit <314b2346df>.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2018-02-19 15:55:28 +01:00
314b2346df Set hints for virPyDictToTypedParams
Predefine hints for all parameters possible to avoid wrong type
convert.

Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com>
2018-02-19 13:07:07 +00:00
b68b3ef399 tests: add special case for virStoragePoolLookupByTargetPath
This new API trips up the sanity test for checking mapping of
all C APIs into Python.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-02-09 13:54:47 +00:00
324197bfaa event-test.py: Remove extra ( in --help output
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2018-02-06 11:58:42 +01:00
99ee8a153c Release of libvirt-python-4.0.0 v4.0.0 2018-01-19 12:13:29 +01:00
6a9905cc97 Use python*_sitearch macros instead of manually defining the dir
Note we use python_sitearch not python2_sitearch, since the former
is more portable.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-12 18:16:01 +00:00
7cb4a80387 Fix filtering of RPM provides for .so files
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-12 18:15:57 +00:00
948d77335e Require libvirt native version matching py version by default
Although we're capable of building against any libvirt >= 0.9.11, 99% of the
time we want RPM builds to be done against matching libvirt version, otherwise
we might silently build against an unexpected/wrong version.

We don't support building against a native libvirt that's newer than the
python binding, since the generator may incorrectly handle new APIs. So use
== instead of >= too.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-12 18:15:54 +00:00
d11f4e4199 Turn on python3 sub-RPMs for RHEL > 7
It is expected that future RHEL-8 will have python3 by default, so enable that.
It is unclear whether python2 will still be available, so leave that enabled
for now.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-12 18:15:52 +00:00
8dfa907b2f Adapt to rename of py2 RPMs from python- to python2- prefix
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-12 18:15:50 +00:00
53a6d49660 Add emacs mode marker to activate rpm-spec highlighting
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-12 18:15:49 +00:00
f6ea01496a Add checks for min supported distros
Be clear about which distros we aim to support with the specfile, so we know
what we can cleanup in the spec later.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-12 18:15:45 +00:00
7cde26caa9 Allow override of which sub-RPMs to build
Allow using

  rpmbuild --define "with_python2 0"

to override the default logic about which python sub-RPMs to build

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-12 18:15:43 +00:00
ba234bd831 Allow disabling of python2 RPM build
With Fedora modularity, it is possible to have add-on repos for multiple
versions of python3. It is thus desirable to be able to build libvirt-python
in these repos, with only the python3 sub-RPMs enabled.

Thus also helps if future RHEL/Fedora drop python2 entirely from their default
repos.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2018-01-12 18:15:27 +00:00
85c371bd26 libvirt-python : PyObject memory leak
libvirt_virConnectDomainEventTunableCallback leak a PyObject.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
2017-12-11 13:32:28 +01:00
349951fc5e Release of libvirt-python 3.10.0 v3.10.0 2017-12-04 18:48:02 +01:00
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