[PATCH] virsh: Two new fields for command domblklist

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

 



Disk "type" and "device" are generally interesting stuffs the
user who wants to known too. Though it's likely breaks the script
which parses the command output by field (e.g. awk), putting
them in the head is better, as it coheres with the user's habit
more. (Trying to find the small word (type, device) after a
very long file path (could be) sounds not a good idea).
---
 tools/virsh.c   |   14 +++++++++++---
 tools/virsh.pod |   14 +++++++-------
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 3af2fd7..31c2b5c 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1905,7 +1905,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
  */
 static const vshCmdInfo info_domblklist[] = {
     {"help", N_("list all domain blocks")},
-    {"desc", N_("Get the names of block devices for a domain.")},
+    {"desc", N_("Get the summary of block devices for a domain.")},
     {NULL, NULL}
 };
 
@@ -1950,14 +1950,19 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
     if (ndisks < 0)
         goto cleanup;
 
-    vshPrint(ctl, "%-10s %s\n", _("Target"), _("Source"));
+    vshPrint(ctl, "%-10s %-10s %-10s %s\n", _("Type"),
+             _("Device"), _("Target"), _("Source"));
     vshPrint(ctl, "------------------------------------------------\n");
 
     for (i = 0; i < ndisks; i++) {
+        char *type;
+        char *device;
         char *target;
         char *source;
 
         ctxt->node = disks[i];
+        type = virXPathString("string(./@type)", ctxt);
+        device = virXPathString("string(./@device)", ctxt);
         target = virXPathString("string(./target/@dev)", ctxt);
         if (!target) {
             vshError(ctl, "unable to query block list");
@@ -1967,7 +1972,10 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
                                 "|./source/@dev"
                                 "|./source/@dir"
                                 "|./source/@name)", ctxt);
-        vshPrint(ctl, "%-10s %s\n", target, source ? source : "-");
+        vshPrint(ctl, "%-10s %-10s %-10s %s\n", type, device,
+                 target, source ? source : "-");
+        VIR_FREE(type);
+        VIR_FREE(device);
         VIR_FREE(target);
         VIR_FREE(source);
     }
diff --git a/tools/virsh.pod b/tools/virsh.pod
index bae6a13..6ae9a90 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -514,13 +514,13 @@ also B<domblklist> for listing these names).
 
 =item B<domblklist> I<domain> [I<--inactive>]
 
-Print a table showing the names of all block devices associated with
-I<domain>, as well as the path to the source of each device.  If
-I<--inactive> is specified, query the block devices that will be used
-on the next boot, rather than those currently in use by a running
-domain.  Other contexts that require a block device name (such as
-I<domblkinfo> or I<snapshot-create> for disk snapshots) will accept
-either target or unique source names printed by this command.
+Print a table showing the brief information of all block devices
+associated with I<domain>. If I<--inactive> is specified, query the
+block devices that will be used on the next boot, rather than those
+currently in use by a running domain. Other contexts that require a
+block device name (such as I<domblkinfo> or I<snapshot-create> for
+disk snapshots) will accept either target or unique source names
+printed by this command.
 
 =item B<domiflist> I<domain> [I<--inactive>]
 
-- 
1.7.7.3

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