[Libvir] virsh list

Daniel Veillard veillard at redhat.com
Tue Mar 4 06:19:48 UTC 2008

On Mon, Mar 03, 2008 at 10:31:56PM +0000, John Levon wrote:
> On Mon, Mar 03, 2008 at 09:44:31PM +0000, Richard W.M. Jones wrote:
> > > Am I the only one who finds the default behaviour of virsh list really
> > > confusing and annoying? That is, I would like --all to be the default.
> > 
> > Me too, but can we change it without breaking scripts or similar?
> Well, you've hit upon a good question here. Is virsh interactive, or
> scriptable? Within Sun we generally attempt to clearly delineate these
> things, precisely for reasons like the above.

  well to me clearly it was designed to be both, clearly it's intended to
be interactive since we link with libhistory if found, and also the command
parsing infrastructure was designed so that any command can also be used
as separated executions.

> 'virsh list' would have grown a '-p' option, that printed a
> machine-parsable output. That way, you can change the human output as
> needed (for example, you can translate 'blocked' into $LANG).

  Hum, I don't think there is anything preventing adding such an option

> Anyway, in this case, I think fixing up virsh list would be less pain
> than leaving it. Anything that's trying to parse human-readable output
> needs to be written carefully. For example, I don't think you'd have the
> same objection to adding a field to 'vcpuinfo', but that's just as
> likely to break scripts. I'm happy to hear contradictory opinions :)

  Disagreed, adding a field at the end probably won't break most scripts
using sed/awk to extract data, but showing stopped machines will.
  But we can add a 'virsh show' command doing a complete listing, then
it's just a matter of rerouting a few synapses, easier done than changing
running code ;-)

> In the longer term it would be good to make sure all new commands have
> the above considerations when reviewing the visible CLI. Perhaps we can
> go back and add -p options to things as appropriate too.

  Definitely !


Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard at redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

More information about the libvir-list mailing list