qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] accel: print an error message and exit if plugin not loaded
@ 2022-09-05 10:13 Claudio Fontana
  2022-09-05 12:06 ` Richard Henderson
  0 siblings, 1 reply; 9+ messages in thread
From: Claudio Fontana @ 2022-09-05 10:13 UTC (permalink / raw)
  To: Richard Henderson, Paolo Bonzini; +Cc: Claudio Fontana, qemu-devel

If module_load_one, module_load_file fail for any reason
(permissions, plugin not installed, ...), we need to provide some notification
to the user to understand that this is happening; otherwise the errors
reported on initialization will make no sense to the user.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
---
 accel/accel-softmmu.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/accel/accel-softmmu.c b/accel/accel-softmmu.c
index 67276e4f52..807708ee86 100644
--- a/accel/accel-softmmu.c
+++ b/accel/accel-softmmu.c
@@ -66,15 +66,21 @@ void accel_init_ops_interfaces(AccelClass *ac)
 {
     const char *ac_name;
     char *ops_name;
+    ObjectClass *oc;
     AccelOpsClass *ops;
 
     ac_name = object_class_get_name(OBJECT_CLASS(ac));
     g_assert(ac_name != NULL);
 
     ops_name = g_strdup_printf("%s" ACCEL_OPS_SUFFIX, ac_name);
-    ops = ACCEL_OPS_CLASS(module_object_class_by_name(ops_name));
+    oc = module_object_class_by_name(ops_name);
+    if (!oc) {
+        error_report("fatal: could not find module object of type \"%s\", "
+                     "plugin might not be loaded correctly", ops_name);
+        exit(EXIT_FAILURE);
+    }
     g_free(ops_name);
-
+    ops = ACCEL_OPS_CLASS(oc);
     /*
      * all accelerators need to define ops, providing at least a mandatory
      * non-NULL create_vcpu_thread operation.
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-09-07  7:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-05 10:13 [PATCH] accel: print an error message and exit if plugin not loaded Claudio Fontana
2022-09-05 12:06 ` Richard Henderson
2022-09-05 14:36   ` Claudio Fontana
2022-09-05 15:43     ` Claudio Fontana
2022-09-05 16:07       ` Richard Henderson
2022-09-06  9:53       ` Gerd Hoffmann
2022-09-06 11:59         ` Claudio Fontana
2022-09-06 12:14           ` Claudio Fontana
2022-09-07  7:46             ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).