qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 1/3] qemu-img: Add --backing-chain option to


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v2 1/3] qemu-img: Add --backing-chain option to info command
Date: Tue, 16 Oct 2012 16:51:12 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Oct 16, 2012 at 12:04:24PM +0200, Kevin Wolf wrote:
> Am 15.10.2012 14:44, schrieb Stefan Hajnoczi:
> > The qemu-img info --backing-chain option enumerates the backing file
> > chain.  For example, for base.qcow2 <- snap1.qcow2 <- snap2.qcow2 the
> > output becomes:
> > 
> >   $ qemu-img info --backing-chain snap2.qcow2
> >   image: snap2.qcow2
> >   file format: qcow2
> >   virtual size: 100M (104857600 bytes)
> >   disk size: 196K
> >   cluster_size: 65536
> >   backing file: snap1.qcow2
> >   backing file format: qcow2
> > 
> >   image: snap1.qcow2
> >   file format: qcow2
> >   virtual size: 100M (104857600 bytes)
> >   disk size: 196K
> >   cluster_size: 65536
> >   backing file: base.qcow2
> >   backing file format: qcow2
> > 
> >   image: base.qcow2
> >   file format: qcow2
> >   virtual size: 100M (104857600 bytes)
> >   disk size: 136K
> >   cluster_size: 65536
> > 
> > Signed-off-by: Stefan Hajnoczi <address@hidden>
> > ---
> >  qemu-img.c | 98 
> > ++++++++++++++++++++++++++++++++++++++++++++++++--------------
> >  1 file changed, 76 insertions(+), 22 deletions(-)
> > 
> > diff --git a/qemu-img.c b/qemu-img.c
> > index f17f187..c717f3e 100644
> > --- a/qemu-img.c
> > +++ b/qemu-img.c
> > @@ -1249,7 +1249,10 @@ static void dump_human_image_info(ImageInfo *info)
> >      }
> >  }
> >  
> > -enum {OPTION_OUTPUT = 256};
> > +enum {
> > +    OPTION_OUTPUT = 256,
> > +    OPTION_BACKING_CHAIN = 257,
> > +};
> >  
> >  typedef enum OutputFormat {
> >      OFORMAT_JSON,
> > @@ -1260,7 +1263,9 @@ static int img_info(int argc, char **argv)
> >  {
> >      int c;
> >      OutputFormat output_format = OFORMAT_HUMAN;
> > -    const char *filename, *fmt, *output;
> > +    bool chain = false;
> > +    const char *output;
> > +    char *filename, *fmt;
> 
> Maybe I'm missing something, but where are the strings pointed at by
> filename and fmt ever modified? If they aren't, strdup() isn't necessary
> either.

It's necessary because the loop strdups the current image's backing
file, then frees the current image info (including the original backing
file string).  To avoid special cases for the topmost image filename/fmt
we just strdup them.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]