]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Fix domifaddr output in quiet mode
authorLuyao Huang <lhuang@redhat.com>
Fri, 3 Apr 2015 09:41:03 +0000 (17:41 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 3 Apr 2015 10:23:03 +0000 (12:23 +0200)
In virsh we have two printing functions: vshPrint() which prints a
string onto stdout and vshPrintExtra() which does not print anything
if virsh is run in quiet mode. Usually, the former is used to print
actual results, while the latter to print strings like table headers
and other formatting stuff. However, in cmdDomIfAddr we have
mistakenly used vshPrintExtra even for actual data. After this patch,
the output should look like the following:

  # virsh -q domifaddr test3 --source agent
  lo         00:00:00:00:00:00    ipv4         127.0.0.1/8
  -          -                    ipv6         ::1/128
  ens8       52:54:00:1a:cb:3f    ipv6         fe80::5054:ff:fe1a:cb3f/64
  virbr0     52:54:00:db:51:e7    ipv4         192.168.122.1/24
  virbr0-nic 52:54:00:db:51:e7    N/A          N/A

Signed-off-by: Luyao Huang <lhuang@redhat.com>
tools/virsh-domain-monitor.c

index 6951db24f601438b03f0a46370bb3ecd039134d0..96865311a98c97f6c3f63ae0a11299e7766d0ca8 100644 (file)
@@ -2278,9 +2278,9 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
 
         /* When the interface has no IP address */
         if (!iface->naddrs) {
-            vshPrintExtra(ctl, " %-10s %-17s    %-12s %s\n",
-                          iface->name,
-                          iface->hwaddr ? iface->hwaddr : "N/A", "N/A", "N/A");
+            vshPrint(ctl, " %-10s %-17s    %-12s %s\n",
+                     iface->name,
+                     iface->hwaddr ? iface->hwaddr : "N/A", "N/A", "N/A");
             continue;
         }
 
@@ -2313,12 +2313,12 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
 
             /* Don't repeat interface name */
             if (full || !j)
-                vshPrintExtra(ctl, " %-10s %-17s    %s\n",
-                              iface->name,
-                              iface->hwaddr ? iface->hwaddr : "", ip_addr_str);
+                vshPrint(ctl, " %-10s %-17s    %s\n",
+                         iface->name,
+                         iface->hwaddr ? iface->hwaddr : "", ip_addr_str);
             else
-                vshPrintExtra(ctl, " %-10s %-17s    %s\n",
-                              "-", "-", ip_addr_str);
+                vshPrint(ctl, " %-10s %-17s    %s\n",
+                         "-", "-", ip_addr_str);
 
             virBufferFreeAndReset(&buf);
             VIR_FREE(ip_addr_str);