summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libvirt-override-api.xml13
-rw-r--r--libvirt-override.c125
2 files changed, 138 insertions, 0 deletions
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 4f609ee..b76fb4e 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -529,5 +529,18 @@
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='flags' type='unsigned int' info='unused, always pass 0'/>
</function>
+ <function name='virNodeSetMemoryParameters' file='python'>
+ <info>Change the node memory tunables</info>
+ <return type='int' info='-1 in case of error, 0 in case of success.'/>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ <arg name='params' type='virTypedParameterPtr' info='pointer to the memory tunable objects'/>
+ <arg name='flags' type='int' info='unused, always pass 0'/>
+ </function>
+ <function name='virNodeGetMemoryParameters' file='python'>
+ <info>Get the node memory parameters</info>
+ <return type='str *' info='None in case of error, returns a dictionary of params'/>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ <arg name='flags' type='int' info='unused, always pass 0'/>
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index 57f2c45..25f9d3f 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -6146,6 +6146,129 @@ cleanup:
return py_retval;
}
+static PyObject *
+libvirt_virNodeSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ virConnectPtr conn;
+ PyObject *pyobj_conn, *info;
+ PyObject *ret = NULL;
+ int i_retval;
+ int nparams = 0;
+ Py_ssize_t size = 0;
+ unsigned int flags;
+ virTypedParameterPtr params, new_params;
+
+ if (!PyArg_ParseTuple(args,
+ (char *)"OOi:virNodeSetMemoryParameters",
+ &pyobj_conn, &info, &flags))
+ return NULL;
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ 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 = virNodeGetMemoryParameters(conn, NULL, &nparams, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (i_retval < 0)
+ return VIR_PY_INT_FAIL;
+
+ if (nparams == 0) {
+ PyErr_Format(PyExc_LookupError,
+ "no settable attributes");
+ return NULL;
+ }
+
+ if (VIR_ALLOC_N(params, nparams) < 0)
+ return PyErr_NoMemory();
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ i_retval = virNodeGetMemoryParameters(conn, 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 = virNodeSetMemoryParameters(conn, 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_virNodeGetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ virConnectPtr conn;
+ PyObject *pyobj_conn;
+ PyObject *ret = NULL;
+ int i_retval;
+ int nparams = 0;
+ unsigned int flags;
+ virTypedParameterPtr params;
+
+ if (!PyArg_ParseTuple(args, (char *)"Oi:virNodeGetMemoryParameters",
+ &pyobj_conn, &flags))
+ return NULL;
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ i_retval = virNodeGetMemoryParameters(conn, 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 = virNodeGetMemoryParameters(conn, 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;
+}
+
+
/************************************************************************
* *
* The registration stuff *
@@ -6260,6 +6383,8 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek, METH_VARARGS, NULL},
{(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek, METH_VARARGS, NULL},
{(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors, METH_VARARGS, NULL},
+ {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters, METH_VARARGS, NULL},
+ {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};