[Sheepdog] [PATCH, RFC] collie: add -r/--raw option for machine-readable output

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Sun Jun 19 18:09:25 CEST 2011


At Thu, 16 Jun 2011 18:14:36 +0100,
Chris Webb wrote:
> 
> MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp> writes:
> 
> > > @@ -387,8 +396,9 @@ static void print_vdi_list(uint32_t vid, char *name, char *tag, uint32_t snapid,
> > >  	size_to_str(cow_objs * SD_DATA_OBJ_SIZE, cow_objs_str, sizeof(cow_objs_str));
> > >  
> > >  	if (!data || strcmp(name, data) == 0) {
> > > -		printf("%c %-8s %5d %7s %7s %7s %s  %7" PRIx32 "\n",
> > > -		       is_current(i) ? ' ' : 's', name, snapid,
> > > +		printf(raw_output ? "%c %s %d %s %s %s %s %" PRIx32 "\n"
> > > +				  : "%c %-8s %5d %7s %7s %7s %s  %7" PRIx32 "\n",
> > > +		       is_current(i) ? (raw_output ? '=' : ' ') : 's', name, snapid,
> > >  		       vdi_size_str, my_objs_str, cow_objs_str, dbuf, vid);
> > 
> > A vdi name can contain spaces, so shouldn't we espace them?
> 
> Ah, can they? In that case, yes, I'd have thought so, but probably also in
> the human-readable output for consistency?

For example:
 $ qemu-img create "sheepdog:t e s t" 1G

The output of listing vdis is:

 $ collie vdi list
   name        id    size    used  shared    creation time   vdi id
 ------------------------------------------------------------------
   t e s t      1  1.0 GB  0.0 MB  0.0 MB 2011-06-20 01:04   9256e9

I think this output is human-readable. :)

> 
> Presumably we do ' ' -> '\ ' and '\' -> '\\' so shell read will do the right
> thing. Can vdi names also contains tabs and newlines? If so, I should
> probably quote those too, though I don't think shell convention defines a
> sensible way to backslash-quote a newline does it?

I don't know the way to include tabs or newlines into a program
argument string.  I think it is enough to handle only ' ' and '\'.

Thanks,

Kazutaka



More information about the sheepdog mailing list