From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWEUa-0007ki-Ok for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:34:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWEUW-0002e5-7v for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:34:24 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:38029) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWEUV-0002cI-Ik for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:34:20 -0400 Message-ID: <55023E92.4060906@huawei.com> Date: Fri, 13 Mar 2015 09:34:10 +0800 From: Gonglei MIME-Version: 1.0 References: <1426178624-32638-1-git-send-email-afaerber@suse.de> <1426178624-32638-4-git-send-email-afaerber@suse.de> In-Reply-To: <1426178624-32638-4-git-send-email-afaerber@suse.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2 3/9] qom: Implement qom-set HMP command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , qemu-devel@nongnu.org Cc: Luiz Capitulino On 2015/3/13 0:43, Andreas Färber wrote: > Re-implemented based on qmp_qom_set() to facilitate argument parsing. > > Warn about ambiguous path arguments. > > Signed-off-by: Andreas Färber > --- > hmp-commands.hx | 13 +++++++++++++ > hmp.c | 21 +++++++++++++++++++++ > hmp.h | 1 + > 3 files changed, 35 insertions(+) > > Reviewed-by: Gonglei > diff --git a/hmp-commands.hx b/hmp-commands.hx > index c3b93d6..1a6cd3e 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -1671,6 +1671,19 @@ Print QOM properties of object at location @var{path} > ETEXI > > { > + .name = "qom-set", > + .args_type = "path:s,property:s,value:s", > + .params = "path property value", > + .help = "set QOM property", > + .mhandler.cmd = hmp_qom_set, > + }, > + > +STEXI > +@item qom-set @var{path} @var{property} @var{value} > +Set QOM property @var{property} of object at location @var{path} to value @var{value} > +ETEXI > + > + { > .name = "info", > .args_type = "item:s?", > .params = "[subcommand]", > diff --git a/hmp.c b/hmp.c > index f6df075..811f9a3 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -1878,3 +1878,24 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict) > } > hmp_handle_error(mon, &err); > } > + > +void hmp_qom_set(Monitor *mon, const QDict *qdict) > +{ > + const char *path = qdict_get_str(qdict, "path"); > + const char *property = qdict_get_str(qdict, "property"); > + const char *value = qdict_get_str(qdict, "value"); > + Error *err = NULL; > + bool ambiguous = false; > + Object *obj; > + > + obj = object_resolve_path(path, &ambiguous); > + if (obj == NULL) { > + error_set(&err, QERR_DEVICE_NOT_FOUND, path); > + } else { > + if (ambiguous) { > + monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", path); > + } > + object_property_parse(obj, value, property, &err); > + } > + hmp_handle_error(mon, &err); > +} > diff --git a/hmp.h b/hmp.h > index 18c0f52..44049e8 100644 > --- a/hmp.h > +++ b/hmp.h > @@ -96,6 +96,7 @@ void hmp_object_del(Monitor *mon, const QDict *qdict); > void hmp_info_memdev(Monitor *mon, const QDict *qdict); > void hmp_info_memory_devices(Monitor *mon, const QDict *qdict); > void hmp_qom_list(Monitor *mon, const QDict *qdict); > +void hmp_qom_set(Monitor *mon, const QDict *qdict); > void object_add_completion(ReadLineState *rs, int nb_args, const char *str); > void object_del_completion(ReadLineState *rs, int nb_args, const char *str); > void device_add_completion(ReadLineState *rs, int nb_args, const char *str); >