summaryrefslogtreecommitdiffstats
path: root/monitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-12-18 16:35:06 +0100
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:28:24 -0600
commit8c3567700b86e883380b206c1284dcaf6b850f6c (patch)
tree89f585f2f3c4a98b4174d64d513f4f29445cfea3 /monitor.c
parentfcdc1d6844256147a15c26c8bfe08387603d038f (diff)
downloadhqemu-8c3567700b86e883380b206c1284dcaf6b850f6c.zip
hqemu-8c3567700b86e883380b206c1284dcaf6b850f6c.tar.gz
error: Use error_report_err() instead of monitor_printf()
Both error_report_err() and monitor_printf() print to the same destination when monitor_printf() is used correctly, i.e. within an HMP monitor. Elsewhere, monitor_printf() does nothing, while error_report_err() reports to stderr. Most changed functions are HMP command handlers. These should only run within an HMP monitor. The one exception is bdrv_password_cb(), which should also only run within an HMP monitor. Four command handlers prefix the error message with the command name: balloon, migrate_set_capability, migrate_set_parameter, migrate. Pointless, drop. Unlike monitor_printf(), error_report_err() uses the error whole instead of just its message obtained with error_get_pretty(). This avoids suppressing its hint (see commit 50b7b00). Example: (qemu) device_add ivshmem,id=666 Parameter 'id' expects an identifier Identifiers consist of letters, digits, '-', '.', '_', starting with a letter. Try "help device_add" for more information The "Identifiers consist of..." line is new with this patch. Coccinelle semantic patch: @@ expression M, E; @@ - monitor_printf(M, "%s\n", error_get_pretty(E)); - error_free(E); + error_report_err(E); @r1@ expression M, E; format F; position p; @@ - monitor_printf(M, "...%@F@\n", error_get_pretty(E));@p - error_free(E); + error_report_err(E); @script:python@ p << r1.p; @@ print "%s:%s:%s: prefix dropped" % (p[0].file, p[0].line, p[0].column) Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1450452927-8346-4-git-send-email-armbru@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/monitor.c b/monitor.c
index e7e7ae2..c53a453 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1464,8 +1464,7 @@ static void hmp_boot_set(Monitor *mon, const QDict *qdict)
qemu_boot_set(bootdevice, &local_err);
if (local_err) {
- monitor_printf(mon, "%s\n", error_get_pretty(local_err));
- error_free(local_err);
+ error_report_err(local_err);
} else {
monitor_printf(mon, "boot device list now set to %s\n", bootdevice);
}
@@ -4149,8 +4148,7 @@ static void bdrv_password_cb(void *opaque, const char *password,
bdrv_add_key(bs, password, &local_err);
if (local_err) {
- monitor_printf(mon, "%s\n", error_get_pretty(local_err));
- error_free(local_err);
+ error_report_err(local_err);
ret = -EPERM;
}
if (mon->password_completion_cb)
OpenPOWER on IntegriCloud