From patchwork Sat Jan 30 10:56:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 8170661 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 EF0C5BEEE5 for ; Sat, 30 Jan 2016 10:58:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3487F20398 for ; Sat, 30 Jan 2016 10:58:59 +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 43D7420395 for ; Sat, 30 Jan 2016 10:58:58 +0000 (UTC) Received: from localhost ([::1]:38258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPTF3-0005Nj-Ol for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Jan 2016 05:58:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPTDC-00020Z-NY for qemu-devel@nongnu.org; Sat, 30 Jan 2016 05:57:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPTDA-0002Wk-Ak for qemu-devel@nongnu.org; Sat, 30 Jan 2016 05:57:02 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:10516 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPTD9-0002WX-TP for qemu-devel@nongnu.org; Sat, 30 Jan 2016 05:57:00 -0500 Received: from kvm.sw.ru. ([10.28.8.145]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id u0TKtNf0009503; Fri, 29 Jan 2016 23:55:34 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Date: Sat, 30 Jan 2016 13:56:32 +0300 Message-Id: <1454151394-52320-5-git-send-email-vsementsov@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1454151394-52320-1-git-send-email-vsementsov@virtuozzo.com> References: <1454151394-52320-1-git-send-email-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Cc: kwolf@redhat.com, Vladimir Sementsov-Ogievskiy , famz@redhat.com, den@virtuozzo.com, armbru@redhat.com, jsnow@redhat.com Subject: [Qemu-devel] [PATCH 4/6] qapi: add qmp commands for some dirty bitmap functions 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 Add access to bdrv_dirty_bitmap_create_successor, bdrv_dirty_bitmap_abdicate, bdrv_reclaim_dirty_bitmap. Signed-off-by: Vladimir Sementsov-Ogievskiy --- blockdev.c | 51 +++++++++++++++++++++++++++++++ qapi/block-core.json | 36 ++++++++++++++++++++++ qmp-commands.hx | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+) diff --git a/blockdev.c b/blockdev.c index fa34cf6..f03a415 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2733,6 +2733,57 @@ void qmp_block_dirty_bitmap_clear(const char *node, const char *name, aio_context_release(aio_context); } +void qmp_block_dirty_bitmap_create_successor(const char *node, + const char *name, 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_create_successor(bs, bitmap, errp); + + aio_context_release(aio_context); +} + +void qmp_block_dirty_bitmap_abdicate(const char *node, const char *name, + 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_abdicate(bs, bitmap, errp); + + aio_context_release(aio_context); +} + +void qmp_block_dirty_bitmap_reclaim(const char *node, const char *name, + 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_reclaim_dirty_bitmap(bs, bitmap, errp); + + aio_context_release(aio_context); +} + BlockDirtyRangeList *qmp_query_block_dirty_bitmap_ranges(const char *node, const char *name, bool has_start, uint64_t start, bool has_count, uint64_t count, uint32_t max_ranges, bool has_block_io, bool block_io, diff --git a/qapi/block-core.json b/qapi/block-core.json index 89bdeaf..a83c286 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1238,6 +1238,42 @@ 'data': 'BlockDirtyBitmap' } ## +# @block-dirty-bitmap-create-successor +# +# Interface to bdrv_dirty_bitmap_create_successor +# +# Returns: nothing on success +# +# Since 2.6 +## +{ 'command': 'block-dirty-bitmap-create-successor', + 'data': 'BlockDirtyBitmap' } + +## +# @block-dirty-bitmap-abdicate +# +# Interface to bdrv_dirty_bitmap_abdicate +# +# Returns: nothing on success +# +# Since 2.6 +## +{ 'command': 'block-dirty-bitmap-abdicate', + 'data': 'BlockDirtyBitmap' } + +## +# @block-dirty-bitmap-reclaim +# +# Interface to bdrv_reclaim_dirty_bitmap +# +# Returns: nothing on success +# +# Since 2.6 +## +{ 'command': 'block-dirty-bitmap-reclaim', + 'data': 'BlockDirtyBitmap' } + +## # @blockdev-mirror # # Start mirroring a block device's writes to a new destination. diff --git a/qmp-commands.hx b/qmp-commands.hx index 02de44c..6098371 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1457,6 +1457,91 @@ Example: EQMP { + .name = "block-dirty-bitmap-create-successor", + .args_type = "node:B,name:s", + .mhandler.cmd_new = qmp_marshal_block_dirty_bitmap_create_successor, + }, + +SQMP + +block-dirty-bitmap-create-successor +------------------------ +Since 2.6 + +Create a successor bitmap destined to replace this bitmap after an operation. +Requires that the bitmap is not frozen and has no successor. + +Arguments: + +- "node": device/node on which to remove dirty bitmap (json-string) +- "name": name of the dirty bitmap to remove (json-string) + +Example: + +-> { "execute": "block-dirty-bitmap-create-successor", + "arguments": { "node": "drive0", "name": "bitmap0" } } +<- { "return": {} } + +EQMP + + { + .name = "block-dirty-bitmap-abdicate", + .args_type = "node:B,name:s", + .mhandler.cmd_new = qmp_marshal_block_dirty_bitmap_abdicate, + }, + +SQMP + +block-dirty-bitmap-abdicate +------------------------ +Since 2.6 + +For a bitmap with a successor, yield our name to the successor, delete the old +bitmap, and return a handle to the new bitmap. + +Arguments: + +- "node": device/node on which to remove dirty bitmap (json-string) +- "name": name of the dirty bitmap to remove (json-string) + +Example: + +-> { "execute": "block-dirty-bitmap-abdicate", + "arguments": { "node": "drive0", "name": "bitmap0" } } +<- { "return": {} } + +EQMP + + { + .name = "block-dirty-bitmap-reclaim", + .args_type = "node:B,name:s", + .mhandler.cmd_new = qmp_marshal_block_dirty_bitmap_reclaim, + }, + +SQMP + +block-dirty-bitmap-reclaim +------------------------ +Since 2.6 + +In cases of failure where we can no longer safely delete the parent, we may +wish to re-join the parent and child/successor. The merged parent will be +un-frozen, but not explicitly re-enabled. + +Arguments: + +- "node": device/node on which to remove dirty bitmap (json-string) +- "name": name of the dirty bitmap to remove (json-string) + +Example: + +-> { "execute": "block-dirty-bitmap-reclaim", + "arguments": { "node": "drive0", "name": "bitmap0" } } +<- { "return": {} } + +EQMP + + { .name = "query-block-dirty-bitmap-ranges", .args_type = "node:B,name:s,start:i?,count:i?,max-ranges:i," "block-io:b?",