[PATCH v2 3/4] virsh: Realign some outputs

Luke Yue lukedyue at gmail.com
Fri Dec 3 14:19:56 UTC 2021


As it's now "Security labels:" instead of "Security label:".

Signed-off-by: Luke Yue <lukedyue at gmail.com>
---
 tests/virsh-undefine         |  8 ++---
 tests/virshtest.c            | 70 ++++++++++++++++++------------------
 tools/virsh-domain-monitor.c | 42 +++++++++++-----------
 3 files changed, 59 insertions(+), 61 deletions(-)

diff --git a/tests/virsh-undefine b/tests/virsh-undefine
index dbbb367391..7feefdec79 100755
--- a/tests/virsh-undefine
+++ b/tests/virsh-undefine
@@ -35,11 +35,11 @@ $abs_top_builddir/tools/virsh -c test:///default \
 test $? = 0 || fail=1
 sed '/^Persistent/n; /:/d' < out1 > out
 cat <<\EOF > exp || fail=1
-Persistent:     yes
+Persistent:      yes
 
 Domain 'test' has been undefined
 
-Persistent:     no
+Persistent:      no
 
 EOF
 compare exp out || fail=1
@@ -50,11 +50,11 @@ $abs_top_builddir/tools/virsh -c test:///default \
 test $? = 0 || fail=1
 sed '/^Persistent/n; /:/d' < out1 > out
 cat <<\EOF > exp || fail=1
-Persistent:     yes
+Persistent:      yes
 
 Domain '1' has been undefined
 
-Persistent:     no
+Persistent:      no
 
 EOF
 compare exp out || fail=1
diff --git a/tests/virshtest.c b/tests/virshtest.c
index c2c892c60d..012edb8601 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -25,52 +25,52 @@ main(void)
 # define SECURITY_LABEL "libvirt-test (enforcing)"
 # define FC4_MESSAGES "tainted: network configuration using opaque shell scripts"
 # define FC5_MESSAGES "tainted: running with undesirable elevated privileges\n\
-                tainted: network configuration using opaque shell scripts\n\
-                tainted: use of host cdrom passthrough\n\
-                tainted: custom device tree blob used\n\
-                tainted: use of deprecated configuration settings\n\
-                deprecated configuration: CPU model Deprecated-Test"
+                 tainted: network configuration using opaque shell scripts\n\
+                 tainted: use of host cdrom passthrough\n\
+                 tainted: custom device tree blob used\n\
+                 tainted: use of deprecated configuration settings\n\
+                 deprecated configuration: CPU model Deprecated-Test"
 # define GET_BLKIO_PARAMETER "/dev/hda,700"
 # define SET_BLKIO_PARAMETER "/dev/hda,1000"
 # define EQUAL "="
 
 static const char *dominfo_fc4 = "\
-Id:             2\n\
-Name:           fc4\n\
-UUID:           " DOM_FC4_UUID "\n\
-OS Type:        linux\n\
-State:          running\n\
-CPU(s):         1\n\
-Max memory:     261072 KiB\n\
-Used memory:    131072 KiB\n\
-Persistent:     yes\n\
-Autostart:      disable\n\
-Managed save:   no\n\
-Security model: testSecurity\n\
-Security DOI:   \n\
-Security label: " SECURITY_LABEL "\n\
-Messages:       " FC4_MESSAGES "\n\
+Id:              2\n\
+Name:            fc4\n\
+UUID:            " DOM_FC4_UUID "\n\
+OS Type:         linux\n\
+State:           running\n\
+CPU(s):          1\n\
+Max memory:      261072 KiB\n\
+Used memory:     131072 KiB\n\
+Persistent:      yes\n\
+Autostart:       disable\n\
+Managed save:    no\n\
+Security model:  testSecurity\n\
+Security DOI:    \n\
+Security labels: " SECURITY_LABEL "\n\
+Messages:        " FC4_MESSAGES "\n\
 \n";
 static const char *domuuid_fc4 = DOM_FC4_UUID "\n\n";
 static const char *domid_fc4 = "2\n\n";
 static const char *domname_fc4 = "fc4\n\n";
 static const char *domstate_fc4 = "running\n\n";
 static const char *dominfo_fc5 = "\
-Id:             3\n\
-Name:           fc5\n\
-UUID:           " DOM_FC5_UUID "\n\
-OS Type:        linux\n\
-State:          running\n\
-CPU(s):         4\n\
-Max memory:     2097152 KiB\n\
-Used memory:    2097152 KiB\n\
-Persistent:     yes\n\
-Autostart:      disable\n\
-Managed save:   no\n\
-Security model: testSecurity\n\
-Security DOI:   \n\
-Security label: " SECURITY_LABEL "\n\
-Messages:       " FC5_MESSAGES "\n\
+Id:              3\n\
+Name:            fc5\n\
+UUID:            " DOM_FC5_UUID "\n\
+OS Type:         linux\n\
+State:           running\n\
+CPU(s):          4\n\
+Max memory:      2097152 KiB\n\
+Used memory:     2097152 KiB\n\
+Persistent:      yes\n\
+Autostart:       disable\n\
+Managed save:    no\n\
+Security model:  testSecurity\n\
+Security DOI:    \n\
+Security labels: " SECURITY_LABEL "\n\
+Messages:        " FC5_MESSAGES "\n\
 \n";
 
 static const char *get_blkio_parameters = "\
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 1bb3bed1cb..5ddf48cb06 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1233,39 +1233,39 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
 
     id = virDomainGetID(dom);
     if (id == ((unsigned int)-1))
-        vshPrint(ctl, "%-15s %s\n", _("Id:"), "-");
+        vshPrint(ctl, "%-16s %s\n", _("Id:"), "-");
     else
-        vshPrint(ctl, "%-15s %d\n", _("Id:"), id);
-    vshPrint(ctl, "%-15s %s\n", _("Name:"), virDomainGetName(dom));
+        vshPrint(ctl, "%-16s %d\n", _("Id:"), id);
+    vshPrint(ctl, "%-16s %s\n", _("Name:"), virDomainGetName(dom));
 
     if (virDomainGetUUIDString(dom, &uuid[0]) == 0)
-        vshPrint(ctl, "%-15s %s\n", _("UUID:"), uuid);
+        vshPrint(ctl, "%-16s %s\n", _("UUID:"), uuid);
 
     if ((ostype = virDomainGetOSType(dom)))
-        vshPrint(ctl, "%-15s %s\n", _("OS Type:"), ostype);
+        vshPrint(ctl, "%-16s %s\n", _("OS Type:"), ostype);
 
     if (virDomainGetInfo(dom, &info) == 0) {
-        vshPrint(ctl, "%-15s %s\n", _("State:"),
+        vshPrint(ctl, "%-16s %s\n", _("State:"),
                  virshDomainStateToString(info.state));
 
-        vshPrint(ctl, "%-15s %d\n", _("CPU(s):"), info.nrVirtCpu);
+        vshPrint(ctl, "%-16s %d\n", _("CPU(s):"), info.nrVirtCpu);
 
         if (info.cpuTime != 0) {
             double cpuUsed = info.cpuTime;
 
             cpuUsed /= 1000000000.0;
 
-            vshPrint(ctl, "%-15s %.1lfs\n", _("CPU time:"), cpuUsed);
+            vshPrint(ctl, "%-16s %.1lfs\n", _("CPU time:"), cpuUsed);
         }
 
         if (info.maxMem != UINT_MAX)
-            vshPrint(ctl, "%-15s %lu KiB\n", _("Max memory:"),
+            vshPrint(ctl, "%-16s %lu KiB\n", _("Max memory:"),
                  info.maxMem);
         else
-            vshPrint(ctl, "%-15s %s\n", _("Max memory:"),
+            vshPrint(ctl, "%-16s %s\n", _("Max memory:"),
                  _("no limit"));
 
-        vshPrint(ctl, "%-15s %lu KiB\n", _("Used memory:"),
+        vshPrint(ctl, "%-16s %lu KiB\n", _("Used memory:"),
                  info.memory);
 
     } else {
@@ -1277,21 +1277,21 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
     vshDebug(ctl, VSH_ERR_DEBUG, "Domain persistent flag value: %d\n",
              persistent);
     if (persistent < 0)
-        vshPrint(ctl, "%-15s %s\n", _("Persistent:"), _("unknown"));
+        vshPrint(ctl, "%-16s %s\n", _("Persistent:"), _("unknown"));
     else
-        vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
+        vshPrint(ctl, "%-16s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
 
     /* Check and display whether the domain autostarts or not */
     if (!virDomainGetAutostart(dom, &autostart)) {
-        vshPrint(ctl, "%-15s %s\n", _("Autostart:"),
+        vshPrint(ctl, "%-16s %s\n", _("Autostart:"),
                  autostart ? _("enable") : _("disable"));
     }
 
     has_managed_save = virDomainHasManagedSaveImage(dom, 0);
     if (has_managed_save < 0)
-        vshPrint(ctl, "%-15s %s\n", _("Managed save:"), _("unknown"));
+        vshPrint(ctl, "%-16s %s\n", _("Managed save:"), _("unknown"));
     else
-        vshPrint(ctl, "%-15s %s\n", _("Managed save:"),
+        vshPrint(ctl, "%-16s %s\n", _("Managed save:"),
                  has_managed_save ? _("yes") : _("no"));
 
     /* Security model and label information */
@@ -1305,8 +1305,8 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
     } else {
         /* Only print something if a security model is active */
         if (secmodel.model[0] != '\0') {
-            vshPrint(ctl, "%-15s %s\n", _("Security model:"), secmodel.model);
-            vshPrint(ctl, "%-15s %s\n", _("Security DOI:"), secmodel.doi);
+            vshPrint(ctl, "%-16s %s\n", _("Security model:"), secmodel.model);
+            vshPrint(ctl, "%-16s %s\n", _("Security DOI:"), secmodel.doi);
 
             if (fullseclabels) {
                 int len;
@@ -1337,7 +1337,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
                 }
 
                 if (seclabel->label[0] != '\0')
-                    vshPrint(ctl, "%-15s %s (%s)\n", _("Security label:"),
+                    vshPrint(ctl, "%-16s %s (%s)\n", _("Security labels:"),
                              seclabel->label,
                              seclabel->enforcing ?
                              "enforcing" :
@@ -1345,15 +1345,13 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
 
                 g_clear_pointer(&seclabel, g_free);
             }
-
-            VIR_FREE(seclabel);
         }
     }
 
     if (virDomainGetMessages(dom, &messages, 0) > 0) {
         size_t i;
         for (i = 0; messages[i] != NULL; i++) {
-            vshPrint(ctl, "%-15s %s\n",
+            vshPrint(ctl, "%-16s %s\n",
                      i == 0 ? _("Messages:") : "", messages[i]);
         }
     }
-- 
2.34.1




More information about the libvir-list mailing list