[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 6/8] 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

Signed-off-by: Adam Litke <agl us ibm com>
---
 python/generator.py             |    2 +-
 python/libvirt-override-api.xml |    7 +++++++
 python/libvirt-override.c       |   39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/python/generator.py b/python/generator.py
index b25c74e..d0d3ae6 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -186,7 +186,6 @@ def enum(type, name, value):
 functions_failed = []
 functions_skipped = [
     "virConnectListDomains",
-    'virDomainGetBlockJobInfo',
 ]
 
 skipped_modules = {
@@ -370,6 +369,7 @@ skip_impl = (
     'virDomainSendKey',
     'virNodeGetCPUStats',
     'virNodeGetMemoryStats',
+    'virDomainGetBlockJobInfo',
 )
 
 
diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
index 01207d6..268f897 100644
--- a/python/libvirt-override-api.xml
+++ b/python/libvirt-override-api.xml
@@ -320,5 +320,12 @@
       <arg name='flags' type='unsigned int' info='flags, curently unused'/>
       <return type='int' info="0 on success, -1 on error"/>
     </function>
+    <function name='virDomainGetBlockJobInfo' file='python'>
+      <info>Get progress information for a block job</info>
+      <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
+      <arg name='path' type='const char *' info='Fully-qualified filename of disk'/>
+      <arg name='flags' type='unsigned int' info='fine-tuning flags, currently unused, pass 0.'/>
+      <return type='virDomainBlockJobInfo' info='A dictionary containing job information.' />
+    </function>
   </symbols>
 </api>
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index b713b6a..e89bc97 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -2413,6 +2413,44 @@ libvirt_virDomainGetJobInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
     return(py_retval);
 }
 
+static PyObject *
+libvirt_virDomainGetBlockJobInfo(PyObject *self ATTRIBUTE_UNUSED,
+                                 PyObject *args)
+{
+    virDomainPtr domain;
+    PyObject *pyobj_domain;
+    const char *path;
+    unsigned int flags;
+    virDomainBlockJobInfo info;
+    int c_ret;
+    PyObject *ret;
+
+    if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetBlockJobInfo",
+                          &pyobj_domain, &path, &flags))
+        return(NULL);
+    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+LIBVIRT_BEGIN_ALLOW_THREADS;
+    c_ret = virDomainGetBlockJobInfo(domain, path, &info, flags);
+LIBVIRT_END_ALLOW_THREADS;
+
+    if (c_ret != 1)
+        return VIR_PY_NONE;
+
+    if ((ret = PyDict_New()) == NULL)
+        return VIR_PY_NONE;
+
+    PyDict_SetItem(ret, libvirt_constcharPtrWrap("type"),
+                   libvirt_intWrap(info.type));
+    PyDict_SetItem(ret, libvirt_constcharPtrWrap("bandwidth"),
+                   libvirt_ulongWrap(info.bandwidth));
+    PyDict_SetItem(ret, libvirt_constcharPtrWrap("cur"),
+                   libvirt_ulonglongWrap(info.cur));
+    PyDict_SetItem(ret, libvirt_constcharPtrWrap("end"),
+                   libvirt_ulonglongWrap(info.end));
+
+    return ret;
+}
 
 /*******************************************
  * Helper functions to avoid importing modules
@@ -3872,6 +3910,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 *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo, METH_VARARGS, NULL},
     {NULL, NULL, 0, NULL}
 };
 
-- 
1.7.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]