From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5BPi-00057H-Rc for qemu-devel@nongnu.org; Fri, 02 Aug 2013 05:12:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V5BPY-0000MR-Ig for qemu-devel@nongnu.org; Fri, 02 Aug 2013 05:12:46 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:60482) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5BPX-0000Lh-S2 for qemu-devel@nongnu.org; Fri, 02 Aug 2013 05:12:36 -0400 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Aug 2013 14:23:37 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id D898B394004E for ; Fri, 2 Aug 2013 14:32:18 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7292Mqu38273278 for ; Fri, 2 Aug 2013 14:32:22 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r7292Ooh014976 for ; Fri, 2 Aug 2013 19:02:25 +1000 From: Xu Wang Date: Fri, 2 Aug 2013 05:02:13 -0400 Message-Id: <1375434137-4452-3-git-send-email-gesaint@linux.vnet.ibm.com> In-Reply-To: <1375434137-4452-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1375434137-4452-1-git-send-email-gesaint@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V5 2/6] qemu-img: Add infinite loop checking in bdrv_new_open() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, stefanha@gmail.com, wdongxu@linux.vnet.ibm.com, Xu Wang , xiawenc@linux.vnet.ibm.com From: Xu Wang Every image should be checked if there is infinite loop in backing file chain before open it. So infinite loop check was added into bdrv_new_open(). If @filename is opened with no flags BDRV_O_NO_BACKING, the infinite loop check should be called. Signed-off-by: Xu Wang --- qemu-img.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index 4f01b0a..1a63bbf 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -278,6 +278,13 @@ static BlockDriverState *bdrv_new_open(const char *filename, drv = NULL; } + /* check backing file loop if the whole chain need to be opened */ + if (!(flags & BDRV_O_NO_BACKING) && + bdrv_backing_file_loop_check(filename, fmt, NULL, NULL)) { + error_report("bdrv_new_open: Open %s failed.", filename); + goto fail; + } + ret = bdrv_open(bs, filename, NULL, flags, drv); if (ret < 0) { error_report("Could not open '%s': %s", filename, strerror(-ret)); -- 1.8.1.4