]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: check for RESIZE blocker in the QMP command, not bdrv_truncate()
authorJeff Cody <jcody@redhat.com>
Wed, 25 Jun 2014 20:55:30 +0000 (16:55 -0400)
committerKevin Wolf <kwolf@redhat.com>
Fri, 27 Jun 2014 09:37:35 +0000 (11:37 +0200)
If we check for the RESIZE blocker in bdrv_truncate(), that means a
commit will fail if the overlay layer is larger than the base, due to
the backing blocker.

This is a regression in behavior from 2.0; currently, commit will try to
grow the size of the base image to match the overlay size, if the
overlay size is larger.

By moving this into the QMP command qmp_block_resize(), it allows
usage of bdrv_truncate() within block jobs.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
blockdev.c

diff --git a/block.c b/block.c
index 7d69f312b6d060d67462f50c7a163304c4965aa8..106238d0b7ed6c7f74181c5d27388f25b1a71bb8 100644 (file)
--- a/block.c
+++ b/block.c
@@ -3483,9 +3483,7 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset)
         return -ENOTSUP;
     if (bs->read_only)
         return -EACCES;
-    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, NULL)) {
-        return -EBUSY;
-    }
+
     ret = drv->bdrv_truncate(bs, offset);
     if (ret == 0) {
         ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);
index 03ab153d0117a36584a34f33c07f1a899f9d6294..e8bfa3c6608545b977cc29deb99538db9b133bab 100644 (file)
@@ -1819,6 +1819,11 @@ void qmp_block_resize(bool has_device, const char *device,
         return;
     }
 
+    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, NULL)) {
+        error_set(errp, QERR_DEVICE_IN_USE, device);
+        return;
+    }
+
     /* complete all in-flight operations before resizing the device */
     bdrv_drain_all();