<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small;color:#000000"><span style="color:rgb(34,34,34)">On Mon, Mar 11, 2019 at 12:00 PM Daniel P. Berrangé <<a href="mailto:berrange@redhat.com">berrange@redhat.com</a>> wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sun, Mar 10, 2019 at 03:03:25AM +0200, Nir Soffer wrote:<br>
> Commit 2b4bd07e0a22 (Add check for params, nparams being a dictionary)<br>
> changed the way the optional params argument is treated. If<br>
> libvirt.virDomain.blockCopy() is called without specifying params,<br>
> params is None, and the call will fail with:<br>
> <br>
>     TypeError: block params must be a dictionary<br>
> <br>
> This is wrong as params is defined as kwarg, breaking existing libvirt<br>
> users like oVirt. Remove the check, restoring the previous behaviour.<br>
> <br>
> Resolves: <a href="https://bugzilla.redhat.com/1687114" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/1687114</a><br>
> <br>
> Signed-off-by: Nir Soffer <<a href="mailto:nsoffer@redhat.com" target="_blank">nsoffer@redhat.com</a>><br>
> ---<br>
>  libvirt-override.c | 4 +---<br>
>  1 file changed, 1 insertion(+), 3 deletions(-)<br>
> <br>
> diff --git a/libvirt-override.c b/libvirt-override.c<br>
> index 857c018..127d71c 100644<br>
> --- a/libvirt-override.c<br>
> +++ b/libvirt-override.c<br>
> @@ -8829,19 +8829,17 @@ libvirt_virDomainBlockCopy(PyObject *self ATTRIBUTE_UNUSED,<br>
>  <br>
>      if (!PyArg_ParseTuple(args, (char *) "Ozz|OI:virDomainBlockCopy",<br>
>                            &pyobj_dom, &disk, &destxml, &pyobj_dict, &flags))<br>
>          return NULL;<br>
>  <br>
> +    /* Note: params is optional in libvirt.py */<br>
>      if (PyDict_Check(pyobj_dict)) {<br>
>          if (virPyDictToTypedParams(pyobj_dict, &params, &nparams,<br>
>                                     virPyDomainBlockCopyParams,<br>
>                                     VIR_N_ELEMENTS(virPyDomainBlockCopyParams)) < 0) {<br>
>              return NULL;<br>
>          }<br>
> -    } else {<br>
> -        PyErr_Format(PyExc_TypeError, "block params must be a dictionary");<br>
> -        return NULL;<br>
>      }<br>
<br>
Rather than removing this else branch, I think we should have an explict<br>
check for None first<br>
<br>
   if (pyobj_dict == Py_None) {<br>
       ...no op..<br>
   } else if (PyDict_Check(....)) {<br>
   } else {<br>
       .... error ...<br>
   }<br>
<br>
Can you do that & validate that it works with oVirt.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">Sure, I'll send v2.</div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)"></div><div class="gmail_default" style="font-size:small;color:rgb(0,0,0)">Nir</div></div></div></div>