[libvirt] [PATCHv4 1/2] virsh: add new --details option to pool-list

Richard W.M. Jones rjones at redhat.com
Thu Jul 1 15:06:36 UTC 2010


On Thu, Jul 01, 2010 at 10:51:00AM -0400, Dave Allan wrote:
> On Thu, Jul 01, 2010 at 11:42:12AM +0100, Richard W.M. Jones wrote:
> > On Wed, Jun 23, 2010 at 09:58:34AM +0100, Daniel P. Berrange wrote:
> > > On Tue, Jun 22, 2010 at 12:35:32PM -0600, Eric Blake wrote:
> > > > On 06/22/2010 12:24 PM, Hugh O. Brock wrote:
> > > > >> Correct, we shouldn't change this behaviour - it'll break apps parsing
> > > > >> the output
> > > > > 
> > > > > FWIW Rich Jones complains that the output as it stands is nigh on
> > > > > unparseable anyway. Perhaps we should consider that a bug, and fix
> > > > > it...
> > > > 
> > > > The new --details option is our chance to change output - it outputs
> > > > whatever format we want, because it is a new flag; Rich, do you have any
> > > > preferences about what it _should_ output?
> > > 
> > > --details is still targetted at humans. If you want something more
> > > easily parseable it should use a structured format like CSV. So I
> > > don't think we should be overloading --details for this purpose.
> > 
> > CSV is a good format, but beware the many ways to shoot yourself in
> > the foot.  I recommend using my program "csvtool" (in Fedora/Debian)
> > which can fully and safely parse CSV output from shell scripts, or use
> > a library (eg. Text::CSV for Perl, or csv for Python).  More about
> > this subject here:
> > 
> >   http://libguestfs.org/virt-df.1.html#note_about_csv_format
> > 
> > Rich.
> 
> If we're going to go to all this trouble, how much more difficult
> would it be to implement something like ps -o and give the user
> control of the format?

I think the two issues are orthogonal.  Having said that, csvtool lets
you pull out columns by name, so virsh could change the order or add
new columns in future without causing any (csvtool-using) scripts to
break.

In the example below, I pick columns from the output of 'virt-df --csv'
to demonstrate how this works with these existing tools:

  # virt-df --csv | csvtool namedcol "Virtual Machine,Use%" -
  CentOS5x32,45.2%
  CentOS5x32,35.8%
  Debian5x64,35.6%
  Debian5x64,60.9%
  Debian5x64,3.3%
  Debian5x64,40.5%
  Debian5x64,15.2%
  Debian5x64,20.3%
  F13x64,6.0%
  F13x64,42.2%
  [...truncated...]

Even if virt-df was to rearrange or add columns in future, this would
continue to work.  If a column was deleted from the output of virt-df,
then you'd get an empty result column.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v




More information about the libvir-list mailing list