From patchwork Wed Apr 24 20:36:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 239313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 066182C0104 for ; Thu, 25 Apr 2013 06:37:19 +1000 (EST) Received: from localhost ([::1]:57183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV6RJ-0006Ry-1k for incoming@patchwork.ozlabs.org; Wed, 24 Apr 2013 16:37:17 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV6Qt-0006Ja-5N for qemu-devel@nongnu.org; Wed, 24 Apr 2013 16:36:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UV6Qo-0000z5-Bf for qemu-devel@nongnu.org; Wed, 24 Apr 2013 16:36:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23535) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV6Qo-0000z0-3j for qemu-devel@nongnu.org; Wed, 24 Apr 2013 16:36:46 -0400 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 (8.14.4/8.14.4) with ESMTP id r3OKajWW014966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 24 Apr 2013 16:36:45 -0400 Received: from localhost (ovpn-113-28.phx2.redhat.com [10.3.113.28]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3OKahDT009361; Wed, 24 Apr 2013 16:36:44 -0400 Date: Wed, 24 Apr 2013 16:36:41 -0400 From: Luiz Capitulino To: qemu-devel Message-ID: <20130424163641.3e15bd43@redhat.com> Organization: Red Hat Mime-Version: 1.0 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 , Paolo Bonzini Subject: [Qemu-devel] [PATCH for-1.5] qmp: add query-drive-mirror-capabilities 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The drive-mirror command was extended in QEMU v1.3.0 with two new optional arguments 'granularity' and 'buf-size'. However, there's no way for libvirt to query for the existence of the new arguments. This commit solves this problem by adding the query-drive-mirror-capabilities command, which reports the existence of both arguments. Signed-off-by: Luiz Capitulino --- I'm just mimicking query-migrate-capabilities. I don't know if this is the best way of doing this because we don't allow drive-mirror capabilities to be set and they're always on. On the other hand, if we take a simpler approach like returning a single string of supported new arguments, we may regret it later if we end up having to support capabilities negotiation. Having said that, I don't mind doing this one way or the other and slightly prefer the simpler approach. blockdev.c | 21 +++++++++++++++++++++ qapi-schema.json | 40 ++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 7 +++++++ 3 files changed, 68 insertions(+) diff --git a/blockdev.c b/blockdev.c index 8a1652b..3fa5ade 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1279,6 +1279,27 @@ void qmp_block_commit(const char *device, drive_get_ref(drive_get_by_blockdev(bs)); } +DriveMirrorCapabilityStatusList *qmp_query_drive_mirror_capabilities(Error **errp) +{ + DriveMirrorCapabilityStatusList *caps, *head = NULL; + int i; + + for (i = 0; i < DRIVE_MIRROR_CAPABILITY_MAX; i++) { + if (head == NULL) { + head = g_malloc0(sizeof(*caps)); + caps = head; + } else { + caps->next = g_malloc0(sizeof(*caps)); + caps = caps->next; + } + caps->value = g_malloc(sizeof(*caps->value)); + caps->value->capability = i; + caps->value->state = true; + } + + return head; +} + #define DEFAULT_MIRROR_BUF_SIZE (10 << 20) void qmp_drive_mirror(const char *device, const char *target, diff --git a/qapi-schema.json b/qapi-schema.json index 751d3c2..311882d 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1715,6 +1715,46 @@ '*speed': 'int' } } ## +# @DriveMirrorCapability +# +# Capabilities supported by the driver-mirror command +# +# @granularity: supports setting the dirty bitmap's granularity through the +# 'granularity' argument +# +# @buf-size: supports setting the amount of data to be sent from source +# to target through the 'buf-size' argument +# +# Since: 1.5.0 +## +{ 'enum': 'DriveMirrorCapability', 'data': [ 'granularity', 'buf-size' ] } + +## +# @DriveMirrorCapabilityStatus +# +# Status of drive-mirror capabilities +# +# @capability: capability enumeration +# +# @state: True if supported False otherwise +# +# Since: 1.5.0 +## +{ 'type': 'DriveMirrorCapabilityStatus', + 'data': { 'capability': 'DriveMirrorCapability', 'state': 'bool' } } + +## +# @query-drive-mirror-capabilities +# +# Returns information about current drive-mirror's capabilities status +# +# Returns: @DriveMirrorCapabilityStatus list +# +# Since: 1.5.0 +## +{ 'command': 'query-drive-mirror-capabilities', 'returns': [ 'DriveMirrorCapabilityStatus' ] } + +## # @drive-mirror # # Start mirroring a block device's writes to a new destination. diff --git a/qmp-commands.hx b/qmp-commands.hx index 4d65422..5b4e559 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2715,6 +2715,13 @@ EQMP }, { + .name = "query-drive-mirror-capabilities", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_drive_mirror_capabilities, + }, + + + { .name = "query-cpu-definitions", .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_cpu_definitions,