On 12/29/2011 08:30 PM, Osier Yang wrote:
On 2011年12月29日 19:10, ajia@xxxxxxxxxx wrote:
From: Alex Jia<ajia@xxxxxxxxxx>
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@xxxxxxxxxx>
---
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.
Osier, you're right, I need to avoid memory leaks, however, it seems the
above codes aren't enough, the leaks still exist, I will see it again.
Thanks,
Alex
default:
free(params);
Py_DECREF(info);
Regards,
Osier
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list