[PATCH 5/5] virsh: use new virNetworkDefineXMLFlags when available.

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

 



Currently there is no practical difference between this and using the
old virNetworkDefinXML API, it just allows using the new API to make
sure it's working.

Soon there will be a flag defined for the new function (to request
changes in re-definitions of existing+active networks take effect
immediately), and virsh will add support for that flag.
---
 tools/virsh-network.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 49ec34f..414ca86 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -181,6 +181,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
     const char *from = NULL;
     bool ret = true;
     char *buffer;
+    unsigned flags = 0;
 
     if (!vshConnectionUsability(ctl, ctl->conn))
         return false;
@@ -191,7 +192,16 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
     if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
-    network = virNetworkDefineXML(ctl->conn, buffer);
+    network = virNetworkDefineXMLFlags(ctl->conn, buffer, flags);
+
+    if (network == NULL && last_error->code == VIR_ERR_NO_SUPPORT) {
+        /* fall back to older function that doesn't take flags.  note
+         * that if we want to use flags in the future, we'll have to
+         * error out here when flags != 0.
+         */
+        network = virNetworkDefineXML(ctl->conn, buffer);
+    }
+
     VIR_FREE(buffer);
 
     if (network != NULL) {
-- 
1.7.11.4

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