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

Re: [libvirt] [python PATCH v3 5/5] Implement API bindings for virDomainBlockCopy



On 09/02/14 00:08, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina redhat com>
> ---
> 
> new from v2:
> - removed parameter nparams
> - make params optional
> 
>  generator.py             |  1 +
>  libvirt-override-api.xml |  9 +++++++++
>  libvirt-override.c       | 33 +++++++++++++++++++++++++++++++++
>  3 files changed, 43 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..51d8273 100644
> --- a/libvirt-override-api.xml
> +++ b/libvirt-override-api.xml
> @@ -640,5 +640,14 @@
>        <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='optional pointer to block copy parameter object, or NULL'/>
> +      <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..444a5fe 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 *) "Ozz|Oi:virDomainBlockCopy",
> +                          &pyobj_dom, &disk, &destxml, &pyobj_dict, &nparams,
> +                          &flags))
> +        return VIR_PY_INT_FAIL;

You need to wrap the call below into a if (PyDict_Check(pyobj_dict)) as
it doesn't handle "None" gracefully.

> +    if (virPyDictToTypedParams(pyobj_dict, &params, &nparams, NULL, 0) < 0)
> +        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}
>  };
> 

ACK with the comment above addressed.

Peter

Attachment: signature.asc
Description: OpenPGP digital signature


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