From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0bWm-000569-CR for qemu-devel@nongnu.org; Fri, 27 Jun 2014 15:09:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0bWg-0006ud-6o for qemu-devel@nongnu.org; Fri, 27 Jun 2014 15:09:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0bWf-0006uY-Vw for qemu-devel@nongnu.org; Fri, 27 Jun 2014 15:09:34 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5RJ9Xnh009413 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 27 Jun 2014 15:09:33 -0400 From: Kevin Wolf Date: Fri, 27 Jun 2014 21:08:36 +0200 Message-Id: <1403896146-3063-18-git-send-email-kwolf@redhat.com> In-Reply-To: <1403896146-3063-1-git-send-email-kwolf@redhat.com> References: <1403896146-3063-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 17/47] block: check for RESIZE blocker in the QMP command, not bdrv_truncate() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com From: Jeff Cody 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 Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 4 +--- blockdev.c | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 7d69f31..106238d 100644 --- 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); diff --git a/blockdev.c b/blockdev.c index 03ab153..e8bfa3c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -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(); -- 1.8.3.1