From nobody Tue Nov 11 15:58:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1564046391; cv=none; d=zoho.com; s=zohoarc; b=Zk2tETP4zL5Lx7y2VAr71MGMb60h9OqebSbNfokFeDs9twsVNNphz2lbG+r1OQ81NTMXD1scG6aWh6Y/BrbrM56aOne2WKwHJvkYA1ZZfZXCVa/smOHw4GJMLAlg7W8XFM4EjvQ6oXQM6wmB2K8eE0kwv2ySwohcT4eq7jbMtII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564046391; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=M6p4CJ1hMYPL8/pMHFGbPeOZ//smABa08D2g5A1otEo=; b=MOUp55luiVkMwLeS71ON8tL9OMxlqjg9HX4xdDJ6rq090huum8ee+OiqI41vp5uWiOmgiW8wVrx6BVdyt520ZDwMKgzbjQAIGgcwCewQtGZJ9K2PD3Eo+wZoFRGQcnPaFtBzPnk64soXB9johMss4cN+/98WfjEMm+us//+xXVY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564046391754401.087776056832; Thu, 25 Jul 2019 02:19:51 -0700 (PDT) Received: from localhost ([::1]:57468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZud-0000bj-Sg for importer@patchew.org; Thu, 25 Jul 2019 05:19:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35755) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZtz-0007SK-HW for qemu-devel@nongnu.org; Thu, 25 Jul 2019 05:19:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqZty-00044m-1L for qemu-devel@nongnu.org; Thu, 25 Jul 2019 05:19:07 -0400 Received: from relay.sw.ru ([185.231.240.75]:44250) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqZtx-00042q-NJ; Thu, 25 Jul 2019 05:19:05 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hqZtw-0001bs-Ca; Thu, 25 Jul 2019 12:19:04 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 25 Jul 2019 12:19:00 +0300 Message-Id: <20190725091900.30542-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190725091900.30542-1-vsementsov@virtuozzo.com> References: <20190725091900.30542-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v3 9/9] qcow2-bitmap: move bitmap reopen-rw code to qcow2_reopen_prepare X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, mreitz@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since we have used .bdrv_need_rw_file_child_during_reopen_rw handler, and have write access to file child in reopen-prepare, and we prepared qcow2_reopen_bitmaps_rw to be called from reopening rw -> rw, we now can simple move qcow2_reopen_bitmaps_rw() call to qcow2_reopen_prepare() and handle errors as befits. Hacky handler .bdrv_reopen_bitmaps_rw is not needed more and therefore dropped. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 6 ------ block.c | 19 ------------------- block/qcow2.c | 6 +++++- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 7bd6fd68dd..5077b26561 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -533,12 +533,6 @@ struct BlockDriver { =20 bool (*bdrv_need_rw_file_child_during_reopen_rw)(BlockDriverState *bs= ); =20 - /** - * Bitmaps should be marked as 'IN_USE' in the image on reopening image - * as rw. This handler should realize it. It also should unset readonly - * field of BlockDirtyBitmap's in case of success. - */ - int (*bdrv_reopen_bitmaps_rw)(BlockDriverState *bs, Error **errp); bool (*bdrv_can_store_new_dirty_bitmap)(BlockDriverState *bs, const char *name, uint32_t granularity, diff --git a/block.c b/block.c index 3c8e1c59b4..71b4f9961c 100644 --- a/block.c +++ b/block.c @@ -4037,16 +4037,12 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_sta= te) BlockDriver *drv; BlockDriverState *bs; BdrvChild *child; - bool old_can_write, new_can_write; =20 assert(reopen_state !=3D NULL); bs =3D reopen_state->bs; drv =3D bs->drv; assert(drv !=3D NULL); =20 - old_can_write =3D - !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE); - /* If there are any driver level actions to take */ if (drv->bdrv_reopen_commit) { drv->bdrv_reopen_commit(reopen_state); @@ -4090,21 +4086,6 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_stat= e) } =20 bdrv_refresh_limits(bs, NULL); - - new_can_write =3D - !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE); - if (!old_can_write && new_can_write && drv->bdrv_reopen_bitmaps_rw) { - Error *local_err =3D NULL; - if (drv->bdrv_reopen_bitmaps_rw(bs, &local_err) < 0) { - /* This is not fatal, bitmaps just left read-only, so all foll= owing - * writes will fail. User can remove read-only bitmaps to unbl= ock - * writes. - */ - error_reportf_err(local_err, - "%s: Failed to make dirty bitmaps writable: = ", - bdrv_get_node_name(bs)); - } - } } =20 /* diff --git a/block/qcow2.c b/block/qcow2.c index 1d9fb3ae98..1ef71c1f1f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1815,6 +1815,11 @@ static int qcow2_reopen_prepare(BDRVReopenState *sta= te, if (ret < 0) { goto fail; } + } else { + ret =3D qcow2_reopen_bitmaps_rw(state->bs, errp); + if (ret < 0) { + goto fail; + } } =20 return 0; @@ -5229,7 +5234,6 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_detach_aio_context =3D qcow2_detach_aio_context, .bdrv_attach_aio_context =3D qcow2_attach_aio_context, =20 - .bdrv_reopen_bitmaps_rw =3D qcow2_reopen_bitmaps_rw, .bdrv_can_store_new_dirty_bitmap =3D qcow2_can_store_new_dirty_bitmap, .bdrv_remove_persistent_dirty_bitmap =3D qcow2_remove_persistent_dirty= _bitmap, .bdrv_need_rw_file_child_during_reopen_rw =3D qcow2_has_bitmaps, --=20 2.18.0