From patchwork Fri Jan 17 14:14:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 312079 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E9ADB2C0096 for ; Sat, 18 Jan 2014 01:16:40 +1100 (EST) Received: from localhost ([::1]:38440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4ADu-0007NB-MN for incoming@patchwork.ozlabs.org; Fri, 17 Jan 2014 09:16:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4ADC-00064R-HU for qemu-devel@nongnu.org; Fri, 17 Jan 2014 09:16:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W4AD2-0005uq-PZ for qemu-devel@nongnu.org; Fri, 17 Jan 2014 09:15:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4AD2-0005uj-G8 for qemu-devel@nongnu.org; Fri, 17 Jan 2014 09:15:44 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0HEFdJg015029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 17 Jan 2014 09:15:39 -0500 Received: from dhcp-200-207.str.redhat.com (ovpn-116-93.ams2.redhat.com [10.36.116.93]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0HEFSH8001275; Fri, 17 Jan 2014 09:15:37 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Fri, 17 Jan 2014 15:14:53 +0100 Message-Id: <1389968119-24771-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1389968119-24771-1-git-send-email-kwolf@redhat.com> References: <1389968119-24771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pl@kamp.de, mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, xiawenc@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v3 03/29] 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 Reviewed-by: Max Reitz Reviewed-by: BenoƮt Canet --- 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 20f85cb..9a8562d 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,