From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgU0f-0001Bv-3F for qemu-devel@nongnu.org; Wed, 13 Nov 2013 01:33:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgU0Z-0000UL-3H for qemu-devel@nongnu.org; Wed, 13 Nov 2013 01:33:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgU0Y-0000TZ-Ps for qemu-devel@nongnu.org; Wed, 13 Nov 2013 01:32:59 -0500 Message-ID: <52831D10.9020706@redhat.com> Date: Wed, 13 Nov 2013 14:32:48 +0800 From: Fam Zheng MIME-Version: 1.0 References: <1384310380-9805-1-git-send-email-gesaint@linux.vnet.ibm.com> <1384310380-9805-3-git-send-email-gesaint@linux.vnet.ibm.com> In-Reply-To: <1384310380-9805-3-git-send-email-gesaint@linux.vnet.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V7 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 , qemu-devel@nongnu.org Cc: kwolf@redhat.com, wdongxu@linux.vnet.ibm.com, stefanha@gmail.com, Xu Wang , xiawenc@linux.vnet.ibm.com On 2013=E5=B9=B411=E6=9C=8813=E6=97=A5 10:39, 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 | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/block.c b/block.c > index 3c43179..c2ed6ef 100644 > --- a/block.c > +++ b/block.c > @@ -4629,15 +4629,16 @@ void bdrv_img_create(const char *filename, cons= t char *fmt, > } > > backing_file =3D get_option_parameter(param, BLOCK_OPT_BACKING_FI= LE); > + backing_fmt =3D get_option_parameter(param, BLOCK_OPT_BACKING_FMT)= ; > if (backing_file && backing_file->value.s) { > - if (!strcmp(filename, backing_file->value.s)) { > - error_setg(errp, "Error: Trying to create an image with th= e " > - "same filename as the backing file"); > + if (!bdrv_backing_chain_okay(backing_file->value.s, > + backing_fmt->value.s, filename)) = { > + error_setg(errp, "bdrv_img_create: loop exists, " > + "image create failed"); Another failure path in file_chain_has_loop() is when bdrv_open fails,=20 which is not a backing chain loop. What if the backing file doesn't=20 exist? Would the error message still mention "look exits", which is very=20 confusing? Fam > goto out; > } > } > > - backing_fmt =3D get_option_parameter(param, BLOCK_OPT_BACKING_FMT)= ; > if (backing_fmt && backing_fmt->value.s) { > backing_drv =3D bdrv_find_format(backing_fmt->value.s); > if (!backing_drv) { >