From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Z4G-0003Br-PH for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:20:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4Z40-0007TA-6K for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:20:36 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:59577) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Z3z-0007Su-U7 for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:20:20 -0400 Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Jul 2014 11:20:19 -0600 From: Michael Roth Date: Tue, 8 Jul 2014 12:16:54 -0500 Message-Id: <1404839947-1086-24-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1404839947-1086-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1404839947-1086-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 023/156] block: Use BDRV_O_NO_BACKING where appropriate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Kevin Wolf If you open an image temporarily just because you want to check its size or get it flushed, there's no real reason to open the whole backing file chain. This is a backport of c9fbb99d41b05acf0d7b93deb2fcdbf9047c238e to qemu 1.7.1. The backport was done to fix a bug where QEMU 1.7.1 would crash or freeze when the user take around 80 consecutives snapshots in a row. git bisect would lead to commit: ba2ab2f2ca4150a7e314fbb19fa158bd8ddc36eb and it was clear that BDRV_NO_BACKING was missing. Signed-off-by: Kevin Wolf Signed-off-by: Benoit Canet Signed-off-by: Michael Roth --- block.c | 4 ++-- block/qcow2.c | 3 ++- block/vmdk.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index 8f84dbc..68651a9 100644 --- a/block.c +++ b/block.c @@ -1067,9 +1067,9 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, /* if snapshot, we create a temporary backing file and open it instead of opening 'filename' directly */ - /* if there is a backing file, use it */ bs1 = bdrv_new(""); - ret = bdrv_open(bs1, filename, NULL, 0, drv, &local_err); + ret = bdrv_open(bs1, filename, NULL, BDRV_O_NO_BACKING, drv, + &local_err); if (ret < 0) { bdrv_unref(bs1); goto fail; diff --git a/block/qcow2.c b/block/qcow2.c index b43c7d0..f2897b6 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1605,7 +1605,8 @@ static int qcow2_create2(const char *filename, int64_t total_size, /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */ ret = bdrv_open(bs, filename, NULL, - BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err); + BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_BACKING, + drv, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); goto out; diff --git a/block/vmdk.c b/block/vmdk.c index a7ebd0f..d35a9d7 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1689,7 +1689,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options, } if (backing_file) { BlockDriverState *bs = bdrv_new(""); - ret = bdrv_open(bs, backing_file, NULL, 0, NULL, errp); + ret = bdrv_open(bs, backing_file, NULL, BDRV_O_NO_BACKING, NULL, errp); if (ret != 0) { bdrv_unref(bs); return ret; -- 1.9.1