[libvirt-python PATCH v2] override: add virDomainFSFreeze and virDomainFSThaw API

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

 



From: Tomoki Sekiyama <tomoki.sekiyama@xxxxxxx>

Add binding for the new virDomainFSFreeze and virDomainFSThaw functions
added in libvirt 1.2.5. These require override since these take a list
of mountpoints path string. The methods are named 'fsFreeze' and
'fsThaw'.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@xxxxxxx>
Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---

diff to v1:
-Eric's and mine review comments worked in

 generator.py                  |  3 ++
 libvirt-override-virDomain.py | 12 ++++++
 libvirt-override.c            | 97 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+)

diff --git a/generator.py b/generator.py
index 05ec743..e7b4643 100755
--- a/generator.py
+++ b/generator.py
@@ -517,6 +517,9 @@ skip_function = (
     'virDomainCreateXMLWithFiles', # overridden in virConnect.py
     'virDomainCreateWithFiles', # overridden in virDomain.py
 
+    'virDomainFSFreeze', # overridden in virDomain.py
+    'virDomainFSThaw', # overridden in virDomain.py
+
     # 'Ref' functions have no use for bindings users.
     "virConnectRef",
     "virDomainRef",
diff --git a/libvirt-override-virDomain.py b/libvirt-override-virDomain.py
index c96cc5e..e61ad00 100644
--- a/libvirt-override-virDomain.py
+++ b/libvirt-override-virDomain.py
@@ -47,3 +47,15 @@
         ret = libvirtmod.virDomainCreateWithFiles(self._o, files, flags)
         if ret == -1: raise libvirtError ('virDomainCreateWithFiles() failed', dom=self)
         return ret
+
+    def fsFreeze(self, mountpoints=None, flags=0):
+        """Freeze specified filesystems within the guest """
+        ret = libvirtmod.virDomainFSFreeze(self._o, mountpoints, flags)
+        if ret == -1: raise libvirtError ('virDomainFSFreeze() failed', dom=self)
+        return ret
+
+    def fsThaw(self, mountpoints=None, flags=0):
+        """Thaw specified filesystems within the guest """
+        ret = libvirtmod.virDomainFSThaw(self._o, mountpoints, flags)
+        if ret == -1: raise libvirtError ('virDomainFSThaw() failed', dom=self)
+        return ret
diff --git a/libvirt-override.c b/libvirt-override.c
index 3fa9b9b..c4ac223 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -7554,6 +7554,99 @@ cleanup:
 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
 
 
+#if LIBVIR_CHECK_VERSION(1, 2, 5)
+static PyObject *
+libvirt_virDomainFSFreeze(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
+    PyObject *py_retval = NULL;
+    int c_retval;
+    virDomainPtr domain;
+    PyObject *pyobj_domain;
+    PyObject *pyobj_list;
+    unsigned int flags;
+    unsigned int nmountpoints = 0;
+    char **mountpoints = NULL;
+    size_t i = 0, j;
+
+    if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainFSFreeze",
+                          &pyobj_domain, &pyobj_list, &flags))
+        return NULL;
+    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+    if (PyList_Check(pyobj_list)) {
+        nmountpoints = PyList_Size(pyobj_list);
+
+        if (VIR_ALLOC_N(mountpoints, nmountpoints) < 0)
+            return PyErr_NoMemory();
+
+        for (i = 0; i < nmountpoints; i++) {
+            if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i),
+                                      mountpoints+i) < 0 ||
+                mountpoints[i] == NULL)
+                goto cleanup;
+        }
+    }
+
+    LIBVIRT_BEGIN_ALLOW_THREADS;
+    c_retval = virDomainFSFreeze(domain, (const char **) mountpoints,
+                                 nmountpoints, flags);
+    LIBVIRT_END_ALLOW_THREADS;
+
+    py_retval = libvirt_intWrap(c_retval);
+
+cleanup:
+    for (j = 0 ; j < i ; j++)
+        VIR_FREE(mountpoints[j]);
+    VIR_FREE(mountpoints);
+    return py_retval;
+}
+
+
+static PyObject *
+libvirt_virDomainFSThaw(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
+    PyObject *py_retval = NULL;
+    int c_retval;
+    virDomainPtr domain;
+    PyObject *pyobj_domain;
+    PyObject *pyobj_list;
+    unsigned int flags;
+    unsigned int nmountpoints = 0;
+    char **mountpoints = NULL;
+    size_t i = 0, j;
+
+    if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainFSThaw",
+                          &pyobj_domain, &pyobj_list, &flags))
+        return NULL;
+    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+    if (PyList_Check(pyobj_list)) {
+        nmountpoints = PyList_Size(pyobj_list);
+
+        if (VIR_ALLOC_N(mountpoints, nmountpoints) < 0)
+            return PyErr_NoMemory();
+
+        for (i = 0; i < nmountpoints; i++) {
+            if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i),
+                                      mountpoints+i) < 0 ||
+                mountpoints[i] == NULL)
+                goto cleanup;
+        }
+    }
+
+    LIBVIRT_BEGIN_ALLOW_THREADS;
+    c_retval = virDomainFSThaw(domain, (const char **) mountpoints,
+                               nmountpoints, flags);
+    LIBVIRT_END_ALLOW_THREADS;
+
+    py_retval = libvirt_intWrap(c_retval);
+
+ cleanup:
+    for (j = 0 ; j < i ; j++)
+        VIR_FREE(mountpoints[j]);
+    VIR_FREE(mountpoints);
+    return py_retval;
+}
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
+
 /************************************************************************
  *									*
  *			The registration stuff				*
@@ -7729,6 +7822,10 @@ static PyMethodDef libvirtMethods[] = {
     {(char *) "virDomainCreateXMLWithFiles", libvirt_virDomainCreateXMLWithFiles, METH_VARARGS, NULL},
     {(char *) "virDomainCreateWithFiles", libvirt_virDomainCreateWithFiles, METH_VARARGS, NULL},
 #endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
+#if LIBVIR_CHECK_VERSION(1, 2, 5)
+    {(char *) "virDomainFSFreeze", libvirt_virDomainFSFreeze, METH_VARARGS, NULL},
+    {(char *) "virDomainFSThaw", libvirt_virDomainFSThaw, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
     {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]