qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Eric Blake <eblake@redhat.com>
Cc: "Benoît Canet" <benoit.canet@irqsave.net>,
	kwolf@redhat.com, famz@redhat.com, "Jeff Cody" <jcody@redhat.com>,
	qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 1/3] block: resize backing file image during offline commit, if necessary
Date: Thu, 23 Jan 2014 23:35:00 +0100	[thread overview]
Message-ID: <20140123223500.GE22578@irqsave.net> (raw)
In-Reply-To: <52E192B0.1030804@redhat.com>

Le Thursday 23 Jan 2014 à 15:07:44 (-0700), Eric Blake a écrit :
> On 01/23/2014 03:00 PM, Benoît Canet wrote:
> > Le Thursday 23 Jan 2014 à 16:48:55 (-0500), Jeff Cody a écrit :
> >> Currently, if an image file is logically larger than its backing file,
> >> commiting it via 'qemu-img commit' will fail.
> 
> s/commiting/committing/
> 
> 
> >> +    uint8_t *buf = NULL;
> > 
> > Why assign NULL to buf ? Is it related to the rest of the patch ?
> > 
> > Reviewed-by: Benoit Canet <benoit@irqsave.net>
> > 
> >>      char filename[PATH_MAX];
> >>  
> >>      if (!drv)
> >> @@ -1904,7 +1904,24 @@ int bdrv_commit(BlockDriverState *bs)
> >>          }
> >>      }
> >>  
> >> -    total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
> >> +    length = bdrv_getlength(bs);
> >> +    backing_length = bdrv_getlength(bs->backing_hd);
> >> +
> >> +    if (length < 0 || backing_length < 0) {
> >> +        goto ro_cleanup;
> 
> Because this goto now reaches the ro_cleanup label with buf
> uninitialized, if we don't assign NULL originally.

Thanks for the explanation.

Best regards

Benoît
> 
> >> +    total_sectors = length >> BDRV_SECTOR_BITS;
> >>      buf = g_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
> 
> The old code only ever reached ro_cleanup after assigning buf, and
> ro_cleanup blindly frees buf.
> 
> -- 
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
> 

  parent reply	other threads:[~2014-01-23 22:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-23 21:48 [Qemu-devel] [PATCH v3 0/3] block: commits of snapshots larger than backing files Jeff Cody
2014-01-23 21:48 ` [Qemu-devel] [PATCH v3 1/3] block: resize backing file image during offline commit, if necessary Jeff Cody
2014-01-23 22:00   ` Benoît Canet
2014-01-23 22:07     ` Eric Blake
2014-01-23 22:14       ` Jeff Cody
2014-01-23 22:35       ` Benoît Canet [this message]
2014-01-23 21:48 ` [Qemu-devel] [PATCH v3 2/3] block: resize backing image during active layer commit, if needed Jeff Cody
2014-01-23 22:05   ` Benoît Canet
2014-01-23 22:18     ` Jeff Cody
2014-01-23 22:05   ` Eric Blake
2014-01-23 21:48 ` [Qemu-devel] [PATCH v3 3/3] block: update block commit documentation regarding image truncation Jeff Cody

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140123223500.GE22578@irqsave.net \
    --to=benoit.canet@irqsave.net \
    --cc=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).