[libvirt] [PATCH 2/2] tools: Replace vshPrint with vshPrintExtra on places we forgot about

Erik Skultety eskultet at redhat.com
Fri Nov 11 14:51:55 UTC 2016


Although there already was an effort (b620bdee) to replace vshPrint occurrences
with vshPrintExtra due to '--quiet' flag, there were still some leftovers. So
this patch fixes them, hopefully for good.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1356881

Signed-off-by: Erik Skultety <eskultet at redhat.com>
---
 tools/virsh-domain.c    | 73 +++++++++++++++++++++++++------------------------
 tools/virsh-edit.c      |  4 +--
 tools/virsh-interface.c | 28 +++++++++----------
 tools/virsh-network.c   | 37 +++++++++++++------------
 tools/virsh-nwfilter.c  |  6 ++--
 tools/virsh-pool.c      | 21 +++++++-------
 tools/virsh-snapshot.c  | 20 +++++++-------
 tools/virsh-volume.c    | 12 ++++----
 tools/virt-admin.c      |  4 +--
 9 files changed, 104 insertions(+), 101 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 184f64d..91308e8 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2080,9 +2080,9 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
 
     if (!blocking) {
         if (active)
-            vshPrint(ctl, "%s", _("Active Block Commit started"));
+            vshPrintExtra(ctl, "%s", _("Active Block Commit started"));
         else
-            vshPrint(ctl, "%s", _("Block Commit started"));
+            vshPrintExtra(ctl, "%s", _("Block Commit started"));
 
         ret = true;
         goto cleanup;
@@ -2094,12 +2094,12 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
 
         case VIR_DOMAIN_BLOCK_JOB_CANCELED:
-            vshPrint(ctl, "\n%s", _("Commit aborted"));
+            vshPrintExtra(ctl, "\n%s", _("Commit aborted"));
             goto cleanup;
             break;
 
         case VIR_DOMAIN_BLOCK_JOB_FAILED:
-            vshPrint(ctl, "\n%s", _("Commit failed"));
+            vshPrintExtra(ctl, "\n%s", _("Commit failed"));
             goto cleanup;
             break;
 
@@ -2116,19 +2116,20 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
                 goto cleanup;
             }
 
-            vshPrint(ctl, "\n%s", _("Successfully pivoted"));
+            vshPrintExtra(ctl, "\n%s", _("Successfully pivoted"));
         } else if (finish) {
             if (virDomainBlockJobAbort(dom, path, abort_flags) < 0) {
                 vshError(ctl, _("failed to finish job for disk %s"), path);
                 goto cleanup;
             }
 
-            vshPrint(ctl, "\n%s", _("Commit complete, overlay image kept"));
+            vshPrintExtra(ctl, "\n%s", _("Commit complete, overlay "
+                                         "image kept"));
         } else {
-            vshPrint(ctl, "\n%s", _("Now in synchronized phase"));
+            vshPrintExtra(ctl, "\n%s", _("Now in synchronized phase"));
         }
     } else {
-        vshPrint(ctl, "\n%s", _("Commit complete"));
+        vshPrintExtra(ctl, "\n%s", _("Commit complete"));
     }
 
     ret = true;
@@ -2392,7 +2393,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
     }
 
     if (!blocking) {
-        vshPrint(ctl, "%s", _("Block Copy started"));
+        vshPrintExtra(ctl, "%s", _("Block Copy started"));
         ret = true;
         goto cleanup;
     }
@@ -2403,12 +2404,12 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
 
         case VIR_DOMAIN_BLOCK_JOB_CANCELED:
-            vshPrint(ctl, "\n%s", _("Copy aborted"));
+            vshPrintExtra(ctl, "\n%s", _("Copy aborted"));
             goto cleanup;
             break;
 
         case VIR_DOMAIN_BLOCK_JOB_FAILED:
-            vshPrint(ctl, "\n%s", _("Copy failed"));
+            vshPrintExtra(ctl, "\n%s", _("Copy failed"));
             goto cleanup;
             break;
 
@@ -2424,16 +2425,16 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
         }
 
-        vshPrint(ctl, "\n%s", _("Successfully pivoted"));
+        vshPrintExtra(ctl, "\n%s", _("Successfully pivoted"));
     } else if (finish) {
         if (virDomainBlockJobAbort(dom, path, abort_flags) < 0) {
             vshError(ctl, _("failed to finish job for disk %s"), path);
             goto cleanup;
         }
 
-        vshPrint(ctl, "\n%s", _("Successfully copied"));
+        vshPrintExtra(ctl, "\n%s", _("Successfully copied"));
     } else {
-        vshPrint(ctl, "\n%s", _("Now in mirroring phase"));
+        vshPrintExtra(ctl, "\n%s", _("Now in mirroring phase"));
     }
 
     ret = true;
@@ -2571,7 +2572,7 @@ virshBlockJobInfo(vshControl *ctl,
 
     if (rc == 0) {
         if (!raw)
-            vshPrint(ctl, _("No current block job for %s"), path);
+            vshPrintExtra(ctl, _("No current block job for %s"), path);
         ret = true;
         goto cleanup;
     }
@@ -2802,7 +2803,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
     }
 
     if (!blocking) {
-        vshPrint(ctl, "%s", _("Block Pull started"));
+        vshPrintExtra(ctl, "%s", _("Block Pull started"));
         ret = true;
         goto cleanup;
     }
@@ -2813,18 +2814,18 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
 
         case VIR_DOMAIN_BLOCK_JOB_CANCELED:
-            vshPrint(ctl, "\n%s", _("Pull aborted"));
+            vshPrintExtra(ctl, "\n%s", _("Pull aborted"));
             goto cleanup;
             break;
 
         case VIR_DOMAIN_BLOCK_JOB_FAILED:
-            vshPrint(ctl, "\n%s", _("Pull failed"));
+            vshPrintExtra(ctl, "\n%s", _("Pull failed"));
             goto cleanup;
             break;
 
         case VIR_DOMAIN_BLOCK_JOB_READY:
         case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
-            vshPrint(ctl, "\n%s", _("Pull complete"));
+            vshPrintExtra(ctl, "\n%s", _("Pull complete"));
             break;
     }
 
@@ -4563,18 +4564,18 @@ cmdSaveImageEdit(vshControl *ctl, const vshCmd *cmd)
 
 #define EDIT_GET_XML \
     virDomainSaveImageGetXMLDesc(priv->conn, file, getxml_flags)
-#define EDIT_NOT_CHANGED                                        \
-    do {                                                        \
-        vshPrint(ctl, _("Saved image %s XML configuration "     \
-                        "not changed.\n"), file);               \
-        ret = true;                                             \
-        goto edit_cleanup;                                      \
+#define EDIT_NOT_CHANGED                                             \
+    do {                                                             \
+        vshPrintExtra(ctl, _("Saved image %s XML configuration "     \
+                             "not changed.\n"), file);               \
+        ret = true;                                                  \
+        goto edit_cleanup;                                           \
     } while (0)
 #define EDIT_DEFINE \
     (virDomainSaveImageDefineXML(priv->conn, file, doc_edited, define_flags) == 0)
 #include "virsh-edit.c"
 
-    vshPrint(ctl, _("State file %s edited.\n"), file);
+    vshPrintExtra(ctl, _("State file %s edited.\n"), file);
     ret = true;
 
  cleanup:
@@ -12041,12 +12042,12 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd)
         define_flags &= ~VIR_DOMAIN_DEFINE_VALIDATE;
 
 #define EDIT_GET_XML virDomainGetXMLDesc(dom, query_flags)
-#define EDIT_NOT_CHANGED                                                \
-    do {                                                                \
-        vshPrint(ctl, _("Domain %s XML configuration not changed.\n"),  \
-                 virDomainGetName(dom));                                \
-        ret = true;                                                     \
-        goto edit_cleanup;                                              \
+#define EDIT_NOT_CHANGED                                                     \
+    do {                                                                     \
+        vshPrintExtra(ctl, _("Domain %s XML configuration not changed.\n"),  \
+                      virDomainGetName(dom));                                \
+        ret = true;                                                          \
+        goto edit_cleanup;                                                   \
     } while (0)
 #define EDIT_DEFINE \
     (dom_edited = virshDomainDefine(priv->conn, doc_edited, define_flags))
@@ -12058,8 +12059,8 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd)
 #include "virsh-edit.c"
 #undef EDIT_RELAX
 
-    vshPrint(ctl, _("Domain %s XML configuration edited.\n"),
-             virDomainGetName(dom_edited));
+    vshPrintExtra(ctl, _("Domain %s XML configuration edited.\n"),
+                  virDomainGetName(dom_edited));
 
     ret = true;
 
@@ -13177,7 +13178,7 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    vshPrint(ctl, _("Froze %d filesystem(s)\n"), ret);
+    vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), ret);
 
  cleanup:
     VIR_FREE(mountpoints);
@@ -13230,7 +13231,7 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    vshPrint(ctl, _("Thawed %d filesystem(s)\n"), ret);
+    vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), ret);
 
  cleanup:
     VIR_FREE(mountpoints);
diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c
index 1b39cb7..16d6705 100644
--- a/tools/virsh-edit.c
+++ b/tools/virsh-edit.c
@@ -25,8 +25,8 @@
  * EDIT_NOT_CHANGED - this action is taken if the XML wasn't changed.
  *      Note, that you don't want to jump to cleanup but edit_cleanup label
  *      where temporary variables are free()-d and temporary file is deleted:
- *      #define EDIT_NOT_CHANGED vshPrint(ctl, _("Domain %s XML not changed"), \
- *                                        virDomainGetName(dom)); \
+ *      #define EDIT_NOT_CHANGED vshPrintExtra (ctl, _("Domain %s XML not changed"), \
+ *                                              virDomainGetName(dom)); \
  *                               ret = true; goto edit_cleanup;
  *      Note that this is a statement.
  *
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 7274527..9f7d1bd 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -125,19 +125,19 @@ cmdInterfaceEdit(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
 
 #define EDIT_GET_XML virInterfaceGetXMLDesc(iface, flags)
-#define EDIT_NOT_CHANGED                                                \
-    do {                                                                \
-        vshPrint(ctl, _("Interface %s XML configuration not changed.\n"), \
-                 virInterfaceGetName(iface));                           \
-        ret = true;                                                     \
-        goto edit_cleanup;                                              \
+#define EDIT_NOT_CHANGED                                                       \
+    do {                                                                       \
+        vshPrintExtra(ctl, _("Interface %s XML configuration not changed.\n"), \
+                 virInterfaceGetName(iface));                                  \
+        ret = true;                                                            \
+        goto edit_cleanup;                                                     \
     } while (0)
 #define EDIT_DEFINE \
     (iface_edited = virInterfaceDefineXML(priv->conn, doc_edited, 0))
 #include "virsh-edit.c"
 
-    vshPrint(ctl, _("Interface %s XML configuration edited.\n"),
-             virInterfaceGetName(iface_edited));
+    vshPrintExtra(ctl, _("Interface %s XML configuration edited.\n"),
+                  virInterfaceGetName(iface_edited));
 
     ret = true;
 
@@ -969,8 +969,8 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    vshPrint(ctl, _("Created bridge %s with attached device %s\n"),
-             br_name, if_name);
+    vshPrintExtra(ctl, _("Created bridge %s with attached device %s\n"),
+                  br_name, if_name);
 
     /* start it up unless requested not to */
     if (!nostart) {
@@ -978,7 +978,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
             vshError(ctl, _("Failed to start bridge interface %s"), br_name);
             goto cleanup;
         }
-        vshPrint(ctl, _("Bridge interface %s started\n"), br_name);
+        vshPrintExtra(ctl, _("Bridge interface %s started\n"), br_name);
     }
 
     ret = true;
@@ -1170,8 +1170,8 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    vshPrint(ctl, _("Device %s un-attached from bridge %s\n"),
-             if_name, br_name);
+    vshPrintExtra(ctl, _("Device %s un-attached from bridge %s\n"),
+                  if_name, br_name);
 
     /* unless requested otherwise, undefine the bridge device */
     if (!nostart) {
@@ -1179,7 +1179,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
             vshError(ctl, _("Failed to start interface %s"), if_name);
             goto cleanup;
         }
-        vshPrint(ctl, _("Interface %s started\n"), if_name);
+        vshPrintExtra(ctl, _("Interface %s started\n"), if_name);
     }
 
     ret = true;
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 431a750..eacc277 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -977,20 +977,21 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
 
     if (config) {
         if (live)
-            vshPrint(ctl, _("Updated network %s persistent config and live state"),
-                     virNetworkGetName(network));
+            vshPrintExtra(ctl, _("Updated network %s persistent config and "
+                                 "live state"),
+                          virNetworkGetName(network));
         else
-            vshPrint(ctl, _("Updated network %s persistent config"),
-                     virNetworkGetName(network));
+            vshPrintExtra(ctl, _("Updated network %s persistent config"),
+                          virNetworkGetName(network));
     } else if (live) {
-        vshPrint(ctl, _("Updated network %s live state"),
-                 virNetworkGetName(network));
+        vshPrintExtra(ctl, _("Updated network %s live state"),
+                      virNetworkGetName(network));
     } else if (virNetworkIsActive(network)) {
-        vshPrint(ctl, _("Updated network %s live state"),
-                 virNetworkGetName(network));
+        vshPrintExtra(ctl, _("Updated network %s live state"),
+                      virNetworkGetName(network));
     } else {
-        vshPrint(ctl, _("Updated network %s persistent config"),
-                 virNetworkGetName(network));
+        vshPrintExtra(ctl, _("Updated network %s persistent config"),
+                      virNetworkGetName(network));
     }
 
     ret = true;
@@ -1089,19 +1090,19 @@ cmdNetworkEdit(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
 
 #define EDIT_GET_XML virshNetworkGetXMLDesc(network)
-#define EDIT_NOT_CHANGED                                                \
-    do {                                                                \
-        vshPrint(ctl, _("Network %s XML configuration not changed.\n"), \
-                 virNetworkGetName(network));                           \
-        ret = true;                                                     \
-        goto edit_cleanup;                                              \
+#define EDIT_NOT_CHANGED                                                     \
+    do {                                                                     \
+        vshPrintExtra(ctl, _("Network %s XML configuration not changed.\n"), \
+                      virNetworkGetName(network));                           \
+        ret = true;                                                          \
+        goto edit_cleanup;                                                   \
     } while (0)
 #define EDIT_DEFINE \
     (network_edited = virNetworkDefineXML(priv->conn, doc_edited))
 #include "virsh-edit.c"
 
-    vshPrint(ctl, _("Network %s XML configuration edited.\n"),
-             virNetworkGetName(network_edited));
+    vshPrintExtra(ctl, _("Network %s XML configuration edited.\n"),
+                  virNetworkGetName(network_edited));
 
     ret = true;
 
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
index daf58a5..d4a88b2 100644
--- a/tools/virsh-nwfilter.c
+++ b/tools/virsh-nwfilter.c
@@ -416,7 +416,7 @@ cmdNWFilterEdit(vshControl *ctl, const vshCmd *cmd)
 #define EDIT_GET_XML virNWFilterGetXMLDesc(nwfilter, 0)
 #define EDIT_NOT_CHANGED                                        \
     do {                                                        \
-        vshPrint(ctl, _("Network filter %s XML "                \
+        vshPrintExtra(ctl, _("Network filter %s XML "           \
                         "configuration not changed.\n"),        \
                  virNWFilterGetName(nwfilter));                 \
         ret = true;                                             \
@@ -426,8 +426,8 @@ cmdNWFilterEdit(vshControl *ctl, const vshCmd *cmd)
     (nwfilter_edited = virNWFilterDefineXML(priv->conn, doc_edited))
 #include "virsh-edit.c"
 
-    vshPrint(ctl, _("Network filter %s XML configuration edited.\n"),
-             virNWFilterGetName(nwfilter_edited));
+    vshPrintExtra(ctl, _("Network filter %s XML configuration edited.\n"),
+                  virNWFilterGetName(nwfilter_edited));
 
     ret = true;
 
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 3bc96b2..7118a6c 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -1384,8 +1384,9 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
         goto cleanup;
 
     /* Display the header */
-    vshPrint(ctl, outputStr, _("Name"), _("State"), _("Autostart"),
-             _("Persistent"), _("Capacity"), _("Allocation"), _("Available"));
+    vshPrintExtra(ctl, outputStr, _("Name"), _("State"), _("Autostart"),
+                  _("Persistent"), _("Capacity"), _("Allocation"),
+                  _("Available"));
     for (i = nameStrLength + stateStrLength + autostartStrLength
                            + persistStrLength + capStrLength
                            + allocStrLength + availStrLength
@@ -1865,19 +1866,19 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd)
     }
 
 #define EDIT_GET_XML virStoragePoolGetXMLDesc(pool, flags)
-#define EDIT_NOT_CHANGED                                                \
-    do {                                                                \
-        vshPrint(ctl, _("Pool %s XML configuration not changed.\n"),    \
-                 virStoragePoolGetName(pool));                          \
-        ret = true;                                                     \
-        goto edit_cleanup;                                              \
+#define EDIT_NOT_CHANGED                                                     \
+    do {                                                                     \
+        vshPrintExtra(ctl, _("Pool %s XML configuration not changed.\n"),    \
+                 virStoragePoolGetName(pool));                               \
+        ret = true;                                                          \
+        goto edit_cleanup;                                                   \
     } while (0)
 #define EDIT_DEFINE \
     (pool_edited = virStoragePoolDefineXML(priv->conn, doc_edited, 0))
 #include "virsh-edit.c"
 
-    vshPrint(ctl, _("Pool %s XML configuration edited.\n"),
-             virStoragePoolGetName(pool_edited));
+    vshPrintExtra(ctl, _("Pool %s XML configuration edited.\n"),
+                  virStoragePoolGetName(pool_edited));
 
     ret = true;
 
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 95db096..e4d0df7 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -556,16 +556,16 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
 
 #define EDIT_GET_XML \
     virDomainSnapshotGetXMLDesc(snapshot, getxml_flags)
-#define EDIT_NOT_CHANGED                                                \
-    do {                                                                \
-        /* Depending on flags, we re-edit even if XML is unchanged.  */ \
-        if (!(define_flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) {     \
-            vshPrint(ctl,                                               \
-                     _("Snapshot %s XML configuration not changed.\n"), \
-                     name);                                             \
-            ret = true;                                                 \
-            goto edit_cleanup;                                          \
-        }                                                               \
+#define EDIT_NOT_CHANGED                                                     \
+    do {                                                                     \
+        /* Depending on flags, we re-edit even if XML is unchanged.  */      \
+        if (!(define_flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) {          \
+            vshPrintExtra(ctl,                                               \
+                          _("Snapshot %s XML configuration not changed.\n"), \
+                          name);                                             \
+            ret = true;                                                      \
+            goto edit_cleanup;                                               \
+        }                                                                    \
     } while (0)
 #define EDIT_DEFINE \
     (strstr(doc, "<state>disk-snapshot</state>") ? \
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 8831f44..96b4a7b 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -1123,10 +1123,10 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
     }
 
     if (virStorageVolResize(vol, capacity, flags) == 0) {
-        vshPrint(ctl,
-                 delta ? _("Size of volume '%s' successfully changed by %s\n")
-                 : _("Size of volume '%s' successfully changed to %s\n"),
-                 virStorageVolGetName(vol), capacityStr);
+        vshPrintExtra(ctl,
+                      delta ? _("Size of volume '%s' successfully changed by %s\n")
+                      : _("Size of volume '%s' successfully changed to %s\n"),
+                      virStorageVolGetName(vol), capacityStr);
         ret = true;
     } else {
         vshError(ctl,
@@ -1502,8 +1502,8 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
         goto cleanup;
 
     /* Display the header */
-    vshPrint(ctl, outputStr, _("Name"), _("Path"), _("Type"),
-             ("Capacity"), _("Allocation"));
+    vshPrintExtra(ctl, outputStr, _("Name"), _("Path"), _("Type"),
+                  _("Capacity"), _("Allocation"));
     for (i = nameStrLength + pathStrLength + typeStrLength
                            + capStrLength + allocStrLength
                            + 10; i > 0; i--)
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index b1e0c49..70b0e51 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -391,8 +391,8 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
         goto cleanup;
     }
 
-    printf(" %-5s %-15s\n", "Id", "Name");
-    printf("---------------\n");
+    vshPrintExtra(ctl, " %-5s %-15s\n", "Id", "Name");
+    vshPrintExtra(ctl, "---------------\n");
     for (i = 0; i < nsrvs; i++)
         vshPrint(ctl, " %-5zu %-15s\n", i, virAdmServerGetName(srvs[i]));
 
-- 
2.5.5




More information about the libvir-list mailing list