diff options
Diffstat (limited to 'libvirt-override.c')
-rw-r--r-- | libvirt-override.c | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/libvirt-override.c b/libvirt-override.c index 4e8a97e..792cfa3 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -1109,6 +1109,130 @@ cleanup: } static PyObject * +libvirt_virDomainSetInterfaceParameters(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) +{ + virDomainPtr domain; + PyObject *pyobj_domain, *info; + PyObject *ret = NULL; + int i_retval; + int nparams = 0; + Py_ssize_t size = 0; + unsigned int flags; + const char *device = NULL; + virTypedParameterPtr params, new_params; + + if (!PyArg_ParseTuple(args, + (char *)"OzOi:virDomainSetInterfaceParameters", + &pyobj_domain, &device, &info, &flags)) + return NULL; + domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); + + if ((size = PyDict_Size(info)) < 0) + return NULL; + + if (size == 0) { + PyErr_Format(PyExc_LookupError, + "Need non-empty dictionary to set attributes"); + return NULL; + } + + LIBVIRT_BEGIN_ALLOW_THREADS; + i_retval = virDomainGetInterfaceParameters(domain, device, NULL, &nparams, flags); + LIBVIRT_END_ALLOW_THREADS; + + if (i_retval < 0) + return VIR_PY_INT_FAIL; + + if (nparams == 0) { + PyErr_Format(PyExc_LookupError, + "Domain has no settable attributes"); + return NULL; + } + + if (VIR_ALLOC_N(params, nparams) < 0) + return PyErr_NoMemory(); + + LIBVIRT_BEGIN_ALLOW_THREADS; + i_retval = virDomainGetInterfaceParameters(domain, device, params, &nparams, flags); + LIBVIRT_END_ALLOW_THREADS; + + if (i_retval < 0) { + ret = VIR_PY_INT_FAIL; + goto cleanup; + } + + new_params = setPyVirTypedParameter(info, params, nparams); + if (!new_params) + goto cleanup; + + LIBVIRT_BEGIN_ALLOW_THREADS; + i_retval = virDomainSetInterfaceParameters(domain, device, new_params, size, flags); + LIBVIRT_END_ALLOW_THREADS; + + if (i_retval < 0) { + ret = VIR_PY_INT_FAIL; + goto cleanup; + } + + ret = VIR_PY_INT_SUCCESS; + +cleanup: + virTypedParameterArrayClear(params, nparams); + VIR_FREE(params); + VIR_FREE(new_params); + return ret; +} + +static PyObject * +libvirt_virDomainGetInterfaceParameters(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) +{ + virDomainPtr domain; + PyObject *pyobj_domain; + PyObject *ret = NULL; + int i_retval; + int nparams = 0; + unsigned int flags; + const char *device = NULL; + virTypedParameterPtr params; + + if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetInterfaceParameters", + &pyobj_domain, &device, &flags)) + return NULL; + domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); + + LIBVIRT_BEGIN_ALLOW_THREADS; + i_retval = virDomainGetInterfaceParameters(domain, device, NULL, &nparams, flags); + LIBVIRT_END_ALLOW_THREADS; + + if (i_retval < 0) + return VIR_PY_NONE; + + if (!nparams) + return PyDict_New(); + + if (VIR_ALLOC_N(params, nparams) < 0) + return PyErr_NoMemory(); + + LIBVIRT_BEGIN_ALLOW_THREADS; + i_retval = virDomainGetInterfaceParameters(domain, device, params, &nparams, flags); + LIBVIRT_END_ALLOW_THREADS; + + if (i_retval < 0) { + ret = VIR_PY_NONE; + goto cleanup; + } + + ret = getPyVirTypedParameter(params, nparams); + +cleanup: + virTypedParameterArrayClear(params, nparams); + VIR_FREE(params); + return ret; +} + +static PyObject * libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { virDomainPtr domain; @@ -5256,6 +5380,8 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virDomainGetMemoryParameters", libvirt_virDomainGetMemoryParameters, METH_VARARGS, NULL}, {(char *) "virDomainSetNumaParameters", libvirt_virDomainSetNumaParameters, METH_VARARGS, NULL}, {(char *) "virDomainGetNumaParameters", libvirt_virDomainGetNumaParameters, METH_VARARGS, NULL}, + {(char *) "virDomainSetInterfaceParameters", libvirt_virDomainSetInterfaceParameters, METH_VARARGS, NULL}, + {(char *) "virDomainGetInterfaceParameters", libvirt_virDomainGetInterfaceParameters, METH_VARARGS, NULL}, {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus, METH_VARARGS, NULL}, {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu, METH_VARARGS, NULL}, {(char *) "virDomainPinVcpuFlags", libvirt_virDomainPinVcpuFlags, METH_VARARGS, NULL}, |