diff mbox

[02/54] qcow2: Use BB for resizing in qcow2_amend_options()

Message ID 1487689130-30373-3-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf Feb. 21, 2017, 2:57 p.m. UTC
In order to able to conver 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>
---
 block/qcow2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Max Reitz Feb. 22, 2017, 12:28 p.m. UTC | #1
On 21.02.2017 15:57, Kevin Wolf wrote:
> In order to able to conver 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>
> ---
>  block/qcow2.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>
Eric Blake Feb. 22, 2017, 3:53 p.m. UTC | #2
On 02/21/2017 08:57 AM, Kevin Wolf wrote:
> In order to able to conver bdrv_truncate() to take a BdrvChild and

s/conver/convert/

> 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>
> ---
>  block/qcow2.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
diff mbox

Patch

diff --git a/block/qcow2.c b/block/qcow2.c
index 3e274bd..254545a 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -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;
         }