[PATCH 1/7] api: add public virNetworkDefineXMLFlags() and remote protocol

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

 



This new API allows to define network with given flags.

Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 include/libvirt/libvirt-network.h |  3 +++
 src/driver-network.h              |  6 +++++
 src/libvirt-network.c             | 41 +++++++++++++++++++++++++++++++
 src/libvirt_public.syms           |  1 +
 src/remote/remote_driver.c        |  1 +
 src/remote/remote_protocol.x      | 19 +++++++++++++-
 src/remote_protocol-structs       |  8 ++++++
 7 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-network.h b/include/libvirt/libvirt-network.h
index c9ff0a49ed..be9d6eb2cb 100644
--- a/include/libvirt/libvirt-network.h
+++ b/include/libvirt/libvirt-network.h
@@ -124,6 +124,9 @@ virNetworkPtr           virNetworkCreateXML     (virConnectPtr conn,
  */
 virNetworkPtr           virNetworkDefineXML     (virConnectPtr conn,
                                                  const char *xmlDesc);
+virNetworkPtr           virNetworkDefineXMLFlags(virConnectPtr conn,
+                                                 const char *xmlDesc,
+                                                 unsigned int flags);
 
 /*
  * Delete persistent network
diff --git a/src/driver-network.h b/src/driver-network.h
index 040ef383b3..d31d7c667d 100644
--- a/src/driver-network.h
+++ b/src/driver-network.h
@@ -73,6 +73,11 @@ typedef virNetworkPtr
 (*virDrvNetworkDefineXML)(virConnectPtr conn,
                           const char *xml);
 
+typedef virNetworkPtr
+(*virDrvNetworkDefineXMLFlags)(virConnectPtr conn,
+                               const char *xml,
+                               unsigned int flags);
+
 typedef int
 (*virDrvNetworkUndefine)(virNetworkPtr network);
 
@@ -172,6 +177,7 @@ struct _virNetworkDriver {
     virDrvNetworkLookupByName networkLookupByName;
     virDrvNetworkCreateXML networkCreateXML;
     virDrvNetworkDefineXML networkDefineXML;
+    virDrvNetworkDefineXMLFlags networkDefineXMLFlags;
     virDrvNetworkUndefine networkUndefine;
     virDrvNetworkUpdate networkUpdate;
     virDrvNetworkCreate networkCreate;
diff --git a/src/libvirt-network.c b/src/libvirt-network.c
index 145487d599..b633f49ca9 100644
--- a/src/libvirt-network.c
+++ b/src/libvirt-network.c
@@ -465,6 +465,47 @@ virNetworkDefineXML(virConnectPtr conn, const char *xml)
 }
 
 
+/**
+ * virNetworkDefineXMLFlags:
+ * @conn: pointer to the hypervisor connection
+ * @xml: the XML description for the network, preferably in UTF-8
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Define an inactive persistent virtual network or modify an existing
+ * persistent one from the XML description.
+ *
+ * virNetworkFree should be used to free the resources after the
+ * network object is no longer needed.
+ *
+ * Returns NULL in case of error, a pointer to the network otherwise
+ */
+virNetworkPtr
+virNetworkDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
+{
+    VIR_DEBUG("conn=%p, xml=%s, flags=0x%x", conn, NULLSTR(xml), flags);
+
+    virResetLastError();
+
+    virCheckConnectReturn(conn, NULL);
+    virCheckReadOnlyGoto(conn->flags, error);
+    virCheckNonNullArgGoto(xml, error);
+
+    if (conn->networkDriver && conn->networkDriver->networkDefineXMLFlags) {
+        virNetworkPtr ret;
+        ret = conn->networkDriver->networkDefineXMLFlags(conn, xml, flags);
+        if (!ret)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(conn);
+    return NULL;
+}
+
+
 /**
  * virNetworkUndefine:
  * @network: pointer to a defined network
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 68f5e9c900..3a5fa7cb09 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -899,6 +899,7 @@ LIBVIRT_7.3.0 {
 LIBVIRT_7.7.0 {
     global:
         virNWFilterDefineXMLFlags;
+        virNetworkDefineXMLFlags;
 } 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 9ee22e7e15..b64a86af63 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8553,6 +8553,7 @@ static virNetworkDriver network_driver = {
     .networkLookupByName = remoteNetworkLookupByName, /* 0.3.0 */
     .networkCreateXML = remoteNetworkCreateXML, /* 0.3.0 */
     .networkDefineXML = remoteNetworkDefineXML, /* 0.3.0 */
+    .networkDefineXMLFlags = remoteNetworkDefineXMLFlags, /* 7.7.0 */
     .networkUndefine = remoteNetworkUndefine, /* 0.3.0 */
     .networkUpdate = remoteNetworkUpdate, /* 0.10.2 */
     .networkCreate = remoteNetworkCreate, /* 0.3.0 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 56f610839e..df1b126b0c 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1538,6 +1538,15 @@ struct remote_network_define_xml_ret {
     remote_nonnull_network net;
 };
 
+struct remote_network_define_xml_flags_args {
+    remote_nonnull_string xml;
+    unsigned int flags;
+};
+
+struct remote_network_define_xml_flags_ret {
+    remote_nonnull_network net;
+};
+
 struct remote_network_undefine_args {
     remote_nonnull_network net;
 };
@@ -6801,5 +6810,13 @@ enum remote_procedure {
      * @acl: nwfilter:write
      * @acl: nwfilter:save
      */
-    REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS = 431
+    REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS = 431,
+
+    /**
+     * @generate: both
+     * @priority: high
+     * @acl: network:write
+     * @acl: network:save
+     */
+    REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432
 };
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index d51f12f781..dad83361fa 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1104,6 +1104,13 @@ struct remote_network_define_xml_args {
 struct remote_network_define_xml_ret {
         remote_nonnull_network     net;
 };
+struct remote_network_define_xml_flags_args {
+        remote_nonnull_string      xml;
+        u_int                    flags;
+};
+struct remote_network_define_xml_flags_ret {
+        remote_nonnull_network     net;
+};
 struct remote_network_undefine_args {
         remote_nonnull_network     net;
 };
@@ -3631,4 +3638,5 @@ enum remote_procedure {
         REMOTE_PROC_NODE_DEVICE_UNDEFINE = 429,
         REMOTE_PROC_NODE_DEVICE_CREATE = 430,
         REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS = 431,
+        REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432,
 };
-- 
2.31.1




[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