From nobody Wed Nov 5 18:11:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496403132173805.9673060951426; Fri, 2 Jun 2017 04:32:12 -0700 (PDT) Received: from localhost ([::1]:49057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGkoL-0007TZ-HK for importer@patchew.org; Fri, 02 Jun 2017 07:32:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGkej-0006Ho-CI for qemu-devel@nongnu.org; Fri, 02 Jun 2017 07:22:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGkef-0005c6-MU for qemu-devel@nongnu.org; Fri, 02 Jun 2017 07:22:13 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:40873 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGkef-0005Yy-9e for qemu-devel@nongnu.org; Fri, 02 Jun 2017 07:22:09 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v52BLwPF031321; Fri, 2 Jun 2017 14:22:01 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Fri, 2 Jun 2017 14:21:41 +0300 Message-Id: <20170602112158.232757-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170602112158.232757-1-vsementsov@virtuozzo.com> References: <20170602112158.232757-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH v20 13/30] block: new bdrv_reopen_bitmaps_rw interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, famz@redhat.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add format driver handler, which should mark loaded read-only bitmaps as 'IN_USE' in the image and unset read_only field in corresponding BdrvDirtyBitmap's. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: John Snow --- block.c | 17 +++++++++++++++++ include/block/block_int.h | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/block.c b/block.c index 04af7697dc..161db9e32a 100644 --- a/block.c +++ b/block.c @@ -2946,12 +2946,16 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_sta= te) { BlockDriver *drv; BlockDriverState *bs; + 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); @@ -2965,6 +2969,19 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_stat= e) bs->read_only =3D !(reopen_state->flags & BDRV_O_RDWR); =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_report_err(local_err); + } + } } =20 /* diff --git a/include/block/block_int.h b/include/block/block_int.h index 8d3724cce6..1dc6f2e90d 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -380,6 +380,13 @@ struct BlockDriver { uint64_t parent_perm, uint64_t parent_shared, uint64_t *nperm, uint64_t *nshared); =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); + QLIST_ENTRY(BlockDriver) list; }; =20 --=20 2.11.1