[libvirt-python][PATCH] Implement virNodeHugeTLB

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

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 generator.py                   |  2 ++
 libvirt-override-virConnect.py |  7 ++++
 libvirt-override.c             | 78 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+)

diff --git a/generator.py b/generator.py
index bdac877..a35c05c 100755
--- a/generator.py
+++ b/generator.py
@@ -522,6 +522,8 @@ skip_function = (
     'virDomainGetTime', # overridden in virDomain.py
     'virDomainSetTime', # overridden in virDomain.py
 
+    'virNodeHugeTLB', # overridden in virConnect.py
+
     # 'Ref' functions have no use for bindings users.
     "virConnectRef",
     "virDomainRef",
diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py
index c228eb2..9c46e0f 100644
--- a/libvirt-override-virConnect.py
+++ b/libvirt-override-virConnect.py
@@ -383,3 +383,10 @@
         if ret is None:raise libvirtError('virDomainCreateXMLWithFiles() failed', conn=self)
         __tmp = virDomain(self,_obj=ret)
         return __tmp
+
+    def hugeTLB(self, node=-1, flags=0):
+        """Get info on huge pages. Pass node=-1 for list of supported
+        hugepages sizes """
+        ret = libvirtmod.virNodeHugeTLB(self._o, node, flags)
+        if ret is None: raise libvirtError('virNodeHugeTLB() failed', conn=self)
+        return ret
diff --git a/libvirt-override.c b/libvirt-override.c
index a7a6213..1d1dc4e 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -7740,6 +7740,81 @@ libvirt_virDomainSetTime(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
 }
 #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
 
+#if LIBVIR_CHECK_VERSION(1, 2, 6)
+static PyObject *
+libvirt_virNodeHugeTLB(PyObject *self ATTRIBUTE_UNUSED,
+                       PyObject *args) {
+    virConnectPtr conn;
+    PyObject *pyobj_conn, *py_retval = NULL;
+    PyObject *dict = NULL;
+    int node = -1;
+    virTypedParameterPtr params;
+    int nparams = 0;
+    unsigned int flags;
+    int c_retval;
+    ssize_t i, j;
+    unsigned int count = 0;
+
+    if (!PyArg_ParseTuple(args, (char *)"Oii:virNodeHugeTLB",
+                          &pyobj_conn, &node, &flags))
+        return NULL;
+    conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+    LIBVIRT_BEGIN_ALLOW_THREADS;
+    c_retval = virNodeHugeTLB(conn, node, NULL, &nparams, flags);
+    LIBVIRT_END_ALLOW_THREADS;
+
+    if (c_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;
+    c_retval = virNodeHugeTLB(conn, node, params, &nparams, flags);
+    LIBVIRT_END_ALLOW_THREADS;
+
+    if (c_retval < 0) {
+        py_retval = VIR_PY_NONE;
+        goto cleanup;
+    }
+
+    if (!(dict = PyDict_New()))
+        goto cleanup;
+
+    j = i = nparams;
+    while (i) {
+        PyObject *key, *val;
+
+        i--;
+
+        if (STREQ(VIR_NODE_HUGE_PAGE_SIZE, params[i].field)) {
+            val = getPyVirTypedParameter(params + i, j - i);
+            key = libvirt_uintWrap(count++);
+
+            if (!val || !key ||
+                PyDict_SetItem(dict, key, val) < 0) {
+                Py_XDECREF(val);
+                Py_XDECREF(key);
+                goto cleanup;
+            }
+            j = i;
+        }
+    }
+
+    py_retval = dict;
+    dict = NULL;
+
+ cleanup:
+    virTypedParamsFree(params, nparams);
+    Py_XDECREF(dict);
+    return py_retval;
+}
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
+
 /************************************************************************
  *									*
  *			The registration stuff				*
@@ -7921,6 +7996,9 @@ static PyMethodDef libvirtMethods[] = {
     {(char *) "virDomainGetTime", libvirt_virDomainGetTime, METH_VARARGS, NULL},
     {(char *) "virDomainSetTime", libvirt_virDomainSetTime, METH_VARARGS, NULL},
 #endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
+#if LIBVIR_CHECK_VERSION(1, 2, 6)
+    {(char *) "virNodeHugeTLB", libvirt_virNodeHugeTLB, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
     {NULL, NULL, 0, NULL}
 };
 
-- 
1.9.3

--
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]