[PATCH 1/5] list: Define new API virConnectListAllNWFilters

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

 



This is to list the network fitler objects. No flags are supported

include/libvirt/libvirt.h.in: Declare enum virConnectListAllNWFilterFlags
                              and virConnectListAllNWFilters.
python/generator.py: Skip auto-generating
src/driver.h: (virDrvConnectListAllNWFilters)
src/libvirt.c: Implement the public API
src/libvirt_public.syms: Export the symbol to public
---
 include/libvirt/libvirt.h.in |    4 ++-
 python/generator.py          |    1 +
 src/driver.h                 |    5 ++++
 src/libvirt.c                |   50 ++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |    1 +
 5 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 96d0760..86f640d 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -4115,7 +4115,9 @@ int                     virConnectNumOfNWFilters (virConnectPtr conn);
 int                     virConnectListNWFilters  (virConnectPtr conn,
                                                   char **const names,
                                                   int maxnames);
-
+int                     virConnectListAllNWFilters(virConnectPtr conn,
+                                                   virNWFilterPtr **filters,
+                                                   unsigned int flags);
 /*
  * Lookup nwfilter by name or uuid
  */
diff --git a/python/generator.py b/python/generator.py
index a8e4ec6..d3163e4 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -465,6 +465,7 @@ skip_function = (
     'virConnectListAllNetworks', # overridden in virConnect.py
     'virConnectListAllInterfaces', # overridden in virConnect.py
     'virConnectListAllNodeDevices', # overridden in virConnect.py
+    'virConnectListAllNWFilters', # overridden in virConnect.py
 
     'virStreamRecvAll', # Pure python libvirt-override-virStream.py
     'virStreamSendAll', # Pure python libvirt-override-virStream.py
diff --git a/src/driver.h b/src/driver.h
index 34a94af..9984a85 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1638,6 +1638,10 @@ typedef int
     (*virDrvConnectListNWFilters)         (virConnectPtr conn,
                                            char **const names,
                                            int maxnames);
+typedef int
+    (*virDrvConnectListAllNWFilters)      (virConnectPtr conn,
+                                           virNWFilterPtr **filters,
+                                           unsigned int flags);
 typedef virNWFilterPtr
     (*virDrvNWFilterLookupByName)         (virConnectPtr conn,
                                            const char *name);
@@ -1675,6 +1679,7 @@ struct _virNWFilterDriver {
 
     virDrvConnectNumOfNWFilters numOfNWFilters;
     virDrvConnectListNWFilters  listNWFilters;
+    virDrvConnectListAllNWFilters  listAllNWFilters;
     virDrvNWFilterLookupByName  nwfilterLookupByName;
     virDrvNWFilterLookupByUUID  nwfilterLookupByUUID;
     virDrvNWFilterDefineXML     defineXML;
diff --git a/src/libvirt.c b/src/libvirt.c
index b8d0bec..55a2f4e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -16153,6 +16153,56 @@ error:
     return -1;
 }
 
+/**
+ * virConnectListAllNWFilters:
+ * @conn: Pointer to the hypervisor connection.
+ * @filters: Pointer to a variable to store the array containing the network
+ *           filter objects or NULL if the list is not required (just returns
+ *           number of network filters).
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Collect the list of network filters, and allocate an array to store those
+ * objects.
+ *
+ * Returns the number of network filters found or -1 and sets @filters to  NULL
+ * in case of error.  On success, the array stored into @filters is guaranteed to
+ * have an extra allocated element set to NULL but not included in the return count,
+ * to make iteration easier.  The caller is responsible for calling
+ * virNWFilterFree() on each array element, then calling free() on @filters.
+ */
+int
+virConnectListAllNWFilters(virConnectPtr conn,
+                           virNWFilterPtr **filters,
+                           unsigned int flags)
+{
+    VIR_DEBUG("conn=%p, filters=%p, flags=%x", conn, filters, flags);
+
+    virResetLastError();
+
+    if (filters)
+        *filters = NULL;
+
+    if (!VIR_IS_CONNECT(conn)) {
+        virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+
+    if (conn->nwfilterDriver &&
+        conn->nwfilterDriver->listAllNWFilters) {
+        int ret;
+        ret = conn->nwfilterDriver->listAllNWFilters(conn, filters, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(conn);
+    return -1;
+}
 
 /**
  * virConnectListNWFilters:
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 5a4451b..a918bc8 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -559,6 +559,7 @@ LIBVIRT_0.10.2 {
         virConnectListAllInterfaces;
         virConnectListAllNetworks;
         virConnectListAllNodeDevices;
+        virConnectListAllNWFilters;
         virConnectListAllStoragePools;
         virStoragePoolListAllVolumes;
 } LIBVIRT_0.10.2;
-- 
1.7.7.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]