From patchwork Tue Jan 26 10:38:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 8120081 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 76508BEEED for ; Tue, 26 Jan 2016 10:42:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D03DA20265 for ; Tue, 26 Jan 2016 10:42:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 129E62025B for ; Tue, 26 Jan 2016 10:42:38 +0000 (UTC) Received: from localhost ([::1]:42939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO153-0003Ly-E8 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jan 2016 05:42:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO12R-0006ML-Ck for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:39:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO12Q-0007Sg-8S for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:39:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO12L-0007SF-Pk; Tue, 26 Jan 2016 05:39:49 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6A99A3E5B0; Tue, 26 Jan 2016 10:39:49 +0000 (UTC) Received: from fam-t430.redhat.com (vpn1-5-65.pek2.redhat.com [10.72.5.65]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0QAcRTJ016464; Tue, 26 Jan 2016 05:39:41 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 26 Jan 2016 18:38:17 +0800 Message-Id: <1453804705-7205-9-git-send-email-famz@redhat.com> In-Reply-To: <1453804705-7205-1-git-send-email-famz@redhat.com> References: <1453804705-7205-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, jsnow@redhat.com, Markus Armbruster , mreitz@redhat.com, vsementsov@parallels.com, Stefan Hajnoczi Subject: [Qemu-devel] [RFC PATCH 08/16] qmp: Add optional parameter "persistent" in block-dirty-bitmap-add X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When omitted it defaults to false with unchanged behavior. When set to true, the created dirty bitmap is made persistent if supported, it requires support from the active image format. Otherwise an error is returned. Signed-off-by: Fam Zheng Reviewed-by: John Snow --- blockdev.c | 8 +++++++- qapi/block-core.json | 6 +++++- qmp-commands.hx | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 07cfe25..08236f2 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1997,6 +1997,7 @@ static void block_dirty_bitmap_add_prepare(BlkActionState *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->granularity, + action->has_persistent, action->persistent, &local_err); if (!local_err) { @@ -2640,10 +2641,12 @@ out: 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; if (!name || name[0] == '\0') { error_setg(errp, "Bitmap name cannot be empty"); @@ -2669,7 +2672,10 @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name, granularity = bdrv_get_default_bitmap_granularity(bs); } - bdrv_create_dirty_bitmap(bs, granularity, name, errp); + bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp); + if (bitmap && has_persistent && persistent) { + bdrv_dirty_bitmap_set_persistent(bs, bitmap, true, false, errp); + } out: aio_context_release(aio_context); diff --git a/qapi/block-core.json b/qapi/block-core.json index 30c2e5f..0ac107c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1162,10 +1162,14 @@ # @granularity: #optional the bitmap granularity, default is 64k for # block-dirty-bitmap-add # +# @persistent: #optinal whether to make the bitmap persistent, default is false. +# (Since 2.6) +# # Since 2.4 ## { 'struct': 'BlockDirtyBitmapAdd', - 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32' } } + 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32', + '*persistent': 'bool' } } ## # @block-dirty-bitmap-add diff --git a/qmp-commands.hx b/qmp-commands.hx index db072a6..bd4428e 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1373,7 +1373,7 @@ EQMP { .name = "block-dirty-bitmap-add", - .args_type = "node:B,name:s,granularity:i?", + .args_type = "node:B,name:s,granularity:i?,persistent:b?", .mhandler.cmd_new = qmp_marshal_block_dirty_bitmap_add, }, @@ -1390,6 +1390,7 @@ Arguments: - "node": device/node on which to create dirty bitmap (json-string) - "name": name of the new dirty bitmap (json-string) - "granularity": granularity to track writes with (int, optional) +- "persistent": whether the bitmap is persistent (bool, optional, default to no) Example: