Signed-off-by:Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx> Signed-off-by: Lei Li <lilei@xxxxxxxxxxxxxxxxxx> --- python/generator.py | 2 + python/libvirt-override-api.xml | 16 ++++++++++++++ python/libvirt-override.c | 43 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 0 deletions(-) diff --git a/python/generator.py b/python/generator.py index 71afdb7..9d786c4 100755 --- a/python/generator.py +++ b/python/generator.py @@ -414,6 +414,8 @@ skip_impl = ( 'virDomainGetBlockJobInfo', 'virDomainMigrateGetMaxSpeed', 'virDomainBlockStatsFlags', + 'virDomainSetBlockIoThrottle', + 'virDomainGetBlockIoThrottle', ) qemu_skip_impl = ( diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml index ef02f34..5d85923 100644 --- a/python/libvirt-override-api.xml +++ b/python/libvirt-override-api.xml @@ -375,5 +375,21 @@ <arg name='flags' type='unsigned int' info='flags, currently unused, pass 0.'/> <return type='unsigned long' info='current max migration speed, or None in case of error'/> </function> + <function name='virDomainSetBlockIoThrottle' file='python'> + <info>Change the I/O throttle for a block device</info> + <arg name='dom' type='virDomainPtr' info='pointer to the domain'/> + <arg name='disk' type='const char *' info='disk name'/> + <arg name='info' type='virDomainBlockIoThrottleInfoPtr' info='io throttle limits'/> + <arg name='flags' type='unsigned int' info='0 on display, 1 on set.'/> + <return type='virDomainSetBlockIoThrottleInfo' info='0 in case of operation has started, -1 in case of failure'/> + </function> + <function name='virDomainGetBlockIoThrottle' file='python'> + <info>Get the I/O throttle for a block device</info> + <arg name='dom' type='virDomainPtr' info='pointer to the domain'/> + <arg name='disk' type='const char *' info='disk name'/> + <arg name='reply' type='virDomainBlockIoThrottleInfoPtr' info='io throttle info'/> + <arg name='flags' type='unsigned int' info='0 on display, 1 on set.'/> + <return type='virDomainGetBlockIoThrottleInfo' info='A dictionary containing block I/O limits information.'/> + </function> </symbols> </api> diff --git a/python/libvirt-override.c b/python/libvirt-override.c index 1759bae..c005cf0 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -3195,6 +3195,48 @@ LIBVIRT_END_ALLOW_THREADS; return ret; } +static PyObject * +libvirt_virDomainGetBlockIoThrottle(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) +{ + virDomainPtr domain; + PyObject *pyobj_domain; + const char *disk; + unsigned int flags; + virDomainBlockIoThrottleInfo reply; + int c_ret; + PyObject *ret; + + if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetBlockIoThrottle", + &pyobj_domain, &disk, &flags)) + return(NULL); + domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); + +LIBVIRT_BEGIN_ALLOW_THREADS; + c_ret = virDomainGetBlockIoThrottle(domain, disk, &reply, flags); +LIBVIRT_END_ALLOW_THREADS; + + if (c_ret != 1) + return VIR_PY_NONE; + + if ((ret = PyDict_New()) == NULL) + return VIR_PY_NONE; + + PyDict_SetItem(ret, libvirt_constcharPtrWrap("bps"), + libvirt_intWrap(reply.bps)); + PyDict_SetItem(ret, libvirt_constcharPtrWrap("bps_rd"), + libvirt_intWrap(reply.bps_rd)); + PyDict_SetItem(ret, libvirt_constcharPtrWrap("bps_wr"), + libvirt_intWrap(reply.bps_wr)); + PyDict_SetItem(ret, libvirt_constcharPtrWrap("iops"), + libvirt_intWrap(reply.iops)); + PyDict_SetItem(ret, libvirt_constcharPtrWrap("iops_rd"), + libvirt_intWrap(reply.iops_rd)); + PyDict_SetItem(ret, libvirt_constcharPtrWrap("iops_wr"), + libvirt_intWrap(reply.iops_wr)); + return ret; +} + /******************************************* * Helper functions to avoid importing modules * for every callback @@ -4837,6 +4879,7 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames, METH_VARARGS, NULL}, {(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot, METH_VARARGS, NULL}, {(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo, METH_VARARGS, NULL}, + {(char *) "virDomainGetBlockIoThrottle", libvirt_virDomainGetBlockIoThrottle, METH_VARARGS, NULL}, {(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL}, {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} -- 1.7.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list