mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +00:00
python: add python binding for virDomainGetBlkioParameters
This commit is contained in:
parent
1768bf63ed
commit
9d5cef1872
@ -208,10 +208,10 @@
|
||||
<arg name='params' type='virBlkioParameterPtr' info='pointer to blkio tunable objects'/>
|
||||
</function>
|
||||
<function name='virDomainGetBlkioParameters' file='python'>
|
||||
<info>Get the blkio parameters, the @params array will be filled with the values.</info>
|
||||
<return type='int' info='-1 in case of error, 0 in case of success.'/>
|
||||
<info>Get the blkio parameters</info>
|
||||
<return type='virSchedParameterPtr' info='None in case of error, returns a dictionary of params'/>
|
||||
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||
<arg name='params' type='virBlkioParameterPtr' info='pointer to blkio tunable objects'/>
|
||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||
</function>
|
||||
<function name='virDomainSetMemoryParameters' file='python'>
|
||||
<info>Change the memory tunables</info>
|
||||
|
@ -572,11 +572,84 @@ libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
|
||||
return VIR_PY_INT_FAIL;
|
||||
}
|
||||
|
||||
/* FIXME: This is a place holder for the implementation. */
|
||||
static PyObject *
|
||||
libvirt_virDomainGetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
|
||||
PyObject *args ATTRIBUTE_UNUSED) {
|
||||
return VIR_PY_INT_FAIL;
|
||||
PyObject *args) {
|
||||
virDomainPtr domain;
|
||||
PyObject *pyobj_domain, *info;
|
||||
int i_retval;
|
||||
int nparams = 0, i;
|
||||
unsigned int flags;
|
||||
virTypedParameterPtr params;
|
||||
|
||||
if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetBlkioParameters",
|
||||
&pyobj_domain, &flags))
|
||||
return(NULL);
|
||||
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
|
||||
|
||||
LIBVIRT_BEGIN_ALLOW_THREADS;
|
||||
i_retval = virDomainGetBlkioParameters(domain, 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 = virDomainGetBlkioParameters(domain, 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;
|
||||
|
||||
switch (params[i].type) {
|
||||
case VIR_TYPED_PARAM_INT:
|
||||
val = PyInt_FromLong((long)params[i].value.i);
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_UINT:
|
||||
val = PyInt_FromLong((long)params[i].value.ui);
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_LLONG:
|
||||
val = PyLong_FromLongLong((long long)params[i].value.l);
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_ULLONG:
|
||||
val = PyLong_FromLongLong((long long)params[i].value.ul);
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_DOUBLE:
|
||||
val = PyFloat_FromDouble((double)params[i].value.d);
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_BOOLEAN:
|
||||
val = PyBool_FromLong((long)params[i].value.b);
|
||||
break;
|
||||
|
||||
default:
|
||||
free(params);
|
||||
Py_DECREF(info);
|
||||
return VIR_PY_NONE;
|
||||
}
|
||||
|
||||
key = libvirt_constcharPtrWrap(params[i].field);
|
||||
PyDict_SetItem(info, key, val);
|
||||
}
|
||||
free(params);
|
||||
return(info);
|
||||
}
|
||||
|
||||
/* FIXME: This is a place holder for the implementation. */
|
||||
|
Loading…
Reference in New Issue
Block a user