From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyfJY-0008VF-Ko for qemu-devel@nongnu.org; Mon, 15 Jul 2013 05:43:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UyfJU-0002rh-Rh for qemu-devel@nongnu.org; Mon, 15 Jul 2013 05:43:28 -0400 Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]:50395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyfJU-0002rF-Kg for qemu-devel@nongnu.org; Mon, 15 Jul 2013 05:43:24 -0400 Received: by mail-pa0-f44.google.com with SMTP id lj1so10998646pab.3 for ; Mon, 15 Jul 2013 02:43:23 -0700 (PDT) From: Xu Wang Date: Mon, 15 Jul 2013 05:42:33 -0400 Message-Id: <1373881356-3294-5-git-send-email-cngesaint@gmail.com> In-Reply-To: <1373881356-3294-1-git-send-email-cngesaint@gmail.com> References: <1373881356-3294-1-git-send-email-cngesaint@gmail.com> Subject: [Qemu-devel] [PATCH V3 4/7] block: Add backing file loop check in change_backing_file() 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 Backing file loop should be checked before calling change_backing_ file(). If loop appeared, this calling should be stopped and an error was printed. Signed-off-by: Xu Wang --- block.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block.c b/block.c index e9b9112..bd8240c 100644 --- a/block.c +++ b/block.c @@ -1967,6 +1967,13 @@ int bdrv_change_backing_file(BlockDriverState *bs, return -EINVAL; } + /* Check if loop exists in backing files chain after changed */ + if (bdrv_backing_file_loop_check(bs->filename, + bs->drv ? bs->drv->format_name : NULL, + backing_file, backing_fmt)) { + return -EIO; + } + if (drv->bdrv_change_backing_file != NULL) { ret = drv->bdrv_change_backing_file(bs, backing_file, backing_fmt); } else { -- 1.8.1.4