From nobody Mon Apr 29 19:39:20 2024 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528757115782709.6514430550901; Mon, 11 Jun 2018 15:45:15 -0700 (PDT) Received: from localhost ([::1]:51727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSVYm-0005G3-QE for importer@patchew.org; Mon, 11 Jun 2018 18:45:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSVXN-0004RG-Hs for qemu-devel@nongnu.org; Mon, 11 Jun 2018 18:43:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSVXM-0001TM-Is for qemu-devel@nongnu.org; Mon, 11 Jun 2018 18:43:45 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39552 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSVXI-0001Qm-EH; Mon, 11 Jun 2018 18:43:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF2444023457; Mon, 11 Jun 2018 22:43:39 +0000 (UTC) Received: from probe.redhat.com (ovpn-121-36.rdu2.redhat.com [10.10.121.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59EF12144B29; Mon, 11 Jun 2018 22:43:39 +0000 (UTC) From: John Snow To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Mon, 11 Jun 2018 18:43:38 -0400 Message-Id: <20180611224338.9743-2-jsnow@redhat.com> In-Reply-To: <20180611224338.9743-1-jsnow@redhat.com> References: <20180611224338.9743-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 11 Jun 2018 22:43:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 11 Jun 2018 22:43:40 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jsnow@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 1/1] blockdev: n-ary bitmap merge 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: Kevin Wolf , vsementov@virtuozzo.com, Markus Armbruster , Max Reitz , John Snow 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" It might be nice to have an all-or-nothing merge command that either succeeds in merging all bitmaps or fails for all of them. This way, when assembling bitmaps that represent arbitrary points in time from component bitmaps, we always know the state of the target bitmap even in cases of failure. Signed-off-by: John Snow --- blockdev.c | 40 ++++++++++++++++++++++++++++++---------- qapi/block-core.json | 10 +++++----- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/blockdev.c b/blockdev.c index 041f5d594f..4d60d0a03c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3054,34 +3054,54 @@ void qmp_x_block_dirty_bitmap_disable(const char *n= ode, const char *name, bdrv_disable_dirty_bitmap(bitmap); } =20 -void qmp_x_block_dirty_bitmap_merge(const char *node, const char *dst_name, - const char *src_name, Error **errp) +void qmp_x_block_dirty_bitmap_merge(const char *node, const char *target, + strList *bitmaps, Error **errp) { BlockDriverState *bs; - BdrvDirtyBitmap *dst, *src; + BdrvDirtyBitmap *dst, *src, *anon; + strList *lst; + Error *local_err =3D NULL; =20 - dst =3D block_dirty_bitmap_lookup(node, dst_name, &bs, errp); + dst =3D block_dirty_bitmap_lookup(node, target, &bs, errp); if (!dst) { return; } =20 if (bdrv_dirty_bitmap_frozen(dst)) { error_setg(errp, "Bitmap '%s' is frozen and cannot be modified", - dst_name); + target); return; } else if (bdrv_dirty_bitmap_readonly(dst)) { error_setg(errp, "Bitmap '%s' is readonly and cannot be modified", - dst_name); + target); return; } =20 - src =3D bdrv_find_dirty_bitmap(bs, src_name); - if (!src) { - error_setg(errp, "Dirty bitmap '%s' not found", src_name); + anon =3D bdrv_create_dirty_bitmap(bs, bdrv_dirty_bitmap_granularity(ds= t), + NULL, errp); + if (!anon) { return; } =20 - bdrv_merge_dirty_bitmap(dst, src, errp); + /* Aggregate bitmaps to anonymous temp bitmap */ + for (lst =3D bitmaps; lst; lst =3D lst->next) { + src =3D bdrv_find_dirty_bitmap(bs, lst->value); + if (!src) { + error_setg(errp, "Dirty bitmap '%s' not found", lst->value); + goto out; + } + bdrv_merge_dirty_bitmap(anon, src, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto out; + } + } + + /* Merge into dst; dst is unchanged on failure */ + bdrv_merge_dirty_bitmap(dst, anon, errp); + +out: + bdrv_release_dirty_bitmap(bs, anon); } =20 BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *= node, diff --git a/qapi/block-core.json b/qapi/block-core.json index fff23fc82b..83402da7e7 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1749,14 +1749,14 @@ # # @node: name of device/node which the bitmap is tracking # -# @dst_name: name of the destination dirty bitmap +# @target: name of the destination dirty bitmap # -# @src_name: name of the source dirty bitmap +# @bitmaps: name(s) of the source dirty bitmap(s) # # Since: 3.0 ## { 'struct': 'BlockDirtyBitmapMerge', - 'data': { 'node': 'str', 'dst_name': 'str', 'src_name': 'str' } } + 'data': { 'node': 'str', 'target': 'str', 'bitmaps': ['str'] } } =20 ## # @block-dirty-bitmap-add: @@ -1884,8 +1884,8 @@ # Example: # # -> { "execute": "x-block-dirty-bitmap-merge", -# "arguments": { "node": "drive0", "dst_name": "bitmap0", -# "src_name": "bitmap1" } } +# "arguments": { "node": "drive0", "target": "bitmap0", +# "bitmaps": ["bitmap1"] } } # <- { "return": {} } # ## --=20 2.14.3