Skip to contentSkip to conversation

build qxl as module

PATCH Superseded Gerd Hoffmann 3 participants 8 messages Jun 4, 2020 Kbuild

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover build qxl as module

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(-)
Signature · 1 line
2.18.4
#1 lore raw

PATCH 1/2 qdev: add support for device module loading

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.

---
 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(+)
include/hw/qdev-core.h +3 -0
index b870b279661a..a96c890bb95b 100644
@@ -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
include/qemu/module.h +1 -0
index 011ae1ae7605..077a6b09bca7 100644
@@ -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);
hw/core/qdev.c +47 -0

57 lines not on this page · raw message

qdev-monitor.c +5 -0
index a4735d3bb190..55dddeb2f978 100644
@@ -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) {
Signature · 1 line
2.18.4
#2 lore raw

PATCH 2/2 vga: build qxl as module

In reply to 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?

---
 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(-)
Makefile.objs +1 -0
index 99774cfd2545..28c165c0e623 100644
@@ -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/
 
Makefile.target +7 -0
index 8ed1eba95b9c..c70325df5796 100644
@@ -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 \
hw/core/qdev.c +2 -0
index 20e5c4cbafd8..9ab30676fff7 100644
@@ -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;
hw/Makefile.objs +1 -0
index 660e2b437348..fdbc7b017487 100644
@@ -43,4 +43,5 @@ devices-dirs-y += smbios/
 endif
 
 common-obj-y += $(devices-dirs-y)
+common-obj-m += display/
 obj-y += $(devices-dirs-y)
hw/display/Makefile.objs +3 -1
index 77a7d622bd2d..e2003d7083c2 100644
@@ -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
Signature · 1 line
2.18.4
#3 lore raw
In reply to Gerd Hoffmann
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

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/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#4 lore raw
In reply to Gerd Hoffmann
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

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/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#5 lore raw
In reply to Gerd Hoffmann
Quoted 1 line · Gerd Hoffmann

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 ?

Quoted 5 lines

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

Quoted 13 lines
 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(-)
Signature · 1 line
2.18.4

Regards,
Daniel

Signature · 3 lines
|: 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 :|
#6 lore raw
Quoted 6 lines · Daniel P. Berrangé
Quoted 1 line · Gerd Hoffmann

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

#7 lore raw
Quoted 3 lines

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