qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v8 3/5] module: add Error arguments to module_load and module


From: Richard Henderson
Subject: Re: [PATCH v8 3/5] module: add Error arguments to module_load and module_load_qom
Date: Wed, 28 Sep 2022 08:38:06 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 9/28/22 05:29, Claudio Fontana wrote:
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>
---
  audio/audio.c         |  16 ++--
  block.c               |  20 +++-
  block/dmg.c           |  14 ++-
  hw/core/qdev.c        |  17 +++-
  include/qemu/module.h |  37 +++++++-
  qom/object.c          |  18 +++-
  softmmu/qtest.c       |   8 +-
  ui/console.c          |  18 +++-
  util/module.c         | 209 +++++++++++++++++++++++-------------------
  9 files changed, 234 insertions(+), 123 deletions(-)

LGTM,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]