From nobody Tue Jul 15 06:04:08 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 1486042114439429.7345017422789; Thu, 2 Feb 2017 05:28:34 -0800 (PST) Received: from localhost ([::1]:56561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZHRA-00007s-Ha for importer@patchew.org; Thu, 02 Feb 2017 08:28:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZHKk-0002cE-9E for qemu-devel@nongnu.org; Thu, 02 Feb 2017 08:21:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZHKj-0008HV-3u for qemu-devel@nongnu.org; Thu, 02 Feb 2017 08:21:54 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:32860 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 1cZHKi-0008Fz-On for qemu-devel@nongnu.org; Thu, 02 Feb 2017 08:21:53 -0500 Received: from kvm.qa.sw.ru. (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v12DLkKp005095; Thu, 2 Feb 2017 16:21:47 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 16:21:37 +0300 Message-Id: <20170202132145.168790-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170202132145.168790-1-vsementsov@virtuozzo.com> References: <20170202132145.168790-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 16/24] qmp: add persistent flag to block-dirty-bitmap-add 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 optional 'persistent' flag to qmp command block-dirty-bitmap-add. Default is false. Signed-off-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Denis V. Lunev Reviewed-by: Max Reitz --- blockdev.c | 18 +++++++++++++++++- qapi/block-core.json | 8 +++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 245e1e1d17..40605faccc 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1967,6 +1967,7 @@ static void block_dirty_bitmap_add_prepare(BlkActionS= tate *common, /* AIO context taken and released within qmp_block_dirty_bitmap_add */ qmp_block_dirty_bitmap_add(action->node, action->name, action->has_granularity, action->granularit= y, + action->has_persistent, action->persistent, &local_err); =20 if (!local_err) { @@ -2696,10 +2697,12 @@ out: =20 void qmp_block_dirty_bitmap_add(const char *node, const char *name, bool has_granularity, uint32_t granularity, + bool has_persistent, bool persistent, Error **errp) { AioContext *aio_context; BlockDriverState *bs; + BdrvDirtyBitmap *bitmap; =20 if (!name || name[0] =3D=3D '\0') { error_setg(errp, "Bitmap name cannot be empty"); @@ -2725,7 +2728,20 @@ void qmp_block_dirty_bitmap_add(const char *node, co= nst char *name, granularity =3D bdrv_get_default_bitmap_granularity(bs); } =20 - bdrv_create_dirty_bitmap(bs, granularity, name, errp); + if (!has_persistent) { + persistent =3D false; + } + + if (persistent && + !bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp)) + { + goto out; + } + + bitmap =3D bdrv_create_dirty_bitmap(bs, granularity, name, errp); + if (bitmap !=3D NULL) { + bdrv_dirty_bitmap_set_persistance(bitmap, persistent); + } =20 out: aio_context_release(aio_context); diff --git a/qapi/block-core.json b/qapi/block-core.json index 932f5bb3b4..535df20212 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1559,10 +1559,16 @@ # @granularity: #optional the bitmap granularity, default is 64k for # block-dirty-bitmap-add # +# @persistent: #optional the bitmap is persistent, i.e. it will be saved t= o the +# corresponding block device image file on its close. For now= only +# Qcow2 disks support persistent bitmaps. Default is false. +# (Since 2.9) +# # Since: 2.4 ## { 'struct': 'BlockDirtyBitmapAdd', - 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32' } } + 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32', + '*persistent': 'bool' } } =20 ## # @block-dirty-bitmap-add: --=20 2.11.0