From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgU4s-0003YL-Es for qemu-devel@nongnu.org; Wed, 13 Nov 2013 01:37:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgU4m-0002IQ-CX for qemu-devel@nongnu.org; Wed, 13 Nov 2013 01:37:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgU4m-0002I1-4l for qemu-devel@nongnu.org; Wed, 13 Nov 2013 01:37:20 -0500 Message-ID: <52831E15.2010000@redhat.com> Date: Wed, 13 Nov 2013 14:37:09 +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> <52831D10.9020706@redhat.com> In-Reply-To: <52831D10.9020706@redhat.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, stefanha@gmail.com, wdongxu@linux.vnet.ibm.com, xiawenc@linux.vnet.ibm.com, Xu Wang On 2013=E5=B9=B411=E6=9C=8813=E6=97=A5 14:32, Fam Zheng wrote: > 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, >> const char *fmt, >> } >> >> backing_file =3D get_option_parameter(param, BLOCK_OPT_BACKING_F= ILE); >> + 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 >> the " >> - "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, > which is not a backing chain loop. What if the backing file doesn't > exist? Would the error message still mention "look exits", which is ver= y > confusing? s/look/loop/ Fam > > 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) { >> > >