From patchwork Fri Oct 16 08:57:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 531162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 86FEC14016A for ; Fri, 16 Oct 2015 20:24:23 +1100 (AEDT) Received: from localhost ([::1]:52074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn1FN-000342-1M for incoming@patchwork.ozlabs.org; Fri, 16 Oct 2015 05:24:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn0qA-0008BU-Nk for qemu-devel@nongnu.org; Fri, 16 Oct 2015 04:58:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zn0q7-0002vA-Ja for qemu-devel@nongnu.org; Fri, 16 Oct 2015 04:58:18 -0400 Received: from [59.151.112.132] (port=29450 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn0q6-0002n4-Uy; Fri, 16 Oct 2015 04:58:15 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101913655" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Oct 2015 17:00:23 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t9G8vTDW018532; Fri, 16 Oct 2015 16:57:29 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 16 Oct 2015 16:57:57 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Kevin Wolf , Stefan Hajnoczi Date: Fri, 16 Oct 2015 16:57:46 +0800 Message-ID: <1444985866-12969-5-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1444985866-12969-1-git-send-email-wency@cn.fujitsu.com> References: <1444985866-12969-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Luiz Capitulino , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-devel] [PATCH v6 4/4] hmp: add monitor command to add/remove a child 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 new command is blockdev_change. It does the same thing as the QMP command x-blockdev-change. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Cc: Luiz Capitulino --- hmp-commands.hx | 17 +++++++++++++++++ hmp.c | 38 ++++++++++++++++++++++++++++++++++++++ hmp.h | 1 + 3 files changed, 56 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 3a4ae39..57475cc 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -193,6 +193,23 @@ actions (drive options rerror, werror). ETEXI { + .name = "blockdev_change", + .args_type = "op:s,parent:B,child:B?,node:?", + .params = "operation parent [child] [node]", + .help = "Dynamic reconfigure the block driver state graph", + .mhandler.cmd = hmp_blockdev_change, + }, + +STEXI +@item blockdev_change @var{operation} @var{parent} [@var{child}] [@var{node}] +@findex blockdev_change +Dynamic reconfigure the block driver state graph. It can be used to +add, remove, insert, replace a block driver state. Currently only +the Quorum driver implements this feature to add and remove its child. +This is useful to fix a broken quorum child. +ETEXI + + { .name = "change", .args_type = "device:B,target:F,arg:s?", .params = "device filename [format]", diff --git a/hmp.c b/hmp.c index 5048eee..fc58ae2 100644 --- a/hmp.c +++ b/hmp.c @@ -2346,3 +2346,41 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict) qapi_free_RockerOfDpaGroupList(list); } + +void hmp_blockdev_change(Monitor *mon, const QDict *qdict) +{ + const char *operation = qdict_get_str(qdict, "op"); + const char *parent = qdict_get_str(qdict, "parent"); + const char *child = qdict_get_try_str(qdict, "child"); + const char *node = qdict_get_try_str(qdict, "node"); + ChangeOperation op = CHANGE_OPERATION_ADD; + Error *local_err = NULL; + bool has_child = !!child; + bool has_node = !!node; + + while (ChangeOperation_lookup[op] != NULL) { + if (strcmp(ChangeOperation_lookup[op], operation) == 0) { + break; + } + op++; + } + + if (ChangeOperation_lookup[op] == NULL) { + error_setg(&local_err, "Invalid parameter '%s'", "operation"); + goto out; + } + + /* + * FIXME: we must specify the parameter child, otherwise, + * we can't specify the parameter node. + */ + if (op == CHANGE_OPERATION_ADD) { + has_child = false; + } + + qmp_x_blockdev_change(op, parent, has_child, child, + has_node, node, &local_err); + +out: + hmp_handle_error(mon, &local_err); +} diff --git a/hmp.h b/hmp.h index 81656c3..80a1faf 100644 --- a/hmp.h +++ b/hmp.h @@ -130,5 +130,6 @@ void hmp_rocker(Monitor *mon, const QDict *qdict); void hmp_rocker_ports(Monitor *mon, const QDict *qdict); void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict); void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict); +void hmp_blockdev_change(Monitor *mon, const QDict *qdict); #endif