]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
qcow2: Use BB for resizing in qcow2_amend_options()
authorKevin Wolf <kwolf@redhat.com>
Fri, 17 Feb 2017 09:58:25 +0000 (10:58 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 24 Feb 2017 15:09:23 +0000 (16:09 +0100)
In order to able to convert bdrv_truncate() to take a BdrvChild and
later to correctly check the resize permission here, we need to use a
BlockBackend for resizing the image.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
block/qcow2.c

index 3e274bd1ba48c88655ebb04391076b29e6e6b1fb..254545a83bdd7c535d310938080c1983eb793701 100644 (file)
@@ -3250,7 +3250,11 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
     }
 
     if (new_size) {
-        ret = bdrv_truncate(bs, new_size);
+        BlockBackend *blk = blk_new();
+        blk_insert_bs(blk, bs);
+        ret = blk_truncate(blk, new_size);
+        blk_unref(blk);
+
         if (ret < 0) {
             return ret;
         }