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 ee186c0..0137638 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -4058,7 +4058,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 6f50fa0..00e242f 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -461,6 +461,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 102684c..5ace502 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1611,6 +1611,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);
@@ -1648,6 +1652,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 6d4cd76..ff02c88 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -15931,6 +15931,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 d45e38f..ab5f156 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -551,6 +551,7 @@ LIBVIRT_0.9.14 {
         virConnectListAllNetworks;
         virConnectListAllInterfaces;
         virConnectListAllNodeDevices;
+        virConnectListAllNWFilters;
 } LIBVIRT_0.9.13;
 
 # .... define new API here using predicted next version number ....
-- 
1.7.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to