From 4c9ab1e693c46f3db9c1e7c0e4251ba37bff5e39 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Date: Wed, 17 Oct 2018 18:17:38 +0300 Subject: scripts: Remove check-qerror.sh qerror.h contains leftovers from the now-defunct QError API. There's only a handful of string macros left, and no one is supposed to add anything else. The check-qerror.sh script was used to make sure that all definitions on the qerror.c and qerror.h files were sorted alphabetically. The former was removed three years ago, and the latter is now in a different location, so the script doesn't even work (as a matter of fact the alphabetical order was broken last time someone added a macro -also in 2015- and no one seemed to notice). There's no point in fixing this script so let's just remove it. The rogue macro is also moved to its correct location. Signed-off-by: Alberto Garcia Message-Id: <20181017151738.20299-1-berto@igalia.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- include/qapi/qmp/qerror.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index 145571f..7c76e24 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -79,6 +79,9 @@ #define QERR_QGA_COMMAND_FAILED \ "Guest agent command failed, error was '%s'" +#define QERR_REPLAY_NOT_SUPPORTED \ + "Record/replay feature is not supported for '%s'" + #define QERR_SET_PASSWD_FAILED \ "Could not set password" @@ -88,7 +91,4 @@ #define QERR_UNSUPPORTED \ "this feature or command is not currently supported" -#define QERR_REPLAY_NOT_SUPPORTED \ - "Record/replay feature is not supported for '%s'" - #endif /* QERROR_H */ -- cgit v1.1 From 4b5766488fd3549dc47a75331cf4db62f477536c Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 17 Oct 2018 10:26:25 +0200 Subject: error: Fix use of error_prepend() with &error_fatal, &error_abort MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From include/qapi/error.h: * Pass an existing error to the caller with the message modified: * error_propagate(errp, err); * error_prepend(errp, "Could not frobnicate '%s': ", name); Fei Li pointed out that doing error_propagate() first doesn't work well when @errp is &error_fatal or &error_abort: the error_prepend() is never reached. Since I doubt fixing the documentation will stop people from getting it wrong, introduce error_propagate_prepend(), in the hope that it lures people away from using its constituents in the wrong order. Update the instructions in error.h accordingly. Convert existing error_prepend() next to error_propagate to error_propagate_prepend(). If any of these get reached with &error_fatal or &error_abort, the error messages improve. I didn't check whether that's the case anywhere. Cc: Fei Li Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Eric Blake Message-Id: <20181017082702.5581-2-armbru@redhat.com> --- include/qapi/error.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/qapi/error.h b/include/qapi/error.h index bcb86a7..51b63dd 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -52,8 +52,12 @@ * where Error **errp is a parameter, by convention the last one. * * Pass an existing error to the caller with the message modified: + * error_propagate_prepend(errp, err); + * + * Avoid * error_propagate(errp, err); * error_prepend(errp, "Could not frobnicate '%s': ", name); + * because this fails to prepend when @errp is &error_fatal. * * Create a new error and pass it to the caller: * error_setg(errp, "situation normal, all fouled up"); @@ -215,6 +219,16 @@ void error_setg_win32_internal(Error **errp, */ void error_propagate(Error **dst_errp, Error *local_err); + +/* + * Propagate error object (if any) with some text prepended. + * Behaves like + * error_prepend(&local_err, fmt, ...); + * error_propagate(dst_errp, local_err); + */ +void error_propagate_prepend(Error **dst_errp, Error *local_err, + const char *fmt, ...); + /* * Prepend some text to @errp's human-readable error message. * The text is made by formatting @fmt, @ap like vprintf(). -- cgit v1.1 From e1eb292acec5e9806b1afc33f39629e6d0859732 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 17 Oct 2018 10:26:29 +0200 Subject: vfio: Use warn_report() & friends to report warnings The vfio code reports warnings like error_report(WARN_PREFIX "Could not frobnicate", DEV-NAME); where WARN_PREFIX is defined so the message comes out as vfio warning: DEV-NAME: Could not frobnicate This usage predates the introduction of warn_report() & friends in commit 97f40301f1d. It's time to convert to that interface. Since these functions already prefix the message with "warning: ", replace WARN_PREFIX by VFIO_MSG_PREFIX, so the messages come out like warning: vfio DEV-NAME: Could not frobnicate The next commit will replace ERR_PREFIX. Cc: Alex Williamson Signed-off-by: Markus Armbruster Acked-by: Alex Williamson Reviewed-by: Eric Blake Message-Id: <20181017082702.5581-6-armbru@redhat.com> --- include/hw/vfio/vfio-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index e46a289..1d76303 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -32,7 +32,7 @@ #endif #define ERR_PREFIX "vfio error: %s: " -#define WARN_PREFIX "vfio warning: %s: " +#define VFIO_MSG_PREFIX "vfio %s: " enum { VFIO_DEVICE_TYPE_PCI = 0, -- cgit v1.1 From c3b8e3e0ed40112367369683da1e3745cf203ac0 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 17 Oct 2018 10:26:30 +0200 Subject: vfio: Clean up error reporting after previous commit The previous commit changed vfio's warning messages from vfio warning: DEV-NAME: Could not frobnicate to warning: vfio DEV-NAME: Could not frobnicate To match this change, change error messages from vfio error: DEV-NAME: On fire to vfio DEV-NAME: On fire Note the loss of "error". If we think marking error messages that way is a good idea, we should mark *all* error messages, i.e. make error_report() print it. Cc: Alex Williamson Signed-off-by: Markus Armbruster Acked-by: Alex Williamson Message-Id: <20181017082702.5581-7-armbru@redhat.com> --- include/hw/vfio/vfio-common.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 1d76303..1b434d0 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -31,7 +31,6 @@ #include #endif -#define ERR_PREFIX "vfio error: %s: " #define VFIO_MSG_PREFIX "vfio %s: " enum { -- cgit v1.1 From ab4f931e9f0a6e1c6dd6ecd79118efca418d941f Mon Sep 17 00:00:00 2001 From: Fei Li Date: Wed, 17 Oct 2018 10:26:50 +0200 Subject: ui: Convert vnc_display_init(), init_keyboard_layout() to Error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fei Li Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20181017082702.5581-27-armbru@redhat.com> Reviewed-by: Gerd Hoffmann --- include/ui/console.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/ui/console.h b/include/ui/console.h index fb969ca..c17803c 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -453,7 +453,7 @@ void qemu_display_early_init(DisplayOptions *opts); void qemu_display_init(DisplayState *ds, DisplayOptions *opts); /* vnc.c */ -void vnc_display_init(const char *id); +void vnc_display_init(const char *id, Error **errp); void vnc_display_open(const char *id, Error **errp); void vnc_display_add_client(const char *id, int csock, bool skipauth); int vnc_display_password(const char *id, const char *password); -- cgit v1.1 From 4f7ec696f4b124364c1b145dbe835984edc4c887 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 17 Oct 2018 10:26:52 +0200 Subject: numa: Clean up error reporting in parse_numa() Calling error_report() in a function that takes an Error ** argument is suspicious. parse_numa() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. While there, give parse_numa() internal linkage. Cc: Eduardo Habkost Signed-off-by: Markus Armbruster Reviewed-by: Eduardo Habkost Message-Id: <20181017082702.5581-29-armbru@redhat.com> --- include/sysemu/numa.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 7a0ae75..21713b7 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -22,7 +22,6 @@ struct NumaNodeMem { }; extern NodeInfo numa_info[MAX_NODES]; -int parse_numa(void *opaque, QemuOpts *opts, Error **errp); void parse_numa_opts(MachineState *ms); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[]); -- cgit v1.1 From d10e05f15d5c3dd5e5cc59c5dfff460d89d48580 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 17 Oct 2018 10:26:53 +0200 Subject: tpm: Clean up error reporting in tpm_init_tpmdev() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling error_report() in a function that takes an Error ** argument is suspicious. tpm_init_tpmdev() does that, and then fails without setting an error. Its caller main(), via tpm_init() and qemu_opts_foreach(), is fine with it, but clean it up anyway. Cc: Stefan Berger Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau Reviewed-by: Stefan Berger Message-Id: <20181017082702.5581-30-armbru@redhat.com> --- include/sysemu/tpm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 9ae1ab6..17a97ed 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -16,7 +16,7 @@ #include "qom/object.h" int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); -int tpm_init(void); +void tpm_init(void); void tpm_cleanup(void); typedef enum TPMVersion { -- cgit v1.1 From c4f26c9f37ce511e5fe629c21c180dc6eb7c5a25 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 17 Oct 2018 10:26:57 +0200 Subject: blockdev: Convert drive_new() to Error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling error_report() from within a function that takes an Error ** argument is suspicious. drive_new() calls error_report() even though it can run within drive_init_func(), which takes an Error ** argument. drive_init_func()'s caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway: * Convert drive_new() to Error * Update add_init_drive() to report the error received from drive_new() * Make main() pass &error_fatal through qemu_opts_foreach(), drive_init_func() to drive_new() * Make default_drive() pass &error_abort through qemu_opts_foreach(), drive_init_func() to drive_new() Cc: Kevin Wolf Cc: Max Reitz Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Max Reitz Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20181017082702.5581-34-armbru@redhat.com> --- include/sysemu/blockdev.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index 24954b9..d34c492 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -54,7 +54,8 @@ DriveInfo *drive_get_next(BlockInterfaceType type); QemuOpts *drive_def(const char *optstr); QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, const char *optstr); -DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type); +DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type, + Error **errp); /* device-hotplug */ -- cgit v1.1