Commit 9c75e168 authored by Jeff Cody's avatar Jeff Cody Committed by Kevin Wolf
Browse files

block: check for RESIZE blocker in the QMP command, not bdrv_truncate()



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: default avatarJeff Cody <jcody@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent a7607150
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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);
+5 −0
Original line number Diff line number Diff line
@@ -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();