summaryrefslogtreecommitdiff
path: root/libvirt-override.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Return NULL if python exception is setPavel Hrdina2015-10-051-82/+61
| | | | | | | There is a rule, python API fails, it also in those cases sets an exception. We should follow those rules and in those cases return NULL. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* wrap lines to 80 columnsPavel Hrdina2015-10-051-53/+95
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* fix indentationPavel Hrdina2015-10-051-68/+57
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* indent labels by one spacePavel Hrdina2015-10-051-56/+56
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* cleanup functions definitionPavel Hrdina2015-10-051-99/+212
| | | | | | Follow the libvirt hacking guide and make the code consistent. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* Move utils and shared code into libvirt-utilsPavel Hrdina2015-10-051-413/+0
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* drop unnecessary gotoPavel Hrdina2015-10-051-12/+8
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* remove useless check for NULL before Py_XDECREFPavel Hrdina2015-10-051-6/+3
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* refactor the function to not override python exceptionsPavel Hrdina2015-10-051-16/+8
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* Check return value of PyList_AppendJiri Denemark2015-08-031-8/+38
| | | | | | | | | | | libvirt_virDomainGetSecurityLabelList called PyList_Append without checking its return value. While looking at it I noticed the function did not properly check several other return values either so I fixed them all. https://bugzilla.redhat.com/show_bug.cgi?id=1249511 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
* iothread: Fix crash if virDomainGetIOThreadInfo returns errorv1.2.18Peter Krempa2015-07-301-2/+4
| | | | | | | The cleanup portion of libvirt_virDomainGetIOThreadInfo would try to clean the returned structures but the count of iothreads was set to -1. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1248295
* virPyDictToTypedParams: packing lists of valuesv1.2.17Pavel Boldin2015-06-291-99/+129
| | | | | Pack a list or a tuple of values passed to a Python method to the multi-value parameter.
* Implement the DEVICE_ADDED eventJán Tomko2015-04-151-0/+57
|
* Expose virDomainInterfacesAddresses to python bindingv1.2.14Pavel Hrdina2015-03-281-0/+128
| | | | | | | | | | | | | | | | | | | | | examples/Makefile.am: * Add new file domipaddrs.py examples/README: * Add documentation for the python example libvirt-override-api.xml: * Add new symbol for virDomainInterfacesAddresses libvirt-override.c: * Hand written python api Example: $ python examples/domipaddrs.py qemu:///system f18 Interface MAC address Protocol Address vnet0 52:54:00:20:70:3d ipv4 192.168.105.240/16 Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* Rename virDomainGetIOThreadsInfo to virDomainGetIOThreadInfoJán Tomko2015-03-261-5/+5
|
* Rename virDomainIOThreadsInfoFree to virDomainIOThreadInfoFreeJán Tomko2015-03-261-1/+1
|
* Support virDomainPinIOThreadJohn Ferlan2015-03-111-0/+65
| | | | | | | | | | | | | | | | | | | | | | Support the libvirt_virDomainSetIOThreads method using code that mimics the existing libvirt_virDomainPinVcpuFlags method The following is a sample session assuming guest 'iothr-gst' has IOThreads configured (it's currently running, too) >>> import libvirt >>> con=libvirt.open("qemu:///system") >>> dom=con.lookupByName('iothr-gst') >>> dom.ioThreadsInfo() [(1, [False, False, True, False]), (2, [False, False, False, True]), (3, [True, True, True, True])] >>> cpumap=(True,True,True,False) >>> dom.pinIOThread(3,cpumap) 0 >>> print dom.ioThreadsInfo() [(1, [False, False, True, False]), (2, [False, False, False, True]), (3, [True, True, True, False])] >>> merge
* Support virDomainGetIOThreadsInfo and virDomainIOThreadsInfoFreeJohn Ferlan2015-03-111-0/+95
| | | | | | | | | | | | | | | | | | | | | | | Add support for the libvirt_virDomainGetIOThreadsInfo method. This code mostly follows the libvirt_virDomainGetVcpuPinInfo method, but also takes some from the libvirt_virNodeGetCPUMap method with respect to building the cpumap into the returned tuple rather than two separate tuples which vcpu pinning generates Assuming two domains, one with IOThreads defined (eg, 'iothr-gst') and one without ('noiothr-gst'), execute the following in an 'iothr.py' file: import libvirt con=libvirt.open("qemu:///system") dom=con.lookupByName('iothr-gst') print dom.ioThreadsInfo() dom2=con.lookupByName('noiothr-gst') print dom2.ioThreadsInfo() $ python iothr.py [(1, [False, False, True, False]), (2, [False, False, False, True]), (3, [True, True, True, True])] [] $
* build: make it easier to backport event idsEric Blake2015-01-151-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some cases, it is very easy for downstream distros to backport enum values without requiring a .so bump. Keying the conditional code off of the upstream version where the enum value was added is not ideal, because downstream then has to patch that the feature is available in their build that still reports an earlier version number. For example, if RHEL 7 backports events from 1.2.11 into a build based on 1.2.8, building the python bindings would warn: libvirt-override.c: In function ‘libvirt_virConnectDomainEventRegisterAny’: libvirt-override.c:6653:5: warning: enumeration value ‘VIR_DOMAIN_EVENT_ID_TUNABLE’ not handled in switch [-Wswitch] switch ((virDomainEventID) eventID) { ^ libvirt-override.c:6653:5: warning: enumeration value ‘VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE’ not handled in switch [-Wswitch] The solution is simple - use feature-based probes instead of version probes. Since we already scrape the XML API document of whatever libvirt build we are binding, and that XML already documents any downstream enum additions, we can use those as the features for gating conditional compilation. * generator.py (enum): Track event id names. (buildStubs): Output define wrappers for events. * libvirt-override.c (libvirt_virConnectDomainEventBalloonChangeCallback) (libvirt_virConnectDomainEventPMSuspendDiskCallback) (libvirt_virConnectDomainEventDeviceRemovedCallback) (libvirt_virConnectDomainEventTunableCallback) (libvirt_virConnectDomainEventAgentLifecycleCallback) (libvirt_virConnectDomainEventRegisterAny): Use them. Signed-off-by: Eric Blake <eblake@redhat.com>
* override: iterate virDomainFSInfo.devAliases using ndevAliasesTomoki Sekiyama2014-12-021-3/+4
| | | | | | | | Currently devAliases in virDomainFSInfo struct are iterated as a NULL-terminated list, but that is not guaranteed. It should use ndevAliases which stores the number of the items in devAliases. Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
* event: Add bindings for agent lifecycle eventPeter Krempa2014-11-241-0/+60
| | | | Also add the example.
* override: Implement bindings for virDomainGetFSInfo as domain.fsInfoTomoki Sekiyama2014-11-241-0/+70
| | | | | | | Implement the function which returns a list of tuples, that contains members of virDomainFSInfo struct. Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
* Add dict check for setTime and allow pass 'seconds' parameterLuyao Huang2014-11-111-15/+22
| | | | | | | | | | When pass None or a empty dictionary to time, it will report error. This commit allows a one-element dictionary which contains just 'seconds' field, which results in the same as passing 0 for 'nseconds' field. Moreover, dict is checked for unknown fields. Signed-off-by: Luyao Huang <lhuang@redhat.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Check return value of libvirt_uintUnwrapJiri Denemark2014-11-061-1/+2
| | | | | | | | libvirt_virDomainSendKey didn't check whether libvirt_uintUnwrap succeeded or not. https://bugzilla.redhat.com/show_bug.cgi?id=1161039 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
* virDomainBlockCopy: initialize flags to 0Pavel Hrdina2014-10-221-1/+1
| | | | | | | An optional argument if not passed isn't modified by the PyArg_ParseTuple function. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* flags cannot get right value for blockCopy functionPavel Hrdina2014-10-221-2/+1
| | | | | | | | | | | When use blockCopy, flags cannot get a right value, because PyArg_ParseTuple want to get 6 parameters and blockCopy only pass 5. Flags will get a unpredictable value, this will make the function fail with error: unsupported flags (0x7f6c) in function qemuDomainBlockCopy Signed-off-by: Luyao Huang <lhuang@redhat.com>
* Fix rest of unsigned integer handlingPeter Krempa2014-10-221-64/+64
| | | | | As in the previous patch, fix all places where 'flags' is converted as a signed argument to unsigned including the python code generator.
* Fix parsing of 'flags' argument for bulk stats functionsLuyao Huang2014-10-221-2/+2
| | | | | | | | | | | | | | | | | | | | When 'flags' is set to 'libvirt.VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, python will report a error: OverflowError: signed integer is greater than maximum as VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS is defined as 1<<31. This happens as PyArg_ParseTuple's formatting string containing 'i' as a modifier expects a signed integer. With python >= 2.3, 'I' means unsigned int and 'i' means int so we should use 'I' in the formatting string. See: https://docs.python.org/2/c-api/arg.html Signed-off-by: Luyao Huang <lhuang@redhat.com> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
* Fix function name when parsing arguments in libvirt_virNodeAllocPagesPeter Krempa2014-10-221-1/+1
| | | | | | The override function was copied&pasted from virConnectGetAllDomainStats and the function name after the colon was not changed. Fix the issue as an invalid name would appear in the error message.
* Improve error output when use getTime with a nonzero flags.Luyao Huang2014-10-201-1/+3
| | | | | | | | When give a nonzero flags to getTime, c_retval will get -1 and goto cleanup. But py_retval still is NULL, so set py_retval = VIR_PY_NONE. This will make the output message more correct. Signed-off-by: Luyao Huang <lhuang@redhat.com>
* Change the comment in getPyNodeCPUCount method reflecting correct called methodsPradipta Kr. Banerjee2014-10-161-2/+2
| | | | | | | | Comment mentions virGetNodeCPUMap whereas the actual method is virNodeGetCPUMap. Similarly comment mentions virGetNodeInfo whereas the actual method is virNodeGetInfo Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
* implement new tunable eventv1.2.9Pavel Hrdina2014-09-301-0/+64
| | | | | | Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1147639 Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* Implement new virNodeAllocPages APIMichal Privoznik2014-09-261-0/+67
| | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* override: Fix two uninitialized variables in convertDomainStatsRecordPeter Krempa2014-09-021-2/+2
| | | | | | | | py_record_domain and py_record_stats would be accessed uninitialized if an out-of-memory condition would happen in the first loop. Unlikely, but coverity complained. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1136354
* libvirt-override: fix some build warningsPavel Hrdina2014-09-021-3/+0
| | | | | | | | Remove unused label 'cleanup' in 'libvirt_virConnectGetAllDomainStats' function and remove unused variable 'conn' in function 'libvirt_virDomainListGetStats'. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* Implement API bindings for virDomainBlockCopyv1.2.8Pavel Hrdina2014-09-021-0/+35
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* API: Implement bindings for virDomainListGetStatsPavel Hrdina2014-09-011-0/+52
| | | | | | | | Implement the function by returning a list of tuples instead the array of virDomainStatsRecords and store the typed parameters as dict. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* API: Implement bindings for virConnectGetAllDomainStatsPeter Krempa2014-09-011-0/+95
| | | | | | | | Implement the function by returning a list of tuples instead the array of virDomainStatsRecords and store the typed parameters as dict. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* Fix libvirt_longlongWrap returning a very large valueZhou Yimin2014-08-111-9/+9
| | | | | | | | | | | | | | | | If hypervisor is not Xen, the errs in struct _virDomainBlockStats will be -1. But in KVM when we call domain.blockStats(), errs is 18446744073709551615. To fix that, this patch has two changes: 1. Replace use of the PyLong_FromUnsignedLongLong with PyLong_FromLongLong in function libvirt_longlongWrap 2. If the paramemter of libvirt_longlongWrap is unsigned long long, use libvirt_ulonglongWrap instead because of above change. After this patch, errs is -1 which is consistent with virDomainBlockStats api. Signed-off-by: Zhou Yimin <zhouyimin@huawei.com> Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
* Implement new virNetworkGetDHCPLeases APIv1.2.6-rc2v1.2.6Nehal J Wani2014-06-271-0/+88
| | | | | | | | | | | | | | | | This API returns a list of DHCP leases for all network interfaces connected to the given virtual network or limited output just for one interface if mac is specified. Example Output: [{'iface': 'virbr3', 'ipaddr': '192.168.150.181', 'hostname': 'ubuntu14', 'expirytime': 1403737495L, 'prefix': 24, 'clientid': None, 'mac': '52:54:00:e8:73:eb', 'iaid': None, 'type': 0}, {'iface': 'virbr3', 'ipaddr': '2001:db8:ca2:2:1::bd', 'hostname': 'fedora20-test', 'expirytime': 1403738587L, 'prefix': 64, 'clientid': '00:04:b1:d8:86:42:e1:6a:aa:cf:d5:86:94:23:6f:94:04:cd', 'mac': '52:54:00:5b:40:98', 'iaid': '5980312', 'type': 1}] Signed-off-by: Peter Krempa <pkrempa@redhat.com>
* build: use correct int conversion in NodeGetFreePagesNehal J Wani2014-06-251-1/+1
| | | | | | | | | | | | | | | | | | Commit c8ba859bc7 introduced a compiler warning while un-wrapping a python object to uint in libvirt_virNodeGetFreePages. On compiling libvirt-python against libvirt 1.2.6, we get: libvirt-override.c: In function ‘libvirt_virNodeGetFreePages’: libvirt-override.c:7811:9: warning: pointer targets in passing argument 2 of ‘libvirt_intUnwrap’ differ in signedness [-Wpointer-sign] if (libvirt_intUnwrap(tmp, &pages[i]) < 0) ^ In file included from libvirt-override.c:24:0: typewrappers.h:169:5: note: expected ‘int *’ but argument is of type ‘unsigned int *’ int libvirt_intUnwrap(PyObject *obj, int *val); ^ Signed-off-by: Eric Blake <eblake@redhat.com>
* Implement new virNodeGetFreePages APIMichal Privoznik2014-06-201-0/+107
| | | | | | | | | | | | | | | | | | | | The API expose information on host's free pages counts. For easier access, in python this API returns a dictionary such as: In [4]: conn.getFreePages([2048,1*1024*1024], -1, 5) Out[4]: {-1: {2048: 114, 1048576: 4}, 0: {2048: 3, 1048576: 1}, 1: {2048: 100, 1048576: 1}, 2: {2048: 10, 1048576: 1}, 3: {2048: 1, 1048576: 1}} At the top level of the returned dictionary there's a pair of <NUMA node> and another dictionary that contains detailed information on each supported page size. The information then consists of fairs of <page size> and <count of free pages>. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* blockjob: support new BLOCK_JOB_2 eventEric Blake2014-06-181-3/+7
| | | | | | | | | | | | | | | | | Libvirt 1.2.6 is introducing a new block job event that passes disk information by target device rather than host file name. At the python level, we are just a passthrough, so we can reuse all the existing code and just wire up the new enum value. * libvirt-override-virConnect.py (_dispatchDomainEventBlockPullCallback): Rename... (_dispatchDomainEventBlockJobCallback): ...to this, and make generic to both events. * libvirt-override.c (libvirt_virConnectDomainEventBlockJobCallback): Match naming. (libvirt_virConnectDomainEventRegisterAny): Allow new registration. Signed-off-by: Eric Blake <eblake@redhat.com>
* fix leak in memoryStats with older pythonv1.2.5Martin Kletzander2014-05-271-24/+44
| | | | | | | | | | | | | | | libvirt_virDomainMemoryStats() function creates a dictionary without any checks whether the additions were successful, whether the python objects were created and, most importantly, without decrementing the reference count on the objects added to the dictionary. This is somehow not an issue with current upstream versions, however with python 2.6 this exposes a leak in our bindings. The following patch works on both old and new CPython versions and is already used in other parts of the code, so it's also most straightforward. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1099860 Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
* Implement virDomain{Get,Set}Time APIsMichal Privoznik2014-05-201-0/+95
| | | | | | | | | While the setter can be generated automatically, the getter is not. However, it would be a lot easier if they both share the same logic: a python dictionary to represent the time: dict['seconds'] to represent seconds, and dict['nseconds'] to represent nanoseconds. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* override: add virDomainFSFreeze and virDomainFSThaw APITomoki Sekiyama2014-05-161-0/+97
| | | | | | | | | | Add binding for the new virDomainFSFreeze and virDomainFSThaw functions added in libvirt 1.2.5. These require override since these take a list of mountpoints path string. The methods are named 'fsFreeze' and 'fsThaw'. Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Fix potential crash when setting partial cpu/memory/numa/interface limits on ↵Brian Rak2014-03-311-12/+12
| | | | | | | | domains The number of parameters in new_params is not guaranteed to be the same as the number of parameters in params. Use the correct count when freeing new_params to avoid crashes.
* event: fix domain reference bugsEric Blake2014-03-251-119/+200
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Noticed this bug while adding qemu monitor events; there's probably lots of other misuse of libvirt_virDomainPtrWrap, but for now I'm limiting the fix to all copied-and-pasted event callbacks, since I'm about to copy it again in the next patch. While at it, check for failure to extract the "conn" key from the opaque callback struct, and hoist that check to occur before we reach the point where it is harder to undo on failure (the network code was the only code that had it in the right place, but then it failed to restore thread state on failure). The graphics callback is still not clean; but incremental improvements are better than nothing. * libvirt-override.c (libvirt_virConnectDomainEventCallback) (libvirt_virConnectDomainEvetnLifecycleCallback) (libvirt_virConnectDomainEventGenericCallback) (libvirt_virConnectDomainEventRTCChangeCallback) (libvirt_virConnectDomainEventWatchdogCallback) (libvirt_virConnectDomainEventIOErrorCallback) (libvirt_virConnectDomainEventIOErrorReasonCallback) (libvirt_virConnectDomainEventGraphicsCallback) (libvirt_virConnectDomainEventBlockJobCallback) (libvirt_virConnectDomainEventDiskChangeCallback) (libvirt_virConnectDomainEventTrayChangeCallback) (libvirt_virConnectDomainEventPMWakeupCallback) (libvirt_virConnectDomainEventPMSuspendCallback) (libvirt_virConnectDomainEventBalloonChangeCallback) (libvirt_virConnectDomainEventPMSuspendDiskCallback) (libvirt_virConnectDomainEventDeviceRemovedCallback): Don't pass NULL to PyObject_CallMethod. (libvirt_virConnectNetworkEventLifecycleCallback): Likewise, and don't corrupt thread state. Signed-off-by: Eric Blake <eblake@redhat.com>
* maint: balance {} usageEric Blake2014-03-241-6/+8
| | | | | | | | | | Emacs gets lost when finding function boundaries when #ifdef sections do not have balanced {}. * libvirt-override.c (libvirt_PyString_Check): New define. (virPyDictToTypedParams): Avoid unbalanced {} across ifdef. Signed-off-by: Eric Blake <eblake@redhat.com>
* override: Return NULL on python failure in getCPUModelNamesCole Robinson2014-03-201-1/+1
| | | | | Eric pointed this out on the last patch, but I pushed it before noticing his message.