[PATCH v2 1/2] virsh: allow both --uuid and --name at same cmd

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

 



From: Chen Hanxiao <chenhanxiao@xxxxxxxxx>

virsh # list  --uuid --name
c7    49c765a0-25e7-40d0-964f-dac99724b32c
f23   918f1dd6-b19f-412b-ba17-d113bad89af8

Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxx>
---
v2: drop uuid-name option, enable both --uuid and --name

 tools/virsh-domain-monitor.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 0a93949..c712fa5 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -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"));
-- 
2.5.0


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