Re: [PATCH 7/8] Support virDomain{Set, Get}BlockIoTune in the python API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/15/2011 02:02 AM, Lei Li wrote:
> Python support for both setting and getting block I/O throttle.
> 
> Signed-off-by: Lei Li <lilei@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx>
> ---
>  python/generator.py             |    2 +

Yay - I get to undo my hack from 1/8.

>  python/libvirt-override-api.xml |   16 ++++
>  python/libvirt-override.c       |  178 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 196 insertions(+), 0 deletions(-)
> 
> +++ 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='virDomainSetBlockIoTune' file='python'>
> +      <info>Change the I/O throttle for a block device</info>

Tweak the wording to be more like libvirt.c.

> +    /* convert to a Python tuple of long objects */
> +    for (i = 0; i < nparams; i++) {
> +        PyObject *key, *val;
> +        key = libvirt_constcharPtrWrap(params[i].field);
> +        val = PyDict_GetItem(pyinfo, key);
> +        Py_DECREF(key);
> +
> +        if (val == NULL)
> +            continue;
> +
> +        switch (params[i].type) {
> +        case VIR_TYPED_PARAM_INT:
> +            params[i].value.i = (int)PyInt_AS_LONG(val);
> +            break;
> +
> +        case VIR_TYPED_PARAM_UINT:
> +            params[i].value.ui = (unsigned int)PyInt_AS_LONG(val);
> +            break;
> +
> +        case VIR_TYPED_PARAM_LLONG:
> +            params[i].value.l = (long long)PyLong_AsLongLong(val);
> +            break;
> +
> +        case VIR_TYPED_PARAM_ULLONG:
> +            params[i].value.ul = (unsigned long long)PyLong_AsLongLong(val);
> +            break;
> +
> +        case VIR_TYPED_PARAM_DOUBLE:
> +            params[i].value.d = (double)PyFloat_AsDouble(val);
> +            break;
> +
> +        case VIR_TYPED_PARAM_BOOLEAN:
> +            {
> +                PyObject *hacktrue = PyBool_FromLong(1);
> +                params[i].value.b = hacktrue == val ? 1: 0;
> +                Py_DECREF(hacktrue);
> +            }
> +            break;
> +
> +        default:

You know, I bet that the recent introduction of VIR_TYPED_PARAM_STRING
breaks the python handling of global blkio parameters (at any rate, when
we fix that, we should also fix this to handle strings, even if no one
currently sends a string for a per-device io tuning parameter).

> +            free(params);
> +            return VIR_PY_INT_FAIL;
> +        }
> +    }
> +
> +    LIBVIRT_BEGIN_ALLOW_THREADS;
> +    c_ret = virDomainSetMemoryParameters(domain, params, nparams, flags);
> +    LIBVIRT_END_ALLOW_THREADS;

Huh?  Why are we setting memory parameters?  Too much copy-and-paste.

Here's what I'm squashing in:

diff --git i/python/generator.py w/python/generator.py
index d6bf994..88c52b9 100755
--- i/python/generator.py
+++ w/python/generator.py
@@ -472,9 +472,6 @@ skip_function = (
     "virNWFilterGetConnect",
     "virStoragePoolGetConnect",
     "virStorageVolGetConnect",
-
-    "virDomainGetBlockIoTune", # not implemented yet
-    "virDomainSetBlockIoTune", # not implemented yet
 )

 qemu_skip_function = (
diff --git i/python/libvirt-override-api.xml
w/python/libvirt-override-api.xml
index a05da3c..6aad49c 100644
--- i/python/libvirt-override-api.xml
+++ w/python/libvirt-override-api.xml
@@ -376,18 +376,18 @@
       <return type='unsigned long' info='current max migration speed,
or None in case of error'/>
     </function>
     <function name='virDomainSetBlockIoTune' file='python'>
-      <info>Change the I/O throttle for a block device</info>
+      <info>Change the I/O tunables 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='params' type='virTypedParameterPtr' info='Pointer to
blkio throttle params object'/>
+      <arg name='params' type='virTypedParameterPtr' info='Pointer to
blkio tuning params object'/>
       <arg name='flags' type='unsigned int' info='an OR&apos;ed set of
virDomainModificationImpact'/>
       <return type='int' info='0 in case of success, -1 in case of
failure'/>
     </function>
     <function name='virDomainGetBlockIoTune' file='python'>
-      <info>Get the I/O throttle a block device</info>
+      <info>Get the I/O tunables 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='params' type='virTypedParameterPtr' info='Pointer to
blkio throttle params object'/>
+      <arg name='params' type='virTypedParameterPtr' info='Pointer to
blkio tuning params object'/>
       <arg name='flags' type='unsigned int' info='an OR&apos;ed set of
virDomainModificationImpact'/>
       <return type='int' info='0 in case of success, -1 in case of
failure'/>
     </function>
diff --git i/python/libvirt-override.c w/python/libvirt-override.c
index be76d87..cfb9a31 100644
--- i/python/libvirt-override.c
+++ w/python/libvirt-override.c
@@ -3277,7 +3277,7 @@ libvirt_virDomainSetBlockIoTune(PyObject *self
ATTRIBUTE_UNUSED,
     }

     LIBVIRT_BEGIN_ALLOW_THREADS;
-    c_ret = virDomainSetMemoryParameters(domain, params, nparams, flags);
+    c_ret = virDomainSetBlockIoTune(domain, disk, params, nparams, flags);
     LIBVIRT_END_ALLOW_THREADS;

     if (c_ret < 0) {


-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]