From patchwork Wed Dec 11 21:08:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 300416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A0B282C0185 for ; Thu, 12 Dec 2013 08:09:54 +1100 (EST) Received: from localhost ([::1]:60218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vqr2V-0007Y8-Oq for incoming@patchwork.ozlabs.org; Wed, 11 Dec 2013 16:09:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vqr1k-0007HH-DC for qemu-devel@nongnu.org; Wed, 11 Dec 2013 16:09:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vqr1Y-0000g9-Ec for qemu-devel@nongnu.org; Wed, 11 Dec 2013 16:09:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vqr1Y-0000fm-4i for qemu-devel@nongnu.org; Wed, 11 Dec 2013 16:08:52 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBBL8mBg029419 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 11 Dec 2013 16:08:48 -0500 Received: from dhcp-200-207.str.redhat.com (ovpn-116-104.ams2.redhat.com [10.36.116.104]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rBBL8d8m028102; Wed, 11 Dec 2013 16:08:46 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 11 Dec 2013 22:08:10 +0100 Message-Id: <1386796109-15264-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1386796109-15264-1-git-send-email-kwolf@redhat.com> References: <1386796109-15264-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, pl@kamp.de, stefanha@redhat.com Subject: [Qemu-devel] [PATCH 03/22] block: Update BlockLimits when they might have changed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When reopening with different flags, or when backing files disappear from the chain, the limits may change. Make sure they get updated in these cases. Signed-off-by: Kevin Wolf Reviewed-by: Wenchao Xia --- block.c | 5 ++++- block/stream.c | 2 ++ include/block/block.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 79a325f..8eae359 100644 --- a/block.c +++ b/block.c @@ -479,7 +479,7 @@ int bdrv_create_file(const char* filename, QEMUOptionParameter *options, return ret; } -static int bdrv_refresh_limits(BlockDriverState *bs) +int bdrv_refresh_limits(BlockDriverState *bs) { BlockDriver *drv = bs->drv; @@ -1464,6 +1464,8 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state) reopen_state->bs->enable_write_cache = !!(reopen_state->flags & BDRV_O_CACHE_WB); reopen_state->bs->read_only = !(reopen_state->flags & BDRV_O_RDWR); + + bdrv_refresh_limits(reopen_state->bs); } /* @@ -2261,6 +2263,7 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, } new_top_bs->backing_hd = base_bs; + bdrv_refresh_limits(new_top_bs); QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) { /* so that bdrv_close() does not recursively close the chain */ diff --git a/block/stream.c b/block/stream.c index 46bec7d..dd0b4ac 100644 --- a/block/stream.c +++ b/block/stream.c @@ -75,6 +75,8 @@ static void close_unused_images(BlockDriverState *top, BlockDriverState *base, unused->backing_hd = NULL; bdrv_unref(unused); } + + bdrv_refresh_limits(top); } static void coroutine_fn stream_run(void *opaque) diff --git a/include/block/block.h b/include/block/block.h index 36efaea..64fb319 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -249,6 +249,7 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset); int64_t bdrv_getlength(BlockDriverState *bs); int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); +int bdrv_refresh_limits(BlockDriverState *bs); int bdrv_commit(BlockDriverState *bs); int bdrv_commit_all(void); int bdrv_change_backing_file(BlockDriverState *bs,