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.
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.
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>
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>
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.
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.
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.
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.
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.
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.
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.
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.
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.
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>
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>
This patch adds binding for virNodeGetMemoryStats method of libvirtd.
Return value is represented as a python dictionary mapping field
names to values.
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>
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.
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
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
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
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
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>
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.
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>
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>
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