Enable virDomainStreamDiskInfo in the python API. dom.StreamDiskInfo() will
return a list containing a dictionary for each active stream. Each dictionary
contains items to report: the disk alias, the current stream offset, and the
total disk size.
virDomainStreamDisk() works with the automatic wrappers.
* python/generator.py: reenable bindings for this entry point
* python/libvirt-override-api.xml python/libvirt-override.c: the
generator can't handle this new function, add the new binding,
and the XML description
Signed-off-by: Adam Litke <agl(a)us.ibm.com>
---
python/generator.py | 4 +--
python/libvirt-override-api.xml | 5 ++++
python/libvirt-override.c | 46 +++++++++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/python/generator.py b/python/generator.py
index 69ffcad..2c5f6b2 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -166,8 +166,6 @@ def enum(type, name, value):
functions_failed = []
functions_skipped = [
"virConnectListDomains",
- "virDomainStreamDisk",
- "virDomainStreamDiskInfo",
]
skipped_modules = {
@@ -182,7 +180,6 @@ skipped_types = {
'virConnectDomainEventIOErrorCallback': "No function types in
python",
'virConnectDomainEventGraphicsCallback': "No function types in
python",
'virEventAddHandleFunc': "No function types in python",
- 'virStreamDiskStatePtr': "Not implemented yet",
}
#######################################################################
@@ -344,6 +341,7 @@ skip_impl = (
'virNodeDeviceListCaps',
'virConnectBaselineCPU',
'virDomainRevertToSnapshot',
+ 'virDomainStreamDiskInfo',
)
diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
index 54deeb5..9a74551 100644
--- a/python/libvirt-override-api.xml
+++ b/python/libvirt-override-api.xml
@@ -308,5 +308,10 @@
<arg name='flags' type='unsigned int' info='flags, curently
unused'/>
<return type='int' info="0 on success, -1 on error"/>
</function>
+ <function name='virDomainStreamDiskInfo' file='python'>
+ <info>collect information about active disk streams</info>
+ <arg name='domain' type='virDomainPtr' info='pointer to the
domain'/>
+ <return type='virDomainStreamDiskInfo *' info='A list containing one
dictionary of statistics for each active stream' />
+ </function>
</symbols>
</api>
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 4a9b432..984d3ef 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -3508,6 +3508,51 @@ libvirt_virConnectDomainEventDeregisterAny(ATTRIBUTE_UNUSED
PyObject * self,
return (py_retval);
}
+static PyObject *
+libvirt_virDomainStreamDiskInfo(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args) {
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ unsigned int nr_streams, i;
+ struct _virStreamDiskState streams[VIR_STREAM_DISK_MAX_STREAMS];
+ PyObject *ret;
+
+ if (!PyArg_ParseTuple(args, (char *)"O:virDomainStreamDiskInfo",
+ &pyobj_domain))
+ return(NULL);
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ nr_streams = virDomainStreamDiskInfo(domain, streams,
+ VIR_STREAM_DISK_MAX_STREAMS, 0);
+ if (nr_streams == -1)
+ return VIR_PY_NONE;
+
+ if ((ret = PyList_New(nr_streams)) == NULL)
+ return VIR_PY_NONE;
+
+ for (i = 0; i < nr_streams; i++) {
+ PyObject *dict = PyDict_New();
+ if (dict == NULL)
+ goto error;
+ PyDict_SetItem(dict, libvirt_constcharPtrWrap("path"),
+ libvirt_constcharPtrWrap(streams[i].path));
+ PyDict_SetItem(dict, libvirt_constcharPtrWrap("offset"),
+ libvirt_ulonglongWrap(streams[i].offset));
+ PyDict_SetItem(dict, libvirt_constcharPtrWrap("size"),
+ libvirt_ulonglongWrap(streams[i].size));
+ PyList_SetItem(ret, i, dict);
+ }
+ return ret;
+
+error:
+ for (i = 0; i < PyList_Size(ret); i++) {
+ PyObject *item = PyList_GET_ITEM(ret, i);
+ Py_XDECREF(item);
+ }
+ Py_DECREF(ret);
+ return VIR_PY_NONE;
+}
+
/************************************************************************
* *
@@ -3585,6 +3630,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo, METH_VARARGS,
NULL},
{(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames,
METH_VARARGS, NULL},
{(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot,
METH_VARARGS, NULL},
+ {(char *) "virDomainStreamDiskInfo", libvirt_virDomainStreamDiskInfo,
METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
--
1.7.3