From 70b9433109ed99217b812f19800de550e2e0ecd5 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 13 Feb 2015 12:50:26 +0100 Subject: QemuOpts: Wean off qerror_report_err() qerror_report_err() is a transitional interface to help with converting existing monitor commands to QMP. It should not be used elsewhere. The only remaining user in qemu-option.c is qemu_opts_parse(). Is it used in QMP context? If not, we can simply replace qerror_report_err() by error_report_err(). The uses in qemu-img.c, qemu-io.c, qemu-nbd.c and under tests/ are clearly not in QMP context. The uses in vl.c aren't either, because the only QMP command handlers there are qmp_query_status() and qmp_query_machines(), and they don't call it. Remaining uses: * drive_def(): Command line -drive and such, HMP drive_add and pci_add * hmp_chardev_add(): HMP chardev-add * monitor_parse_command(): HMP core * tmp_config_parse(): Command line -tpmdev * net_host_device_add(): HMP host_net_add * net_client_parse(): Command line -net and -netdev * qemu_global_option(): Command line -global * vnc_parse_func(): Command line -display, -vnc, default display, HMP change, QMP change. Bummer. * qemu_pci_hot_add_nic(): HMP pci_add * usb_net_init(): Command line -usbdevice, HMP usb_add Propagate errors through qemu_opts_parse(). Create a convenience function qemu_opts_parse_noisily() that passes errors to error_report_err(). Switch all non-QMP users outside tests to it. That leaves vnc_parse_func(). Propagate errors through it. Since I'm touching it anyway, rename it to vnc_parse(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Reviewed-by: Luiz Capitulino --- ui/vnc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/vnc.c b/ui/vnc.c index 69b605c..7f0ce7a 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3749,10 +3749,10 @@ static void vnc_auto_assign_id(QemuOptsList *olist, QemuOpts *opts) qemu_opts_set_id(opts, id); } -QemuOpts *vnc_parse_func(const char *str) +QemuOpts *vnc_parse(const char *str, Error **errp) { QemuOptsList *olist = qemu_find_opts("vnc"); - QemuOpts *opts = qemu_opts_parse(olist, str, 1); + QemuOpts *opts = qemu_opts_parse(olist, str, true, errp); const char *id; if (!opts) { -- cgit v1.1 From 75158ebbe259f0bd8bf435e8f4827a43ec89c877 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 16 Mar 2015 08:57:47 +0100 Subject: qerror: Eliminate QERR_DEVICE_NOT_FOUND Error classes other than ERROR_CLASS_GENERIC_ERROR should not be used in new code. Hiding them in QERR_ macros makes new uses hard to spot. Fortunately, there's just one such macro left. Eliminate it with this coccinelle semantic patch: @@ expression EP, E; @@ -error_set(EP, QERR_DEVICE_NOT_FOUND, E) +error_set(EP, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", E) Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Reviewed-by: Luiz Capitulino --- ui/input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/input.c b/ui/input.c index eeeabe8..e96e1ea 100644 --- a/ui/input.c +++ b/ui/input.c @@ -84,7 +84,8 @@ void qemu_input_handler_bind(QemuInputHandlerState *s, dev = qdev_find_recursive(sysbus_get_default(), device_id); if (dev == NULL) { - error_set(errp, QERR_DEVICE_NOT_FOUND, device_id); + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", device_id); return; } -- cgit v1.1 From c6bd8c706a799eb0fece99f468aaa22b818036f3 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 17 Mar 2015 11:54:50 +0100 Subject: qerror: Clean up QERR_ macros to expand into a single string These macros expand into error class enumeration constant, comma, string. Unclean. Has been that way since commit 13f59ae. The error class is always ERROR_CLASS_GENERIC_ERROR since the previous commit. Clean up as follows: * Prepend every use of a QERR_ macro by ERROR_CLASS_GENERIC_ERROR, and delete it from the QERR_ macro. No change after preprocessing. * Rewrite error_set(ERROR_CLASS_GENERIC_ERROR, ...) into error_setg(...). Again, no change after preprocessing. Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Reviewed-by: Luiz Capitulino --- ui/vnc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/vnc.c b/ui/vnc.c index 7f0ce7a..b5e7906 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -427,7 +427,7 @@ VncInfo *qmp_query_vnc(Error **errp) if (getsockname(vd->lsock, (struct sockaddr *)&sa, &salen) == -1) { - error_set(errp, QERR_UNDEFINED_ERROR); + error_setg(errp, QERR_UNDEFINED_ERROR); goto out_error; } @@ -435,7 +435,7 @@ VncInfo *qmp_query_vnc(Error **errp) host, sizeof(host), serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV) < 0) { - error_set(errp, QERR_UNDEFINED_ERROR); + error_setg(errp, QERR_UNDEFINED_ERROR); goto out_error; } -- cgit v1.1 From d49b68364414d649b8e26232f2a600d415611662 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 17 Mar 2015 18:29:20 +0100 Subject: qerror: Move #include out of qerror.h Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Reviewed-by: Luiz Capitulino --- ui/input.c | 1 + ui/spice-core.c | 1 + ui/vnc.c | 1 + 3 files changed, 3 insertions(+) (limited to 'ui') diff --git a/ui/input.c b/ui/input.c index e96e1ea..1a552d1 100644 --- a/ui/input.c +++ b/ui/input.c @@ -1,6 +1,7 @@ #include "hw/qdev.h" #include "sysemu/sysemu.h" #include "qapi-types.h" +#include "qemu/error-report.h" #include "qmp-commands.h" #include "trace.h" #include "ui/input.h" diff --git a/ui/spice-core.c b/ui/spice-core.c index a30da3c..bf4fd07 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -22,6 +22,7 @@ #include "qemu-common.h" #include "ui/qemu-spice.h" +#include "qemu/error-report.h" #include "qemu/thread.h" #include "qemu/timer.h" #include "qemu/queue.h" diff --git a/ui/vnc.c b/ui/vnc.c index b5e7906..af16584 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -29,6 +29,7 @@ #include "trace.h" #include "hw/qdev.h" #include "sysemu/sysemu.h" +#include "qemu/error-report.h" #include "qemu/sockets.h" #include "qemu/timer.h" #include "qemu/acl.h" -- cgit v1.1 From cc7a8ea740ec74a144e866a1d24aa6b490e31923 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 17 Mar 2015 17:22:46 +0100 Subject: Include qapi/qmp/qerror.h exactly where needed In particular, don't include it into headers. Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Reviewed-by: Luiz Capitulino --- ui/vnc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'ui') diff --git a/ui/vnc.c b/ui/vnc.c index af16584..2ffd9e5 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -34,6 +34,7 @@ #include "qemu/timer.h" #include "qemu/acl.h" #include "qemu/config-file.h" +#include "qapi/qmp/qerror.h" #include "qapi/qmp/types.h" #include "qmp-commands.h" #include "qemu/osdep.h" -- cgit v1.1 From a0b1a66ea39bca011108734147a72232a4d08c7a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 17 Mar 2015 18:16:21 +0100 Subject: Include monitor/monitor.h exactly where needed In particular, don't include it into headers. Signed-off-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Reviewed-by: Luiz Capitulino --- ui/input-legacy.c | 1 - ui/spice-display.c | 1 - ui/vnc-jobs.c | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 3e9bb38..e50f296 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -23,7 +23,6 @@ */ #include "sysemu/sysemu.h" -#include "monitor/monitor.h" #include "ui/console.h" #include "qapi/error.h" #include "qmp-commands.h" diff --git a/ui/spice-display.c b/ui/spice-display.c index cc4a6ce..0360abf 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -19,7 +19,6 @@ #include "ui/qemu-spice.h" #include "qemu/timer.h" #include "qemu/queue.h" -#include "monitor/monitor.h" #include "ui/console.h" #include "sysemu/sysemu.h" #include "trace.h" diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c index c8ee203..22c9abc 100644 --- a/ui/vnc-jobs.c +++ b/ui/vnc-jobs.c @@ -29,6 +29,7 @@ #include "vnc.h" #include "vnc-jobs.h" #include "qemu/sockets.h" +#include "block/aio.h" /* * Locking: -- cgit v1.1