This new API function allows to define nwfilter with given flags.
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
include/libvirt/libvirt-nwfilter.h | 3 +++
src/driver-nwfilter.h | 6 +++++
src/libvirt-nwfilter.c | 43 ++++++++++++++++++++++++++++++
src/libvirt_public.syms | 5 ++++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 18 ++++++++++++-
src/remote_protocol-structs | 8 ++++++
7 files changed, 83 insertions(+), 1 deletion(-)
diff --git a/include/libvirt/libvirt-nwfilter.h b/include/libvirt/libvirt-nwfilter.h
index 44ca1b3fae..041b1fc33b 100644
--- a/include/libvirt/libvirt-nwfilter.h
+++ b/include/libvirt/libvirt-nwfilter.h
@@ -85,6 +85,9 @@ virNWFilterPtr virNWFilterLookupByUUIDString (virConnectPtr
conn,
*/
virNWFilterPtr virNWFilterDefineXML (virConnectPtr conn,
const char *xmlDesc);
+virNWFilterPtr virNWFilterDefineXMLFlags(virConnectPtr conn,
+ const char *xmlDesc,
+ unsigned int flags);
/*
* Delete persistent nwfilter
diff --git a/src/driver-nwfilter.h b/src/driver-nwfilter.h
index fd76e3af84..1ec591ece9 100644
--- a/src/driver-nwfilter.h
+++ b/src/driver-nwfilter.h
@@ -49,6 +49,11 @@ typedef virNWFilterPtr
(*virDrvNWFilterDefineXML)(virConnectPtr conn,
const char *xmlDesc);
+typedef virNWFilterPtr
+(*virDrvNWFilterDefineXMLFlags)(virConnectPtr conn,
+ const char *xmlDesc,
+ unsigned int flags);
+
typedef int
(*virDrvNWFilterUndefine)(virNWFilterPtr nwfilter);
@@ -98,6 +103,7 @@ struct _virNWFilterDriver {
virDrvNWFilterLookupByName nwfilterLookupByName;
virDrvNWFilterLookupByUUID nwfilterLookupByUUID;
virDrvNWFilterDefineXML nwfilterDefineXML;
+ virDrvNWFilterDefineXMLFlags nwfilterDefineXMLFlags;
virDrvNWFilterUndefine nwfilterUndefine;
virDrvNWFilterGetXMLDesc nwfilterGetXMLDesc;
virDrvConnectListAllNWFilterBindings connectListAllNWFilterBindings;
diff --git a/src/libvirt-nwfilter.c b/src/libvirt-nwfilter.c
index e299385895..c5c53327d3 100644
--- a/src/libvirt-nwfilter.c
+++ b/src/libvirt-nwfilter.c
@@ -406,6 +406,49 @@ virNWFilterDefineXML(virConnectPtr conn, const char *xmlDesc)
}
+/**
+ * virNWFilterDefineXMLFlags:
+ * @conn: pointer to the hypervisor connection
+ * @xmlDesc: an XML description of the nwfilter
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Define a new network filter, based on an XML description
+ * similar to the one returned by virNWFilterGetXMLDesc()
+ *
+ * virNWFilterFree should be used to free the resources after the
+ * nwfilter object is no longer needed.
+ *
+ * Returns a new nwfilter object or NULL in case of failure
+ */
+virNWFilterPtr
+virNWFilterDefineXMLFlags(virConnectPtr conn, const char *xmlDesc, unsigned int flags)
+{
+ VIR_DEBUG("conn=%p, xmlDesc=%s", conn, NULLSTR(xmlDesc));
+
+ virResetLastError();
+
+ virCheckFlags(0, NULL);
+
+ virCheckConnectReturn(conn, NULL);
+ virCheckNonNullArgGoto(xmlDesc, error);
+ virCheckReadOnlyGoto(conn->flags, error);
+
+ if (conn->nwfilterDriver &&
conn->nwfilterDriver->nwfilterDefineXMLFlags) {
+ virNWFilterPtr ret;
+ ret = conn->nwfilterDriver->nwfilterDefineXMLFlags(conn, xmlDesc, flags);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(conn);
+ return NULL;
+}
+
+
/**
* virNWFilterUndefine:
* @nwfilter: a nwfilter object
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 5678a13cda..68f5e9c900 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -896,4 +896,9 @@ LIBVIRT_7.3.0 {
virNodeDeviceCreate;
} LIBVIRT_7.2.0;
+LIBVIRT_7.7.0 {
+ global:
+ virNWFilterDefineXMLFlags;
+} LIBVIRT_7.3.0;
+
# .... define new API here using predicted next version number ....
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index c03c68ec30..9ee22e7e15 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8680,6 +8680,7 @@ static virNWFilterDriver nwfilter_driver = {
.nwfilterLookupByName = remoteNWFilterLookupByName, /* 0.8.0 */
.nwfilterGetXMLDesc = remoteNWFilterGetXMLDesc, /* 0.8.0 */
.nwfilterDefineXML = remoteNWFilterDefineXML, /* 0.8.0 */
+ .nwfilterDefineXMLFlags = remoteNWFilterDefineXMLFlags, /* 7.7.0 */
.nwfilterUndefine = remoteNWFilterUndefine, /* 0.8.0 */
.connectNumOfNWFilters = remoteConnectNumOfNWFilters, /* 0.8.0 */
.connectListNWFilters = remoteConnectListNWFilters, /* 0.8.0 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index de69704b68..56f610839e 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1627,6 +1627,15 @@ struct remote_nwfilter_define_xml_ret {
remote_nonnull_nwfilter nwfilter;
};
+struct remote_nwfilter_define_xml_flags_args {
+ remote_nonnull_string xml;
+ unsigned int flags;
+};
+
+struct remote_nwfilter_define_xml_flags_ret {
+ remote_nonnull_nwfilter nwfilter;
+};
+
struct remote_nwfilter_undefine_args {
remote_nonnull_nwfilter nwfilter;
};
@@ -6784,6 +6793,13 @@ enum remote_procedure {
* @priority: high
* @acl: node_device:start
*/
- REMOTE_PROC_NODE_DEVICE_CREATE = 430
+ REMOTE_PROC_NODE_DEVICE_CREATE = 430,
+ /**
+ * @generate: both
+ * @priority: high
+ * @acl: nwfilter:write
+ * @acl: nwfilter:save
+ */
+ REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS = 431
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 6b46328adc..d51f12f781 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1174,6 +1174,13 @@ struct remote_nwfilter_define_xml_args {
struct remote_nwfilter_define_xml_ret {
remote_nonnull_nwfilter nwfilter;
};
+struct remote_nwfilter_define_xml_flags_args {
+ remote_nonnull_string xml;
+ u_int flags;
+};
+struct remote_nwfilter_define_xml_flags_ret {
+ remote_nonnull_nwfilter nwfilter;
+};
struct remote_nwfilter_undefine_args {
remote_nonnull_nwfilter nwfilter;
};
@@ -3623,4 +3630,5 @@ enum remote_procedure {
REMOTE_PROC_NODE_DEVICE_DEFINE_XML = 428,
REMOTE_PROC_NODE_DEVICE_UNDEFINE = 429,
REMOTE_PROC_NODE_DEVICE_CREATE = 430,
+ REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS = 431,
};
--
2.31.1