On 09/01/14 22:18, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
generator.py | 1 +
libvirt-override-api.xml | 10 ++++++++++
libvirt-override.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+)
diff --git a/generator.py b/generator.py
index 1daf866..a798274 100755
--- a/generator.py
+++ b/generator.py
@@ -464,6 +464,7 @@ skip_impl = (
'virConnectGetCPUModelNames',
'virNodeGetFreePages',
'virNetworkGetDHCPLeases',
+ 'virDomainBlockCopy',
)
lxc_skip_impl = (
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 09bbbf8..f0049d7 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -640,5 +640,15 @@
<arg name='flags' type='unsigned int' info='unused, pass
0'/>
<return type='char *' info="list of leases"/>
</function>
+ <function name="virDomainBlockCopy" file="python">
+ <info>Copy the guest-visible contents of a disk image to a new file
described by destxml</info>
+ <arg name='dom' type='virDomainPtr' info='pointer to domain
object'/>
+ <arg name='disk' type='const char *' info='path to the
block device, or device shorthand'/>
+ <arg name='destxml' type='const char *' info='XML
description of the copy destination'/>
+ <arg name='params' type='virTypedParameterPtr'
info='pointer to block copy parameter object, or NULL'/>
+ <arg name='nparams' type='int' info='nuber of block copy
parameters (this value can be the same or less then the number of parameters
supported)'/>
Humm, the python generator doesn't have nice typed parameter support.
This actually wouldn't be usable from python as this python method
is generated:
def blockCopy(self, disk, destxml, params, nparams, flags=0):
"""Copy the guest-visible contents of a disk image to a new file
described by destxml """
ret = libvirtmod.virDomainBlockCopy(self._o, disk, destxml, params, nparams,
flags)
if ret == -1: raise libvirtError ('virDomainBlockCopy() failed',
dom=self)
return ret
As there is no nice way to construct a typed parameter in python
we usually convert them to or from dicts. This will require you
to write the python impl too and ...
+ <arg name='flags' type='unsigned int'
info='bitwise-OR of virDomainBlockCopyFlags'/>
+ <return type='int' info='0 if the operation has started, -1 on
failure'/>
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index 569778d..733a16f 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -8096,6 +8096,38 @@ libvirt_virDomainListGetStats(PyObject *self ATTRIBUTE_UNUSED,
return py_retval;
}
+
+static PyObject *
+libvirt_virDomainBlockCopy(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
+{
+ PyObject *pyobj_dom = NULL;
+ PyObject *pyobj_dict = NULL;
+
+ virDomainPtr dom;
+ char *disk = NULL;
+ char *destxml = NULL;
+ virTypedParameterPtr params;
+ int nparams;
+ unsigned int flags;
+ int c_retval;
+
+ if (!PyArg_ParseTuple(args, (char *) "OzzOii:virDomainBlockCopy",
+ &pyobj_dom, &disk, &destxml, &pyobj_dict,
&nparams,
... drop nparams here as that is infered from the length of the dict ...
+ &flags))
+ return VIR_PY_INT_FAIL;
+
+ if (virPyDictToTypedParams(pyobj_dict, ¶ms, &nparams, NULL, 0) < 0)
and finally overwritten here.
+ return VIR_PY_INT_FAIL;
+
+ dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainBlockCopy(dom, disk, destxml, params, nparams, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ return libvirt_intWrap(c_retval);
+}
+
#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
/************************************************************************
@@ -8286,6 +8318,7 @@ static PyMethodDef libvirtMethods[] = {
#if LIBVIR_CHECK_VERSION(1, 2, 8)
{(char *) "virConnectGetAllDomainStats",
libvirt_virConnectGetAllDomainStats, METH_VARARGS, NULL},
{(char *) "virDomainListGetStats", libvirt_virDomainListGetStats,
METH_VARARGS, NULL},
+ {(char *) "virDomainBlockCopy", libvirt_virDomainBlockCopy, METH_VARARGS,
NULL},
#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
{NULL, NULL, 0, NULL}
};
You might be fine if you drop the "nparams" argument from the XML describing the
API.
You also probably should make the argument optional by passing an empty dict or NONE
as a default value (IIRC by using keyword "Optional" in the description)
depending on what
virPyDictToTypedParams takes as missing typed params.
Peter