aboutsummaryrefslogtreecommitdiff
path: root/ui/console.c
diff options
context:
space:
mode:
authorClaudio Fontana <cfontana@suse.de>2022-09-29 11:30:33 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2022-11-06 09:48:50 +0100
commitc551fb0b53db5d9a1f0116e8cce12f994605c9ea (patch)
tree3ac62766e92f14c5e954bf2a82d926afb995344e /ui/console.c
parentdbc0e80553c067f56cb236d9de2cd0d50f3c6131 (diff)
downloadqemu-c551fb0b53db5d9a1f0116e8cce12f994605c9ea.zip
qemu-c551fb0b53db5d9a1f0116e8cce12f994605c9ea.tar.gz
qemu-c551fb0b53db5d9a1f0116e8cce12f994605c9ea.tar.bz2
module: add Error arguments to module_load and module_load_qom
improve error handling during module load, by changing: bool module_load(const char *prefix, const char *lib_name); void module_load_qom(const char *type); to: int module_load(const char *prefix, const char *name, Error **errp); int module_load_qom(const char *type, Error **errp); where the return value is: -1 on module load error, and errp is set with the error 0 on module or one of its dependencies are not installed 1 on module load success 2 on module load success (module already loaded or built-in) module_load_qom_one has been introduced in: commit 28457744c345 ("module: qom module support"), which built on top of module_load_one, but discarded the bool return value. Restore it. Adapt all callers to emit errors, or ignore them, or fail hard, as appropriate in each context. Replace the previous emission of errors via fprintf in _some_ error conditions with Error and error_report, so as to emit to the appropriate target. A memory leak is also fixed as part of the module_load changes. audio: when attempting to load an audio module, report module load errors. Note that still for some callers, a single issue may generate multiple error reports, and this could be improved further. Regarding the audio code itself, audio_add() seems to ignore errors, and this should probably be improved. block: when attempting to load a block module, report module load errors. For the code paths that already use the Error API, take advantage of those to report module load errors into the Error parameter. For the other code paths, we currently emit the error, but this could be improved further by adding Error parameters to all possible code paths. console: when attempting to load a display module, report module load errors. qdev: when creating a new qdev Device object (DeviceState), report load errors. If a module cannot be loaded to create that device, now abort execution (if no CONFIG_MODULE) or exit (if CONFIG_MODULE). qom/object.c: when initializing a QOM object, or looking up class_by_name, report module load errors. qtest: when processing the "module_load" qtest command, report errors in the load of the module. Signed-off-by: Claudio Fontana <cfontana@suse.de> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220929093035.4231-4-cfontana@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'ui/console.c')
-rw-r--r--ui/console.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/ui/console.c b/ui/console.c
index 44dfb0f..3c0d9b0 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2632,7 +2632,11 @@ bool qemu_display_find_default(DisplayOptions *opts)
for (i = 0; i < (int)ARRAY_SIZE(prio); i++) {
if (dpys[prio[i]] == NULL) {
- ui_module_load(DisplayType_str(prio[i]));
+ Error *local_err = NULL;
+ int rv = ui_module_load(DisplayType_str(prio[i]), &local_err);
+ if (rv < 0) {
+ error_report_err(local_err);
+ }
}
if (dpys[prio[i]] == NULL) {
continue;
@@ -2650,7 +2654,11 @@ void qemu_display_early_init(DisplayOptions *opts)
return;
}
if (dpys[opts->type] == NULL) {
- ui_module_load(DisplayType_str(opts->type));
+ Error *local_err = NULL;
+ int rv = ui_module_load(DisplayType_str(opts->type), &local_err);
+ if (rv < 0) {
+ error_report_err(local_err);
+ }
}
if (dpys[opts->type] == NULL) {
error_report("Display '%s' is not available.",
@@ -2680,7 +2688,11 @@ void qemu_display_help(void)
printf("none\n");
for (idx = DISPLAY_TYPE_NONE; idx < DISPLAY_TYPE__MAX; idx++) {
if (!dpys[idx]) {
- ui_module_load(DisplayType_str(idx));
+ Error *local_err = NULL;
+ int rv = ui_module_load(DisplayType_str(idx), &local_err);
+ if (rv < 0) {
+ error_report_err(local_err);
+ }
}
if (dpys[idx]) {
printf("%s\n", DisplayType_str(dpys[idx]->type));