summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Link libvirtmod_* modules also with libvirtv8.8.0Bastian Germann2022-09-091-2/+2
| | | | | | | 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>
* Replace uint with unsigned intBastian Germann2022-09-092-2/+2
| | | | | | Mingw-w64 target does not support uint definition. Signed-off-by: Bastian Germann <bage@linutronix.de>
* Post-release version bump to 8.8.0Jiri Denemark2022-09-011-1/+1
| | | | Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
* Post-release version bump to 8.7.0v8.7.0Jiri Denemark2022-08-011-1/+1
| | | | Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
* libvirt-utils: Clear error when guessing typed param typev8.6.0Michal Privoznik2022-07-081-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add VIR_DOMAIN_IOTHREAD_THREAD_POOL_{MIN,MAX} macrosMichal Privoznik2022-07-081-0/+4
| | | | | | | | | | | | | | 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>
* Post-release version bump to 8.6.0Jiri Denemark2022-07-011-1/+1
| | | | Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
* setup: make 'clean' command compatible again with distutilsv8.5.0Pino Toscano2022-06-251-0/+10
| | | | | | | | | | | | | | | | | | 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 a965c91c6fa1275613edbbef75c0422574eb9ff2 Signed-off-by: Pino Toscano <ptoscano@redhat.com>
* setup: advertize Python 3.9 and 3.10 supportDaniel P. Berrangé2022-06-081-0/+2
| | | | | | | Add classifiers that indicate we intend to support python versions 3.9 and 3.10. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* examples: remove use of deprecated setDaemon methodDaniel P. Berrangé2022-06-081-6/+10
| | | | | | | | 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>
* tests: expand AIO tests and add more commentsDaniel P. Berrangé2022-06-081-8/+40
| | | | | | | | | | | | | 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>
* tests: use mocks to allow calling virEventRegisterImpl many timesDaniel P. Berrangé2022-06-084-25/+102
| | | | | | | | | | | | | | 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>
* tests: add libvirtaio test coverageChris Gunn2022-06-083-1/+129
| | | | Signed-off-by: Chris Gunn <chrisgun@microsoft.com>
* libvirtaio: add better docs on best practice usage patternDaniel P. Berrangé2022-06-081-2/+21
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* libvirtio: lazy create the Event object in drain()Daniel P. Berrangé2022-06-081-5/+11
| | | | | | | | | | | | | | | | | | | | | 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>
* libvirtaio: convert to using 'async' / 'await' syntaxChris Gunn2022-06-081-9/+6
| | | | | | | | | | | | | 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>
* libvirtaio: drop back compat for python < 3.4.4Chris Gunn2022-06-081-11/+3
| | | | | | | | | | 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>
* Post-release version bump to 8.5.0Jiri Denemark2022-06-011-1/+1
| | | | Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
* Add an override impl for virDomainRestoreParams and virDomainSaveParamsv8.4.0Michal Privoznik2022-05-133-0/+105
| | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Post-release version bump to 8.4.0Jiri Denemark2022-05-021-1/+1
| | | | Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
* setup: switch to running API coverage test using pytestv8.3.0Daniel P. Berrangé2022-04-212-5/+0
| | | | | | The API coverage test is no longer a special case. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* sanitytest: skip tests when seeing broken lxml implementationDaniel P. Berrangé2022-04-211-2/+38
| | | | | | | | | | | | | | | | | 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>
* sanitytest: turn into a normal python unittestDaniel P. Berrangé2022-04-211-29/+25
| | | | | | | 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>
* sanitytest: move function/enum identification into a helper methodDaniel P. Berrangé2022-04-211-54/+59
| | | | | | | | | 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>
* sanitytest: move class identification into a helper methodDaniel P. Berrangé2022-04-211-34/+38
| | | | | | | | | 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>
* sanitytest: move initial class method mapping into a helper methodDaniel P. Berrangé2022-04-211-68/+72
| | | | | | | | | 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>
* sanitytest: move class method mapping fixup into a helper methodDaniel P. Berrangé2022-04-211-116/+120
| | | | | | | | | 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>
* sanitytest: move C to python API mapping check into a helper methodDaniel P. Berrangé2022-04-211-10/+12
| | | | | | | | | 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>
* sanitytest: move python to C API mapping check into a helper methodDaniel P. Berrangé2022-04-211-16/+17
| | | | | | | | | 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>
* sanitytest: move C API binding check into a helper methodDaniel P. Berrangé2022-04-211-18/+26
| | | | | | | | | 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>
* sanitytest: stop passing python module path into sanity testDaniel P. Berrangé2022-04-212-5/+1
| | | | | | | | | | | | | | | | | | 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 eaded7bdadf3ccdc4b208ec0ed65a1b23b8b5f69 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>
* sanitytest: stop passing API XML path into sanity testDaniel P. Berrangé2022-04-212-9/+2
| | | | | | | | | | | 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>
* setup: switch from distutils to setuptoolsDaniel P. Berrangé2022-04-211-4/+4
| | | | | | | | | 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>
* setup: remove use of distutils.util.get_platformDaniel P. Berrangé2022-04-211-15/+24
| | | | | | | | | | The 'get_platform' function is used to determine the platform specific component of the build output directory containing the loadable modules and python code. There is no nice replacement for this function, but we can achieve our goal by simply scaning for the desired subdirectory, which should exist by the time 'test' runs. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* setup: override 'build_ext' / 'build_py' commands rather than 'build'Daniel P. Berrangé2022-04-211-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | We override the 'build' command to invoke the code generator before the extensions are compiled. The 'build' command, however, is merely a wrapper around several other commands. It is possible for the user to directly invoke those commands, in which case our code generator won't get a chance to run: $ python setup.py build_ext running build_ext building 'libvirtmod' extension creating build/temp.linux-x86_64-3.10 creating build/temp.linux-x86_64-3.10/build gcc ..snip... -c build/libvirt.c -o build/temp.linux-x86_64-3.10/build/libvirt.o cc1: fatal error: build/libvirt.c: No such file or directory compilation terminated. error: command '/usr/lib64/ccache/gcc' failed with exit code 1 To solve this we instead override 'build_ext' and 'build_py'. This in turn means we call the generator to emit C code separately from Python code. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* setup: replace distutils.dir_util.remove_tree with shutilsDaniel P. Berrangé2022-04-211-2/+1
| | | | | | | The distutils.dir_util.remove_tree method has no compelling benefit over using the standard python shutils module. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* setup: replace distutils.spawn with subprocessDaniel P. Berrangé2022-04-211-16/+13
| | | | | | | The distutils.spawn method has no compelling benefit over using the standard python subprocess module. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* setup: replace distutils.spawn.find_executable with shutilsDaniel P. Berrangé2022-04-211-2/+1
| | | | | | | The distutils.spawn.find_executable method has no compelling benefit over using the standard python shutils module. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* setup: introduce an explicit check for pkg-config operationDaniel P. Berrangé2022-04-211-16/+16
| | | | | | | | Instead of searching for the pkg-config binary manually, just try to run it and catch the exception raised if it isn't found. Use the --version flag as a way to validate that it is at least somewhat functional. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* setup: stop inheriting from 'clean' commandDaniel P. Berrangé2022-04-211-4/+1
| | | | | | | | | The default 'clean' command impl deletes only intermediate files from the 'build' directory. We've overridden it to delete everything. There is no benefit in inheriting from the default impl, given our subclass will delete everything. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* setup: drop the 'rpm' commandDaniel P. Berrangé2022-04-211-21/+0
| | | | | | | This duplicates funtionality already provided by the 'bdist_rpm' command. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: introduce ability to selectively generate codeDaniel P. Berrangé2022-04-211-2/+8
| | | | | | | | Currently we always generate both the C code and Python code at the same time. To cope with following changes to the build process, we want to be able to generate C and Python separately. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: rename methods for code generationDaniel P. Berrangé2022-04-211-4/+4
| | | | | | The names make it clearer exactly what is being generated by each. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: split function skip logic out of C generatorDaniel P. Berrangé2022-04-211-29/+55
| | | | | | | | | | | | | | The python generator needs to know whether certain functions were skipped in the C generator. This is achieved by the C generator deleting skipped functions as it runs. This is an unhelpful side effect as it makes it impossible to run the python generator without first running the C generator. This refactors buildStubs to get rid of the global side effects it has, by providing some helper functions for buildWrappers to use. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: split function type validation out of C generatorDaniel P. Berrangé2022-04-211-29/+62
| | | | | | | | | | | As a side effect of generating the C code, the buildStubs methods checks for various unsupported types and reports errors. This is an undesirable side effect, if we want to skip C code generation. Splitting function type validation out into a separate method allows better reuse. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: split loading of APIs out from writing stubsDaniel P. Berrangé2022-04-211-4/+9
| | | | | | | | | | The buildStubs method has a side effect of loading and parsing the API XML files, which the buildWrappers method then relies on. Splitting API loading into a separate method will facilitate running only the buildWrappers method in future. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: merge python wrapper generator methodsDaniel P. Berrangé2022-04-212-232/+71
| | | | | | | Instead of having three separate methods for generating python wrappers, merge them all together. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: refactor buildWrappers to make it more genericDaniel P. Berrangé2022-04-212-21/+33
| | | | | | | Prepare for using buildWrappers to generate code for the QEMU / LXC APIs too. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: simplify some repeated code patternsDaniel P. Berrangé2022-04-211-56/+17
| | | | | | | | Now that we're using common data structures for all the main libvirt, QEMU and LXC APIs, several of the functions have code duplication that can be eliminated. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* generator: use single function for registering all enumsDaniel P. Berrangé2022-04-211-18/+7
| | | | | | | Now that we only use a single dict for tracking all enums, we only need a single function for registering them. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>