From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9W63-0001Tu-QA for qemu-devel@nongnu.org; Thu, 17 Dec 2015 05:47:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9W62-0003Vw-T9 for qemu-devel@nongnu.org; Thu, 17 Dec 2015 05:47:43 -0500 From: "Dr. David Alan Gilbert (git)" Date: Thu, 17 Dec 2015 10:47:31 +0000 Message-Id: <1450349251-10326-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH 1/1] HMP: Add equivalent to x-blockdev-change List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: wency@cn.fujitsu.com, zhang.zhanghailiang@huawei.com, qemu-devel@nongnu.org Cc: qemu-block@nongnu.org From: "Dr. David Alan Gilbert" x-blockdev-change has no HMP equivalent, so add x_block_change. Example useages are: x_block_change foo -a bah to add the node bah to the parent foo x_block_change foo -d bah to delete the node bah from the parent foo Signed-off-by: Dr. David Alan Gilbert --- hmp-commands.hx | 18 ++++++++++++++++++ hmp.c | 20 ++++++++++++++++++++ hmp.h | 1 + 3 files changed, 39 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index a381b0b..cf2459b 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -57,6 +57,24 @@ Quit the emulator. ETEXI { + .name = "x_block_change", + .args_type = "parent:B,add:-a,del:-d,child:B", + .params = "parent [-a] [-d] child", + .help = "add or remove a child from a block driver", + .mhandler.cmd = hmp_block_change, + }, + +STEXI +@item x_block_change +@findex x_block_change +Dynamically reconfigure the block driver state graph. It can be used +to add, remove, insert or replace a block driver state. Currently only +the Quorum driver implements this feature to add or remove its child. +This is useful to fix a broken quorum child. +ETEXI + + + { .name = "block_resize", .args_type = "device:B,size:o", .params = "device size", diff --git a/hmp.c b/hmp.c index dc6dc30..631dacb 100644 --- a/hmp.c +++ b/hmp.c @@ -1042,6 +1042,26 @@ void hmp_balloon(Monitor *mon, const QDict *qdict) } } +void hmp_block_change(Monitor *mon, const QDict *qdict) +{ + const char *parent = qdict_get_str(qdict, "parent"); + const char *child = qdict_get_str(qdict, "child"); + bool add = qdict_get_try_bool(qdict, "add", false); + bool del = qdict_get_try_bool(qdict, "del", false); + Error *err = NULL; + + if (add == del) { + error_setg(&err, "One of -a or -d must be set"); + hmp_handle_error(mon, &err); + return; + } + + qmp_x_blockdev_change(parent, + del, child, + add, child, &err); + hmp_handle_error(mon, &err); +} + void hmp_block_resize(Monitor *mon, const QDict *qdict) { const char *device = qdict_get_str(qdict, "device"); diff --git a/hmp.h b/hmp.h index 864a300..1588850 100644 --- a/hmp.h +++ b/hmp.h @@ -53,6 +53,7 @@ void hmp_cont(Monitor *mon, const QDict *qdict); void hmp_system_wakeup(Monitor *mon, const QDict *qdict); void hmp_nmi(Monitor *mon, const QDict *qdict); void hmp_set_link(Monitor *mon, const QDict *qdict); +void hmp_block_change(Monitor *mon, const QDict *qdict); void hmp_block_passwd(Monitor *mon, const QDict *qdict); void hmp_balloon(Monitor *mon, const QDict *qdict); void hmp_block_resize(Monitor *mon, const QDict *qdict); -- 2.5.0