All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] module fixes
@ 2020-07-20 10:03 Gerd Hoffmann
  2020-07-20 10:03 ` [PATCH 1/3] qxl: fix modular builds with dtrace Gerd Hoffmann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2020-07-20 10:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Gerd Hoffmann



Gerd Hoffmann (3):
  qxl: fix modular builds with dtrace
  module: ignore NULL type
  module: silence errors for module_load_qom_all().

 include/qemu/module.h |  8 ++++----
 hw/display/qxl.c      |  9 +++++++++
 softmmu/qtest.c       |  2 +-
 util/module.c         | 20 +++++++++++++-------
 4 files changed, 27 insertions(+), 12 deletions(-)

-- 
2.18.4



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

* [PATCH 1/3] qxl: fix modular builds with dtrace
  2020-07-20 10:03 [PATCH 0/3] module fixes Gerd Hoffmann
@ 2020-07-20 10:03 ` Gerd Hoffmann
  2020-07-20 10:03 ` [PATCH 2/3] module: ignore NULL type Gerd Hoffmann
  2020-07-20 10:03 ` [PATCH 3/3] module: silence errors for module_load_qom_all() Gerd Hoffmann
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2020-07-20 10:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Gerd Hoffmann

Checking the enable/disable state of tracepoints via
trace_event_get_state_backends() does not work for modules.

qxl checks the state for a small optimization (avoid g_strndup
call in case log_buf will not be used anyway), so we can just
drop that check for modular builds.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/qxl.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index d5627119ec62..11871340e75d 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -1762,7 +1762,16 @@ async_common:
         qxl_set_mode(d, val, 0);
         break;
     case QXL_IO_LOG:
+#ifdef CONFIG_MODULES
+        /*
+         * FIXME
+         * trace_event_get_state_backends() does not work for modules,
+         * it leads to "undefined symbol: qemu_qxl_io_log_semaphore"
+         */
+        if (true) {
+#else
         if (trace_event_get_state_backends(TRACE_QXL_IO_LOG) || d->guestdebug) {
+#endif
             /* We cannot trust the guest to NUL terminate d->ram->log_buf */
             char *log_buf = g_strndup((const char *)d->ram->log_buf,
                                       sizeof(d->ram->log_buf));
-- 
2.18.4



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

* [PATCH 2/3] module: ignore NULL type
  2020-07-20 10:03 [PATCH 0/3] module fixes Gerd Hoffmann
  2020-07-20 10:03 ` [PATCH 1/3] qxl: fix modular builds with dtrace Gerd Hoffmann
@ 2020-07-20 10:03 ` Gerd Hoffmann
  2020-07-20 10:03 ` [PATCH 3/3] module: silence errors for module_load_qom_all() Gerd Hoffmann
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2020-07-20 10:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Gerd Hoffmann

Just return in case module_load_qom_one(NULL) is called.
vga_interface_available() can do that.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 util/module.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/util/module.c b/util/module.c
index 90e9bd42c6c7..0ab00851f0a4 100644
--- a/util/module.c
+++ b/util/module.c
@@ -275,6 +275,9 @@ void module_load_qom_one(const char *type)
 {
     int i;
 
+    if (!type) {
+        return;
+    }
     if (module_loaded_qom_all) {
         return;
     }
-- 
2.18.4



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

* [PATCH 3/3] module: silence errors for module_load_qom_all().
  2020-07-20 10:03 [PATCH 0/3] module fixes Gerd Hoffmann
  2020-07-20 10:03 ` [PATCH 1/3] qxl: fix modular builds with dtrace Gerd Hoffmann
  2020-07-20 10:03 ` [PATCH 2/3] module: ignore NULL type Gerd Hoffmann
@ 2020-07-20 10:03 ` Gerd Hoffmann
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2020-07-20 10:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Gerd Hoffmann

Add mayfail bool parameter to module loading functions.  Set it to true
for module_load_qom_all() because device modules might not load into all
system emulation variants.  qemu-system-s390x for example will not load
qxl because it lacks vga support.  Makes "make check" less chatty.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/qemu/module.h |  8 ++++----
 softmmu/qtest.c       |  2 +-
 util/module.c         | 17 ++++++++++-------
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/include/qemu/module.h b/include/qemu/module.h
index 9121a475c1b6..944d403cbd15 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -61,15 +61,15 @@ typedef enum {
 #define fuzz_target_init(function) module_init(function, \
                                                MODULE_INIT_FUZZ_TARGET)
 #define migration_init(function) module_init(function, MODULE_INIT_MIGRATION)
-#define block_module_load_one(lib) module_load_one("block-", lib)
-#define ui_module_load_one(lib) module_load_one("ui-", lib)
-#define audio_module_load_one(lib) module_load_one("audio-", lib)
+#define block_module_load_one(lib) module_load_one("block-", lib, false)
+#define ui_module_load_one(lib) module_load_one("ui-", lib, false)
+#define audio_module_load_one(lib) module_load_one("audio-", lib, false)
 
 void register_module_init(void (*fn)(void), module_init_type type);
 void register_dso_module_init(void (*fn)(void), module_init_type type);
 
 void module_call_init(module_init_type type);
-bool module_load_one(const char *prefix, const char *lib_name);
+bool module_load_one(const char *prefix, const char *lib_name, bool mayfail);
 void module_load_qom_one(const char *type);
 void module_load_qom_all(void);
 
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 5672b75c354b..be81c9b9b83c 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -670,7 +670,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         g_assert(words[1] && words[2]);
 
         qtest_send_prefix(chr);
-        if (module_load_one(words[1], words[2])) {
+        if (module_load_one(words[1], words[2], false)) {
             qtest_sendf(chr, "OK\n");
         } else {
             qtest_sendf(chr, "FAIL\n");
diff --git a/util/module.c b/util/module.c
index 0ab00851f0a4..3c5fbd0bc8c1 100644
--- a/util/module.c
+++ b/util/module.c
@@ -109,7 +109,7 @@ void module_call_init(module_init_type type)
 }
 
 #ifdef CONFIG_MODULES
-static int module_load_file(const char *fname)
+static int module_load_file(const char *fname, bool mayfail)
 {
     GModule *g_module;
     void (*sym)(void);
@@ -133,8 +133,10 @@ static int module_load_file(const char *fname)
 
     g_module = g_module_open(fname, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
     if (!g_module) {
-        fprintf(stderr, "Failed to open module: %s\n",
-                g_module_error());
+        if (!mayfail) {
+            fprintf(stderr, "Failed to open module: %s\n",
+                    g_module_error());
+        }
         ret = -EINVAL;
         goto out;
     }
@@ -166,7 +168,7 @@ out:
 }
 #endif
 
-bool module_load_one(const char *prefix, const char *lib_name)
+bool module_load_one(const char *prefix, const char *lib_name, bool mayfail)
 {
     bool success = false;
 
@@ -223,7 +225,7 @@ bool module_load_one(const char *prefix, const char *lib_name)
     for (i = 0; i < n_dirs; i++) {
         fname = g_strdup_printf("%s/%s%s",
                 dirs[i], module_name, HOST_DSOSUF);
-        ret = module_load_file(fname);
+        ret = module_load_file(fname, mayfail);
         g_free(fname);
         fname = NULL;
         /* Try loading until loaded a module file */
@@ -284,7 +286,8 @@ void module_load_qom_one(const char *type)
     for (i = 0; i < ARRAY_SIZE(qom_modules); i++) {
         if (strcmp(qom_modules[i].type, type) == 0) {
             module_load_one(qom_modules[i].prefix,
-                            qom_modules[i].module);
+                            qom_modules[i].module,
+                            false);
             return;
         }
     }
@@ -305,7 +308,7 @@ void module_load_qom_all(void)
             /* one module implementing multiple types -> load only once */
             continue;
         }
-        module_load_one(qom_modules[i].prefix, qom_modules[i].module);
+        module_load_one(qom_modules[i].prefix, qom_modules[i].module, true);
     }
     module_loaded_qom_all = true;
 }
-- 
2.18.4



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

end of thread, other threads:[~2020-07-20 10:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20 10:03 [PATCH 0/3] module fixes Gerd Hoffmann
2020-07-20 10:03 ` [PATCH 1/3] qxl: fix modular builds with dtrace Gerd Hoffmann
2020-07-20 10:03 ` [PATCH 2/3] module: ignore NULL type Gerd Hoffmann
2020-07-20 10:03 ` [PATCH 3/3] module: silence errors for module_load_qom_all() Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.