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

260 Commits

Author SHA1 Message Date
Pavel Hrdina
fc76416248 generator.py: add mapping for VIR_DOMAIN_QEMU_AGENT_COMMAND_*
Libvirt commit <95f5ac9ae52455e9da47afc95fa31c9456ac27ae> changed the
VIR_DOMAIN_QEMU_AGENT_COMMAND_* enum values to use different enum values
instead of direct numbers.  We need to translate it back.

Traceback (most recent call last):
  File "generator.py", line 2143, in <module>
    qemuBuildWrappers(sys.argv[1])
  File "generator.py", line 2008, in qemuBuildWrappers
    items.sort(key=lambda i: (int(i[1]), i[0]))
  File "generator.py", line 2008, in <lambda>
    items.sort(key=lambda i: (int(i[1]), i[0]))
ValueError: invalid literal for int() with base 10: 'VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK'

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2019-11-28 10:55:18 +01:00
Daniel P. Berrangé
873e0ca7db Custom impl for virConnectSetIdentity which can't be generated
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-20 13:51:20 +01:00
Daniel P. Berrangé
6dff8e4f3f generator: fix constructor for virNetworkPort
The virNetworkPort class is passed both the virNetwork parent
python class and the virNetworkPort C object. This needs special
handling in the generator, similar to how virDomainSnapshots are
dealt with.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-12 15:28:13 +01:00
Michal Privoznik
17937cc337 Implement virDomainGetGuestInfo
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-08-29 12:04:56 +02:00
Eric Blake
358a8640fa Add virDomainCheckpoint APIs
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>
2019-07-29 13:39:39 -05:00
Daniel P. Berrangé
05089cc402 generator: fix naming of getter APIs for virNetworkPort
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-06-20 14:10:08 +01:00
Daniel P. Berrangé
a4de6e2ed8 Add support for virNetworkPort object & APIs
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>
2019-06-20 12:11:59 +01:00
Eric Blake
5301118fd1 generator.py: typo fix
Signed-off-by: Eric Blake <eblake@redhat.com>
2019-02-07 14:52:09 -06:00
John Ferlan
9bc102103c Implement API binding for virDomainSetIOThreadParams
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>
2018-11-20 13:24:18 -05:00
Daniel P. Berrangé
c1f06dde29 Fix bugs in nwfilter binding APIs
We did not correctly mangle the API names in two cases, and we also
forgot to specialize the lookup method name in the sanity test.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-28 12:29:21 +01:00
Daniel P. Berrangé
d5aae37c61 Add support for nwfilter binding objects / apis
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-28 12:04:05 +01:00
Erik Skultety
6c136b8150 Add support for virNodeGetSEVInfo
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>
2018-06-14 17:23:19 +02:00
Erik Skultety
dbae262811 Add support for virDomainGetLaunchSecurityInfo
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>
2018-06-14 17:22:59 +02:00
Jiri Denemark
0f3f82e8be Add support for virConnectBaselineHypervisorCPU
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>
2018-06-01 08:16:48 +02:00
Marc Hartmayer
318e305512 libvirt_qemu/lxc: fix a namespace issue
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2018-05-16 10:40:46 +02:00
Marc Hartmayer
0a07908e69 libvirt_qemu/lxc: import 'sys' package
This fixes the pylint [1] warning "E: 25,16: Undefined variable
'sys' (undefined-variable)".

[1] https://www.pylint.org/

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2018-05-16 10:40:46 +02:00
Cédric Bosdonnat
bedc937cce Don't hardcode interpreter path
This is particularly useful on operating systems that don't ship
Python as part of the base system (eg. FreeBSD) while still working
just as well as it did before on Linux.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
2017-11-30 08:48:36 +01:00
John Ferlan
100177c3dc Introduce virDomainMigrateGetMaxDowntime API
Introduce wrapper for virDomainMigrateGetMaxDowntime
2017-08-26 08:58:41 -04:00
Michal Privoznik
d7e1c976f4 virStream: Introduce virStreamSparse{Recv,Send}All
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>
2017-05-24 13:32:37 +02:00
Michal Privoznik
2e4cb22122 virStream: Introduce virStreamRecvFlags
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>
2017-05-23 13:43:15 +02:00
Michal Privoznik
1f42d8629f Implement virStreamSendHole/virStreamRecvHole
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>
2017-05-23 13:43:12 +02:00
Daniel P. Berrange
405f537bd0 Removed unused 'functions_list_exception_test' code from generator
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>
2017-01-27 09:58:40 +00:00
Daniel P. Berrange
60f71591b9 Removed unused 'converter_type' code from generator
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>
2017-01-27 09:58:40 +00:00
Daniel P. Berrange
d5feb2f664 Removed unused 'classes_ancestor' code from generator
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>
2017-01-27 09:58:40 +00:00
Daniel P. Berrange
34a5fa2f61 Removed unused 'py_return_types' code from generator
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>
2017-01-27 09:58:40 +00:00
Daniel P. Berrange
bc90127cb6 Removed unused 'foreign_encoding_args' code from generator
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>
2017-01-27 09:58:40 +00:00
Daniel P. Berrange
0c53a316ea Removed unused 'function_post' code from generator
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>
2017-01-27 09:58:40 +00:00
Daniel P. Berrange
f916d855c7 Removed unused 'reference_keepers' code from generator
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>
2017-01-27 09:58:40 +00:00
Daniel P. Berrange
431afe83ce Protect against user accidentally calling constructors directly
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>
2017-01-27 09:58:40 +00:00
Daniel P. Berrange
69797c4726 Add support for secret event APIs
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-01-09 18:07:40 +00:00
Daniel P. Berrange
ff560532fd Add override impl for virStorageVolGetInfoFlags
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-12-21 13:17:28 +00:00
Daniel P. Berrange
f5edaf1ba5 Remove bogus \o escape in regex
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>
2016-12-21 10:35:17 +00:00
Jovanka Gulicoska
58a986984f Python binding for node poll lifecycle events API 2016-08-02 09:55:56 -04:00
Michal Privoznik
570669f29f Add support for virDomainGetGuestVcpus
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>
2016-06-23 10:57:11 +02:00
Jovanka Gulicoska
7eaab4a6c2 Python binding for storage pool lifecycle events API
Code matches the network event API implementation
2016-06-16 12:25:44 -04:00
Peter Krempa
3026a0593b generator.py: Consider symbols from libvirt-common
Some of the libvirt public API was moved into the libvirt-common.h file.
We should consider it while building python too.
2016-04-21 15:46:00 +02:00
Qiaowei Ren
f97c782105 python: add python binding for Perf API
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>
2016-03-31 16:02:05 +02:00
Luyao Huang
3a97b3212d generator: fix build fail with old xml lib
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>
2015-09-21 12:04:59 +02:00
Jiri Denemark
d3e2aff6a7 Provide symbolic names for typed parameters
https://bugzilla.redhat.com/show_bug.cgi?id=1222795

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-08 11:28:52 +02:00
Guido Günther
06e8ea4702 Sort tuples on both items
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
2015-05-20 19:03:04 +02:00
Guido Günther
25448b07b1 Simplify sorting
funcs.keys() can't be None, only the empty array
2015-05-20 19:03:02 +02:00
Guido Günther
49118f6d95 Sort dictionary keys
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
2015-05-20 19:02:47 +02:00
Pavel Hrdina
0be1f5e31a Expose virDomainInterfacesAddresses to python binding
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>
2015-03-28 11:21:56 +01:00
Ján Tomko
e1e9b27096 Rename virDomainGetIOThreadsInfo to virDomainGetIOThreadInfo 2015-03-26 16:48:18 +01:00
Ján Tomko
c58b696a56 Rename virDomainIOThreadsInfoFree to virDomainIOThreadInfoFree 2015-03-26 16:44:23 +01:00
John Ferlan
b5c3aa95f3 Support virDomainPinIOThread
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
2015-03-11 15:03:31 -04:00
John Ferlan
d9b519c21a Support virDomainGetIOThreadsInfo and virDomainIOThreadsInfoFree
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])]
[]
$
2015-03-11 15:02:18 -04:00
Eric Blake
ab6eb69f8d build: make it easier to backport event ids
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>
2015-01-15 09:14:50 -07:00
Richard W.M. Jones
e3da7ade42 Add c_pointer method to classes.
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
2014-12-11 11:21:36 +00:00
Tomoki Sekiyama
c6def1bf95 override: Implement bindings for virDomainGetFSInfo as domain.fsInfo
Implement the function which returns a list of tuples, that contains members
of virDomainFSInfo struct.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
2014-11-24 17:30:49 +01:00