* [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree
@ 2015-03-12 16:43 Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 1/9] scripts: Add qom-tree script Andreas Färber
` (11 more replies)
0 siblings, 12 replies; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 16:43 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Crosthwaite, Markus Armbruster, Luiz Capitulino,
Hani Benhabiles, Paolo Bonzini, Andreas Färber
Hello,
The main patch of this series is an HMP command "info qom-tree",
which displays the machine composition tree. This names all objects,
including those missing in "info qtree" for lack of bus or for not being a device.
Properties can be listed with "qom-list" and set with "qom-set", like in QMP.
"qom-get" and displaying properties as part of "info qom-tree" ran into
StringOutputVisitor limitations - this v2 therefore stubs that support out
so that we don't crash.
This series has been around for a year now; I hope to get at least qom-list and
the basic info qom-tree into v2.3, as visualization of my upcoming CPU changes.
Also included are two proposed cleanups of nodes in /machine namespace.
By making it easier to inspect the tree, I hope we'll detect this earlier.
Regards,
Andreas
v1 -> v2:
* Included qom-tree script in series, updating Anthony's email address (Eric)
and dropping reference to "info qtree" from subject (Paolo);
script did otherwise not change, so leaving 2013 copyright
* Renamed from "info qom-composition" to "info qom-tree" (Hani/Paolo)
* Renamed functions from do_* to hmp_* according to changed surrounding code
* Simplified qom-list according to Hani's suggestion
* Added warning for ambiguous paths to qom-set (Hani)
* Added patch stubbing out StringOutputVisitor struct support for qom-get (Hani)
* Added documentation for info qom-tree
* Implemented "info qom-tree /foo" and "info qom-tree -v" options
* Added patch cleaning up MemoryRegion nodes from /machine
* Added patch cleaning up IRQ nodes from /machine
$ ./x86_64-softmmu/qemu-system-x86_64 -S -display none -monitor stdio
QEMU 2.0.50 monitor - type 'help' for more information
(qemu) info qom-tree
/machine (pc-i440fx-2.1-machine)
/peripheral-anon (container)
/peripheral (container)
/unattached (container)
/sysbus (System)
/device[0] (qemu64-x86_64-cpu)
/apic (apic)
/device[1] (kvmvapic)
/device[2] (i440FX)
/device[3] (PIIX3)
/isa.0 (ISA)
/device[4] (isa-i8259)
/device[5] (isa-i8259)
/device[6] (cirrus-vga)
/device[7] (hpet)
/device[8] (mc146818rtc)
/device[9] (isa-pit)
/device[10] (isa-pcspk)
/device[11] (isa-serial)
/device[12] (isa-parallel)
/device[13] (i8042)
/device[14] (vmport)
/device[15] (vmmouse)
/device[16] (port92)
/device[17] (isa-fdc)
/device[18] (e1000)
/device[19] (piix3-ide)
/ide.0 (IDE)
/ide.1 (IDE)
/device[20] (ide-cd)
/device[21] (PIIX4_PM)
/i2c (i2c-bus)
/device[22] (smbus-eeprom)
/device[23] (smbus-eeprom)
/device[24] (smbus-eeprom)
/device[25] (smbus-eeprom)
/device[26] (smbus-eeprom)
/device[27] (smbus-eeprom)
/device[28] (smbus-eeprom)
/device[29] (smbus-eeprom)
/icc-bridge (icc-bridge)
/icc (icc-bus)
/fw_cfg (fw_cfg)
/i440fx (i440FX-pcihost)
/pci.0 (PCI)
/ioapic (ioapic)
(qemu) qom-list
/
(qemu) qom-list /
backend (child<container>)
machine (child<pc-i440fx-2.1-machine>)
type (string)
(qemu) qom-list /machine
i440fx (child<i440FX-pcihost>)
fw_cfg (child<fw_cfg>)
icc-bridge (child<icc-bridge>)
unattached (child<container>)
peripheral (child<container>)
peripheral-anon (child<container>)
type (string)
(qemu) qom-get /machine type
"pc-i440fx-2.1-machine"
(qemu) qom-get /machine/unassigned/device[0] realized
Device '/machine/unassigned/device[0]' not found
(qemu) qom-get /machine/unattached/device[0] realized
true
(qemu) qom-set /machine/unattached/device[0] realized true
(qemu) qom-set /machine/unattached/device[0] realized false
(qemu)
Cc: Hani Benhabiles <hani@linux.com>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Andreas Färber (9):
scripts: Add qom-tree script
qom: Implement qom-list HMP command
qom: Implement qom-set HMP command
qom: Implement info qom-tree HMP command
qapi: Stub out StringOutputVisitor struct support
qom: Implement qom-get HMP command
qom: Add verbose option to info qom-tree HMP command
memory: Move owner-less MemoryRegions to /machine/unattached
qdev: Move owner-less IRQs to /machine/unattached
hmp-commands.hx | 41 ++++++++++++++++++++
hmp.c | 69 +++++++++++++++++++++++++++++++++
hmp.h | 3 ++
hw/core/qdev.c | 5 ++-
include/monitor/qdev.h | 1 +
memory.c | 2 +-
monitor.c | 7 ++++
qapi/string-output-visitor.c | 14 +++++++
qdev-monitor.c | 92 ++++++++++++++++++++++++++++++++++++++++++++
scripts/qmp/qom-tree | 70 +++++++++++++++++++++++++++++++++
10 files changed, 301 insertions(+), 3 deletions(-)
create mode 100755 scripts/qmp/qom-tree
--
2.1.4
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2 1/9] scripts: Add qom-tree script
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
@ 2015-03-12 16:43 ` Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 2/9] qom: Implement qom-list HMP command Andreas Färber
` (10 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 16:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber
Functionally it is a recursive qom-list with qom-get per non-child<>
property. Some failures needed to be handled, such as trying to read a
pointer property, which is not representable in QMP. Those print a
literal "<EXCEPTION>".
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
scripts/qmp/qom-tree | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
create mode 100755 scripts/qmp/qom-tree
diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree
new file mode 100755
index 0000000..aea11d4
--- /dev/null
+++ b/scripts/qmp/qom-tree
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+##
+# QEMU Object Model test tools
+#
+# Copyright IBM, Corp. 2011
+# Copyright (c) 2013 SUSE LINUX Products GmbH
+#
+# Authors:
+# Anthony Liguori <aliguori@amazon.com>
+# Andreas Faerber <afaerber@suse.de>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or later. See
+# the COPYING file in the top-level directory.
+##
+
+import sys
+import os
+from qmp import QEMUMonitorProtocol
+
+cmd, args = sys.argv[0], sys.argv[1:]
+socket_path = None
+path = None
+prop = None
+
+def usage():
+ return '''environment variables:
+ QMP_SOCKET=<path | addr:port>
+usage:
+ %s [-h] [-s <QMP socket path | addr:port>] [<path>]
+''' % cmd
+
+def usage_error(error_msg = "unspecified error"):
+ sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg))
+ exit(1)
+
+if len(args) > 0:
+ if args[0] == "-h":
+ print usage()
+ exit(0);
+ elif args[0] == "-s":
+ try:
+ socket_path = args[1]
+ except:
+ usage_error("missing argument: QMP socket path or address");
+ args = args[2:]
+
+if not socket_path:
+ if os.environ.has_key('QMP_SOCKET'):
+ socket_path = os.environ['QMP_SOCKET']
+ else:
+ usage_error("no QMP socket path or address given");
+
+srv = QEMUMonitorProtocol(socket_path)
+srv.connect()
+
+def list_node(path):
+ print '%s' % path
+ items = srv.command('qom-list', path=path)
+ for item in items:
+ if not item['type'].startswith('child<'):
+ try:
+ print ' %s: %s (%s)' % (item['name'], srv.command('qom-get', path=path, property=item['name']), item['type'])
+ except:
+ print ' %s: <EXCEPTION> (%s)' % (item['name'], item['type'])
+ print ''
+ for item in items:
+ if item['type'].startswith('child<'):
+ list_node(path + '/' + item['name'])
+
+list_node('/machine')
--
2.1.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2 2/9] qom: Implement qom-list HMP command
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 1/9] scripts: Add qom-tree script Andreas Färber
@ 2015-03-12 16:43 ` Andreas Färber
2015-03-13 1:32 ` Gonglei
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 3/9] qom: Implement qom-set " Andreas Färber
` (9 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 16:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber, Luiz Capitulino
Implement it as a wrapper for QMP qom-list, but mimic the behavior of
scripts/qmp/qom-list in making the path argument optional and listing
the root if absent, to hint users what kind of path to pass.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hmp-commands.hx | 13 +++++++++++++
hmp.c | 26 ++++++++++++++++++++++++++
hmp.h | 1 +
3 files changed, 40 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index d5022d8..c3b93d6 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1658,6 +1658,19 @@ Add CPU with id @var{id}
ETEXI
{
+ .name = "qom-list",
+ .args_type = "path:s?",
+ .params = "path",
+ .help = "list QOM properties",
+ .mhandler.cmd = hmp_qom_list,
+ },
+
+STEXI
+@item qom-list [@var{path}]
+Print QOM properties of object at location @var{path}
+ETEXI
+
+ {
.name = "info",
.args_type = "item:s?",
.params = "[subcommand]",
diff --git a/hmp.c b/hmp.c
index 71c28bc..f6df075 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1852,3 +1852,29 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
qapi_free_MemoryDeviceInfoList(info_list);
}
+
+void hmp_qom_list(Monitor *mon, const QDict *qdict)
+{
+ const char *path = qdict_get_try_str(qdict, "path");
+ ObjectPropertyInfoList *list;
+ Error *err = NULL;
+
+ if (path == NULL) {
+ monitor_printf(mon, "/\n");
+ return;
+ }
+
+ list = qmp_qom_list(path, &err);
+ if (err == NULL) {
+ ObjectPropertyInfoList *start = list;
+ while (list != NULL) {
+ ObjectPropertyInfo *value = list->value;
+
+ monitor_printf(mon, "%s (%s)\n",
+ value->name, value->type);
+ list = list->next;
+ }
+ qapi_free_ObjectPropertyInfoList(start);
+ }
+ hmp_handle_error(mon, &err);
+}
diff --git a/hmp.h b/hmp.h
index 81177b2..18c0f52 100644
--- a/hmp.h
+++ b/hmp.h
@@ -95,6 +95,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict);
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 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);
--
2.1.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2 3/9] qom: Implement qom-set HMP command
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 1/9] scripts: Add qom-tree script Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 2/9] qom: Implement qom-list HMP command Andreas Färber
@ 2015-03-12 16:43 ` Andreas Färber
2015-03-13 1:34 ` Gonglei
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 4/9] qom: Implement info qom-tree " Andreas Färber
` (8 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 16:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber, Luiz Capitulino
Re-implemented based on qmp_qom_set() to facilitate argument parsing.
Warn about ambiguous path arguments.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
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{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);
--
2.1.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2 4/9] qom: Implement info qom-tree HMP command
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
` (2 preceding siblings ...)
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 3/9] qom: Implement qom-set " Andreas Färber
@ 2015-03-12 16:43 ` Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 5/9] qapi: Stub out StringOutputVisitor struct support Andreas Färber
` (7 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 16:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber, Luiz Capitulino
To complement qdev's bus-oriented info qtree, info qom-tree
prints a hierarchical view of the QOM composition tree.
By default, the machine composition tree is shown. This can be overriden
by supplying a path argument, such as "info qom-tree /".
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hmp-commands.hx | 2 ++
include/monitor/qdev.h | 1 +
monitor.c | 7 +++++++
qdev-monitor.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 67 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 1a6cd3e..3c1915a 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1766,6 +1766,8 @@ show balloon information
show device tree
@item info qdm
show qdev device model list
+@item info qom-tree
+show object composition tree
@item info roms
show roms
@item info tpm
diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h
index 5eb4a11..7190752 100644
--- a/include/monitor/qdev.h
+++ b/include/monitor/qdev.h
@@ -8,6 +8,7 @@
void hmp_info_qtree(Monitor *mon, const QDict *qdict);
void hmp_info_qdm(Monitor *mon, const QDict *qdict);
+void hmp_info_qom_tree(Monitor *mon, const QDict *dict);
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
int qdev_device_help(QemuOpts *opts);
DeviceState *qdev_device_add(QemuOpts *opts);
diff --git a/monitor.c b/monitor.c
index c86a89e..48f7f5a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2889,6 +2889,13 @@ static mon_cmd_t info_cmds[] = {
.mhandler.cmd = hmp_info_qdm,
},
{
+ .name = "qom-tree",
+ .args_type = "path:s?",
+ .params = "[path]",
+ .help = "show QOM composition tree",
+ .mhandler.cmd = hmp_info_qom_tree,
+ },
+ {
.name = "roms",
.args_type = "",
.params = "",
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 5d30ac5..1d87f57 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -678,6 +678,63 @@ void hmp_info_qdm(Monitor *mon, const QDict *qdict)
qdev_print_devinfos(true);
}
+typedef struct QOMCompositionState {
+ Monitor *mon;
+ int indent;
+} QOMCompositionState;
+
+static void print_qom_composition(Monitor *mon, Object *obj, int indent);
+
+static int print_qom_composition_child(Object *obj, void *opaque)
+{
+ QOMCompositionState *s = opaque;
+
+ print_qom_composition(s->mon, obj, s->indent);
+
+ return 0;
+}
+
+static void print_qom_composition(Monitor *mon, Object *obj, int indent)
+{
+ QOMCompositionState s = {
+ .mon = mon,
+ .indent = indent + 2,
+ };
+ char *name;
+
+ if (obj == object_get_root()) {
+ name = g_strdup("");
+ } else {
+ name = object_get_canonical_path_component(obj);
+ }
+ monitor_printf(mon, "%*s/%s (%s)\n", indent, "", name,
+ object_get_typename(obj));
+ g_free(name);
+ object_child_foreach(obj, print_qom_composition_child, &s);
+}
+
+void hmp_info_qom_tree(Monitor *mon, const QDict *dict)
+{
+ const char *path = qdict_get_try_str(dict, "path");
+ Object *obj;
+ bool ambiguous = false;
+
+ if (path) {
+ obj = object_resolve_path(path, &ambiguous);
+ if (!obj) {
+ monitor_printf(mon, "Path '%s' could not be resolved.\n", path);
+ return;
+ }
+ if (ambiguous) {
+ monitor_printf(mon, "Warning: Path '%s' is ambiguous.\n", path);
+ return;
+ }
+ } else {
+ obj = qdev_get_machine();
+ }
+ print_qom_composition(mon, obj, 0);
+}
+
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
Error *local_err = NULL;
--
2.1.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2 5/9] qapi: Stub out StringOutputVisitor struct support
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
` (3 preceding siblings ...)
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 4/9] qom: Implement info qom-tree " Andreas Färber
@ 2015-03-12 16:43 ` Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 6/9] qom: Implement qom-get HMP command Andreas Färber
` (6 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 16:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Roth, Andreas Färber, Luiz Capitulino
Avoid a segfault when visiting, e.g., the QOM rtc-time property,
by implementing the struct callbacks and raising an Error.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
qapi/string-output-visitor.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 1ab8574..8b6cb9b 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -304,6 +304,18 @@ end_list(Visitor *v, Error **errp)
}
+static void start_struct(Visitor *v, void **obj, const char *kind,
+ const char *name, size_t unused,
+ Error **errp)
+{
+ error_setg(errp, "struct type not implemented");
+}
+
+static void end_struct(Visitor *v, Error **errp)
+{
+ error_setg(errp, "struct type not implemented");
+}
+
char *string_output_get_string(StringOutputVisitor *sov)
{
char *string = g_string_free(sov->string, false);
@@ -349,6 +361,8 @@ StringOutputVisitor *string_output_visitor_new(bool human)
v->visitor.start_list = start_list;
v->visitor.next_list = next_list;
v->visitor.end_list = end_list;
+ v->visitor.start_struct = start_struct;
+ v->visitor.end_struct = end_struct;
return v;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2 6/9] qom: Implement qom-get HMP command
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
` (4 preceding siblings ...)
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 5/9] qapi: Stub out StringOutputVisitor struct support Andreas Färber
@ 2015-03-12 16:43 ` Andreas Färber
2015-03-13 1:36 ` Gonglei
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 7/9] qom: Add verbose option to info qom-tree " Andreas Färber
` (5 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 16:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber, Luiz Capitulino
Reimplement it based on qmp_qom_get() to avoid converting QObjects back
to strings.
Inspired-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hmp-commands.hx | 13 +++++++++++++
hmp.c | 22 ++++++++++++++++++++++
hmp.h | 1 +
3 files changed, 36 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 3c1915a..6fb6bdb 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-get",
+ .args_type = "path:s,property:s",
+ .params = "path property",
+ .help = "print QOM property",
+ .mhandler.cmd = hmp_qom_get,
+ },
+
+STEXI
+@item qom-get @var{path} @var{property}
+Print QOM property @var{property} of object at location @var{path}
+ETEXI
+
+ {
.name = "qom-set",
.args_type = "path:s,property:s,value:s",
.params = "path property value",
diff --git a/hmp.c b/hmp.c
index 811f9a3..6db4005 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1879,6 +1879,28 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, &err);
}
+void hmp_qom_get(Monitor *mon, const QDict *qdict)
+{
+ const char *path = qdict_get_str(qdict, "path");
+ const char *property = qdict_get_str(qdict, "property");
+ Error *err = NULL;
+ Object *obj;
+ char *value;
+
+ obj = object_resolve_path(path, NULL);
+ if (obj == NULL) {
+ error_set(&err, QERR_DEVICE_NOT_FOUND, path);
+ hmp_handle_error(mon, &err);
+ return;
+ }
+ value = object_property_print(obj, property, true, &err);
+ if (err == NULL) {
+ monitor_printf(mon, "%s\n", value);
+ g_free(value);
+ }
+ hmp_handle_error(mon, &err);
+}
+
void hmp_qom_set(Monitor *mon, const QDict *qdict)
{
const char *path = qdict_get_str(qdict, "path");
diff --git a/hmp.h b/hmp.h
index 44049e8..a4d0ae4 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_get(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);
--
2.1.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2 7/9] qom: Add verbose option to info qom-tree HMP command
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
` (5 preceding siblings ...)
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 6/9] qom: Implement qom-get HMP command Andreas Färber
@ 2015-03-12 16:43 ` Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 8/9] memory: Move owner-less MemoryRegions to /machine/unattached Andreas Färber
` (4 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 16:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Hani Benhabiles, Andreas Färber, Luiz Capitulino
It lists object properties, as equivalent to what info qtree displays.
Cc: Hani Benhabiles <hani@linux.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
monitor.c | 6 +++---
qdev-monitor.c | 49 ++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/monitor.c b/monitor.c
index 48f7f5a..9e16b4a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2890,9 +2890,9 @@ static mon_cmd_t info_cmds[] = {
},
{
.name = "qom-tree",
- .args_type = "path:s?",
- .params = "[path]",
- .help = "show QOM composition tree",
+ .args_type = "verbose:-v,path:s?",
+ .params = "[-v] [path]",
+ .help = "show QOM composition tree (-v: show properties)",
.mhandler.cmd = hmp_info_qom_tree,
},
{
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 1d87f57..845abfa 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -22,6 +22,7 @@
#include "monitor/monitor.h"
#include "monitor/qdev.h"
#include "qmp-commands.h"
+#include "qapi/string-output-visitor.h"
#include "sysemu/arch_init.h"
#include "qemu/config-file.h"
@@ -681,40 +682,74 @@ void hmp_info_qdm(Monitor *mon, const QDict *qdict)
typedef struct QOMCompositionState {
Monitor *mon;
int indent;
+ bool verbose;
} QOMCompositionState;
-static void print_qom_composition(Monitor *mon, Object *obj, int indent);
+static void print_qom_composition(Monitor *mon, Object *obj, int indent,
+ bool verbose);
static int print_qom_composition_child(Object *obj, void *opaque)
{
QOMCompositionState *s = opaque;
- print_qom_composition(s->mon, obj, s->indent);
+ print_qom_composition(s->mon, obj, s->indent, s->verbose);
return 0;
}
-static void print_qom_composition(Monitor *mon, Object *obj, int indent)
+static void print_qom_composition(Monitor *mon, Object *obj, int indent,
+ bool verbose)
{
QOMCompositionState s = {
.mon = mon,
.indent = indent + 2,
+ .verbose = verbose,
};
- char *name;
+ ObjectProperty *prop;
+ StringOutputVisitor *mo;
+ Error *local_err = NULL;
+ char *name, *str;
if (obj == object_get_root()) {
name = g_strdup("");
} else {
name = object_get_canonical_path_component(obj);
}
- monitor_printf(mon, "%*s/%s (%s)\n", indent, "", name,
- object_get_typename(obj));
+ if (verbose) {
+ monitor_printf(mon, "%*s/%s\n", indent, "", name);
+ QTAILQ_FOREACH(prop, &obj->properties, node) {
+ mo = string_output_visitor_new(true);
+ if (!prop->get) {
+ monitor_printf(mon, "%*s%s (write-only)\n", indent + 2, "",
+ prop->name);
+ } else {
+ prop->get(obj, string_output_get_visitor(mo), prop->opaque,
+ prop->name, &local_err);
+ if (local_err) {
+ monitor_printf(mon, "%*s%s: Error: %s\n", indent + 2, "",
+ prop->name, error_get_pretty(local_err));
+ error_free(local_err);
+ local_err = NULL;
+ } else {
+ str = string_output_get_string(mo);
+ monitor_printf(mon, "%*s%s: %s\n", indent + 2, "",
+ prop->name, str);
+ g_free(str);
+ }
+ }
+ string_output_visitor_cleanup(mo);
+ }
+ } else {
+ monitor_printf(mon, "%*s/%s (%s)\n", indent, "", name,
+ object_get_typename(obj));
+ }
g_free(name);
object_child_foreach(obj, print_qom_composition_child, &s);
}
void hmp_info_qom_tree(Monitor *mon, const QDict *dict)
{
+ bool verbose = qdict_get_try_bool(dict, "verbose", 0);
const char *path = qdict_get_try_str(dict, "path");
Object *obj;
bool ambiguous = false;
@@ -732,7 +767,7 @@ void hmp_info_qom_tree(Monitor *mon, const QDict *dict)
} else {
obj = qdev_get_machine();
}
- print_qom_composition(mon, obj, 0);
+ print_qom_composition(mon, obj, 0, verbose);
}
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
--
2.1.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2 8/9] memory: Move owner-less MemoryRegions to /machine/unattached
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
` (6 preceding siblings ...)
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 7/9] qom: Add verbose option to info qom-tree " Andreas Färber
@ 2015-03-12 16:43 ` Andreas Färber
2015-03-12 18:05 ` Paolo Bonzini
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 9/9] qdev: Move owner-less IRQs " Andreas Färber
` (3 subsequent siblings)
11 siblings, 1 reply; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 16:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Andreas Färber
This cleans up the official /machine namespace. In particular
/machine/system and /machine/io as well as entries with non-sanitized
node names.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/memory.c b/memory.c
index 20f6d9e..ee3f2a8 100644
--- a/memory.c
+++ b/memory.c
@@ -868,7 +868,7 @@ void memory_region_init(MemoryRegion *mr,
uint64_t size)
{
if (!owner) {
- owner = qdev_get_machine();
+ owner = container_get(qdev_get_machine(), "/unattached");
}
object_initialize(mr, sizeof(*mr), TYPE_MEMORY_REGION);
--
2.1.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2 9/9] qdev: Move owner-less IRQs to /machine/unattached
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
` (7 preceding siblings ...)
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 8/9] memory: Move owner-less MemoryRegions to /machine/unattached Andreas Färber
@ 2015-03-12 16:43 ` Andreas Färber
2015-03-13 1:30 ` [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Gonglei
` (2 subsequent siblings)
11 siblings, 0 replies; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 16:43 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Crosthwaite, Andreas Färber
Move non-qdev-gpio[*] from /machine into /machine/unattached.
For the PC this moves 25 nodes from the stable namespace into the unstable.
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/core/qdev.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6be5866..6e6a65d 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -501,8 +501,9 @@ void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
* with an error without doing anything. If it has none, it will
* never fail. So we can just call it with a NULL Error pointer.
*/
- object_property_add_child(qdev_get_machine(), "non-qdev-gpio[*]",
- OBJECT(pin), NULL);
+ object_property_add_child(container_get(qdev_get_machine(),
+ "/unattached"),
+ "non-qdev-gpio[*]", OBJECT(pin), NULL);
}
object_property_set_link(OBJECT(dev), OBJECT(pin), propname, &error_abort);
g_free(propname);
--
2.1.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH v2 8/9] memory: Move owner-less MemoryRegions to /machine/unattached
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 8/9] memory: Move owner-less MemoryRegions to /machine/unattached Andreas Färber
@ 2015-03-12 18:05 ` Paolo Bonzini
2015-03-12 19:16 ` Andreas Färber
0 siblings, 1 reply; 19+ messages in thread
From: Paolo Bonzini @ 2015-03-12 18:05 UTC (permalink / raw)
To: Andreas Färber, qemu-devel
On 12/03/2015 17:43, Andreas Färber wrote:
> This cleans up the official /machine namespace. In particular
> /machine/system and /machine/io as well as entries with non-sanitized
> node names.
Just a question: isn't it /machine/system[0] and /machine/io[0]?
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> memory.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/memory.c b/memory.c
> index 20f6d9e..ee3f2a8 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -868,7 +868,7 @@ void memory_region_init(MemoryRegion *mr,
> uint64_t size)
> {
> if (!owner) {
> - owner = qdev_get_machine();
> + owner = container_get(qdev_get_machine(), "/unattached");
> }
>
> object_initialize(mr, sizeof(*mr), TYPE_MEMORY_REGION);
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH v2 8/9] memory: Move owner-less MemoryRegions to /machine/unattached
2015-03-12 18:05 ` Paolo Bonzini
@ 2015-03-12 19:16 ` Andreas Färber
0 siblings, 0 replies; 19+ messages in thread
From: Andreas Färber @ 2015-03-12 19:16 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Am 12.03.2015 um 19:05 schrieb Paolo Bonzini:
> On 12/03/2015 17:43, Andreas Färber wrote:
>> This cleans up the official /machine namespace. In particular
>> /machine/system and /machine/io as well as entries with non-sanitized
>> node names.
>
> Just a question: isn't it /machine/system[0] and /machine/io[0]?
You're right. Still, now that these names are used in a global generic
context, I think "system" is too generic - "/machine/system-memory"
would be better than "/machine/system[0]".
Other names I referred to above are "vga ioports remapped[0]", "bochs
dispi interface[0]" and "qemu extended regs[0]", each containing spaces.
I.e., those names were at the time chosen as textual descriptions and
not as QOM path components.
>>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>> memory.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/memory.c b/memory.c
>> index 20f6d9e..ee3f2a8 100644
>> --- a/memory.c
>> +++ b/memory.c
>> @@ -868,7 +868,7 @@ void memory_region_init(MemoryRegion *mr,
>> uint64_t size)
>> {
>> if (!owner) {
>> - owner = qdev_get_machine();
>> + owner = container_get(qdev_get_machine(), "/unattached");
>> }
>>
>> object_initialize(mr, sizeof(*mr), TYPE_MEMORY_REGION);
>>
>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Do you have any outstanding memory patches, or should I fix up the
commit message and take it through qom-next?
Thanks,
Andreas
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
` (8 preceding siblings ...)
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 9/9] qdev: Move owner-less IRQs " Andreas Färber
@ 2015-03-13 1:30 ` Gonglei
2015-03-17 5:15 ` Alistair Francis
2015-03-17 7:33 ` Markus Armbruster
2015-03-17 17:17 ` Andreas Färber
11 siblings, 1 reply; 19+ messages in thread
From: Gonglei @ 2015-03-13 1:30 UTC (permalink / raw)
To: Andreas Färber, qemu-devel
Cc: Paolo Bonzini, Peter Crosthwaite, Hani Benhabiles,
Markus Armbruster, Luiz Capitulino
On 2015/3/13 0:43, Andreas Färber wrote:
> Hello,
>
> The main patch of this series is an HMP command "info qom-tree",
> which displays the machine composition tree. This names all objects,
> including those missing in "info qtree" for lack of bus or for not being a device.
>
> Properties can be listed with "qom-list" and set with "qom-set", like in QMP.
>
> "qom-get" and displaying properties as part of "info qom-tree" ran into
> StringOutputVisitor limitations - this v2 therefore stubs that support out
> so that we don't crash.
>
> This series has been around for a year now; I hope to get at least qom-list and
> the basic info qom-tree into v2.3, as visualization of my upcoming CPU changes.
>
I have been looking forward to these HMP commands are merged. ;)
They are coming now...
Regards,
-Gonglei
> Also included are two proposed cleanups of nodes in /machine namespace.
> By making it easier to inspect the tree, I hope we'll detect this earlier.
>
> Regards,
> Andreas
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/9] qom: Implement qom-list HMP command
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 2/9] qom: Implement qom-list HMP command Andreas Färber
@ 2015-03-13 1:32 ` Gonglei
0 siblings, 0 replies; 19+ messages in thread
From: Gonglei @ 2015-03-13 1:32 UTC (permalink / raw)
To: Andreas Färber, qemu-devel; +Cc: Luiz Capitulino
On 2015/3/13 0:43, Andreas Färber wrote:
> Implement it as a wrapper for QMP qom-list, but mimic the behavior of
> scripts/qmp/qom-list in making the path argument optional and listing
> the root if absent, to hint users what kind of path to pass.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hmp-commands.hx | 13 +++++++++++++
> hmp.c | 26 ++++++++++++++++++++++++++
> hmp.h | 1 +
> 3 files changed, 40 insertions(+)
>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index d5022d8..c3b93d6 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1658,6 +1658,19 @@ Add CPU with id @var{id}
> ETEXI
>
> {
> + .name = "qom-list",
> + .args_type = "path:s?",
> + .params = "path",
> + .help = "list QOM properties",
> + .mhandler.cmd = hmp_qom_list,
> + },
> +
> +STEXI
> +@item qom-list [@var{path}]
> +Print QOM properties of object at location @var{path}
> +ETEXI
> +
> + {
> .name = "info",
> .args_type = "item:s?",
> .params = "[subcommand]",
> diff --git a/hmp.c b/hmp.c
> index 71c28bc..f6df075 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -1852,3 +1852,29 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
>
> qapi_free_MemoryDeviceInfoList(info_list);
> }
> +
> +void hmp_qom_list(Monitor *mon, const QDict *qdict)
> +{
> + const char *path = qdict_get_try_str(qdict, "path");
> + ObjectPropertyInfoList *list;
> + Error *err = NULL;
> +
> + if (path == NULL) {
> + monitor_printf(mon, "/\n");
> + return;
> + }
> +
> + list = qmp_qom_list(path, &err);
> + if (err == NULL) {
> + ObjectPropertyInfoList *start = list;
> + while (list != NULL) {
> + ObjectPropertyInfo *value = list->value;
> +
> + monitor_printf(mon, "%s (%s)\n",
> + value->name, value->type);
> + list = list->next;
> + }
> + qapi_free_ObjectPropertyInfoList(start);
> + }
> + hmp_handle_error(mon, &err);
> +}
> diff --git a/hmp.h b/hmp.h
> index 81177b2..18c0f52 100644
> --- a/hmp.h
> +++ b/hmp.h
> @@ -95,6 +95,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict);
> 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 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);
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/9] qom: Implement qom-set HMP command
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 3/9] qom: Implement qom-set " Andreas Färber
@ 2015-03-13 1:34 ` Gonglei
0 siblings, 0 replies; 19+ messages in thread
From: Gonglei @ 2015-03-13 1:34 UTC (permalink / raw)
To: Andreas Färber, qemu-devel; +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 <afaerber@suse.de>
> ---
> hmp-commands.hx | 13 +++++++++++++
> hmp.c | 21 +++++++++++++++++++++
> hmp.h | 1 +
> 3 files changed, 35 insertions(+)
>
>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
> 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);
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH v2 6/9] qom: Implement qom-get HMP command
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 6/9] qom: Implement qom-get HMP command Andreas Färber
@ 2015-03-13 1:36 ` Gonglei
0 siblings, 0 replies; 19+ messages in thread
From: Gonglei @ 2015-03-13 1:36 UTC (permalink / raw)
To: Andreas Färber, qemu-devel; +Cc: Luiz Capitulino
On 2015/3/13 0:43, Andreas Färber wrote:
> Reimplement it based on qmp_qom_get() to avoid converting QObjects back
> to strings.
>
> Inspired-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hmp-commands.hx | 13 +++++++++++++
> hmp.c | 22 ++++++++++++++++++++++
> hmp.h | 1 +
> 3 files changed, 36 insertions(+)
>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 3c1915a..6fb6bdb 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-get",
> + .args_type = "path:s,property:s",
> + .params = "path property",
> + .help = "print QOM property",
> + .mhandler.cmd = hmp_qom_get,
> + },
> +
> +STEXI
> +@item qom-get @var{path} @var{property}
> +Print QOM property @var{property} of object at location @var{path}
> +ETEXI
> +
> + {
> .name = "qom-set",
> .args_type = "path:s,property:s,value:s",
> .params = "path property value",
> diff --git a/hmp.c b/hmp.c
> index 811f9a3..6db4005 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -1879,6 +1879,28 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict)
> hmp_handle_error(mon, &err);
> }
>
> +void hmp_qom_get(Monitor *mon, const QDict *qdict)
> +{
> + const char *path = qdict_get_str(qdict, "path");
> + const char *property = qdict_get_str(qdict, "property");
> + Error *err = NULL;
> + Object *obj;
> + char *value;
> +
> + obj = object_resolve_path(path, NULL);
> + if (obj == NULL) {
> + error_set(&err, QERR_DEVICE_NOT_FOUND, path);
> + hmp_handle_error(mon, &err);
> + return;
> + }
> + value = object_property_print(obj, property, true, &err);
> + if (err == NULL) {
> + monitor_printf(mon, "%s\n", value);
> + g_free(value);
> + }
> + hmp_handle_error(mon, &err);
> +}
> +
> void hmp_qom_set(Monitor *mon, const QDict *qdict)
> {
> const char *path = qdict_get_str(qdict, "path");
> diff --git a/hmp.h b/hmp.h
> index 44049e8..a4d0ae4 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_get(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);
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree
2015-03-13 1:30 ` [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Gonglei
@ 2015-03-17 5:15 ` Alistair Francis
0 siblings, 0 replies; 19+ messages in thread
From: Alistair Francis @ 2015-03-17 5:15 UTC (permalink / raw)
To: Gonglei
Cc: Peter Crosthwaite, Markus Armbruster,
qemu-devel@nongnu.org Developers, Hani Benhabiles, Paolo Bonzini,
Luiz Capitulino, Andreas Färber
On Fri, Mar 13, 2015 at 11:30 AM, Gonglei <arei.gonglei@huawei.com> wrote:
> On 2015/3/13 0:43, Andreas Färber wrote:
>> Hello,
>>
>> The main patch of this series is an HMP command "info qom-tree",
>> which displays the machine composition tree. This names all objects,
>> including those missing in "info qtree" for lack of bus or for not being a device.
>>
>> Properties can be listed with "qom-list" and set with "qom-set", like in QMP.
>>
>> "qom-get" and displaying properties as part of "info qom-tree" ran into
>> StringOutputVisitor limitations - this v2 therefore stubs that support out
>> so that we don't crash.
>>
>> This series has been around for a year now; I hope to get at least qom-list and
>> the basic info qom-tree into v2.3, as visualization of my upcoming CPU changes.
>>
> I have been looking forward to these HMP commands are merged. ;)
>
> They are coming now...
This is great!
Unfortunately I don't understand it enough to sign off on anything,
but it looks good.
I did do some testing on some pretty big machines and it seems to work well.
Tested-by: Alistair Francis <alistair.francis@xilinx.com>
Thanks,
Alistair
>
> Regards,
> -Gonglei
>> Also included are two proposed cleanups of nodes in /machine namespace.
>> By making it easier to inspect the tree, I hope we'll detect this earlier.
>>
>> Regards,
>> Andreas
>
>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
` (9 preceding siblings ...)
2015-03-13 1:30 ` [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Gonglei
@ 2015-03-17 7:33 ` Markus Armbruster
2015-03-17 17:17 ` Andreas Färber
11 siblings, 0 replies; 19+ messages in thread
From: Markus Armbruster @ 2015-03-17 7:33 UTC (permalink / raw)
To: Andreas Färber
Cc: Paolo Bonzini, Peter Crosthwaite, Hani Benhabiles, qemu-devel,
Luiz Capitulino
Andreas Färber <afaerber@suse.de> writes:
> Hello,
>
> The main patch of this series is an HMP command "info qom-tree",
> which displays the machine composition tree. This names all objects,
> including those missing in "info qtree" for lack of bus or for not being a device.
>
> Properties can be listed with "qom-list" and set with "qom-set", like in QMP.
>
> "qom-get" and displaying properties as part of "info qom-tree" ran into
> StringOutputVisitor limitations - this v2 therefore stubs that support out
> so that we don't crash.
>
> This series has been around for a year now; I hope to get at least qom-list and
> the basic info qom-tree into v2.3, as visualization of my upcoming CPU changes.
>
> Also included are two proposed cleanups of nodes in /machine namespace.
> By making it easier to inspect the tree, I hope we'll detect this earlier.
I haven't been able to try it out (up to my ears in an almost finished
task), but this sounds like it'll save me quite some messing around with
qom-fuse. Awesome, thanks!
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
` (10 preceding siblings ...)
2015-03-17 7:33 ` Markus Armbruster
@ 2015-03-17 17:17 ` Andreas Färber
11 siblings, 0 replies; 19+ messages in thread
From: Andreas Färber @ 2015-03-17 17:17 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Crosthwaite, Gonglei (Arei),
Markus Armbruster, Luiz Capitulino, Hani Benhabiles,
Paolo Bonzini, Alistair Francis
Am 12.03.2015 um 17:43 schrieb Andreas Färber:
> Andreas Färber (9):
> scripts: Add qom-tree script
> qom: Implement qom-list HMP command
> qom: Implement qom-set HMP command
> qom: Implement info qom-tree HMP command
Applied this half.
> qapi: Stub out StringOutputVisitor struct support
> qom: Implement qom-get HMP command
> qom: Add verbose option to info qom-tree HMP command
Here I erred on the side of caution, deferring it.
If we go with this StringOutputVisitor workaround, then I should at
least add a test case.
Of course it would be great if someone volunteered to clean up list
handling and implement struct handling properly, but a year later my
hopes are quite dim.
> memory: Move owner-less MemoryRegions to /machine/unattached
> qdev: Move owner-less IRQs to /machine/unattached
Applied these two.
Thanks,
Andreas
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2015-03-17 17:18 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12 16:43 [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 1/9] scripts: Add qom-tree script Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 2/9] qom: Implement qom-list HMP command Andreas Färber
2015-03-13 1:32 ` Gonglei
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 3/9] qom: Implement qom-set " Andreas Färber
2015-03-13 1:34 ` Gonglei
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 4/9] qom: Implement info qom-tree " Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 5/9] qapi: Stub out StringOutputVisitor struct support Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 6/9] qom: Implement qom-get HMP command Andreas Färber
2015-03-13 1:36 ` Gonglei
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 7/9] qom: Add verbose option to info qom-tree " Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 8/9] memory: Move owner-less MemoryRegions to /machine/unattached Andreas Färber
2015-03-12 18:05 ` Paolo Bonzini
2015-03-12 19:16 ` Andreas Färber
2015-03-12 16:43 ` [Qemu-devel] [PATCH v2 9/9] qdev: Move owner-less IRQs " Andreas Färber
2015-03-13 1:30 ` [Qemu-devel] [PATCH v2 0/9] qom: HMP commands to supersede info qtree Gonglei
2015-03-17 5:15 ` Alistair Francis
2015-03-17 7:33 ` Markus Armbruster
2015-03-17 17:17 ` Andreas Färber
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.