summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2010-04-28 13:42:13 +0100
committerDaniel P. Berrange <berrange@redhat.com>2010-04-29 17:21:32 +0100
commit05776e09fc5a63789347468f3c7bb16b49f8ce1e (patch)
treed36ab307b5e16cdbe504bf99015c470fe3f41b8d
parentAdd new domblkinfo command to virsh (diff)
downloadlibvirt-05776e09fc5a63789347468f3c7bb16b49f8ce1e.tar.gz
libvirt-05776e09fc5a63789347468f3c7bb16b49f8ce1e.tar.bz2
libvirt-05776e09fc5a63789347468f3c7bb16b49f8ce1e.zip
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
-rwxr-xr-xpython/generator.py1
-rw-r--r--python/libvirt-override-api.xml7
-rw-r--r--python/libvirt-override.c27
3 files changed, 35 insertions, 0 deletions
diff --git a/python/generator.py b/python/generator.py
index 23b8f5fde..a243c825b 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -288,6 +288,7 @@ skip_impl = (
'virConnGetLastError',
'virGetLastError',
'virDomainGetInfo',
+ 'virDomainGetBlockInfo',
'virDomainGetJobInfo',
'virNodeGetInfo',
'virDomainGetUUID',
diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
index 76a102d52..9ba8e4e9e 100644
--- a/python/libvirt-override-api.xml
+++ b/python/libvirt-override-api.xml
@@ -48,6 +48,13 @@
<return type='int *' info='the list of information or None in case of error'/>
<arg name='domain' type='virDomainPtr' info='a domain object'/>
</function>
+ <function name='virDomainGetBlockInfo' file='python'>
+ <info>Extract information about a domain block device size</info>
+ <return type='int *' info='the list of information or None in case of error'/>
+ <arg name='domain' type='virDomainPtr' info='a domain object'/>
+ <arg name='path' type='const char *' info='path to the block device or file'/>
+ <arg name='flags' type='unsigned int' info='currently unused'/>
+ </function>
<function name='virDomainGetJobInfo' file='python'>
<info>Extract information about an active job being processed for a domain.</info>
<return type='int *' info='the list of information or None in case of error'/>
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 9ada15cc5..7c7682c63 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -1015,6 +1015,32 @@ libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
}
static PyObject *
+libvirt_virDomainGetBlockInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
+ PyObject *py_retval;
+ int c_retval;
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ virDomainBlockInfo info;
+ const char *path;
+ unsigned int flags;
+
+ if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetInfo", &pyobj_domain, &path, &flags))
+ return(NULL);
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainGetBlockInfo(domain, path, &info, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+ if (c_retval < 0)
+ return VIR_PY_NONE;
+ py_retval = PyList_New(3);
+ PyList_SetItem(py_retval, 0, libvirt_ulonglongWrap(info.capacity));
+ PyList_SetItem(py_retval, 1, libvirt_ulonglongWrap(info.allocation));
+ PyList_SetItem(py_retval, 2, libvirt_ulonglongWrap(info.physical));
+ return(py_retval);
+}
+
+static PyObject *
libvirt_virNodeGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
PyObject *py_retval;
int c_retval;
@@ -3393,6 +3419,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny, METH_VARARGS, NULL},
{(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny, METH_VARARGS, NULL},
{(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, METH_VARARGS, NULL},
+ {(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo, METH_VARARGS, NULL},
{(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL},
{(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL},
{(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString, METH_VARARGS, NULL},