From nobody Mon Feb 9 13:38:59 2026 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=1559320512; cv=none; d=zoho.com; s=zohoarc; b=niTGvmdYKV6XkxXI8KCEelJr3KcFKhsuzGbaGMhsNN6Txh4rbpEqSiqJA3fZ5jMaF6ZLxIpJLJiHE3OC87XcoO4RlchIxZDCPCl9jaPK+ZBILw6H9x2/K7GsRVKOZNSkvP+jF7ajutunSbkqDDlD3pmtEaSLaIxepu/TJNEAq2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559320512; 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=fIuxOpjesoIJdcvmSZEkt6Wmva9R/JAtomhKTfhwEks=; b=S8Ur12cN/l4yB9fyAbYMKX8ZyxTnF4wegZcCYwzqLU2Fez3ZaOKNQYqw1s3LO08s7uG/CMeHWkN4qXNpVCktT2nKUSsspxv3JcFltgVKyN7LVU8DWzEU9DTKC5aaAhWwenIvFXmEr+YEG/meAa8dWKM+nCdnIjxzjJ1HqTccusc= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559320512594837.6648344378758; Fri, 31 May 2019 09:35:12 -0700 (PDT) Received: from localhost ([127.0.0.1]:46163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWkU9-00081l-Ki for importer@patchew.org; Fri, 31 May 2019 12:34:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWkRu-0006mB-7U for qemu-devel@nongnu.org; Fri, 31 May 2019 12:32:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWkRs-0008DV-NK for qemu-devel@nongnu.org; Fri, 31 May 2019 12:32:10 -0400 Received: from relay.sw.ru ([185.231.240.75]:57244) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hWkRs-0008Aj-8x; Fri, 31 May 2019 12:32:08 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hWkRp-0006Lb-2U; Fri, 31 May 2019 19:32:05 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 31 May 2019 19:32:02 +0300 Message-Id: <20190531163202.162543-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190531163202.162543-1-vsementsov@virtuozzo.com> References: <20190531163202.162543-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 v2 9/9] qcow2-bitmap: move bitmap reopen-rw code to qcow2_reopen_prepare 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: 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 7b22fb5d9c..a35b3e0d96 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 56e1388908..b5527ae713 100644 --- a/block.c +++ b/block.c @@ -3894,16 +3894,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); @@ -3947,21 +3943,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 ffc067a8ac..945fae74b5 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; @@ -5215,7 +5220,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