qemu-devel
[Top][All Lists]
Advanced

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

Re: [RFC 3/3] qom: Improve error message in module_object_class_by_name(


From: Gerd Hoffmann
Subject: Re: [RFC 3/3] qom: Improve error message in module_object_class_by_name()
Date: Wed, 21 Jul 2021 11:54:45 +0200

>  ObjectClass *module_object_class_by_name(const char *typename)
>  {
>      ObjectClass *oc;
> @@ -1031,8 +1049,20 @@ ObjectClass *module_object_class_by_name(const char 
> *typename)
>      oc = object_class_by_name(typename);
>  #ifdef CONFIG_MODULES
>      if (!oc) {
> +        char *module_name;
>          module_load_qom_one(typename);
>          oc = object_class_by_name(typename);
> +        module_name = get_accel_module_name(typename);
> +        if (module_name) {
> +            if (!module_is_loaded(module_name)) {
> +                fprintf(stderr, "%s module is missing, install the "
> +                                "package or config the library path "
> +                                "correctly.\n", module_name);
> +                g_free(module_name);
> +                exit(1);
> +            }
> +            g_free(module_name);
> +        }

This error logging should IMHO be moved to util/module.c.  Either have a
helper function to print the error message, or have
module_load_qom_one() print it.

There is also no need to hard-code the module names.  We have the module
database and module_load_qom_one() uses it to figure which module must
be loaded for a specific qom object.  We can likewise use the database
for printing the error message.

take care,
  Gerd




reply via email to

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