1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2024-10-26 07:55:06 +03:00
Commit Graph

1265 Commits

Author SHA1 Message Date
Michal Privoznik
4d0e586061 typewrappers: Rework libvirt_uintWrap()
Python C API offers PyLong_FromUnsignedLong() which allows us to
drop typecast.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2023-02-13 14:51:11 +01:00
Michal Privoznik
f8fefdf45c typewrappers: Rework libvirt_uintUnwrap()
Python C API offers PyLong_AsUnsignedLong() which already raises
an exception on negative values. Rewrite our libvirt_uintUnwrap()
to use that and drop check for negative values.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2023-02-13 14:24:32 +01:00
Jiri Denemark
8ef7420806 Post-release version bump to 9.1.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-01-16 12:45:47 +01:00
Peter Krempa
c59d3232b7 override: domain: Implement override for virDomainFDAssociate
The bindings generator can't generate proper bindings for FD passing so
the bindings need to be implemented manually both the python wrapper and
the C backend.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2023-01-12 13:52:25 +01:00
Erik Skultety
d75be36877 ci: manifest: Define RPM artifacts for regular CentOS Stream 8 build
Commit 7360326 missed the fact that artifacts were only defined for the
libvirt Git type of libvirt-python build (git is cloned, libvirt is
built and then libvirt-python) based on the
'native_git_build_job_prebuilt_env' job template whereas libvirt CI
expects the RPM artifacts to come from a job based on the
'native_build_job' template instead.

Note that this patch is a hotfix to something which requires a proper
cleanup to stay consistent with the way we're handling the same thing
in libvirt-perl.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-01-06 15:58:57 +01:00
Erik Skultety
230589a837 .gitignore: Ignore more common Python build artifacts
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-01-06 10:19:13 +01:00
Erik Skultety
7360326272 ci: manifest: Define artifacts cache
After commit 6e0d4d53 we lost RPM artifacts cache breaking the whole
integration CI. The reason for that is that we manually defined the
artifacts cache in gitlab.yml instead of manifest.yml. Naturally with
the next lcitool update, gitlab.yml got overwritten according to
manifest.yml which didn't define any artifacts cache.

Fixes: 6e0d4d53d5

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-01-05 08:33:02 +01:00
Erik Skultety
68ee981379 ci: manifest: Replace 'expiry' with 'expire_in'
'expiry' isn't a keyword in lcitool anymore, the only reason why
everything has kept working despite lcitool updates is that lcitool
sets 'expire_in' to 2 days by default.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-01-05 08:28:12 +01:00
Erik Skultety
6e0d4d53d5 ci: Refresh and add Fedora 37 target
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2023-01-04 15:06:09 +01:00
Jiri Denemark
deabf3d88c Post-release version bump to 9.0.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-12-01 11:00:04 +01:00
Daniel P. Berrangé
082d69ee50 rpm: add explicit build dep on python3-setuptools
We previously got this implicitly via a dep from python3-pytest
so never noticed that it was missing. The implicit dep is going
away in rawhide real soon.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-11-23 12:24:29 +00:00
Jiri Denemark
42305fb615 Post-release version bump to 8.10.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-11-01 12:37:38 +01:00
Peter Krempa
5b5cd3dacc ci: Expose built RPMs as artifacts
Expose the artifacts from the centos-stream-8/9 and fedora 35/36 jobs so
that the main libvirt integration testing project can consume them.

The new libvirt sub-rpm containing a python helper to access QMP
directly requires python environment which we didn't yet install in the
integration job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2022-10-13 08:35:32 +00:00
Chris Gunn
9716b459ca Fix memory leak in libvirt_virStreamRecv.
The libvirt_virStreamRecv function uses a temporary allocated buffer to
receive data before copying the data into a Python byte array. But
there are some error paths where this buffer is not freed. This change
fixes that memory leak.

Signed-off-by: Chris Gunn <chrisgun@microsoft.com>
2022-10-10 13:36:18 -07:00
Erik Skultety
d9b9517cc3 ci: Fix the stage of the api-coverage job
The 'extends' stanza supports a list, however there's a merge algorithm
in place where a subsequent list entry overwrites all conflicting
settings from the previous one - which is exactly what happened here as
the gitlab-build-{local,prebuilt}-env job template overwrote
api-coverage's stage to 'builds' whereas the original was
'sanity_checks'.

Fixes: 4733e2a2d1

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2022-10-03 11:41:24 +02:00
Jiri Denemark
bf95d64c72 Post-release version bump to 8.9.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-10-03 08:56:38 +00:00
Daniel P. Berrangé
4733e2a2d1 ci: refresh with latest lcitool manifest
This refresh switches the CI for contributors to be triggered by merge
requests. Pushing to a branch in a fork will no longer run CI pipelines,
in order to avoid consuming CI minutes. To regain the original behaviour
contributors can opt-in to a pipeline on push

   git push <remote> -o ci.variable=RUN_PIPELINE=1

This variable can also be set globally on the repository, though this is
not recommended. Upstream repo pushes to branches will run CI.

The use of containers has changed in this update, with only the upstream
repo creating containers, in order to avoid consuming contributors'
limited storage quotas. A fork with existing container images may delete
them. Containers will be rebuilt upstream when pushing commits with CI
changes to the default branch. Any other scenario with CI changes will
simply install build pre-requisite packages in a throaway environment,
using the ci/buildenv/ scripts. These scripts may also be used on a
contributor's local machines.

With pipelines triggered by merge requests, it is also now possible to
workaround the inability of contributors to run pipelines if they have
run out of CI quota. A project member can trigger a pipeline from the
merge request, which will run in context of upstream, however, note
this should only be done after reviewing the code for any malicious
CI changes.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-09-30 12:24:31 -04:00
Bastian Germann
c2374d3f4e Link libvirtmod_* modules also with libvirt
The -lvirt linker flag has to be added to the libvirtmod_qemu and
libvirtmod_lxc modules as well.

Signed-off-by: Bastian Germann <bage@linutronix.de>
2022-09-09 17:28:51 +02:00
Bastian Germann
b4f1d3b4ee Replace uint with unsigned int
Mingw-w64 target does not support uint definition.

Signed-off-by: Bastian Germann <bage@linutronix.de>
2022-09-09 17:18:56 +02:00
Jiri Denemark
292da8384c Post-release version bump to 8.8.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-09-01 12:01:10 +02:00
Jiri Denemark
62681e1569 Post-release version bump to 8.7.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-08-01 09:40:54 +02:00
Michal Privoznik
3532ba2b8c libvirt-utils: Clear error when guessing typed param type
Our APIs which accept typed parameters are usually exposed in
python as accepting dictionary, for instance:

  virDomainSetIOThreadParams(..., virTypedParameterPtr params, ...) ->
  virDomain.setIOThreadParams(..., {}, ...)

Now, before calling the C API, the dictionary is processed by
virPyDictToTypedParams() which accepts an additional argument:
array that hints types for each typed parameter. However, if a
key is not in the array we guess what the correct type might be.
This is done by attempting conversion from python into string, if
that fails then into boolean, then into long, only to fall back
to double. Now, for the long type we can have two cases: the
value is non-negative (ULL) or it is negative (LL). Therefore, we
firstly attempt ULL case and if that fails we stick with the
latter.

However, after we attempted the ULL conversion, python records an
error internally (which is then queried via PyErr_Occurred()),
but the error is never cleared out. This leads to spurious paths
taken afterwards: e.g. when libvirt_longlongUnwrap() is trying to
convert -1, it fails. But not rightfully - the PyErr_Occurred()
check it performs has nothing to do with any of its actions,
rather than our guessing work done before.

Therefore, clear the error after we've guessed the type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-08 08:21:58 +02:00
Michal Privoznik
b943a5bd18 Add VIR_DOMAIN_IOTHREAD_THREAD_POOL_{MIN,MAX} macros
The python version of virDomainSetIOThreadParams
(setIOThreadParams()), expects two arguments on input: the thread
ID and a dictionary which is then translated into our typed
parameters. During this translation we use a helper array which
holds type for each typed parameter supported
(virPyDomainSetIOThreadParams[]). Otherwise we guess what the
correct type is. Now, when introducing
VIR_DOMAIN_IOTHREAD_THREAD_POOL_{MIN,MAX} typed params into
libvirt I forgot to update the array. Do that now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-08 08:18:15 +02:00
Jiri Denemark
2c8e159373 Post-release version bump to 8.6.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-07-01 11:27:50 +02:00
Pino Toscano
ba4db43f63 setup: make 'clean' command compatible again with distutils
After the switch of 'my_clean' to a simple Command, the 'clean' command
has no more bits for options, resulting in distutils (either external
or embedded in setuptools) complaining about it:

  distutils.errors.DistutilsClassError: command class <class '__main__.my_clean'> must provide 'user_options' attribute (a list of tuples)

To overcome that, provide all the standard bits from options, i.e. the
'user_options' list, and the 'initialize_options' & 'finalize_options'
methods. In addition, add a dummy 'all' option, as distutils wants it:

  error: error in [...]/.pydistutils.cfg: command 'my_clean' has no such option 'all'

Fixes commit a965c91c6f

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2022-06-25 06:38:30 +02:00
Daniel P. Berrangé
b34fbaf405 setup: advertize Python 3.9 and 3.10 support
Add classifiers that indicate we intend to support python versions
3.9 and 3.10.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-08 16:43:52 +01:00
Daniel P. Berrangé
693a93f85b examples: remove use of deprecated setDaemon method
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>
2022-06-08 16:43:52 +01:00
Daniel P. Berrangé
438b86fda1 tests: expand AIO tests and add more comments
Add a test for one more usage scenario that was possible in the past,
whereby libvirt events are registered before starting the asyncio
loop, but we let libvirt find the loop associated with the current
thread.

Skip the test relies on auto-creating an event loop with Python >= 3.10
since it now triggers a deprecation warning which will soon turn into a
RuntimeError.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-08 16:43:52 +01:00
Daniel P. Berrangé
e3fab09382 tests: use mocks to allow calling virEventRegisterImpl many times
We currently have to run each of the test_aio.py test cases in a
separate process, because libvirt.virEventRegisterImpl can only be
called once per process. This leads to quite unpleasant console
output when running tests.

By introducing a mock for libvirt.virEventRegisterImpl we can
regain the ability to run everything in a single process. The only
caveat is that it relies on tests to fully cleanup, but in practice
this is ok for our current tests.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-08 16:43:52 +01:00
Chris Gunn
b9f79758c9 tests: add libvirtaio test coverage
Signed-off-by: Chris Gunn <chrisgun@microsoft.com>
2022-06-08 16:43:52 +01:00
Daniel P. Berrangé
c2fae558c3 libvirtaio: add better docs on best practice usage pattern
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-08 16:43:52 +01:00
Daniel P. Berrangé
376a977659 libvirtio: lazy create the Event object in drain()
The drain method uses an asyncio.Event object to be notified when other
coroutines have removed all registered callbacks. The Event object needs
to be associated with the coroutine that the event loop is running with
and currently this is achieved by passing in the 'loop' parameter.

Unfortunately Python 3.10 has removed the 'loop' parameter and now the
object is associated implicitly with the current thread's event loop.
At the time the virEventAsyncIOImpl constructor is called, however,
there is no guarantee that an event loop has been set for the thread.
The explicitly passed in 'loop' parameter would handle this scenario.

For portability with Python >= 3.10 we need to delay creation of the
Event object until we have a guarantee that there is a loop associated
with the current thread. This is achieved by lazily creating the Event
object inside the 'drain' method, which is expected to be invoked from
coroutine context and thus ensure a loop is associated.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-08 16:43:52 +01:00
Chris Gunn
30f8123072 libvirtaio: convert to using 'async' / 'await' syntax
The 'async' keyword is new in Python 3.5, as a way to declare that a
method is a coroutine. This replaces the '@asyncio.coroutine' decorator
that is deprecated since 3.8 and scheduled to be removed in 3.11

The 'await' keyword has to be used instead of 'yield' from any
coroutines declared with 'async'.

Signed-off-by: Chris Gunn <chrisgun@microsoft.com>
[DB: Split off from a larger patch mixing multiple changes]
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-08 16:43:52 +01:00
Chris Gunn
ca3731a126 libvirtaio: drop back compat for python < 3.4.4
setup.py ensures we have python >= 3.5, so there is no need to do
back compat with the 'asyncio.ensure_future' method, which was new
in 3.4.4

Signed-off-by: Chris Gunn <chrisgun@microsoft.com>
[DB: Split off from a larger patch mixing multiple changes]
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-08 16:43:52 +01:00
Jiri Denemark
8a0e3f052b Post-release version bump to 8.5.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-06-01 09:31:33 +02:00
Michal Privoznik
c40c5f0cfc Add an override impl for virDomainRestoreParams and virDomainSaveParams
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-13 13:28:11 +02:00
Jiri Denemark
f27567e993 Post-release version bump to 8.4.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2022-05-02 13:38:10 +02:00
Daniel P. Berrangé
60044515a2 setup: switch to running API coverage test using pytest
The API coverage test is no longer a special case.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
6feb31a7a1 sanitytest: skip tests when seeing broken lxml implementation
The python lxml registers some global callbacks with libxml2. As a
result when another user of libxml2 calls APIs, it can trigger the
python callbacks that lxml previously registered. Execution of the
python callbacks in this case is often unsafe and leads to SEGVs.

This hasn't been a problem since the sanitytest.py test has been
a standalone program we execute. When it gets turned into a real
python unit test, it will run in the same process as all the other
tests and trigger the crash.

A mitigation was added in lxml 4.5.2 which is good enough to let
us continuing using lxml.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
3551c04ecb sanitytest: turn into a normal python unittest
The sanitytest.py file is now using the normal python unittest
pattern, though we invoke the one test explicitly for now.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
8cb4b852d1 sanitytest: move function/enum identification into a helper method
This is a step towards turning the sanitytest.py file into a normal
python unittest.

Best viewed with the '-b' flag to diff.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
9fb3a9b234 sanitytest: move class identification into a helper method
This is a step towards turning the sanitytest.py file into a normal
python unittest.

Best viewed with the '-b' flag to diff.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
f850a9f9e6 sanitytest: move initial class method mapping into a helper method
This is a step towards turning the sanitytest.py file into a normal
python unittest.

Best viewed with the '-b' flag to diff.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
4ae177d49c sanitytest: move class method mapping fixup into a helper method
This is a step towards turning the sanitytest.py file into a normal
python unittest.

Best viewed with the '-b' flag to diff.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
b29d0aaa26 sanitytest: move C to python API mapping check into a helper method
This is a step towards turning the sanitytest.py file into a normal
python unittest.

Best viewed with the '-b' flag to diff.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
87e62db6d3 sanitytest: move python to C API mapping check into a helper method
This is a step towards turning the sanitytest.py file into a normal
python unittest.

Best viewed with the '-b' flag to diff.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
45fa54ab67 sanitytest: move C API binding check into a helper method
This is a step towards turning the sanitytest.py file into a normal
python unittest.

Best viewed with the '-b' flag to diff.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
d4dfac2a43 sanitytest: stop passing python module path into sanity test
We want to move over to make sanitytest.py operate like a more normal
test script, which means making it self contained.

The setup.py already sets the PYTHONPATH thanks to changes introduced
in:

  commit eaded7bdad
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Tue Mar 18 11:11:48 2014 +0000

    Add support for running unit tests with nose

so passing the python module path into sanitytest.py is redundant.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
4e5d903fc3 sanitytest: stop passing API XML path into sanity test
We want to move over to make sanitytest.py operate like a more normal
test script, which means making it self contained.

The test already knows how to find the libvirt API XML path using
pkg-config and if an override location is required, this can be done
by pointing $PKG_CONFIG_PATH to a suitable place.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 15:00:29 +00:00
Daniel P. Berrangé
b0e9f12f2f setup: switch from distutils to setuptools
The distutils package is deprecated and targetted for deletion in Python
3.12, so we need to switch to setuptools. Thanks to all the preceeding
changes this is no more difficult than changing the import statements.

Closes https://gitlab.com/libvirt/libvirt-python/-/issues/1
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21 12:34:06 +01:00