qemu-s390x
[Top][All Lists]
Advanced

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

Re: [PATCH v2 1/1] hw/s390x: modularize virtio-gpu-ccw


From: Gerd Hoffmann
Subject: Re: [PATCH v2 1/1] hw/s390x: modularize virtio-gpu-ccw
Date: Wed, 3 Mar 2021 08:07:50 +0100

  Hi,

> The only approaches I can think of to make type_register_mayfail()
> "work" involve adding a dependency check in type_register_internal()
> before the call to type_table_add() is made. This can "work" for modules,
> because for types loaded from we can hope, that all dependencies are
> already, as modules are loaded relatively late.

Yes, for modules the lazy binding should not be needed and we should be
able to check for the parent at registration time.  module.c keeps track
of whenever phase1 init for builtin qom objects did happen already, so
we can use that instead of passing mayfail through a bunch of function
calls.  Quick & dirty test hack below.

BTW: "qemu-system-x86_64 -device help" tries to load all modules and is
a nice test case ;)

HTH,
  Gerd

commit 75ca3012e626318b562bcb51ecdc34400e25f2d0
Author: Gerd Hoffmann <kraxel@redhat.com>
Date:   Tue Mar 2 16:26:39 2021 +0100

    [hack] modular type init check

diff --git a/qom/object.c b/qom/object.c
index 491823db4a2d..01785e73f495 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -135,11 +135,22 @@ static TypeImpl *type_new(const TypeInfo *info)
     return ti;
 }
 
+/* HACK: util/module.c */
+extern bool modules_init_done[MODULE_INIT_MAX];
+static TypeImpl *type_get_by_name(const char *name);
+
 static TypeImpl *type_register_internal(const TypeInfo *info)
 {
     TypeImpl *ti;
     ti = type_new(info);
 
+    if (modules_init_done[MODULE_INIT_QOM]) {
+        if (ti->parent && !type_get_by_name(ti->parent)) {
+            g_free(ti);
+            return NULL;
+        }
+    }
+
     type_table_add(ti);
     return ti;
 }
diff --git a/util/module.c b/util/module.c
index cbe89fede628..b7b519eed62c 100644
--- a/util/module.c
+++ b/util/module.c
@@ -34,7 +34,7 @@ typedef struct ModuleEntry
 typedef QTAILQ_HEAD(, ModuleEntry) ModuleTypeList;
 
 static ModuleTypeList init_type_list[MODULE_INIT_MAX];
-static bool modules_init_done[MODULE_INIT_MAX];
+bool modules_init_done[MODULE_INIT_MAX];
 
 static ModuleTypeList dso_init_list;
 




reply via email to

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