Wire up the ListAll, LookupByPortDev and GetXMLDesc APIs to allow the
virsh nwfilter-binding-list & nwfilter-binding-dumpxml commands to
work.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/nwfilter/nwfilter_driver.c | 71 ++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index caccecadda..6544261b38 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -714,6 +714,74 @@ nwfilterTeardownFilter(virDomainNetDefPtr net)
}
+static virNWFilterBindingPtr
+nwfilterBindingLookupByPortDev(virConnectPtr conn,
+ const char *portdev)
+{
+ virNWFilterBindingPtr ret = NULL;
+ virNWFilterBindingObjPtr obj;
+
+ obj = virNWFilterBindingObjListFindByPortDev(driver->bindings,
+ portdev);
+ if (!obj)
+ goto cleanup;
+
+ if (virNWFilterBindingLookupByPortDevEnsureACL(conn, obj->def) < 0)
+ goto cleanup;
+
+ ret = virGetNWFilterBinding(conn, obj->def->portdevname,
obj->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;
+ char *ret = NULL;
+
+ virCheckFlags(0, NULL);
+
+ obj = virNWFilterBindingObjListFindByPortDev(driver->bindings,
+ binding->portdev);
+ if (!obj)
+ goto cleanup;
+
+ if (virNWFilterBindingGetXMLDescEnsureACL(binding->conn, obj->def) < 0)
+ goto cleanup;
+
+ ret = virNWFilterBindingDefFormat(obj->def);
+
+ cleanup:
+ virNWFilterBindingObjEndAPI(&obj);
+ return ret;
+}
+
+
static virNWFilterDriver nwfilterDriver = {
.name = "nwfilter",
.connectNumOfNWFilters = nwfilterConnectNumOfNWFilters, /* 0.8.0 */
@@ -724,6 +792,9 @@ static virNWFilterDriver nwfilterDriver = {
.nwfilterDefineXML = nwfilterDefineXML, /* 0.8.0 */
.nwfilterUndefine = nwfilterUndefine, /* 0.8.0 */
.nwfilterGetXMLDesc = nwfilterGetXMLDesc, /* 0.8.0 */
+ .nwfilterBindingLookupByPortDev = nwfilterBindingLookupByPortDev, /* 4.4.0 */
+ .connectListAllNWFilterBindings = nwfilterConnectListAllNWFilterBindings, /* 4.4.0
*/
+ .nwfilterBindingGetXMLDesc = nwfilterBindingGetXMLDesc, /* 4.4.0 */
};
--
2.17.0