summaryrefslogtreecommitdiffstats
path: root/qdev-monitor.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-09-10 10:19:16 -0600
committerMarkus Armbruster <armbru@redhat.com>2015-09-18 14:34:39 +0200
commit50b7b000c9171c1253c1c875f46f654c3c0e1fc8 (patch)
tree2972106f6aeee4784741c5bcf4673e0f1d67ccaa /qdev-monitor.c
parent615cf669b55a689f9e535ecf87075e50004b6e0a (diff)
downloadhqemu-50b7b000c9171c1253c1c875f46f654c3c0e1fc8.zip
hqemu-50b7b000c9171c1253c1c875f46f654c3c0e1fc8.tar.gz
hmp: Allow for error message hints on HMP
Commits 7216ae3d and d2828429 disabled some error message hints, all because a change to use modern error reporting meant that the hint would be output prior to the actual error. Fix this by making hints a first-class member of Error. For example, we are now back to the pleasant: $ qemu-system-x86_64 --nodefaults -S --vnc :0 --chardev null,id=, qemu-system-x86_64: --chardev null,id=,: Parameter 'id' expects an identifier Identifiers consist of letters, digits, '-', '.', '_', starting with a letter. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1441901956-21991-1-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'qdev-monitor.c')
-rw-r--r--qdev-monitor.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/qdev-monitor.c b/qdev-monitor.c
index f9e2d62..0bf7f83 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -289,37 +289,35 @@ static Object *qdev_get_peripheral_anon(void)
return dev;
}
-#if 0 /* conversion from qerror_report() to error_set() broke their use */
-static void qbus_list_bus(DeviceState *dev)
+static void qbus_list_bus(DeviceState *dev, Error **errp)
{
BusState *child;
const char *sep = " ";
- error_printf("child buses at \"%s\":",
- dev->id ? dev->id : object_get_typename(OBJECT(dev)));
+ error_append_hint(errp, "child buses at \"%s\":",
+ dev->id ? dev->id : object_get_typename(OBJECT(dev)));
QLIST_FOREACH(child, &dev->child_bus, sibling) {
- error_printf("%s\"%s\"", sep, child->name);
+ error_append_hint(errp, "%s\"%s\"", sep, child->name);
sep = ", ";
}
- error_printf("\n");
}
-static void qbus_list_dev(BusState *bus)
+static void qbus_list_dev(BusState *bus, Error **errp)
{
BusChild *kid;
const char *sep = " ";
- error_printf("devices at \"%s\":", bus->name);
+ error_append_hint(errp, "devices at \"%s\":", bus->name);
QTAILQ_FOREACH(kid, &bus->children, sibling) {
DeviceState *dev = kid->child;
- error_printf("%s\"%s\"", sep, object_get_typename(OBJECT(dev)));
- if (dev->id)
- error_printf("/\"%s\"", dev->id);
+ error_append_hint(errp, "%s\"%s\"", sep,
+ object_get_typename(OBJECT(dev)));
+ if (dev->id) {
+ error_append_hint(errp, "/\"%s\"", dev->id);
+ }
sep = ", ";
}
- error_printf("\n");
}
-#endif
static BusState *qbus_find_bus(DeviceState *dev, char *elem)
{
@@ -461,11 +459,7 @@ static BusState *qbus_find(const char *path, Error **errp)
if (!dev) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", elem);
-#if 0 /* conversion from qerror_report() to error_set() broke this: */
- if (!monitor_cur_is_qmp()) {
- qbus_list_dev(bus);
- }
-#endif
+ qbus_list_dev(bus, errp);
return NULL;
}
@@ -483,11 +477,7 @@ static BusState *qbus_find(const char *path, Error **errp)
if (dev->num_child_bus) {
error_setg(errp, "Device '%s' has multiple child buses",
elem);
-#if 0 /* conversion from qerror_report() to error_set() broke this: */
- if (!monitor_cur_is_qmp()) {
- qbus_list_bus(dev);
- }
-#endif
+ qbus_list_bus(dev, errp);
} else {
error_setg(errp, "Device '%s' has no child bus", elem);
}
@@ -503,11 +493,7 @@ static BusState *qbus_find(const char *path, Error **errp)
bus = qbus_find_bus(dev, elem);
if (!bus) {
error_setg(errp, "Bus '%s' not found", elem);
-#if 0 /* conversion from qerror_report() to error_set() broke this: */
- if (!monitor_cur_is_qmp()) {
- qbus_list_bus(dev);
- }
-#endif
+ qbus_list_bus(dev, errp);
return NULL;
}
}
OpenPOWER on IntegriCloud