mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-08-02 04:21:59 +03:00
Support virDomainPinIOThread
Support the libvirt_virDomainSetIOThreads method using code that mimics the existing libvirt_virDomainPinVcpuFlags method The following is a sample session assuming guest 'iothr-gst' has IOThreads configured (it's currently running, too) >>> import libvirt >>> con=libvirt.open("qemu:///system") >>> dom=con.lookupByName('iothr-gst') >>> dom.ioThreadsInfo() [(1, [False, False, True, False]), (2, [False, False, False, True]), (3, [True, True, True, True])] >>> cpumap=(True,True,True,False) >>> dom.pinIOThread(3,cpumap) 0 >>> print dom.ioThreadsInfo() [(1, [False, False, True, False]), (2, [False, False, False, True]), (3, [True, True, True, False])] >>> merge
This commit is contained in:
@ -436,6 +436,7 @@ skip_impl = (
|
|||||||
'virDomainGetEmulatorPinInfo',
|
'virDomainGetEmulatorPinInfo',
|
||||||
'virDomainPinEmulator',
|
'virDomainPinEmulator',
|
||||||
'virDomainGetIOThreadsInfo',
|
'virDomainGetIOThreadsInfo',
|
||||||
|
'virDomainPinIOThread',
|
||||||
'virSecretGetValue',
|
'virSecretGetValue',
|
||||||
'virSecretSetValue',
|
'virSecretSetValue',
|
||||||
'virSecretGetUUID',
|
'virSecretGetUUID',
|
||||||
|
@ -284,6 +284,14 @@
|
|||||||
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||||
<return type='char *' info="list of IOThreads information including the iothread_id, the cpumap, and the cpumap length for each iothread_id."/>
|
<return type='char *' info="list of IOThreads information including the iothread_id, the cpumap, and the cpumap length for each iothread_id."/>
|
||||||
</function>
|
</function>
|
||||||
|
<function name='virDomainPinIOThread' file='python'>
|
||||||
|
<info>Dynamically change the real CPUs which can be allocated to an IOThread. This function requires privileged access to the hypervisor.</info>
|
||||||
|
<return type='int' info='0 in case of success, -1 in case of failure.'/>
|
||||||
|
<arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
|
||||||
|
<arg name='iothread_val' type='unsigned int' info='iothread_id number'/>
|
||||||
|
<arg name='cpumap' type='unsigned char *' info='pointer to a bit map of real CPUs (in 8-bit bytes) (IN) Each bit set to 1 means that corresponding CPU is usable. Bytes are stored in little-endian order: CPU0-7, 8-15... In each byte, lowest CPU number is least significant bit.'/>
|
||||||
|
<arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
|
||||||
|
</function>
|
||||||
<function name='virDomainSetSchedulerParameters' file='python'>
|
<function name='virDomainSetSchedulerParameters' file='python'>
|
||||||
<info>Change the scheduler parameters</info>
|
<info>Change the scheduler parameters</info>
|
||||||
<return type='int' info='-1 in case of error, 0 in case of success.'/>
|
<return type='int' info='-1 in case of error, 0 in case of success.'/>
|
||||||
|
@ -2081,6 +2081,70 @@ cleanup:
|
|||||||
return py_retval;
|
return py_retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
libvirt_virDomainPinIOThread(PyObject *self ATTRIBUTE_UNUSED,
|
||||||
|
PyObject *args)
|
||||||
|
{
|
||||||
|
virDomainPtr domain;
|
||||||
|
PyObject *pyobj_domain, *pycpumap;
|
||||||
|
PyObject *ret = NULL;
|
||||||
|
unsigned char *cpumap;
|
||||||
|
int cpumaplen, iothread_val, tuple_size, cpunum;
|
||||||
|
size_t i;
|
||||||
|
unsigned int flags;
|
||||||
|
int i_retval;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, (char *)"OiOI:virDomainPinIOThread",
|
||||||
|
&pyobj_domain, &iothread_val, &pycpumap, &flags))
|
||||||
|
return NULL;
|
||||||
|
domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
|
||||||
|
|
||||||
|
if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
|
||||||
|
return VIR_PY_INT_FAIL;
|
||||||
|
|
||||||
|
if (PyTuple_Check(pycpumap)) {
|
||||||
|
if ((tuple_size = PyTuple_Size(pycpumap)) == -1)
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "Unexpected type, tuple is required");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
cpumaplen = VIR_CPU_MAPLEN(cpunum);
|
||||||
|
if (VIR_ALLOC_N(cpumap, cpumaplen) < 0)
|
||||||
|
return PyErr_NoMemory();
|
||||||
|
|
||||||
|
for (i = 0; i < tuple_size; i++) {
|
||||||
|
PyObject *flag = PyTuple_GetItem(pycpumap, i);
|
||||||
|
bool b;
|
||||||
|
|
||||||
|
if (!flag || libvirt_boolUnwrap(flag, &b) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (b)
|
||||||
|
VIR_USE_CPU(cpumap, i);
|
||||||
|
else
|
||||||
|
VIR_UNUSE_CPU(cpumap, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; i < cpunum; i++)
|
||||||
|
VIR_UNUSE_CPU(cpumap, i);
|
||||||
|
|
||||||
|
LIBVIRT_BEGIN_ALLOW_THREADS;
|
||||||
|
i_retval = virDomainPinIOThread(domain, iothread_val,
|
||||||
|
cpumap, cpumaplen, flags);
|
||||||
|
LIBVIRT_END_ALLOW_THREADS;
|
||||||
|
if (i_retval < 0) {
|
||||||
|
ret = VIR_PY_INT_FAIL;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
ret = VIR_PY_INT_SUCCESS;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(cpumap);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
|
#endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@ -8577,6 +8641,7 @@ static PyMethodDef libvirtMethods[] = {
|
|||||||
#endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
|
#endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */
|
||||||
#if LIBVIR_CHECK_VERSION(1, 2, 14)
|
#if LIBVIR_CHECK_VERSION(1, 2, 14)
|
||||||
{(char *) "virDomainGetIOThreadsInfo", libvirt_virDomainGetIOThreadsInfo, METH_VARARGS, NULL},
|
{(char *) "virDomainGetIOThreadsInfo", libvirt_virDomainGetIOThreadsInfo, METH_VARARGS, NULL},
|
||||||
|
{(char *) "virDomainPinIOThread", libvirt_virDomainPinIOThread, METH_VARARGS, NULL},
|
||||||
#endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
|
#endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */
|
||||||
{(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools, METH_VARARGS, NULL},
|
{(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools, METH_VARARGS, NULL},
|
||||||
{(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools, METH_VARARGS, NULL},
|
{(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools, METH_VARARGS, NULL},
|
||||||
|
Reference in New Issue
Block a user