]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block: Use BDRV_O_NO_BACKING where appropriate
authorKevin Wolf <kwolf@redhat.com>
Fri, 18 Apr 2014 13:44:19 +0000 (15:44 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 25 Jun 2014 21:33:46 +0000 (16:33 -0500)
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 <kwolf@redhat.com>
Signed-off-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block.c
block/qcow2.c
block/vmdk.c

diff --git a/block.c b/block.c
index 8f84dbc5cb3ad4196f7312c77caec8cd0b13d82c..68651a9ba442736c185569b8f5e815ae9b7dc4bb 100644 (file)
--- 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;
index b43c7d0a3e228ebe9b3738edf34c6631a5fb701e..f2897b64aa4ee0e077e705ad287fc5eb536b890a 100644 (file)
@@ -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;
index a7ebd0f1257c76dfe64d61cc7228209b0a94b12a..d35a9d7e02317205949c4a04b8927962806de0e4 100644 (file)
@@ -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;