From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW6D8-00017i-OC for qemu-devel@nongnu.org; Thu, 12 Mar 2015 12:43:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YW6D5-0001K6-G6 for qemu-devel@nongnu.org; Thu, 12 Mar 2015 12:43:50 -0400 Received: from cantor2.suse.de ([195.135.220.15]:47918 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW6D5-0001Jw-9n for qemu-devel@nongnu.org; Thu, 12 Mar 2015 12:43:47 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Thu, 12 Mar 2015 17:43:38 +0100 Message-Id: <1426178624-32638-4-git-send-email-afaerber@suse.de> In-Reply-To: <1426178624-32638-1-git-send-email-afaerber@suse.de> References: <1426178624-32638-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [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: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Luiz Capitulino Re-implemented based on qmp_qom_set() to facilitate argument parsing. Warn about ambiguous path arguments. Signed-off-by: Andreas F=C3=A4rber --- hmp-commands.hx | 13 +++++++++++++ hmp.c | 21 +++++++++++++++++++++ hmp.h | 1 + 3 files changed, 35 insertions(+) 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{pa= th} ETEXI =20 { + .name =3D "qom-set", + .args_type =3D "path:s,property:s,value:s", + .params =3D "path property value", + .help =3D "set QOM property", + .mhandler.cmd =3D 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 valu= e @var{value} +ETEXI + + { .name =3D "info", .args_type =3D "item:s?", .params =3D "[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 =3D qdict_get_str(qdict, "path"); + const char *property =3D qdict_get_str(qdict, "property"); + const char *value =3D qdict_get_str(qdict, "value"); + Error *err =3D NULL; + bool ambiguous =3D false; + Object *obj; + + obj =3D object_resolve_path(path, &ambiguous); + if (obj =3D=3D NULL) { + error_set(&err, QERR_DEVICE_NOT_FOUND, path); + } else { + if (ambiguous) { + monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", pat= h); + } + 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 *s= tr); void object_del_completion(ReadLineState *rs, int nb_args, const char *s= tr); void device_add_completion(ReadLineState *rs, int nb_args, const char *s= tr); --=20 2.1.4