1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-08-03 08:21:58 +03:00
Commit Graph

689 Commits

Author SHA1 Message Date
cd2d02ab0d Implement the DEVICE_ADDED event 2015-04-15 18:48:23 +02:00
17330a8314 Post-release version bump to 1.2.15
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-04-02 10:50:46 +02:00
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>
v1.2.14
2015-03-28 11:21:56 +01:00
e1e9b27096 Rename virDomainGetIOThreadsInfo to virDomainGetIOThreadInfo 2015-03-26 16:48:18 +01:00
c58b696a56 Rename virDomainIOThreadsInfoFree to virDomainIOThreadInfoFree 2015-03-26 16:44:23 +01:00
52c6643404 Post-release version bump to 1.2.14
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-19 14:18:21 +01:00
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
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
713ed9d570 Clarify description for virNodeGetSecurityModel
s/host/hypervisor/ to match the wording used by the C binding.

https://bugzilla.redhat.com/show_bug.cgi?id=1198518
2015-03-05 16:08:51 +01:00
9ef9794a3e Post-release version bump to 1.2.13 v1.2.13 2015-01-27 14:07:10 +00:00
1180fa9893 sanitytest: fix mapping test for virDomainDefineXMLFlags
The libvirt API has in the name "virDomain" but it's correctly mapped
into "virConnect" class. Create an exception in the sanity test.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
v1.2.12
2015-01-19 16:16:10 +01:00
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
1598bd7dd5 Bump version to 1.2.12 for new dev cycle
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-12-16 14:09:25 +01:00
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
v1.2.11
2014-12-11 11:21:36 +00:00
8b0e955d95 override: iterate virDomainFSInfo.devAliases using ndevAliases
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>
2014-12-02 09:13:57 +01:00
39f19f0a2d fix examples
The dhcpleases example had an old usage of print function. The formating
of leases record was also wrong.

The event-test example had an old usage of exceptions.

It's mainly to make examples compatible with python3.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-12-01 17:34:31 +01:00
acc47bcb71 event: Add bindings for agent lifecycle event
Also add the example.
2014-11-24 17:53:12 +01:00
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
3d1d3fd52a Add dict check for setTime and allow pass 'seconds' parameter
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>
2014-11-11 15:58:12 +01:00
8dcdc7f2b4 Check return value of libvirt_uintUnwrap
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>
2014-11-06 11:45:05 +01:00
f1c079ccc0 Bump version to 1.2.11 for new dev cycle 2014-11-03 10:41:27 -05:00
8e09c79a07 fix libvirt headers list
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>
v1.2.10
2014-10-28 12:06:50 -06:00
309be0a148 virDomainBlockCopy: initialize flags to 0
An optional argument if not passed isn't modified by the
PyArg_ParseTuple function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-10-22 13:38:55 +02:00
a7303a56b5 flags cannot get right value for blockCopy function
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>
2014-10-22 11:11:28 +02:00
7aaa02b47a Fix rest of unsigned integer handling
As in the previous patch, fix all places where 'flags' is converted as a
signed argument to unsigned including the python code generator.
2014-10-22 09:43:47 +02:00
b3aa7da4bb Fix parsing of 'flags' argument for bulk stats functions
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>
2014-10-22 09:43:47 +02:00
7bfe4e3cf6 Fix function name when parsing arguments in libvirt_virNodeAllocPages
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.
2014-10-22 09:43:43 +02:00
d8b7aa4b18 Improve error output when use getTime with a nonzero flags.
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>
2014-10-20 17:06:12 +02:00
8feae56ce4 Change the comment in getPyNodeCPUCount method reflecting correct called methods
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>
2014-10-16 09:26:58 +02:00
02cc5d62bd setup.py: fix rpm build to return 1 on error
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-10-07 13:08:55 +02:00
5346d9d9a3 sanitytest: define long for python version >= 3
Commit c58c7f362a fixed 32-bit python
build but broke build with python3 due to the lack of 'long' in the
newer version of python.  This patch aims to fix it with a simple
string comparison of sys.version and '3'.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-07 10:35:10 +02:00
c58c7f362a sanitytest: count with the fact that large enums can be long
On 32-bit systems, one new flag that has the value of 1 << 31, namely
VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, fails to fit into an
'int' on python and is therefore of type 'long'.  Fix sanitytest to
count with such fact in order to avoid build failures on 32-bit systems.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-07 10:08:38 +02:00
09b157076f sanitytest: check for exported enums
We are already collecting list of enums exported and list of enums we
want to have available.  Event though there was an issue with one enum
fixed with 014d9bbaf3, there was no test
for it and this commit tries to fix that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-06 17:20:32 +02:00
c34113f9f6 Post-release version bump for new dev cycle
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-10-02 14:55:21 +02:00
714aa155e8 implement new tunable event
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1147639

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
v1.2.9
2014-09-30 19:15:29 +02:00
a03b509d1c Implement new virNodeAllocPages API
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-26 12:01:17 +02:00
4acfb16940 generator: Free strings after libvirt_charPtrWrap
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>
2014-09-12 11:00:57 +02:00
23e22c2df1 override: Fix two uninitialized variables in convertDomainStatsRecord
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
2014-09-02 14:41:12 +02:00
bc6da3214c libvirt-override: fix some build warnings
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>
2014-09-02 11:49:42 +02:00
8b12cb6f76 Post-release version bump for new dev cycle
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-02 11:04:58 +02:00
0379d2a31a Implement API bindings for virDomainBlockCopy
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
v1.2.8
2014-09-02 00:29:26 +02:00
5ead8c1b0c API: Implement bindings for virDomainListGetStats
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>
2014-09-01 22:12:46 +02:00
285487954f API: Implement bindings for virConnectGetAllDomainStats
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>
2014-09-01 22:12:18 +02:00
7edf050a26 API: Skip 'virDomainStatsRecordListFree'
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>
2014-09-01 22:11:56 +02:00
62cfebc2e1 generator: resolve one level of enum reference
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>
2014-09-01 22:11:48 +02:00
2175f4f3da build: Fix build warning on libvirt-python
On compiling libvirt-python, we get such a warning:

libvirt-qemu-override.c: In function ‘libvirt_qemu_virConnectDomainQemuMonitorEventRegister’:
libvirt-qemu-override.c:304: warning: suggest explicit braces to avoid ambiguous ‘else’

Py_DECREF is a macro using if/else on older Python releases.
The solution is to add braces.
Python 2.7 and newer has the macro wrapped in a do { } while(0) block.

Signed-off-by: Mo Yuxiang <Moyuxiang@huawei.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2014-08-19 12:43:28 +02:00
86ee51ce97 Fix libvirt_longlongWrap returning a very large value
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>
2014-08-11 16:28:26 +02:00
cffaeb075e maint: document use of libvirt's run script
Ever since libvirt commit 78c09530, it's easier to just use the
run script.

* README: Mention run script.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-04 11:09:34 -06:00
af803d2f9b Bump version to 1.2.8 for new dev cycle
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-04 11:06:13 -06:00
e715a1c86b spec: Reorganize to satisfy buggy spectool
spectool parses a specfile and strips everything but a preamble.
However, if the first section is preceded by %if clause, it keeps it
there which then makes rpmbuild complain about unmatched %if. Let's make
the buggy tool happy by moving sections around so that the first one is
not in any conditional.
v1.2.7
2014-07-29 16:24:48 +02:00