summaryrefslogtreecommitdiff
path: root/generator.py
Commit message (Collapse)AuthorAgeFilesLines
...
* virStream: Introduce virStreamSparse{Recv,Send}AllMichal Privoznik2017-05-241-0/+2
| | | | | | | Yet again, our parser is not capable of generating proper wrapper. To be fair, this one wold be really tough anyway. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* virStream: Introduce virStreamRecvFlagsMichal Privoznik2017-05-231-0/+1
| | | | | | | Yet again, we need a custom wrapper over virStreamRecvFlags because our generator is not capable of generating it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Implement virStreamSendHole/virStreamRecvHoleMichal Privoznik2017-05-231-0/+2
| | | | | | | | The return value for virStreamRecvHole is slightly different to its C counterpart. In python, either it returns the hole size or None if C API fails. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Removed unused 'functions_list_exception_test' code from generatorv3.1.0Daniel P. Berrange2017-01-271-21/+8
| | | | | | | | The 'functions_list_exception_test' data structure and associated code in the generator is inherited from libxml. This has never been used in libvirt, so delete it to simplify the generator. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Removed unused 'converter_type' code from generatorDaniel P. Berrange2017-01-271-15/+0
| | | | | | | | The 'converter_type' data structure and associated code in the generator is inherited from libxml. This has never been used in libvirt, so delete it to simplify the generator. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Removed unused 'classes_ancestor' code from generatorDaniel P. Berrange2017-01-271-34/+22
| | | | | | | | The 'classes_ancestor' data structure and associated code in the generator is inherited from libxml. This has never been used in libvirt, so delete it to simplify the generator. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Removed unused 'py_return_types' code from generatorDaniel P. Berrange2017-01-271-13/+0
| | | | | | | | The 'py_return_types' data structure and associated code in the generator is inherited from libxml. This has never been used in libvirt, so delete it to simplify the generator. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Removed unused 'foreign_encoding_args' code from generatorDaniel P. Berrange2017-01-271-5/+0
| | | | | | | | The 'foreign_encoding_args' data structure and associated code in the generator is inherited from libxml. This has never been used in libvirt, so delete it to simplify the generator. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Removed unused 'function_post' code from generatorDaniel P. Berrange2017-01-271-28/+0
| | | | | | | | The 'function_post' data structure and associated code in the generator is inherited from libxml. This has never been used in libvirt, so delete it to simplify the generator. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Removed unused 'reference_keepers' code from generatorDaniel P. Berrange2017-01-271-24/+0
| | | | | | | | The 'reference_keepers' data structure and associated code in the generator is inherited from libxml. This has never been used in libvirt, so delete it to simplify the generator. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Protect against user accidentally calling constructors directlyDaniel P. Berrange2017-01-271-0/+2
| | | | | | | | | | | | | | | | | | | | | When using libvirt python you must never call the object constructors directly, as these are expecting to be passed a wrapped C object. For example import libvirt c = libvirt.virConnect("qemu:///system") c.listAllDomains() will mysteriously segfault. With this change the user now gets an slightly more helpful error Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/berrange/src/virt/libvirt-python/build/libvirt.py", line 3409, in __init__ raise Exception("Expected a wrapped C Object but got %s" % type(_obj)) Exception: Expected a wrapped C Object but got <type 'str'> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Add support for secret event APIsDaniel P. Berrange2017-01-091-0/+2
| | | | Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Add override impl for virStorageVolGetInfoFlagsDaniel P. Berrange2016-12-211-0/+1
| | | | Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Remove bogus \o escape in regexDaniel P. Berrange2016-12-211-1/+1
| | | | | | | | One of the regexes has a bogus \o instead of plain 'o'. Somehow this magically worked on all versions of python, until 3.6 came along and complained Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Python binding for node poll lifecycle events APIJovanka Gulicoska2016-08-021-0/+2
|
* Add support for virDomainGetGuestVcpusMichal Privoznik2016-06-231-0/+1
| | | | | | | | This function has virTypedParameterPtr as one of the args and our generator is unable to deal with that. Therefore we must provide implementation. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Python binding for storage pool lifecycle events APIJovanka Gulicoska2016-06-161-0/+2
| | | | Code matches the network event API implementation
* generator.py: Consider symbols from libvirt-commonv1.3.4Peter Krempa2016-04-211-0/+1
| | | | | Some of the libvirt public API was moved into the libvirt-common.h file. We should consider it while building python too.
* python: add python binding for Perf APIQiaowei Ren2016-03-311-0/+2
| | | | | | | | This patch adds the python binding for virDomainSetPerfEvents and virDomainSetPerfEvents API. Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* generator: fix build fail with old xml libLuyao Huang2015-09-211-1/+1
| | | | | | | | | | | | | | | | | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=1222795#c6 if build libvirt-python with some old xml lib (python-pyxml), build will fail and error like this: File "generator.py", line 139, in start if "string" in attrs: File "/usr/local/lib/python2.7/site-packages/_xmlplus/sax/xmlreader.py" \ , line 316, in __getitem__ return self._attrs[name] KeyError: 0 This is an old issue and have been mentioned in commit 3ae0a76d. There is no __contains__ in class AttributesImpl, python will use __getitem__ in this place, so we will get error. Let's use 'YYY in XXX.keys()' to avoid this issue. Signed-off-by: Luyao Huang <lhuang@redhat.com>
* Provide symbolic names for typed parametersJiri Denemark2015-06-081-0/+8
| | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=1222795 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
* Sort tuples on both itemsGuido Günther2015-05-201-3/+3
| | | | | | | | In order to achieve reproducible builds[0] we want the items within enums always generated in the same order so sort on both items in the tuple. [0] https://wiki.debian.org/ReproducibleBuilds/About
* Simplify sortingGuido Günther2015-05-201-4/+1
| | | | funcs.keys() can't be None, only the empty array
* Sort dictionary keysGuido Günther2015-05-201-4/+4
| | | | | | | In order to achive reproducible builds[0] we want functions and enums always generated in the same order. [0] https://wiki.debian.org/ReproducibleBuilds/About
* Expose virDomainInterfacesAddresses to python bindingv1.2.14Pavel Hrdina2015-03-281-0/+2
| | | | | | | | | | | | | | | | | | | | | 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-2/+2
|
* Rename virDomainIOThreadsInfoFree to virDomainIOThreadInfoFreeJán Tomko2015-03-261-1/+1
|
* Support virDomainPinIOThreadJohn Ferlan2015-03-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | 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/+5
| | | | | | | | | | | | | | | | | | | | | | | 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-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add c_pointer method to classes.v1.2.11Richard W.M. Jones2014-12-111-0/+32
| | | | | | | | | | | | | | This returns the raw C pointer to the underlying object, eg: conn = libvirt.open(None) print "0x%x" % conn.c_pointer() # returns virConnectPtr of the connection dom = conn.lookupByName("test") print "0x%x" % dom.c_pointer() # returns virDomainPtr of the domain The reason behind this is to allow us to transparently pass Python dom objects through the libguestfs Python API. https://bugzilla.redhat.com/show_bug.cgi?id=1075164
* override: Implement bindings for virDomainGetFSInfo as domain.fsInfoTomoki Sekiyama2014-11-241-0/+5
| | | | | | | Implement the function which returns a list of tuples, that contains members of virDomainFSInfo struct. Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
* fix libvirt headers listv1.2.10Dmitry Guryanov2014-10-281-8/+18
| | | | | | | | Since libvirt.h has been split out, generator.py should be fixed accordingly. So add full list of header files. Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
* Fix rest of unsigned integer handlingPeter Krempa2014-10-221-1/+1
| | | | | As in the previous patch, fix all places where 'flags' is converted as a signed argument to unsigned including the python code generator.
* Implement new virNodeAllocPages APIMichal Privoznik2014-09-261-0/+1
| | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* generator: Free strings after libvirt_charPtrWrapMichal Privoznik2014-09-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=1140998 Up till bb3301ba the wrapper was freeing the passed strings for us. However that changed after the commit. So now we don't free any strings which results in memory leaks as reported upstream [1]: ==14265== 2,407 bytes in 1 blocks are definitely lost in loss record 1,457 of 1,550 ==14265== at 0x4C2845D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==14265== by 0x5C46624: xdr_string (in /usr/lib64/libc-2.17.so) ==14265== by 0xCFD9FCD: xdr_remote_nonnull_string (remote_protocol.c:31) ==14265== by 0xCFDC2C8: xdr_remote_domain_get_xml_desc_ret (remote_protocol.c:1617) ==14265== by 0xCFF0811: virNetMessageDecodePayload (virnetmessage.c:407) ==14265== by 0xCFE68FB: virNetClientProgramCall (virnetclientprogram.c:379) ==14265== by 0xCFBE8B1: callFull.isra.2 (remote_driver.c:6578) ==14265== by 0xCFC7F04: remoteDomainGetXMLDesc (remote_driver.c:6600) ==14265== by 0xCF8167C: virDomainGetXMLDesc (libvirt.c:4380) ==14265== by 0xCC2C4DF: libvirt_virDomainGetXMLDesc (libvirt.c:1141) ==14265== by 0x4F12B93: PyEval_EvalFrameEx (in /usr/lib64/libpython2.7.so.1.0) ==14265== by 0x4F141AC: PyEval_EvalCodeEx (in /usr/lib64/libpython2.7.so.1.0) The python documentation clearly advise us to call free() [2]. From an example in their docs: PyObject *res; char *buf = (char *) malloc(BUFSIZ); /* for I/O */ if (buf == NULL) return PyErr_NoMemory(); ...Do some I/O operation involving buf... res = PyString_FromString(buf); free(buf); /* malloc'ed */ return res; Moreover, instead of using VIR_FREE() (which we are not exporting), I'll just go with bare free(). 1: https://www.redhat.com/archives/libvir-list/2014-September/msg00736.html 2: https://docs.python.org/2/c-api/memory.html Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Implement API bindings for virDomainBlockCopyv1.2.8Pavel Hrdina2014-09-021-0/+1
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* API: Implement bindings for virDomainListGetStatsPavel Hrdina2014-09-011-0/+1
| | | | | | | | 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/+1
| | | | | | | | 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: Skip 'virDomainStatsRecordListFree'Peter Krempa2014-09-011-0/+1
| | | | | | | | The new API function doesn't make sense to be exported in python. The bindings will return native types instead of the struct array. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* generator: resolve one level of enum referencePavel Hrdina2014-09-011-1/+15
| | | | | | | | | | | | | In the libvirt.h we have one enum defined by references from another enum and it leads in wrong order of definitons in python code. To prevent this we should resolve that references before we generate the python code. For now we have only one level of references so we will count with that in the generator but we should update it in the future to be more flexible. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* Implement new virNetworkGetDHCPLeases APIv1.2.6-rc2v1.2.6Nehal J Wani2014-06-271-0/+4
| | | | | | | | | | | | | | | | 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>
* Implement new virNodeGetFreePages APIMichal Privoznik2014-06-201-0/+1
| | | | | | | | | | | | | | | | | | | | 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>
* Implement virDomain{Get,Set}Time APIsMichal Privoznik2014-05-201-0/+2
| | | | | | | | | 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/+3
| | | | | | | | | | 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>
* qemu: support arbitrary monitor eventsEric Blake2014-03-251-8/+12
| | | | | | | | | | | | | | | | | | | | | | Wrap the new virConnectDomainQemuMonitorEventRegister function added in libvirt 1.2.3. This patch copies heavily from network events (commit 6ea5be0) and from event loop callbacks in libvirt-override.c, since in the libvirt_qemu module, we must expose top-level functions rather than class members. * generator.py (qemu_skip_function): Don't generate event code. (qemuBuildWrappers): Delay manual portion until after imports. * libvirt-qemu-override.py (qemuMonitorEventRegister) (qemuMonitorEventDeregister): New file. * libvirt-qemu-override.c (libvirt_qemu_virConnectDomainQemuMonitorEventFreeFunc) (libvirt_qemu_virConnectDomainQemuMonitorEventCallback) (libvirt_qemu_virConnectDomainQemuMonitorEventRegister) (libvirt_qemu_virConnectDomainQemuMonitorEventDeregister) (libvirt_qemu_lookupPythonFunc, getLibvirtQemuDictObject) (getLibvirtQemuModuleObject): New functions. Signed-off-by: Eric Blake <eblake@redhat.com>
* generator: Add virConnectDomainQemuMonitorEventCallback to skipped_typesMartin Kletzander2014-03-251-0/+1
| | | | Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
* generator: Skip exporting only sentinelsv1.2.2-rc2Martin Kletzander2014-02-201-5/+14
| | | | | | | | | | | | When enum type has '_LAST' in its name, but is not the last type in that enum, it's skipped even though it shouldn't be. Currently, this is the case for only VIR_NETWORK_UPDATE_COMMAND_ADD_LAST inside an enum virNetworkUpdateCommand. Also, since _LAST types can have other enums instead of values, that needs to be filtered out using a try-except when converting the value. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
* Added python binding for the new network events APICédric Bosdonnat2013-12-111-0/+2
| | | | | | | The new network events code requires manual binding code to be written. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* generator: Sort enums and functions when generating codeDaniel P. Berrange2013-12-091-2/+8
| | | | | | | | To assist in diff comparisons between code generated with different versions of Python, do an explicit sort of all functions and enums. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>