[libvirt] [PATCH] Change virsh list behavior

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@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;

It looks good to me. +1 Thanks Atsushi SAKAI Ryan Scott <Ryan.Scott@Sun.COM> wrote:
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@sun.com>

On Wed, Jun 25, 2008 at 03:42:59PM -0700, Ryan Scott wrote:
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.
But that breaks the behaviour for everybody and sounds a bit late for this. I'm fine with adding a --active flag to be able to explicitely specify the behaviour chosen, but changing the default behaviour directly looks a problem to me. If you really use it from command line maybe a shell alias for 'virsh list' can do, no ? Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Thu, Jun 26, 2008 at 11:51:01AM -0400, Daniel Veillard wrote:
On Wed, Jun 25, 2008 at 03:42:59PM -0700, Ryan Scott wrote:
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.
But that breaks the behaviour for everybody and sounds a bit late for this. I'm fine with adding a --active flag to be able to explicitely specify the behaviour chosen, but changing the default behaviour directly looks a problem to me. If you really use it from command line maybe a shell alias for 'virsh list' can do, no ?
Yep, the compatability with existing scripts using virsh is the reason I didn't change it when we first added inactive domain support. One possible option is for us to add a config file for virsh in, for example /etc/libvirt/virsh.conf which could let the admin override the default settings. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (4)
-
Atsushi SAKAI
-
Daniel P. Berrange
-
Daniel Veillard
-
Ryan Scott