[libvirt] [PATCH] Change virsh list behavior

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

 




At the popular request of pretty much everyone in Sun who uses virsh...

Change virsh list to list all domains, and add an "--active" flag to list only the active domains.

Signed-off-by: Ryan Scott <ryan.scott@xxxxxxx>
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -551,6 +551,7 @@ static vshCmdInfo info_list[] = {
 
 static vshCmdOptDef opts_list[] = {
     {"inactive", VSH_OT_BOOL, 0, gettext_noop("list inactive domains")},
+    {"active", VSH_OT_BOOL, 0, gettext_noop("list only active domains")},
     {"all", VSH_OT_BOOL, 0, gettext_noop("list inactive & active domains")},
     {NULL, 0, 0, NULL}
 };
@@ -559,13 +560,17 @@ static vshCmdOptDef opts_list[] = {
 static int
 cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
 {
-    int inactive = vshCommandOptBool(cmd, "inactive");
+    int inactiveOpt = vshCommandOptBool(cmd, "inactive");
+    int activeOpt = vshCommandOptBool(cmd, "active");
     int all = vshCommandOptBool(cmd, "all");
-    int active = !inactive || all ? 1 : 0;
+    int active, inactive;
     int *ids = NULL, maxid = 0, i;
     char **names = NULL;
     int maxname = 0;
-    inactive |= all;
+
+    /* If no options are specified, default to both active and inactive */
+    active = activeOpt || all || !inactiveOpt;
+    inactive = inactiveOpt || all || !activeOpt;
 
     if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
         return FALSE;
--
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]