[PATCH] virsh: Fix net-desc --config output

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

 



Fixes the following bug:
Command:          `net-desc --config [--title] my_network`
Expected Output:  Title/Description of persistent config
Output:           Title/Description of live config

This was caused due to the usage of a single `flags` variable in
`virshGetNetworkDescription()` which ended up in a wrong enum being
passed to `virNetworkGetMetadata()` (enum being that of LIVE instead of
CONFIG).

Although the domain object has the same code, this didn't cause a problem
there because the enum values of `VIR_DOMAIN_INACTIVE_XML` and
`VIR_DOMAIN_METADATA_CONFIG` turn out to be the same (1 << 1), whereas
they are not for network equivalent ones (1 << 0, 1 << 1).

Signed-off-by: K Shiva Kiran <shiva_kr@xxxxxxxxxx>
---
 tools/virsh-network.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 49778d0f4f..8965d87c9c 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -366,7 +366,8 @@ static const vshCmdOptDef opts_network_desc[] = {
 /* extract description or title from network xml */
 static char *
 virshGetNetworkDescription(vshControl *ctl, virNetworkPtr net,
-                           bool title, unsigned int flags)
+                           bool title, unsigned int flags,
+                           unsigned int queryflags)
 {
     char *desc = NULL;
     g_autoptr(xmlDoc) doc = NULL;
@@ -394,7 +395,7 @@ virshGetNetworkDescription(vshControl *ctl, virNetworkPtr net,
     }
 
     /* fall back to xml */
-    if (virshNetworkGetXMLFromNet(ctl, net, flags, &doc, &ctxt) < 0)
+    if (virshNetworkGetXMLFromNet(ctl, net, queryflags, &doc, &ctxt) < 0)
         return NULL;
 
     if (title)
@@ -454,7 +455,7 @@ cmdNetworkDesc(vshControl *ctl, const vshCmd *cmd)
         g_autofree char *descNet = NULL;
         g_autofree char *descNew = NULL;
 
-        if (!(descNet = virshGetNetworkDescription(ctl, net, title, queryflags)))
+        if (!(descNet = virshGetNetworkDescription(ctl, net, title, flags, queryflags)))
             return false;
 
         if (!descArg)
@@ -515,7 +516,7 @@ cmdNetworkDesc(vshControl *ctl, const vshCmd *cmd)
             vshPrintExtra(ctl, "%s", _("Network description updated successfully"));
 
     } else {
-        g_autofree char *desc = virshGetNetworkDescription(ctl, net, title, queryflags);
+        g_autofree char *desc = virshGetNetworkDescription(ctl, net, title, flags, queryflags);
         if (!desc)
             return false;
 
@@ -1128,7 +1129,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
             if (optTitle) {
                 g_autofree char *title = NULL;
 
-                if (!(title = virshGetNetworkDescription(ctl, network, true, 0)))
+                if (!(title = virshGetNetworkDescription(ctl, network, true, 0, 0)))
                     goto cleanup;
                 if (vshTableRowAppend(table,
                             virNetworkGetName(network),
-- 
2.42.0





[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