[PATCH python 5/5] Add missing impl of virNetworkListAllPorts

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

 



This API needs manual impl as the generator cannot cope

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 libvirt-override-virNetwork.py | 11 ++++++++
 libvirt-override.c             | 46 ++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)
 create mode 100644 libvirt-override-virNetwork.py

diff --git a/libvirt-override-virNetwork.py b/libvirt-override-virNetwork.py
new file mode 100644
index 0000000..749ee44
--- /dev/null
+++ b/libvirt-override-virNetwork.py
@@ -0,0 +1,11 @@
+    def listAllPorts(self, flags=0):
+        """List all domains and returns a list of domain objects"""
+        ret = libvirtmod.virNetworkListAllPorts(self._o, flags)
+        if ret is None:
+            raise libvirtError("virNetworkListAllPorts() failed", conn=self)
+
+        retlist = list()
+        for domptr in ret:
+            retlist.append(virNetwork(self, _obj=domptr))
+
+        return retlist
diff --git a/libvirt-override.c b/libvirt-override.c
index c73305b..5ae4406 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -9946,6 +9946,51 @@ libvirt_virNodeGetSEVInfo(PyObject *self ATTRIBUTE_UNUSED,
 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
 
 #if LIBVIR_CHECK_VERSION(5, 5, 0)
+static PyObject *
+libvirt_virNetworkListAllPorts(PyObject *self ATTRIBUTE_UNUSED,
+                               PyObject *args)
+{
+    PyObject *pyobj_conn;
+    PyObject *py_retval = NULL;
+    virNetworkPtr conn;
+    virNetworkPortPtr *doms = NULL;
+    int c_retval = 0;
+    ssize_t i;
+    unsigned int flags;
+
+    if (!PyArg_ParseTuple(args, (char *)"OI:virNetworkListAllPorts",
+                          &pyobj_conn, &flags))
+        return NULL;
+    conn = (virNetworkPtr) PyvirNetwork_Get(pyobj_conn);
+
+    LIBVIRT_BEGIN_ALLOW_THREADS;
+    c_retval = virNetworkListAllPorts(conn, &doms, flags);
+    LIBVIRT_END_ALLOW_THREADS;
+
+    if (c_retval < 0)
+        return VIR_PY_NONE;
+
+    if (!(py_retval = PyList_New(c_retval)))
+        goto cleanup;
+
+    for (i = 0; i < c_retval; i++) {
+        VIR_PY_LIST_SET_GOTO(py_retval, i, libvirt_virNetworkPortPtrWrap(doms[i]), error);
+        /* python steals the pointer */
+        doms[i] = NULL;
+    }
+
+ cleanup:
+    for (i = 0; i < c_retval; i++)
+        if (doms[i])
+            virNetworkPortFree(doms[i]);
+    VIR_FREE(doms);
+    return py_retval;
+
+ error:
+    Py_CLEAR(py_retval);
+    goto cleanup;
+}
+
 static PyObject *
 libvirt_virNetworkPortSetParameters(PyObject *self ATTRIBUTE_UNUSED,
                                     PyObject *args)
@@ -10286,6 +10331,7 @@ static PyMethodDef libvirtMethods[] = {
     {(char *) "virNodeGetSEVInfo", libvirt_virNodeGetSEVInfo, METH_VARARGS, NULL},
 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
 #if LIBVIR_CHECK_VERSION(5, 5, 0)
+    {(char *) "virNetworkListAllPorts", libvirt_virNetworkListAllPorts, METH_VARARGS, NULL},
     {(char *) "virNetworkPortSetParameters", libvirt_virNetworkPortSetParameters, METH_VARARGS, NULL},
     {(char *) "virNetworkPortGetParameters", libvirt_virNetworkPortGetParameters, METH_VARARGS, NULL},
 #endif /* LIBVIR_CHECK_VERSION(5, 5, 0) */
-- 
2.21.0

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

  Powered by Linux