]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: allow both --uuid and --name at same time
authorChen Hanxiao <chenhanxiao@gmail.com>
Sat, 9 Jul 2016 10:06:55 +0000 (18:06 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 11 Jul 2016 12:00:51 +0000 (14:00 +0200)
#virsh list --uuid --name
49c765a0-25e7-40d0-964f-dac99724b32c   c7
918f1dd6-b19f-412b-ba17-d113bad89af8   f23

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
tools/virsh-domain-monitor.c
tools/virsh.pod

index 0a93949721b51eb8e85881d991fb82da7e5986ac..c712fa5e1b661c8d89018d075daae12363373aec 100644 (file)
@@ -1844,12 +1844,8 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
     FILTER("state-shutoff", VIR_CONNECT_LIST_DOMAINS_SHUTOFF);
     FILTER("state-other",   VIR_CONNECT_LIST_DOMAINS_OTHER);
 
-    if (optTable + optName + optUUID > 1) {
-        vshError(ctl, "%s",
-                 _("Only one argument from --table, --name and --uuid "
-                   "may be specified."));
-        return false;
-    }
+    VSH_EXCLUSIVE_OPTIONS("table", "name");
+    VSH_EXCLUSIVE_OPTIONS("table", "uuid");
 
     if (!optUUID && !optName)
         optTable = true;
@@ -1907,6 +1903,12 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
                          state == -2 ? _("saved")
                          : virshDomainStateToString(state));
             }
+        } else if (optUUID && optName) {
+            if (virDomainGetUUIDString(dom, uuid) < 0) {
+                vshError(ctl, "%s", _("Failed to get domain's UUID"));
+                goto cleanup;
+            }
+            vshPrint(ctl, "%-36s %-30s\n", uuid, virDomainGetName(dom));
         } else if (optUUID) {
             if (virDomainGetUUIDString(dom, uuid) < 0) {
                 vshError(ctl, "%s", _("Failed to get domain's UUID"));
index 601cb44557c26d65cbc9352f3d6c48dbb3ff4e56..d7cd10efaf0ad289d3ce235bdcda0c9a06b0089f 100644 (file)
@@ -524,8 +524,14 @@ Note that this flag does not filter the list of domains.
 If I<--name> is specified, domain names are printed instead of the table
 formatted one per line. If I<--uuid> is specified domain's UUID's are printed
 instead of names. Flag I<--table> specifies that the legacy table-formatted
-output should be used. This is the default. All of these are mutually
-exclusive.
+output should be used. This is the default.
+
+If both I<--name> and I<--uuid> are specified, domain UUID's and names
+are printed side by side without any header. Flag I<--table> specifies
+that the legacy table-formatted output should be used. This is the
+default if neither I<--name> nor I<--uuid> are specified. Options
+I<--uuid> and I<--name> are mutually exclusive if option I<--table> is
+specified.
 
 If I<--title> is specified, then the short domain description (title) is
 printed in an extra column. This flag is usable only with the default