From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtkTC-00052z-6y for qemu-devel@nongnu.org; Thu, 19 Dec 2013 15:45:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VtkT6-00064C-7V for qemu-devel@nongnu.org; Thu, 19 Dec 2013 15:45:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtkT5-000647-VC for qemu-devel@nongnu.org; Thu, 19 Dec 2013 15:45:16 -0500 Date: Thu, 19 Dec 2013 11:27:18 -0500 From: Jeff Cody Message-ID: <20131219162718.GE4699@localhost.localdomain> References: <1385447913-19004-1-git-send-email-gesaint@linux.vnet.ibm.com> <1385447913-19004-3-git-send-email-gesaint@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1385447913-19004-3-git-send-email-gesaint@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH V9 2/4] block: Add check infinite loop in bdrv_img_create() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Xu Wang Cc: kwolf@redhat.com, stefanha@gmail.com, famz@redhat.com, qemu-devel@nongnu.org, wdongxu@linux.vnet.ibm.com On Tue, Nov 26, 2013 at 01:38:31AM -0500, Xu Wang wrote: > Backing file loop should be checked before qemu-img create command > execution. If loop is found, qemu-img create should be stopped and > an error printed. > > Signed-off-by: Xu Wang > --- > block.c | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/block.c b/block.c > index 7016ce8..b8cea1c 100644 > --- a/block.c > +++ b/block.c > @@ -4633,14 +4633,6 @@ void bdrv_img_create(const char *filename, const char *fmt, > } > > backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE); > - if (backing_file && backing_file->value.s) { > - if (!strcmp(filename, backing_file->value.s)) { > - error_setg(errp, "Error: Trying to create an image with the " > - "same filename as the backing file"); > - goto out; > - } > - } > - > backing_fmt = get_option_parameter(param, BLOCK_OPT_BACKING_FMT); > if (backing_fmt && backing_fmt->value.s) { > backing_drv = bdrv_find_format(backing_fmt->value.s); > @@ -4651,6 +4643,16 @@ void bdrv_img_create(const char *filename, const char *fmt, > } > } > > + if (backing_file && backing_file->value.s) { > + if (!bdrv_backing_chain_okay(backing_file->value.s, > + backing_drv, filename, > + &local_err)) { > + error_setg(errp, "Failed to create image: %s", > + error_get_pretty(local_err)); > + goto out; This one is OK, because at out: there is an error_propagate(), which will see that errp is already set, and just free local_err at that point. > + } > + } > + > // The size for the image must always be specified, with one exception: > // If we are using a backing file, we can obtain the size from there > size = get_option_parameter(param, BLOCK_OPT_SIZE); > -- > 1.8.1.4 > >