summaryrefslogtreecommitdiff
path: root/libvirt-override.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix sign compare offendersv9.1.0Michal Privoznik2023-02-131-10/+13
| | | | | | | | | | | | | | In a few places we compare signed and unsigned integers. In majority of cases it's because the iteration variable is declared as ssize_t but then in the for() loop it's compared against an unsigned int. But there is one case where the opposite happens (libvirt_virDomainSendKey()), or where an UINT_MAX (which is inherently unsigned) is compared against signed long. Also, use this opportunity to decrease scope of 'j' variable inside of libvirt_virDomainInterfaceAddresses(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Stop typecasting libvirt_intWrap() argumentsMichal Privoznik2023-02-131-35/+35
| | | | | | | There's no need to explicitly typecast arguments passed to libvirt_intWrap() as they are int or long already. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* libvirt-override: Don't typecast strlen() in debug printingsMichal Privoznik2023-02-131-2/+2
| | | | | | | | | | After some data was read from an incoming stream, we debug print their length using strlen() (assuming its text stream, not binary stream). Anyway, the debug format uses %d which then requires strlen() to be typecasted. Well, we can use %zu and drop the typecast. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* libvirt_virConnectOpenAuth: Avoid plain PyLong_AsLong() callMichal Privoznik2023-02-131-2/+4
| | | | | | | | | | | | | When constructing the list of credentials to pass to virConnectOpenAuth(), the virConnectAuth.credtype member is set via plain PyLong_AsLong() without any error checking. Well, the code relies on virConnectOpenAuth() to do sanity check of passed arguments. Switch to libvirt_intUnwrap() which does check for errors and avoid needless trip to libvirt's public API upon error. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* libvirt_virNodeGetInfo fixMichal Privoznik2023-02-131-1/+1
| | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* override: domain: Implement override for virDomainFDAssociatev9.0.0Peter Krempa2023-01-121-0/+56
| | | | | | | | 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>
* Fix memory leak in libvirt_virStreamRecv.Chris Gunn2022-10-101-2/+6
| | | | | | | | | 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>
* 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>
* Add an override impl for virDomainRestoreParams and virDomainSaveParamsv8.4.0Michal Privoznik2022-05-131-0/+89
| | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Add an override impl for virDomainSetLaunchSecurityStatev8.0.0Daniel P. Berrangé2022-01-051-0/+51
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Add support for domain event for memory device size changev7.9.0Daniel P. Berrangé2021-10-081-0/+60
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Add new autostart API for node devicesJonathon Jongsma2021-09-211-0/+29
| | | | | | | Provide a manual override for the virNodeDeviceGetAutostart() API modeled on what's done for the network and storage APIs. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
* Fix BlockThreshold Callback argument conversion once morev7.5.0Peter Krempa2021-06-251-1/+1
| | | | | | | | | | | The conversion was changed from "OssiiO" to "OssLLO". Unfortunately the arguments are unsigned long long, where the proper coversion character is 'K'. Fixes: https://gitlab.com/libvirt/libvirt-python/-/merge_requests/40 Fixes: fd069ac85c8cf1593587dc9287a3d5eb6bd4bdb9 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1976109 Signed-off-by: Peter Krempa <pkrempa@redhat.com>
* iothread: fix memory access out of boundsv7.4.0w005067502021-05-271-4/+8
| | | | | | | | | When the 'pcpu' is larger then the last 'iothr->cpumap' bits, set the list element to False to avoid out of bounds access 'iothr->cpumap'. Signed-off-by: suruifeng <suruifeng@huawei.com> Reviewed-by: Hogan Wang <hogan.wang@huawei.com>
* Fix wrong type for BlockThreshold Callbackv7.1.0renlei42021-03-011-1/+1
| | | | | | | | | | type of threshold and excess are unsigned long long, but PyObject_CallMethod incorrectly set it to int. if threshold or excess greater than 0x7FFFFFFF(max int), those variables will overflow. Signed-off-by: Ren Lei <ren.lei4@zte.com.cn>
* Add impl override for virDomainGetMessagesDaniel P. Berrangé2021-02-151-0/+46
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Avoid signed/unsigned warnings in loop over SSH keysDaniel P. Berrangé2020-12-031-2/+2
| | | | | | | | | libvirt-override.c: In function ‘libvirt_virDomainAuthorizedSSHKeysGet’: libvirt-override.c:10455:19: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare] 10455 | for (i = 0; i < nkeys; i++) | ^ Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Implement virDomainAuthorizedSSHKeys{Get,Set}Michal Privoznik2020-11-191-0/+96
| | | | | | | | Both APIs work with string lists (the getter returns it, the setter gets keys to set from it) -> represent that as a python list. The rest is kept as is in C. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Add support for memory failure event callbacksDaniel P. Berrangé2020-11-121-0/+61
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Replace deprecated PyEval_CallObject with PyObject_CallDaniel P. Berrangé2020-11-121-8/+8
| | | | | | | The former is deprecated since Python 3.9, and the latter has existed for all 3.x and probably before. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* debug: Fix bit-rot in debug outputPhilipp Hahn2020-07-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let the compiler optimize out the printf() call instead of doing it with the pre-processor as the later does not catch format string errors or the following case, where NULLSTR() is used but not defined: > libvirt-qemu-override.c: In function ‘libvirt_qemu_virConnectDomainQemuMonitorEventRegister’: > libvirt-qemu-override.c:271:34: warning: implicit declaration of function ‘NULLSTR’; did you mean ‘NULL’? [-Wimplicit-function-declaration] > 271 | pyobj_conn, pyobj_dom, NULLSTR(event), pyobj_cbData, flags); > | ^~~~~~~ > libvirt-qemu-override.c:39:28: note: in definition of macro ‘DEBUG’ > 39 | while (0) {printf(fmt, __VA_ARGS__);} > | ^~~~~~~~~~~ > libvirt-qemu-override.c:270:11: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Wformat=] > 270 | DEBUG("libvirt_qemu_virConnectDomainQemuMonitorEventRegister(%p %p %s %p %x) called\n", > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 271 | pyobj_conn, pyobj_dom, NULLSTR(event), pyobj_cbData, flags); > | ~~~~~~~~~~~~~~ > | | > | int > libvirt-qemu-override.c:39:23: note: in definition of macro ‘DEBUG’ > 39 | while (0) {printf(fmt, __VA_ARGS__);} > | ^~~ > libvirt-qemu-override.c:270:73: note: format string is defined here > 270 | DEBUG("libvirt_qemu_virConnectDomainQemuMonitorEventRegister(%p %p %s %p %x) called\n", > | ~^ > | | > | char * > | %d Copy the definition of NULLSTR from libvirt/src/internal.h to typewrappers.h Signed-off-by: Philipp Hahn <hahn@univention.de>
* Fix PY_SSIZE_T_CLEAN deprecation warningCole Robinson2020-07-061-9/+10
| | | | | | | | | | | | | | | | | | | | Seen running on fedora 32: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats ret = libvirtmod.virDomainLookupByUUID(self._o, uuid) This comes from here: https://bugs.python.org/issue36381 See the section about PY_SSIZE_T_CLEAN here: https://docs.python.org/3/c-api/arg.html#strings-and-buffers Solution is to use Py_ssize_t instead of int for unpacked '#' values, combined with defined PY_SSIZE_T_CLEAN before importing Python.h. The latter turns these deprecation warnings into runtime segfaults though if we missed an instance. I verified the virt-manager's test suite works fine after this change Signed-off-by: Cole Robinson <crobinso@redhat.com>
* Add overrides for network port UUID getter/lookup methodsDaniel P. Berrangé2020-01-031-0/+83
| | | | | | | The generator creates broken code for all these methods. Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Drop support for python 2Daniel P. Berrangé2019-12-041-41/+10
| | | | | | | | | 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>
* virDomainMigrate3Params: add missing parallel connections paramPavel Hrdina2019-09-231-0/+3
| | | | | | | | Introduced in libvirt 5.2.0 by commit <d3ea986af24>. Reported-by: Liping Cheng <lcheng@redhat.com> Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* virDomainMigrate3Params: add missing bandwidth postcopy paramPavel Hrdina2019-09-231-0/+3
| | | | | | | Introduced in libvirt 5.1.0 by commit <c830187a015>. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* Custom impl for virConnectSetIdentity which can't be generatedDaniel P. Berrangé2019-09-201-0/+64
| | | | | Reviewed-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* virDomainMemoryStats: include hugetlb pgalloc and pgfailPavel Hrdina2019-09-201-0/+8
| | | | | | | | | Introduced in libvirt 5.4.0 by commit <a699b19f6c3>. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1683516 Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* virDomainMemoryStats: include disk cachesPavel Hrdina2019-09-201-0/+5
| | | | | | | | | Introduced in libvirt 4.6.0 by commit <aee04655089>. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1683516 Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* Fix -Wsign-compare warningsCole Robinson2019-09-051-1/+1
| | | | | | | | | | | | libvirt-override.c: In function ‘libvirt_virConnectBaselineHypervisorCPU’: libvirt-override.c:9946:23: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare] libvirt-override.c:9961:19: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare] Use ssize_t as was similarly done in 75ec2acb6163b Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com>
* Implement virDomainGetGuestInfoMichal Privoznik2019-08-291-0/+36
| | | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* Add virDomainCheckpoint APIsEric Blake2019-07-291-0/+96
| | | | | | | | | Copies heavily from existing virDomainSnapshot handling, regarding what special cases the generator has to be taught and what overrides need to be written. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* Add missing impl of virNetworkListAllPortsDaniel P. Berrangé2019-06-201-0/+46
| | | | | | This API needs manual impl as the generator cannot cope Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Fix syntax error with missing ; and too many )Daniel P. Berrangé2019-06-201-1/+1
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Add support for virNetworkPort object & APIsDaniel P. Berrangé2019-06-201-0/+97
| | | | | | | | | Define the various rules in the generator to wire up methods into the virNetwork class and create the new virNetworkPort class. Reviewed-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Fix handling of optional params in blockCopy()Nir Soffer2019-03-121-1/+1
| | | | | | | | | | | | | | | | | Commit 2b4bd07e0a22 (Add check for params, nparams being a dictionary) changed the way the optional params argument is treated. If libvirt.virDomain.blockCopy() is called without specifying params, params is None, and the call will fail with: TypeError: block params must be a dictionary This is wrong as params is defined as kwarg, breaking existing libvirt users like oVirt. Add a check for Py_None, so we accept either a dict or None and fail with TypeError with anything else. Resolves: https://bugzilla.redhat.com/1687114 Signed-off-by: Nir Soffer <nsoffer@redhat.com>
* Fix virDomainPinIOThread typed params checkPavel Hrdina2019-02-251-1/+1
| | | | | | | | The VIR_DOMAIN_IOTHREAD_POLL_SHRINK is unsigned int. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1680546 Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* Fix copy paste error on the version check valueJohn Ferlan2018-11-201-2/+2
| | | | Signed-off-by: John Ferlan <jferlan@redhat.com>
* Implement API binding for virDomainSetIOThreadParamsJohn Ferlan2018-11-201-0/+54
| | | | | | | | Similar to libvirt_virDomainBlockCopy (and migration API's). Create the code for the new API. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
* Add check for params, nparams being a dictionaryJohn Ferlan2018-11-201-0/+13
| | | | | | | | If PyDict_Check fails, we should force an error rather than blindly continuing on. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
* Add missing virPyDictToTypedParams for libvirt_virDomainBlockCopyJohn Ferlan2018-11-201-0/+1
| | | | | | | | Need to free params like similar API's such as libvirt_virDomainMigrate3 and libvirt_virDomainMigrateToURI3. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
* Fix typos in virDomainSetSchedulerParameters nameJohn Ferlan2018-11-201-2/+2
| | | | | Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
* Add support for nwfilter binding objects / apisDaniel P. Berrangé2018-06-281-0/+51
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Add support for virNodeGetSEVInfoErik Skultety2018-06-141-0/+35
| | | | | | | | | | 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>
* Add support for virDomainGetLaunchSecurityInfoErik Skultety2018-06-141-0/+39
| | | | | | | | | 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>
* libvirt_charPtrUnwrap: remove unnecessary check of returned stringPavel Hrdina2018-06-121-8/+4
| | | | | | | | 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>
* libvirt-override: Reset exception if the error is ignoredPavel Hrdina2018-06-121-1/+3
| | | | | | | | 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>
* Add support for virConnectBaselineHypervisorCPUJiri Denemark2018-06-011-0/+60
| | | | | | | | | | 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>
* Fix build with older libvirt versionsDaniel P. Berrangé2018-04-191-0/+32
| | | | | | | | | | | | | | | | | | | | 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 314b2346df2d8e2d7d705b003c693b4fa0189bdf 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>
* Fix virPyDictToTypedParams type hint for block copy paramsPavel Hrdina2018-02-191-1/+1
| | | | | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>