From patchwork Tue Jan 26 10:38:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 8120051 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 2223EBEEE5 for ; Tue, 26 Jan 2016 10:41:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7285820256 for ; Tue, 26 Jan 2016 10:41:48 +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 A8F8A20166 for ; Tue, 26 Jan 2016 10:41:47 +0000 (UTC) Received: from localhost ([::1]:42926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO14F-0001X7-4I for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jan 2016 05:41:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO12a-0006fq-Bp for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:40:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO12Z-0007U6-4U for qemu-devel@nongnu.org; Tue, 26 Jan 2016 05:40:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60550) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO12U-0007TD-HM; Tue, 26 Jan 2016 05:39:58 -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 289FD8F2F2; Tue, 26 Jan 2016 10:39:58 +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 u0QAcRTK016464; Tue, 26 Jan 2016 05:39:50 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 26 Jan 2016 18:38:18 +0800 Message-Id: <1453804705-7205-10-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 09/16] qmp: Add block-dirty-bitmap-set-persistent 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 Signed-off-by: Fam Zheng --- blockdev.c | 20 ++++++++++++++++++++ qapi/block-core.json | 22 ++++++++++++++++++++++ qmp-commands.hx | 31 +++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) diff --git a/blockdev.c b/blockdev.c index 08236f2..a9d6617 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2699,6 +2699,9 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name, name); goto out; } + if (bdrv_dirty_bitmap_set_persistent(bs, bitmap, false, false, errp)) { + goto out; + } bdrv_dirty_bitmap_make_anon(bitmap); bdrv_release_dirty_bitmap(bs, bitmap); @@ -2740,6 +2743,23 @@ void qmp_block_dirty_bitmap_clear(const char *node, const char *name, aio_context_release(aio_context); } +void qmp_block_dirty_bitmap_set_persistent(const char *node, const char *name, + bool persistent, Error **errp) +{ + AioContext *aio_context; + BdrvDirtyBitmap *bitmap; + BlockDriverState *bs; + + bitmap = block_dirty_bitmap_lookup(node, name, &bs, &aio_context, errp); + if (!bitmap || !bs) { + return; + } + + bdrv_dirty_bitmap_set_persistent(bs, bitmap, persistent, false, errp); + + aio_context_release(aio_context); +} + void hmp_drive_del(Monitor *mon, const QDict *qdict) { const char *id = qdict_get_str(qdict, "id"); diff --git a/qapi/block-core.json b/qapi/block-core.json index 0ac107c..52689ed 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1263,6 +1263,28 @@ '*on-target-error': 'BlockdevOnError' } } ## +# @block-dirty-bitmap-set-persistent +# +# Update a dirty bitmap's persistent state on the device +# +# @node: name of device/node which the bitmap is tracking +# +# @name: name of the dirty bitmap +# +# @persistent: #optinal whether to make the bitmap persistent, default is false +# +# Returns: nothing on success +# If @node is not a valid block device, DeviceNotFound +# If @name is not found, GenericError with an explanation +# If an error happens when setting the persistent state, GenericError +# with an explanation +# +# Since 2.6 +## +{ 'command': 'block-dirty-bitmap-set-persistent', + 'data': { 'node': 'str', 'name': 'str', 'persistent': 'bool' } } + +## # @block_set_io_throttle: # # Change I/O throttle limits for a block drive. diff --git a/qmp-commands.hx b/qmp-commands.hx index bd4428e..e37cf09 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1458,6 +1458,37 @@ Example: EQMP { + .name = "block-dirty-bitmap-set-persistent", + .args_type = "node:B,name:s,persistent:b", + .mhandler.cmd_new = qmp_marshal_block_dirty_bitmap_set_persistent, + }, + +SQMP + +block-dirty-bitmap-set-persistent +--------------------------------- +Since 2.6 + +Update the persistent state of a dirty bitmap. Format driver support is +required. + +Arguments: + +- "node": device/node on which to update the dirty bitmap (json-string) +- "name": name of the dirty bitmap to update (json-string) +- "persistent": the state to update to. (json-bool) + +Example: + +-> { "execute": "block-dirty-bitmap-set-persistent", + "arguments": { "node": "drive0", + "name": "bitmap0", + "persistent": true } } +<- { "return": {} } + +EQMP + + { .name = "blockdev-snapshot-sync", .args_type = "device:s?,node-name:s?,snapshot-file:s,snapshot-node-name:s?,format:s?,mode:s?", .mhandler.cmd_new = qmp_marshal_blockdev_snapshot_sync,