[PATCH v4 4/6] nwfilter: wire up new APIs for listing and querying filter bindings

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

 



Wire up the ListAll, LookupByPortDev and GetXMLDesc APIs to allow the
virsh nwfilter-binding-list & nwfilter-binding-dumpxml commands to
work.

Reviewed-by: John Ferlan <jferlan@xxxxxxxxxx>
Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/nwfilter/nwfilter_driver.c | 76 ++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index e49e0e7406..79509fc4c0 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -714,6 +714,79 @@ nwfilterTeardownFilter(virDomainNetDefPtr net)
 }
 
 
+static virNWFilterBindingPtr
+nwfilterBindingLookupByPortDev(virConnectPtr conn,
+                               const char *portdev)
+{
+    virNWFilterBindingPtr ret = NULL;
+    virNWFilterBindingObjPtr obj;
+    virNWFilterBindingDefPtr def;
+
+    obj = virNWFilterBindingObjListFindByPortDev(driver->bindings,
+                                                 portdev);
+    if (!obj)
+        goto cleanup;
+
+    def = virNWFilterBindingObjGetDef(obj);
+    if (virNWFilterBindingLookupByPortDevEnsureACL(conn, def) < 0)
+        goto cleanup;
+
+    ret = virGetNWFilterBinding(conn, def->portdevname, def->filter);
+
+ cleanup:
+    virNWFilterBindingObjEndAPI(&obj);
+    return ret;
+}
+
+
+static int
+nwfilterConnectListAllNWFilterBindings(virConnectPtr conn,
+                                       virNWFilterBindingPtr **bindings,
+                                       unsigned int flags)
+{
+    int ret;
+
+    virCheckFlags(0, -1);
+
+    if (virConnectListAllNWFilterBindingsEnsureACL(conn) < 0)
+        return -1;
+
+    ret = virNWFilterBindingObjListExport(driver->bindings,
+                                          conn,
+                                          bindings,
+                                          virConnectListAllNWFilterBindingsCheckACL);
+
+    return ret;
+}
+
+
+static char *
+nwfilterBindingGetXMLDesc(virNWFilterBindingPtr binding,
+                          unsigned int flags)
+{
+    virNWFilterBindingObjPtr obj;
+    virNWFilterBindingDefPtr def;
+    char *ret = NULL;
+
+    virCheckFlags(0, NULL);
+
+    obj = virNWFilterBindingObjListFindByPortDev(driver->bindings,
+                                                 binding->portdev);
+    if (!obj)
+        goto cleanup;
+
+    def = virNWFilterBindingObjGetDef(obj);
+    if (virNWFilterBindingGetXMLDescEnsureACL(binding->conn, def) < 0)
+        goto cleanup;
+
+    ret = virNWFilterBindingDefFormat(def);
+
+ cleanup:
+    virNWFilterBindingObjEndAPI(&obj);
+    return ret;
+}
+
+
 static virNWFilterDriver nwfilterDriver = {
     .name = "nwfilter",
     .connectNumOfNWFilters = nwfilterConnectNumOfNWFilters, /* 0.8.0 */
@@ -724,6 +797,9 @@ static virNWFilterDriver nwfilterDriver = {
     .nwfilterDefineXML = nwfilterDefineXML, /* 0.8.0 */
     .nwfilterUndefine = nwfilterUndefine, /* 0.8.0 */
     .nwfilterGetXMLDesc = nwfilterGetXMLDesc, /* 0.8.0 */
+    .nwfilterBindingLookupByPortDev = nwfilterBindingLookupByPortDev, /* 4.5.0 */
+    .connectListAllNWFilterBindings = nwfilterConnectListAllNWFilterBindings, /* 4.5.0 */
+    .nwfilterBindingGetXMLDesc = nwfilterBindingGetXMLDesc, /* 4.5.0 */
 };
 
 
-- 
2.17.1

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