All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] build qxl as module
@ 2020-06-04  7:59 Gerd Hoffmann
  2020-06-04  7:59 ` [PATCH 1/2] qdev: add support for device module loading Gerd Hoffmann
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2020-06-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: dinechin, Paolo Bonzini, Daniel P. Berrangé,
	Eduardo Habkost, Gerd Hoffmann



Gerd Hoffmann (2):
  qdev: add support for device module loading
  vga: build qxl as module

 Makefile.objs            |  1 +
 Makefile.target          |  7 ++++++
 include/hw/qdev-core.h   |  3 +++
 include/qemu/module.h    |  1 +
 hw/core/qdev.c           | 49 ++++++++++++++++++++++++++++++++++++++++
 qdev-monitor.c           |  5 ++++
 hw/Makefile.objs         |  1 +
 hw/display/Makefile.objs |  4 +++-
 8 files changed, 70 insertions(+), 1 deletion(-)

-- 
2.18.4



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

* [PATCH 1/2] qdev: add support for device module loading
  2020-06-04  7:59 [PATCH 0/2] build qxl as module Gerd Hoffmann
@ 2020-06-04  7:59 ` Gerd Hoffmann
  2020-06-04  7:59 ` [PATCH 2/2] vga: build qxl as module Gerd Hoffmann
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2020-06-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: dinechin, Paolo Bonzini, Daniel P. Berrangé,
	Eduardo Habkost, Gerd Hoffmann

When compiling devices as modules we'll need some infrastrtucture to
actually load those modules.  This patch adds it.

FIXME: Probably need to sprinkle a qdev_module_load_all() call somewhere
into monitor code to make QOM introspection work properly for modular
devices.  Didn't manage yet to find the place.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/qdev-core.h |  3 +++
 include/qemu/module.h  |  1 +
 hw/core/qdev.c         | 47 ++++++++++++++++++++++++++++++++++++++++++
 qdev-monitor.c         |  5 +++++
 4 files changed, 56 insertions(+)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index b870b279661a..a96c890bb95b 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -552,4 +552,7 @@ void device_listener_unregister(DeviceListener *listener);
  */
 bool qdev_should_hide_device(QemuOpts *opts);
 
+void qdev_module_load_type(const char *type);
+void qdev_module_load_all(void);
+
 #endif
diff --git a/include/qemu/module.h b/include/qemu/module.h
index 011ae1ae7605..077a6b09bca7 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -64,6 +64,7 @@ typedef enum {
 #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 hw_module_load_one(lib) module_load_one("hw-", lib)
 
 void register_module_init(void (*fn)(void), module_init_type type);
 void register_dso_module_init(void (*fn)(void), module_init_type type);
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 9e5538aeaebd..20e5c4cbafd8 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -146,10 +146,57 @@ DeviceState *qdev_create(BusState *bus, const char *name)
     return dev;
 }
 
+/*
+ * Building devices modular is mostly useful in case they have
+ * dependencies to external libraries.  Which is the case for very few
+ * devices.  So with the expecration that this will be rather the
+ * exception than to rule go with a simple hardcoded list for now ...
+ */
+static struct {
+    const char *type;
+    const char *mod;
+} const hwmodules[] = {
+};
+
+static bool qdev_module_loaded_all;
+
+void qdev_module_load_type(const char *type)
+{
+    int i;
+
+    fprintf(stderr, "%s: %s\n", __func__, type);
+    if (qdev_module_loaded_all) {
+        return;
+    }
+    for (i = 0; i < ARRAY_SIZE(hwmodules); i++) {
+        if (strcmp(hwmodules[i].type, type) == 0) {
+            hw_module_load_one(hwmodules[i].mod);
+            return;
+        }
+    }
+}
+
+void qdev_module_load_all(void)
+{
+    int i;
+
+    fprintf(stderr, "%s\n", __func__);
+    if (qdev_module_loaded_all) {
+        return;
+    }
+    for (i = 0; i < ARRAY_SIZE(hwmodules); i++) {
+        hw_module_load_one(hwmodules[i].mod);
+    }
+    qdev_module_loaded_all = true;
+}
+
 DeviceState *qdev_try_create(BusState *bus, const char *type)
 {
     DeviceState *dev;
 
+    if (object_class_by_name(type) == NULL) {
+        qdev_module_load_type(type);
+    }
     if (object_class_by_name(type) == NULL) {
         return NULL;
     }
diff --git a/qdev-monitor.c b/qdev-monitor.c
index a4735d3bb190..55dddeb2f978 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -147,6 +147,7 @@ static void qdev_print_devinfos(bool show_no_user)
     int i;
     bool cat_printed;
 
+    qdev_module_load_all();
     list = object_class_get_list_sorted(TYPE_DEVICE, false);
 
     for (i = 0; i <= DEVICE_CATEGORY_MAX; i++) {
@@ -224,6 +225,10 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
             oc = object_class_by_name(*driver);
         }
     }
+    if (!oc) {
+        qdev_module_load_type(*driver);
+        oc = object_class_by_name(*driver);
+    }
 
     if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) {
         if (*driver != original_name) {
-- 
2.18.4



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

* [PATCH 2/2] vga: build qxl as module
  2020-06-04  7:59 [PATCH 0/2] build qxl as module Gerd Hoffmann
  2020-06-04  7:59 ` [PATCH 1/2] qdev: add support for device module loading Gerd Hoffmann
@ 2020-06-04  7:59 ` Gerd Hoffmann
  2020-06-04  8:23 ` [PATCH 0/2] " no-reply
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2020-06-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: dinechin, Paolo Bonzini, Daniel P. Berrangé,
	Eduardo Habkost, Gerd Hoffmann

Open questions:
 * Do we want this be contigurable?  If so, how?  Does our miniconf
   support tristate Kconfig options?
 * The Makefile.target chunk feels quite hackish.  Better ideas anyone?

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 Makefile.objs            | 1 +
 Makefile.target          | 7 +++++++
 hw/core/qdev.c           | 2 ++
 hw/Makefile.objs         | 1 +
 hw/display/Makefile.objs | 4 +++-
 5 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Makefile.objs b/Makefile.objs
index 99774cfd2545..28c165c0e623 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -59,6 +59,7 @@ common-obj-y += migration/
 common-obj-y += audio/
 common-obj-m += audio/
 common-obj-y += hw/
+common-obj-m += hw/
 
 common-obj-y += replay/
 
diff --git a/Makefile.target b/Makefile.target
index 8ed1eba95b9c..c70325df5796 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -179,6 +179,13 @@ endif # CONFIG_SOFTMMU
 dummy := $(call unnest-vars,,obj-y)
 all-obj-y := $(obj-y)
 
+#
+# common-obj-m has some crap here, probably as side effect from
+# filling obj-y.  Clear it.  Fixes suspious dependency errors when
+# building devices as modules.
+#
+common-obj-m :=
+
 include $(SRC_PATH)/Makefile.objs
 dummy := $(call unnest-vars,.., \
                authz-obj-y \
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 20e5c4cbafd8..9ab30676fff7 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -156,6 +156,8 @@ static struct {
     const char *type;
     const char *mod;
 } const hwmodules[] = {
+    { .type = "qxl-vga",        .mod = "display-qxl"            },
+    { .type = "qxl",            .mod = "display-qxl"            },
 };
 
 static bool qdev_module_loaded_all;
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 660e2b437348..fdbc7b017487 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -43,4 +43,5 @@ devices-dirs-y += smbios/
 endif
 
 common-obj-y += $(devices-dirs-y)
+common-obj-m += display/
 obj-y += $(devices-dirs-y)
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
index 77a7d622bd2d..e2003d7083c2 100644
--- a/hw/display/Makefile.objs
+++ b/hw/display/Makefile.objs
@@ -44,7 +44,9 @@ common-obj-$(CONFIG_ARTIST) += artist.o
 
 obj-$(CONFIG_VGA) += vga.o
 
-common-obj-$(CONFIG_QXL) += qxl.o qxl-logger.o qxl-render.o
+#common-obj-$(CONFIG_QXL) += qxl.mo
+common-obj-m += qxl.mo
+qxl.mo-objs = qxl.o qxl-logger.o qxl-render.o
 
 obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o virtio-gpu-3d.o
 obj-$(CONFIG_VHOST_USER_GPU) += vhost-user-gpu.o
-- 
2.18.4



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

* Re: [PATCH 0/2] build qxl as module
  2020-06-04  7:59 [PATCH 0/2] build qxl as module Gerd Hoffmann
  2020-06-04  7:59 ` [PATCH 1/2] qdev: add support for device module loading Gerd Hoffmann
  2020-06-04  7:59 ` [PATCH 2/2] vga: build qxl as module Gerd Hoffmann
@ 2020-06-04  8:23 ` no-reply
  2020-06-04  8:30 ` no-reply
  2020-06-04  8:48 ` Daniel P. Berrangé
  4 siblings, 0 replies; 8+ messages in thread
From: no-reply @ 2020-06-04  8:23 UTC (permalink / raw)
  To: kraxel; +Cc: berrange, ehabkost, qemu-devel, kraxel, dinechin, pbonzini

Patchew URL: https://patchew.org/QEMU/20200604075943.7001-1-kraxel@redhat.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

Not run: 259
Failures: 127 267
Failed 2 of 119 iotests
make: *** [check-tests/check-block.sh] Error 1
Traceback (most recent call last):
  File "./tests/docker/docker.py", line 665, in <module>
    sys.exit(main())
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=91aa49358c8d4cdeb8843c69db56e178', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-pqbrir70/src/docker-src.2020-06-04-04.07.03.28898:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=91aa49358c8d4cdeb8843c69db56e178
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-pqbrir70/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    16m33.652s
user    0m9.001s


The full log is available at
http://patchew.org/logs/20200604075943.7001-1-kraxel@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

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

* Re: [PATCH 0/2] build qxl as module
  2020-06-04  7:59 [PATCH 0/2] build qxl as module Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2020-06-04  8:23 ` [PATCH 0/2] " no-reply
@ 2020-06-04  8:30 ` no-reply
  2020-06-04  8:48 ` Daniel P. Berrangé
  4 siblings, 0 replies; 8+ messages in thread
From: no-reply @ 2020-06-04  8:30 UTC (permalink / raw)
  To: kraxel; +Cc: berrange, ehabkost, qemu-devel, kraxel, dinechin, pbonzini

Patchew URL: https://patchew.org/QEMU/20200604075943.7001-1-kraxel@redhat.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===

  GEN     docs/interop/qemu-qmp-ref.7
In file included from /tmp/qemu-test/src/hw/display/qxl.h:10,
                 from /tmp/qemu-test/src/hw/display/qxl.c:37:
/tmp/qemu-test/src/include/ui/spice-display.h:21:10: fatal error: spice.h: No such file or directory
 #include <spice.h>
          ^~~~~~~~~
compilation terminated.
In file included from /tmp/qemu-test/src/hw/display/qxl.h:10,
                 from /tmp/qemu-test/src/hw/display/qxl-logger.c:24:
/tmp/qemu-test/src/include/ui/spice-display.h:21:10: fatal error: spice.h: No such file or directory
 #include <spice.h>
          ^~~~~~~~~
compilation terminated.
  AS      pc-bios/optionrom/multiboot.o
make: *** [/tmp/qemu-test/src/rules.mak:69: hw/display/qxl.o] Error 1
make: *** Waiting for unfinished jobs....
  AS      pc-bios/optionrom/linuxboot.o
make: *** [/tmp/qemu-test/src/rules.mak:69: hw/display/qxl-logger.o] Error 1
  CC      pc-bios/optionrom/linuxboot_dma.o
  AS      pc-bios/optionrom/kvmvapic.o
  AS      pc-bios/optionrom/pvh.o
---
  BUILD   pc-bios/optionrom/multiboot.img
In file included from /tmp/qemu-test/src/hw/display/qxl.h:10,
                 from /tmp/qemu-test/src/hw/display/qxl-render.c:23:
/tmp/qemu-test/src/include/ui/spice-display.h:21:10: fatal error: spice.h: No such file or directory
 #include <spice.h>
          ^~~~~~~~~
compilation terminated.
make: *** [/tmp/qemu-test/src/rules.mak:69: hw/display/qxl-render.o] Error 1
  BUILD   pc-bios/optionrom/linuxboot.img
  BUILD   pc-bios/optionrom/kvmvapic.img
  BUILD   pc-bios/optionrom/multiboot.raw
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=412fc17a4ab84b92b93a64f6f7c3365d', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-ef12sg7p/src/docker-src.2020-06-04-04.25.07.24568:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=412fc17a4ab84b92b93a64f6f7c3365d
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-ef12sg7p/src'
make: *** [docker-run-test-mingw@fedora] Error 2

real    4m56.687s
user    0m8.283s


The full log is available at
http://patchew.org/logs/20200604075943.7001-1-kraxel@redhat.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

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

* Re: [PATCH 0/2] build qxl as module
  2020-06-04  7:59 [PATCH 0/2] build qxl as module Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2020-06-04  8:30 ` no-reply
@ 2020-06-04  8:48 ` Daniel P. Berrangé
  2020-06-04  9:18   ` Gerd Hoffmann
  4 siblings, 1 reply; 8+ messages in thread
From: Daniel P. Berrangé @ 2020-06-04  8:48 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: dinechin, Paolo Bonzini, qemu-devel, Eduardo Habkost

On Thu, Jun 04, 2020 at 09:59:41AM +0200, Gerd Hoffmann wrote:
>

There's no info here, or in the commit message about the
intended goal of this modularization ? If we're modularizing
devices, why only qxl and not other devices too ?

> 
> Gerd Hoffmann (2):
>   qdev: add support for device module loading
>   vga: build qxl as module
> 
>  Makefile.objs            |  1 +
>  Makefile.target          |  7 ++++++
>  include/hw/qdev-core.h   |  3 +++
>  include/qemu/module.h    |  1 +
>  hw/core/qdev.c           | 49 ++++++++++++++++++++++++++++++++++++++++
>  qdev-monitor.c           |  5 ++++
>  hw/Makefile.objs         |  1 +
>  hw/display/Makefile.objs |  4 +++-
>  8 files changed, 70 insertions(+), 1 deletion(-)
> 
> -- 
> 2.18.4
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH 0/2] build qxl as module
  2020-06-04  8:48 ` Daniel P. Berrangé
@ 2020-06-04  9:18   ` Gerd Hoffmann
  2020-06-04 11:10     ` Gerd Hoffmann
  0 siblings, 1 reply; 8+ messages in thread
From: Gerd Hoffmann @ 2020-06-04  9:18 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: dinechin, Paolo Bonzini, qemu-devel, Eduardo Habkost

On Thu, Jun 04, 2020 at 09:48:20AM +0100, Daniel P. Berrangé wrote:
> On Thu, Jun 04, 2020 at 09:59:41AM +0200, Gerd Hoffmann wrote:
> >
> 
> There's no info here, or in the commit message about the
> intended goal of this modularization ? If we're modularizing
> devices, why only qxl and not other devices too ?

Same reason we created all the other modules:  Reduce shared library
dependencies of core qemu.  In this case: spice.  This mini-series
alone isn't enough for that, but it should make it easier to make qemu
spice support modular (Christophe looks into that).

Other candidates:
  * virtio-gpu (libvirglrenderer.so).
  * ccid-card-emulated (libcacard.so).

cheers,
  Gerd



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

* Re: [PATCH 0/2] build qxl as module
  2020-06-04  9:18   ` Gerd Hoffmann
@ 2020-06-04 11:10     ` Gerd Hoffmann
  0 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2020-06-04 11:10 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: dinechin, Paolo Bonzini, qemu-devel, Eduardo Habkost

> Other candidates:
>   * virtio-gpu (libvirglrenderer.so).
>   * ccid-card-emulated (libcacard.so).

 * usb-redir (libusbredir.so)
 * usb-host (libusb.so)

usb-host also has a monitor command ("info usbhost").  This uses libusb
too so leaving that in core qemu would be pointless.  So for that one
we'll also need some way for modules to dynamically register monitor
commands.

cheers,
  Gerd



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

end of thread, other threads:[~2020-06-04 11:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04  7:59 [PATCH 0/2] build qxl as module Gerd Hoffmann
2020-06-04  7:59 ` [PATCH 1/2] qdev: add support for device module loading Gerd Hoffmann
2020-06-04  7:59 ` [PATCH 2/2] vga: build qxl as module Gerd Hoffmann
2020-06-04  8:23 ` [PATCH 0/2] " no-reply
2020-06-04  8:30 ` no-reply
2020-06-04  8:48 ` Daniel P. Berrangé
2020-06-04  9:18   ` Gerd Hoffmann
2020-06-04 11:10     ` 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.