Commit Graph

60 Commits

Author SHA1 Message Date
Michal Privoznik
f113ce611b python: Document virNodeGetInfo bug
The memory size in virNodeGetInfo python API binding is reported in MiB
instead of KiB (like we have in C struct). However, there already might
be applications out there relying on this inconsistence so we can't
simply fix it. Document this sad fact as known bug.
2013-09-30 11:42:52 +02:00
Giuseppe Scrivano
de51dc9c9a python: add bindings for virConnectGetCPUModelNames
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-23 16:59:39 -06:00
Jiri Denemark
6f4c6af6ed python: Add bindings for extensible migration APIs
The patch implements wrappers for virDomainMigrate3 and
virDomainMigrateToURI3.
2013-06-25 01:28:39 +02:00
Peter Krempa
d395c81121 python: Fix emulatorpin API bindings
The addition of emulator pinning APIs didn't think of doing the right
job with python APIs for them. The default generator produced unusable
code for this.

This patch switches to proper code as in the case of domain Vcpu pining.
This change can be classified as a python API-breaker but in the state
the code was before I doubt anyone was able to use it successfully.
2013-03-21 12:32:03 +01:00
Guannan Ren
4b143ab231 python: fix bindings that don't raise an exception
For example:
 >>> dom.memoryStats()
 libvir: QEMU Driver error : Requested operation is not valid:\
         domain is not running

There are six such python API functions like so.
The root reason is that generator.py script checks the type of return
value of a python stub function defined in libvirt-api.xml or
libvirt-override-api.xml to see whether to add the raise clause or not
in python wrapper code in libvirt.py.

The type of return value is supposed to be C types.
For those stub functions which return python non-integer data type like
string, list, tuple, dictionary, the existing type in functions varies
from each other which leads problem like this.

Currently, in generator.py, it maintains a buggy whitelist for stub functions
returning a list type. I think it is easy to forget adding new function name
in the whitelist.

This patch makes the value of type consistent with C type "char *"
in libvirt-override-api.xml. For python, any of types could be printed
as string, so I choose "char *" in this case. And the comment in xml
could explain it when adding new function definition.

      <function name='virNodeGetCPUStats' file='python'>
        ...
 -      <return type='virNodeCPUStats' info='...'/>
 +      <return type='char *' info='...'/>
        ...
      </function>
2013-03-21 11:24:49 +08:00
Jiri Denemark
4802d59e6a python: Implement virDomainMigrateGetCompressionCache wrapper 2013-02-22 17:35:59 +01:00
Jiri Denemark
8eb7ab95c2 python: Implement virDomainGetJobStats wrapper 2013-02-22 17:35:58 +01:00
Viktor Mihajlovski
857f116871 virNodeGetCPUMap: Add python binding
Added a method getCPUMap to virConnect.
It can be used as follows:

import libvirt
import sys
import os

conn = libvirt.openReadOnly(None)
if conn == None:
    print 'Failed to open connection to the hypervisor'
    sys.exit(1)

try:
    (cpus, cpumap, online) = conn.getCPUMap(0)
except:
    print 'Failed to extract the node cpu map information'
    sys.exit(1)

print 'CPUs total %d, online %d' % (cpus, online)
print 'CPU map %s' % str(cpumap)

del conn
print "OK"

sys.exit(0)

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2012-10-25 11:34:35 -06:00
Osier Yang
4c4c80df3f node_memory: Expose the APIs to Python bindings
* python/libvirt-override-api.xml: (Add document to describe
  the APIs).
* python/libvirt-override.c: (Implement the API wrappers manually)
2012-09-17 13:55:46 +08:00
Osier Yang
473ee27e6a list: Expose virConnectListAllSecrets to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py: Implementation for listAllSecrets.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-17 13:18:51 +08:00
Osier Yang
f4c1efaa9a list: Expose virConnectListAllNWFilters to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py:
  * Implementation for listAllNWFilters.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-17 12:37:03 +08:00
Osier Yang
a3676b6cb6 list: Expose virConnectListAllNodeDevices to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py:
  * Implementation for listAllNodeDevices.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-17 10:41:03 +08:00
Osier Yang
ec448fbf17 list: Expose virConnectListAllInterfaces to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py:
  * New file, includes implementation of listAllInterfaces.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-12 15:37:09 +08:00
Osier Yang
9cc4270112 list: Expose virConnectListAllNetworks to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py: Implement listAllNetworks.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-11 18:35:14 +08:00
Osier Yang
fa2e35a336 list: Expose virStoragePoolListAllVolumes to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virStoragePool.py:
  * New file, includes implementation of listAllVolumes.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-10 10:41:18 +08:00
Osier Yang
9278578069 python: Expose virStorageListAllStoragePools to python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document
python/libvirt-override-virConnect.py: Add listAllStoragePools
python/libvirt-override.c: Implementation for the wrapper.
2012-09-06 22:16:11 +08:00
Eric Blake
f73d99c2a5 list: provide python bindings for snapshots
This adds support for the new virDomainListAllSnapshots (a domain
function) and virDomainSnapshotListAllChildren (a snapshot function)
to the libvirt-python bindings.  The implementation is done manually
as the generator does not support wrapping lists of C pointers into
python objects.

* python/libvirt-override.c (libvirt_virDomainListAllSnapshots)
(libvirt_virDomainSnapshotListAllChildren): New functions.
* python/libvirt-override-api.xml: Document them.
* python/libvirt-override-virDomain.py (listAllSnapshots): New
file.
* python/libvirt-override-virDomainSnapshot.py (listAllChildren):
Likewise.
* python/Makefile.am (CLASSES_EXTRA): Ship them.
2012-06-19 13:50:03 -06:00
Peter Krempa
bd34cc8c45 python: add API exports for virConnectListAllDomains()
This patch adds export of the new API function
virConnectListAllDomains() to the libvirt-python bindings. The
virConnect object now has method "listAllDomains" that takes only the
flags parameter and returns a python list of virDomain object
corresponding to virDomainPtrs returned by the underlying api.

The implementation is done manually as the generator does not support
wrapping list of virDomainPtrs into virDomain objects.
2012-06-18 21:24:13 +02:00
Guannan Ren
1aeb3d9e7f python: make python APIs use these helper functions
*setPyVirTypedParameter
    *libvirt_virDomainGetCPUStats
2012-03-28 08:54:06 -06:00
Guannan Ren
a772f4eebc python: add virDomainGetCPUStats python binding API
dom.getCPUStats(True, 0)
      [{'cpu_time': 24699446159L, 'system_time': 10870000000L, 'user_time': 950000000L}]
    dom.getCPUStats(False, 0)
      [{'cpu_time': 8535292289L}, {'cpu_time': 1005395355L}, {'cpu_time': 9351766377L}, {'cpu_time': 5813545649L}]

    *generator.py Add a new naming rule
    *libvirt-override-api.xml The API function description
    *libvirt-override.c Implement it.
2012-03-22 10:55:48 -04:00
Alex Jia
8b29c45986 python: Expose virDomain{G,S}etInterfaceParameters APIs in python binding
The v4 patch corrects indentation issues.

The v3 patch follows latest python binding codes and change 'size'
type from int to Py_ssize_t.

An simple example to show how to use it:

#!/usr/bin/env python

import libvirt

conn = libvirt.open(None)
dom = conn.lookupByName('foo')

print dom.interfaceParameters('vnet0', 0)

params = {'outbound.peak': 10,
          'inbound.peak': 10,
          'inbound.burst': 20,
          'inbound.average': 20,
          'outbound.average': 30,
          'outbound.burst': 30}

print dom.setInterfaceParameters('vnet0', params, 0)
print dom.interfaceParameters('vnet0', 0)

Signed-off-by: Alex Jia <ajia@redhat.com>
2012-02-16 10:15:16 +08:00
Guannan Ren
56cec18d76 python: make other APIs share common {get, set}PyVirTypedParameter
*libvirt_virDomainBlockStatsFlags
        *libvirt_virDomainGetSchedulerParameters
        *libvirt_virDomainGetSchedulerParametersFlags
        *libvirt_virDomainSetSchedulerParameters
        *libvirt_virDomainSetSchedulerParametersFlags
        *libvirt_virDomainSetBlkioParameters
        *libvirt_virDomainGetBlkioParameters
        *libvirt_virDomainSetMemoryParameters
        *libvirt_virDomainGetMemoryParameters
        *libvirt_virDomainSetBlockIoTune
        *libvirt_virDomainGetBlockIoTune
2012-02-10 17:17:18 -07:00
Guannan Ren
9c8466daac python: refactoring virTypedParameter conversion for NUMA tuning APIs
*getPyVirTypedParameter
          *setPyVirTypedParameter
          *virDomainSetNumaParameters
          *virDomainGetNumaParameters

Signed-off-by: Eric Blake <eblake@redhat.com>
2012-02-09 16:22:53 -07:00
Jiri Denemark
7bceae0fa6 python: Add binding for virDomainGetDiskErrors 2012-02-01 10:59:27 +01:00
Alex Jia
ae3315aa4a python: Fix problems of virDomain{Set, Get}BlockIoTune bindings
The parameter 'params' is useless for virDomainGetBlockIoTune API,
and the return value type should be a virTypedParameterPtr but not
integer. And "PyArg_ParseTuple" in functions
libvirt_virDomain{Set,Get}BlockIoTune misses format unit for "format"
argument.

* libvirt-override-api.xml: Remove useless the parameter 'params'
from virDomainGetBlockIoTune API, and change return value type from
integer to virTypedParameterPtr.

* python/libvirt-override.c: Add the missed format units.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=770683

Signed-off-by: Alex Jia <ajia@redhat.com>
2011-12-29 14:07:47 +08:00
Osier Yang
d758e0cb64 python: Expose blockPeek and memoryPeek in Python binding
A simple example to show how to use it:

\#! /usr/bin/python

import os
import sys
import libvirt

disk = "/var/lib/libvirt/images/test.img"

conn = libvirt.open(None)
dom = conn.lookupByName('test')

mem_contents = dom.memoryPeek(0, 32, libvirt.VIR_MEMORY_VIRTUAL);
sys.stdout.write(mem_contents)

% python test.py | hexdump
0000000 1660 0209 0000 0000 0000 0000 0000 0000
0000010 0000 0000 0000 0000 d3a0 01d0 0000 0000
0000020
2011-12-15 21:01:33 +08:00
Peter Krempa
17c7795561 python: Expose binding for virNodeGetMemoryStats()
This patch adds binding for virNodeGetMemoryStats method of libvirtd.
Return value is represented as a python dictionary mapping field
names to values.
2011-12-05 12:22:33 +01:00
Peter Krempa
49556023f2 python: Expose binding for virNodeGetCPUStats()
This patch adds binding for virNodeGetCPUStats method of libvirtd.
Return value is represented as a python dictionary mapping field names
to values.
2011-12-05 12:22:33 +01:00
Lei Li
62a19475d2 Support virDomain{Set, Get}BlockIoTune in the python API
Python support for both setting and getting block I/O throttle.

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2011-11-30 11:36:11 -07:00
Eric Blake
f2013c9dd1 snapshot: new virDomainSnapshotListChildrenNames API
The previous API addition allowed traversal up the hierarchy;
this one makes it easier to traverse down the hierarchy.

In the python bindings, virDomainSnapshotNumChildren can be
generated, but virDomainSnapshotListChildrenNames had to copy
from the hand-written example of virDomainSnapshotListNames.

* include/libvirt/libvirt.h.in (virDomainSnapshotNumChildren)
(virDomainSnapshotListChildrenNames): New prototypes.
(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS): New flag alias.
* src/libvirt.c (virDomainSnapshotNumChildren)
(virDomainSnapshotListChildrenNames): New functions.
* src/libvirt_public.syms: Export them.
* src/driver.h (virDrvDomainSnapshotNumChildren)
(virDrvDomainSnapshotListChildrenNames): New callbacks.
* python/generator.py (skip_impl, nameFixup): Update lists.
* python/libvirt-override-api.xml: Likewise.
* python/libvirt-override.c
(libvirt_virDomainSnapshotListChildrenNames): New wrapper function.
2011-10-10 16:54:16 -06:00
Osier Yang
f4c331a744 latency: Expose the new API for Python binding 2011-09-06 12:02:51 +08:00
Jim Fehlig
b12354befe Add public API for getting migration speed
Includes impl of python binding since the generator was not
able to cope.

Note: Requires gendispatch.pl patch from Matthias Bolte

https://www.redhat.com/archives/libvir-list/2011-August/msg01367.html
2011-09-01 11:26:21 -06:00
Hu Tao
26fdb4173b python: add python binding for virDomainSetMemoryParameters 2011-07-28 10:16:49 +02:00
Hu Tao
9b382394d1 python: add python binding for virDomainGetMemoryParameters 2011-07-28 10:15:34 +02:00
Hu Tao
3f08212c3c python: add python binding for virDomainSetBlkioParameters 2011-07-28 10:10:00 +02:00
Hu Tao
9d5cef1872 python: add python binding for virDomainGetBlkioParameters 2011-07-28 09:49:24 +02:00
Taku Izumi
da4009ec40 python: add Python binding for virDomainGetVcpuPinInfo API
This patch adds the Python bindings for virDomainGetVcpuPinInfo API.
* python/generator.py: add it to generator skip list
* python/libvirt-override-api.xml: provide an override description
* python/libvirt-override.c: provide an override binding implementation
2011-07-25 15:04:50 +08:00
Taku Izumi
18a68f7dce python: add Python binding for virDomainPinVcpusFlags API
This patch adds the Python bindings for virDomainPinVcpuFlags API.
* python/generator.py: add it to the generator skip list
* python/libvirt-override-api.xml: provide override description
* python/libvirt-override.c: provide override bindings implementation
2011-07-25 15:00:11 +08:00
Taku Izumi
9e4de11807 python: add Python binding for virDomainGetSchedulerParametersFlags API
This patch adds the Python bindings for
virDomainGetSchedulerParametersFlags API.
2011-07-25 14:57:33 +08:00
Taku Izumi
c5cf6e14ab python: add Python binding for virDomainGetSchedulerParametersFlags API
This patch adds the Python bindings for
virDomainGetSchedulerParametersFlags API.
* python/libvirt-override-api.xml: provide and override description
* python/libvirt-override.c: implement the bindings
2011-07-25 14:54:34 +08:00
Adam Litke
f50750b2d0 Enable virDomainBlockPull in the python API
virDomainGetBlockJobInfo requires manual override since it returns a
custom type.

* python/generator.py: reenable bindings for this entry point
* python/libvirt-override-api.xml python/libvirt-override.c:
  manual overrides
2011-07-22 13:43:53 +08:00
Eric Blake
21ecea2e93 Revert "Enable virDomainBlockPull in the python API."
This reverts commit d74b86f5d6.

Conflicts:

	python/generator.py
2011-06-24 08:41:24 -06:00
Jiri Denemark
67cc825dda Introduce virDomainGetControlInfo API
The API can be used to query current state of an interface to VMM used
to control a domain. In QEMU world this translates into monitor
connection.
2011-06-16 18:26:12 +02:00
Adam Litke
d74b86f5d6 Enable virDomainBlockPull in the python API.
virDomainBlockPullAll and virDomainBlockPullAbort are handled automatically.
virDomainBlockPull and virDomainBlockPullInfo require manual overrides since
they return a custom type.

* python/generator.py: reenable bindings for this entry point
* python/libvirt-override-api.xml python/libvirt-override.c:
  manual overrides

Signed-off-by: Adam Litke <agl@us.ibm.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
2011-06-14 22:37:39 -06:00
Jiri Denemark
d65a924b34 virDomainGetState public API
This API is supposed to replace virDomainGetInfo when the only purpose
of calling it is getting current domain status.
2011-05-16 10:04:18 +02:00
Gui Jianfeng
13c5282122 libvirt: add virDomain{Get,Set}BlkioParameters
Add virDomainSetBlkioParameters virDomainGetBlkioParameters

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
2011-03-10 17:53:16 -07:00
Nikunj A. Dadhania
bf1b76ffaa Adding structure and defines for virDomainSet/GetMemoryParameters
This patch adds a structure virMemoryParameter, it contains the name of
the
parameter and the type of the parameter along with a union.

dv:
+ rename enums to VIR_DOMAIN_MEMORY_PARAM_*
+ remove some extraneous tabs

v4:
+ Add unsigned int flags to the public api for future extensions

v3:
+ Protoype for virDomainGetMemoryParameters and dummy python binding.

v2:
+ Includes dummy python bindings for the library to build cleanly.
+ Define string constants like "hard_limit", etc.
+ re-order this patch.
2010-10-12 19:26:09 +02:00
Philipp Hahn
08fee18cc2 Fix description of virStorageVolGetInfo()
Probably a copy-paste-bug in python/libvirt-override-api.xml:
virStorageVolGetInfo() extracts information about a "storage volume",
not the "storage pool" as virStoragePoolGetInfo() does.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2010-06-18 12:57:54 +02:00
Chris Lalancette
8749256d0b Fix up the python bindings for snapshotting.
This involved a few fixes.  To start with,
an virDomainSnapshot object is really tied to a
domain, not a connection, so we have to generate
a slightly different object so that we can get
at self._dom for the object.

Next, we had to "dummy" up an override piece of
XML with a bogus argument that the function doesn't
actually take.  That's so that the generator places
virDomainRevertToSnapshot underneath the correct
class (namely, the virDomain class).

Finally, we had to hand-implement the
virDomainRevertToSnapshot implementation, ignoring the
bogus pointer we are being passed.

With all of this in place, I was able to successfully
take a snapshot and revert to it using only the
Python bindings.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-05-20 13:49:38 -04:00
Daniel P. Berrange
05776e09fc Implement python binding for virDomainGetBlockInfo
This binds the virDomainGetBlockInfo API to python's blockInfo
method on the domain object

>>> c = libvirt.openReadOnly('qemu:///session')
>>> d = c.lookupByName('demo')
>>> f = d.blockInfo("/dev/loop0", 0)
>>> print f
[1048576000L, 104857600L, 104857600L]

* python/libvirt-override-api.xml: Define override signature
* python/generator.py: Skip C impl generator for virDomainGetBlockInfo
* python/libvirt-override.c: Manual impl of virDomainGetBlockInfo
2010-04-29 17:21:32 +01:00