diff options
author | Adam Litke <agl@us.ibm.com> | 2011-07-22 13:43:53 +0800 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2011-07-22 13:43:53 +0800 |
commit | 3d3872d29da204cdf8e9503f090029e8b5aa88ba (patch) | |
tree | 31e3d2d72e2a25bb027a796857ce2bd2ff855d8c | |
parent | 384d3ae35bb6c4ee90730bd273922447700bea82 (diff) | |
download | libvirt-python-v6-3d3872d29da204cdf8e9503f090029e8b5aa88ba.tar.gz libvirt-python-v6-3d3872d29da204cdf8e9503f090029e8b5aa88ba.tar.xz libvirt-python-v6-3d3872d29da204cdf8e9503f090029e8b5aa88ba.zip |
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
-rwxr-xr-x | generator.py | 2 | ||||
-rw-r--r-- | libvirt-override-api.xml | 7 | ||||
-rw-r--r-- | libvirt-override.c | 39 |
3 files changed, 47 insertions, 1 deletions
diff --git a/generator.py b/generator.py index b25c74e..d0d3ae6 100755 --- a/generator.py +++ b/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/libvirt-override-api.xml b/libvirt-override-api.xml index 01207d6..268f897 100644 --- a/libvirt-override-api.xml +++ b/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/libvirt-override.c b/libvirt-override.c index b713b6a..e89bc97 100644 --- a/libvirt-override.c +++ b/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} }; |