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(a)sun.com>
--- 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;