--- python/generator.py | 1 + python/libvirt-override-api.xml | 7 +++++ python/libvirt-override.c | 55 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 0 deletions(-) diff --git a/python/generator.py b/python/generator.py index 97434ed..85ee614 100755 --- a/python/generator.py +++ b/python/generator.py @@ -372,6 +372,7 @@ skip_impl = ( 'virNodeGetCPUStats', 'virNodeGetMemoryStats', 'virDomainGetBlockJobInfo', + 'virDomainBlockStatsFlags', ) diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml index 2fa5eed..091932f 100644 --- a/python/libvirt-override-api.xml +++ b/python/libvirt-override-api.xml @@ -128,6 +128,13 @@ <arg name='domain' type='virDomainPtr' info='a domain object'/> <arg name='path' type='char *' info='the path for the block device'/> </function> + <function name='virDomainBlockStatsFlags' file='python'> + <info>Extracts block device statistics parameters of a running domain</info> + <return type='virDomainBlockStatsFlagsPtr' info='None in case of error, returns a dictionary of params'/> + <arg name='domain' type='virDomainPtr' info='pointer to domain object'/> + <arg name='path' type='char *' info='the path for the block device'/> + <arg name='flags' type='int' info='flags (unused; pass 0)'/> + </function> <function name='virDomainInterfaceStats' file='python'> <info>Extracts interface device statistics for a domain</info> <return type='virDomainInterfaceStats' info='a tuple of statistics'/> diff --git a/python/libvirt-override.c b/python/libvirt-override.c index b5650e2..01ffa7e 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -100,6 +100,60 @@ libvirt_virDomainBlockStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { } static PyObject * +libvirt_virDomainBlockStatsFlags(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) { + virDomainPtr domain; + PyObject *pyobj_domain, *info; + int i_retval; + int nparams = 0, i; + unsigned int flags; + virDomainBlockStatsFlagsPtr params; + const char *path; + + if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainBlockStatsFlags", + &pyobj_domain, &path, &flags)) + return(NULL); + domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); + + LIBVIRT_BEGIN_ALLOW_THREADS; + i_retval = virDomainBlockStatsFlags(domain, path, NULL, &nparams, flags); + LIBVIRT_END_ALLOW_THREADS; + + if (i_retval < 0) + return VIR_PY_NONE; + + if ((params = malloc(sizeof(*params)*nparams)) == NULL) + return VIR_PY_NONE; + + LIBVIRT_BEGIN_ALLOW_THREADS; + i_retval = virDomainBlockStatsFlags(domain, path, params, &nparams, flags); + LIBVIRT_END_ALLOW_THREADS; + + if (i_retval < 0) { + free(params); + return VIR_PY_NONE; + } + + /* convert to a Python tuple of long objects */ + if ((info = PyDict_New()) == NULL) { + free(params); + return VIR_PY_NONE; + } + for (i = 0 ; i < nparams ; i++) { + PyObject *key, *val; + + val = PyLong_FromLongLong((long long)params[i].value); + key = libvirt_constcharPtrWrap(params[i].field); + + PyDict_SetItem(info, key, val); + } + + free(params); + return(info); +} + + +static PyObject * libvirt_virDomainInterfaceStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { virDomainPtr domain; PyObject *pyobj_domain; @@ -4582,6 +4636,7 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart, METH_VARARGS, NULL}, {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart, METH_VARARGS, NULL}, {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats, METH_VARARGS, NULL}, + {(char *) "virDomainBlockStatsFlags", libvirt_virDomainBlockStatsFlags, METH_VARARGS, NULL}, {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats, METH_VARARGS, NULL}, {(char *) "virDomainMemoryStats", libvirt_virDomainMemoryStats, METH_VARARGS, NULL}, {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory, METH_VARARGS, NULL}, -- 1.7.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list