[libvirt] [PATCH] python: Fix problems of virDomain{Set, Get}BlkioParameters bindings

Osier Yang jyang at redhat.com
Thu Dec 29 12:30:08 UTC 2011


On 2011年12月29日 19:10, ajia at redhat.com wrote:
> From: Alex Jia<ajia at redhat.com>
>
> The parameter 'device_weight' is a string, however, the 'VIR_TYPED_PARAM_STRING'
> type condition is missed by libvirt_virDomain{Set, Get}BlkioParameters bindings,
> the result is we can't get or change 'device_weight' value.
>
> * python/libvirt-override.c: Add missing 'VIR_TYPED_PARAM_STRING' condition into
> libvirt_virDomain{Set, Get}BlkioParameters bindings.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=770795
>
> Signed-off-by: Alex Jia<ajia at redhat.com>
> ---
>   python/libvirt-override.c |    8 ++++++++
>   1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/python/libvirt-override.c b/python/libvirt-override.c
> index d2aad0f..c8ea3dc 100644
> --- a/python/libvirt-override.c
> +++ b/python/libvirt-override.c
> @@ -726,6 +726,10 @@ libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
>               }
>               break;
>
> +        case VIR_TYPED_PARAM_STRING:
> +            params[i].value.s = PyString_AsString(val);
> +            break;
> +
>           default:
>               free(params);
>               return VIR_PY_INT_FAIL;
> @@ -811,6 +815,10 @@ libvirt_virDomainGetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
>               val = PyBool_FromLong((long)params[i].value.b);
>               break;
>
> +        case VIR_TYPED_PARAM_STRING:
> +            val = PyString_FromString((char *)params[i].value.s);
> +            break;
> +

If you tend to fix the problem, you might also want to free() the
params[i].value.s. Something like:

for (i = 0; i < nparams; ++i) {
     if (params[i].type == VIR_TYPED_PARAM_STRING)
         free(params[i].value.s)
}

Both in the default clause branch. And at the end of function.

>           default:
>               free(params);
>               Py_DECREF(info);

Regards,
Osier




More information about the libvir-list mailing list