All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 00/10] Modules 20200702 patches
@ 2020-07-02 12:20 Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 01/10] module: qom module support Gerd Hoffmann
                   ` (11 more replies)
  0 siblings, 12 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

The following changes since commit fc1bff958998910ec8d25db86cd2f53ff125f7ab:

  hw/misc/pca9552: Add missing TypeInfo::class_size field (2020-06-29 21:16:10 +0100)

are available in the Git repository at:

  git://git.kraxel.org/qemu tags/modules-20200702-pull-request

for you to fetch changes up to 474a5d66036d18ee5ccaa88364660d05bf32127b:

  chardev: enable modules, use for braille (2020-07-01 21:08:11 +0200)

----------------------------------------------------------------
qom: add support for qom objects in modules.
build some devices (qxl, virtio-gpu, ccid, usb-redir) as modules.
build braille chardev as module.

note: qemu doesn't rebuild objects on cflags changes (specifically
      -fPIC being added when code is switched from builtin to module).
      Workaround for resulting build errors: "make clean", rebuild.

----------------------------------------------------------------

Gerd Hoffmann (10):
  module: qom module support
  object: qom module support
  qdev: device module support
  build: fix device module builds
  ccid: build smartcard as module
  usb: build usb-redir as module
  vga: build qxl as module
  vga: build virtio-gpu only once
  vga: build virtio-gpu as module
  chardev: enable modules, use for braille

 Makefile.objs            |  2 ++
 Makefile.target          |  7 +++++
 include/qemu/module.h    |  2 ++
 include/qom/object.h     | 12 +++++++
 chardev/char.c           |  2 +-
 hw/core/qdev.c           |  6 ++--
 qdev-monitor.c           |  5 +--
 qom/object.c             | 14 +++++++++
 qom/qom-qmp-cmds.c       |  3 +-
 softmmu/vl.c             |  4 +--
 util/module.c            | 67 ++++++++++++++++++++++++++++++++++++++++
 chardev/Makefile.objs    |  5 ++-
 hw/Makefile.objs         |  2 ++
 hw/display/Makefile.objs | 28 ++++++++++-------
 hw/usb/Makefile.objs     | 13 +++++---
 15 files changed, 148 insertions(+), 24 deletions(-)

-- 
2.18.4



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

* [PULL 01/10] module: qom module support
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
@ 2020-07-02 12:20 ` Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 02/10] object: " Gerd Hoffmann
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

Add support for qom types provided by modules.  For starters use a
manually maintained list which maps qom type to module and prefix.

Two load functions are added:  One to load the module for a specific
type, and one to load all modules (needed for object/device lists as
printed by -- for example -- qemu -device help).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-2-kraxel@redhat.com
---
 include/qemu/module.h |  2 ++
 util/module.c         | 55 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/include/qemu/module.h b/include/qemu/module.h
index 011ae1ae7605..9121a475c1b6 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -70,5 +70,7 @@ 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);
+void module_load_qom_one(const char *type);
+void module_load_qom_all(void);
 
 #endif
diff --git a/util/module.c b/util/module.c
index e48d9aacc05a..ee560a4b4269 100644
--- a/util/module.c
+++ b/util/module.c
@@ -245,3 +245,58 @@ bool module_load_one(const char *prefix, const char *lib_name)
 #endif
     return success;
 }
+
+/*
+ * Building devices and other qom objects modular is mostly useful in
+ * case they have dependencies to external shared libraries, so we can
+ * cut down the core qemu library dependencies.  Which is the case for
+ * only a very few devices & objects.
+ *
+ * So with the expectation that this will be rather the exception than
+ * to rule and the list will not gain that many entries go with a
+ * simple manually maintained list for now.
+ */
+static struct {
+    const char *type;
+    const char *prefix;
+    const char *module;
+} const qom_modules[] = {
+};
+
+static bool module_loaded_qom_all;
+
+void module_load_qom_one(const char *type)
+{
+    int i;
+
+    if (module_loaded_qom_all) {
+        return;
+    }
+    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);
+            return;
+        }
+    }
+}
+
+void module_load_qom_all(void)
+{
+    int i;
+
+    if (module_loaded_qom_all) {
+        return;
+    }
+    for (i = 0; i < ARRAY_SIZE(qom_modules); i++) {
+        if (i > 0 && (strcmp(qom_modules[i - 1].module,
+                             qom_modules[i].module) == 0 &&
+                      strcmp(qom_modules[i - 1].prefix,
+                             qom_modules[i].prefix) == 0)) {
+            /* one module implementing multiple types -> load only once */
+            continue;
+        }
+        module_load_one(qom_modules[i].prefix, qom_modules[i].module);
+    }
+    module_loaded_qom_all = true;
+}
-- 
2.18.4



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

* [PULL 02/10] object: qom module support
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 01/10] module: qom module support Gerd Hoffmann
@ 2020-07-02 12:20 ` Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 03/10] qdev: device " Gerd Hoffmann
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

Little helper function to load modules on demand.  In most cases adding
module loading support for devices and other objects is just
s/object_class_by_name/module_object_class_by_name/ in the right spot.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-3-kraxel@redhat.com
---
 include/qom/object.h | 12 ++++++++++++
 qom/object.c         | 14 ++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index 94a61ccc3fe8..51f188137f1f 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -994,6 +994,18 @@ bool object_class_is_abstract(ObjectClass *klass);
  */
 ObjectClass *object_class_by_name(const char *typename);
 
+/**
+ * module_object_class_by_name:
+ * @typename: The QOM typename to obtain the class for.
+ *
+ * For objects which might be provided by a module.  Behaves like
+ * object_class_by_name, but additionally tries to load the module
+ * needed in case the class is not available.
+ *
+ * Returns: The class for @typename or %NULL if not found.
+ */
+ObjectClass *module_object_class_by_name(const char *typename);
+
 void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
                           const char *implements_type, bool include_abstract,
                           void *opaque);
diff --git a/qom/object.c b/qom/object.c
index 6ece96bc2bfc..34daaf1280f5 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -985,6 +985,20 @@ ObjectClass *object_class_by_name(const char *typename)
     return type->class;
 }
 
+ObjectClass *module_object_class_by_name(const char *typename)
+{
+    ObjectClass *oc;
+
+    oc = object_class_by_name(typename);
+#ifdef CONFIG_MODULES
+    if (!oc) {
+        module_load_qom_one(typename);
+        oc = object_class_by_name(typename);
+    }
+#endif
+    return oc;
+}
+
 ObjectClass *object_class_get_parent(ObjectClass *class)
 {
     TypeImpl *type = type_get_parent(class->type);
-- 
2.18.4



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

* [PULL 03/10] qdev: device module support
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 01/10] module: qom module support Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 02/10] object: " Gerd Hoffmann
@ 2020-07-02 12:20 ` Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 04/10] build: fix device module builds Gerd Hoffmann
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

Hook module loading into the places where we
need it when building devices as modules.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-4-kraxel@redhat.com
---
 hw/core/qdev.c     | 6 ++++--
 qdev-monitor.c     | 5 +++--
 qom/qom-qmp-cmds.c | 3 ++-
 softmmu/vl.c       | 4 ++--
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 2131c7f951dd..9de16eae05b7 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -137,6 +137,9 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
  */
 DeviceState *qdev_new(const char *name)
 {
+    if (!object_class_by_name(name)) {
+        module_load_qom_one(name);
+    }
     return DEVICE(object_new(name));
 }
 
@@ -147,10 +150,9 @@ DeviceState *qdev_new(const char *name)
  */
 DeviceState *qdev_try_new(const char *name)
 {
-    if (!object_class_by_name(name)) {
+    if (!module_object_class_by_name(name)) {
         return NULL;
     }
-
     return DEVICE(object_new(name));
 }
 
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 22da107484c5..8e7a7f7bbdbc 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;
 
+    module_load_qom_all();
     list = object_class_get_list_sorted(TYPE_DEVICE, false);
 
     for (i = 0; i <= DEVICE_CATEGORY_MAX; i++) {
@@ -215,13 +216,13 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
     DeviceClass *dc;
     const char *original_name = *driver;
 
-    oc = object_class_by_name(*driver);
+    oc = module_object_class_by_name(*driver);
     if (!oc) {
         const char *typename = find_typename_by_alias(*driver);
 
         if (typename) {
             *driver = typename;
-            oc = object_class_by_name(*driver);
+            oc = module_object_class_by_name(*driver);
         }
     }
 
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index c5249e44d020..5e2c8cbf333f 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -116,6 +116,7 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
 {
     ObjectTypeInfoList *ret = NULL;
 
+    module_load_qom_all();
     object_class_foreach(qom_list_types_tramp, implements, abstract, &ret);
 
     return ret;
@@ -130,7 +131,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename,
     ObjectPropertyIterator iter;
     ObjectPropertyInfoList *prop_list = NULL;
 
-    klass = object_class_by_name(typename);
+    klass = module_object_class_by_name(typename);
     if (klass == NULL) {
         error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
                   "Device '%s' not found", typename);
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 3e15ee243572..5acb65d7f48c 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -1772,8 +1772,8 @@ static bool vga_interface_available(VGAInterfaceType t)
 
     assert(t < VGA_TYPE_MAX);
     return !ti->class_names[0] ||
-           object_class_by_name(ti->class_names[0]) ||
-           object_class_by_name(ti->class_names[1]);
+           module_object_class_by_name(ti->class_names[0]) ||
+           module_object_class_by_name(ti->class_names[1]);
 }
 
 static const char *
-- 
2.18.4



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

* [PULL 04/10] build: fix device module builds
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2020-07-02 12:20 ` [PULL 03/10] qdev: device " Gerd Hoffmann
@ 2020-07-02 12:20 ` Gerd Hoffmann
  2020-07-03  9:01   ` Claudio Fontana
  2020-07-02 12:20 ` [PULL 05/10] ccid: build smartcard as module Gerd Hoffmann
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

See comment.  Feels quite hackish.  Better ideas anyone?

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-5-kraxel@redhat.com
---
 Makefile.target | 7 +++++++
 1 file changed, 7 insertions(+)

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 \
-- 
2.18.4



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

* [PULL 05/10] ccid: build smartcard as module
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2020-07-02 12:20 ` [PULL 04/10] build: fix device module builds Gerd Hoffmann
@ 2020-07-02 12:20 ` Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 06/10] usb: build usb-redir " Gerd Hoffmann
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

Drops libcacard.so dependency from core qemu.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-6-kraxel@redhat.com
---
 Makefile.objs        | 1 +
 util/module.c        | 2 ++
 hw/Makefile.objs     | 1 +
 hw/usb/Makefile.objs | 4 +++-
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/Makefile.objs b/Makefile.objs
index 98383972eef3..3d45492d8b46 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/util/module.c b/util/module.c
index ee560a4b4269..89da9a3cce05 100644
--- a/util/module.c
+++ b/util/module.c
@@ -261,6 +261,8 @@ static struct {
     const char *prefix;
     const char *module;
 } const qom_modules[] = {
+    { "ccid-card-passthru",    "hw-", "usb-smartcard"         },
+    { "ccid-card-emulated",    "hw-", "usb-smartcard"         },
 };
 
 static bool module_loaded_qom_all;
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 4cbe5e4e57d6..af8fd9a510ed 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 += usb/
 obj-y += $(devices-dirs-y)
diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs
index fa5c3fa1b877..3c5b3d4fadd3 100644
--- a/hw/usb/Makefile.objs
+++ b/hw/usb/Makefile.objs
@@ -29,11 +29,13 @@ common-obj-$(CONFIG_USB_NETWORK)      += dev-network.o
 
 ifeq ($(CONFIG_USB_SMARTCARD),y)
 common-obj-y                          += dev-smartcard-reader.o
-common-obj-$(CONFIG_SMARTCARD)        += smartcard.mo
+ifeq ($(CONFIG_SMARTCARD),y)
+common-obj-m                          += smartcard.mo
 smartcard.mo-objs := ccid-card-passthru.o ccid-card-emulated.o
 smartcard.mo-cflags := $(SMARTCARD_CFLAGS)
 smartcard.mo-libs := $(SMARTCARD_LIBS)
 endif
+endif
 
 ifeq ($(CONFIG_POSIX),y)
 common-obj-$(CONFIG_USB_STORAGE_MTP)  += dev-mtp.o
-- 
2.18.4



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

* [PULL 06/10] usb: build usb-redir as module
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2020-07-02 12:20 ` [PULL 05/10] ccid: build smartcard as module Gerd Hoffmann
@ 2020-07-02 12:20 ` Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 07/10] vga: build qxl " Gerd Hoffmann
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

Drops libusbredirparser.so dependency from core qemu.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-7-kraxel@redhat.com
---
 util/module.c        | 1 +
 hw/usb/Makefile.objs | 9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/util/module.c b/util/module.c
index 89da9a3cce05..e3226165e91c 100644
--- a/util/module.c
+++ b/util/module.c
@@ -263,6 +263,7 @@ static struct {
 } const qom_modules[] = {
     { "ccid-card-passthru",    "hw-", "usb-smartcard"         },
     { "ccid-card-emulated",    "hw-", "usb-smartcard"         },
+    { "usb-redir",             "hw-", "usb-redirect"          },
 };
 
 static bool module_loaded_qom_all;
diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs
index 3c5b3d4fadd3..e342ff59fab0 100644
--- a/hw/usb/Makefile.objs
+++ b/hw/usb/Makefile.objs
@@ -43,9 +43,12 @@ endif
 
 # usb redirection
 ifeq ($(CONFIG_USB),y)
-common-obj-$(CONFIG_USB_REDIR) += redirect.o quirks.o
-redirect.o-cflags = $(USB_REDIR_CFLAGS)
-redirect.o-libs = $(USB_REDIR_LIBS)
+ifeq ($(CONFIG_USB_REDIR),y)
+common-obj-m += redirect.mo
+redirect.mo-objs = redirect.o quirks.o
+redirect.mo-cflags = $(USB_REDIR_CFLAGS)
+redirect.mo-libs = $(USB_REDIR_LIBS)
+endif
 endif
 
 # usb pass-through
-- 
2.18.4



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

* [PULL 07/10] vga: build qxl as module
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2020-07-02 12:20 ` [PULL 06/10] usb: build usb-redir " Gerd Hoffmann
@ 2020-07-02 12:20 ` Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 08/10] vga: build virtio-gpu only once Gerd Hoffmann
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

First step in making spice support modular.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-8-kraxel@redhat.com
---
 util/module.c            | 2 ++
 hw/Makefile.objs         | 1 +
 hw/display/Makefile.objs | 5 ++++-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/util/module.c b/util/module.c
index e3226165e91c..7c76d2a84b94 100644
--- a/util/module.c
+++ b/util/module.c
@@ -264,6 +264,8 @@ static struct {
     { "ccid-card-passthru",    "hw-", "usb-smartcard"         },
     { "ccid-card-emulated",    "hw-", "usb-smartcard"         },
     { "usb-redir",             "hw-", "usb-redirect"          },
+    { "qxl-vga",               "hw-", "display-qxl"           },
+    { "qxl",                   "hw-", "display-qxl"           },
 };
 
 static bool module_loaded_qom_all;
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index af8fd9a510ed..14b7ea4eb62e 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -43,5 +43,6 @@ devices-dirs-y += smbios/
 endif
 
 common-obj-y += $(devices-dirs-y)
+common-obj-m += display/
 common-obj-m += usb/
 obj-y += $(devices-dirs-y)
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
index 77a7d622bd2d..76b3571e4902 100644
--- a/hw/display/Makefile.objs
+++ b/hw/display/Makefile.objs
@@ -44,7 +44,10 @@ common-obj-$(CONFIG_ARTIST) += artist.o
 
 obj-$(CONFIG_VGA) += vga.o
 
-common-obj-$(CONFIG_QXL) += qxl.o qxl-logger.o qxl-render.o
+ifeq ($(CONFIG_QXL),y)
+common-obj-m += qxl.mo
+qxl.mo-objs = qxl.o qxl-logger.o qxl-render.o
+endif
 
 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] 23+ messages in thread

* [PULL 08/10] vga: build virtio-gpu only once
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
                   ` (6 preceding siblings ...)
  2020-07-02 12:20 ` [PULL 07/10] vga: build qxl " Gerd Hoffmann
@ 2020-07-02 12:20 ` Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 09/10] vga: build virtio-gpu as module Gerd Hoffmann
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200624131045.14512-9-kraxel@redhat.com
---
 hw/display/Makefile.objs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
index 76b3571e4902..d619594ad4d3 100644
--- a/hw/display/Makefile.objs
+++ b/hw/display/Makefile.objs
@@ -49,12 +49,12 @@ common-obj-m += qxl.mo
 qxl.mo-objs = qxl.o qxl-logger.o qxl-render.o
 endif
 
-obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o virtio-gpu-3d.o
-obj-$(CONFIG_VHOST_USER_GPU) += vhost-user-gpu.o
-obj-$(call land,$(CONFIG_VIRTIO_GPU),$(CONFIG_VIRTIO_PCI)) += virtio-gpu-pci.o
-obj-$(call land,$(CONFIG_VHOST_USER_GPU),$(CONFIG_VIRTIO_PCI)) += vhost-user-gpu-pci.o
-obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o
-obj-$(CONFIG_VHOST_USER_VGA) += vhost-user-vga.o
+common-obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o virtio-gpu-3d.o
+common-obj-$(CONFIG_VHOST_USER_GPU) += vhost-user-gpu.o
+common-obj-$(call land,$(CONFIG_VIRTIO_GPU),$(CONFIG_VIRTIO_PCI)) += virtio-gpu-pci.o
+common-obj-$(call land,$(CONFIG_VHOST_USER_GPU),$(CONFIG_VIRTIO_PCI)) += vhost-user-gpu-pci.o
+common-obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o
+common-obj-$(CONFIG_VHOST_USER_VGA) += vhost-user-vga.o
 virtio-gpu.o-cflags := $(VIRGL_CFLAGS)
 virtio-gpu.o-libs += $(VIRGL_LIBS)
 virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS)
-- 
2.18.4



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

* [PULL 09/10] vga: build virtio-gpu as module
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
                   ` (7 preceding siblings ...)
  2020-07-02 12:20 ` [PULL 08/10] vga: build virtio-gpu only once Gerd Hoffmann
@ 2020-07-02 12:20 ` Gerd Hoffmann
  2020-07-02 12:20 ` [PULL 10/10] chardev: enable modules, use for braille Gerd Hoffmann
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

Drops libvirglrenderer.so dependency from core qemu.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-10-kraxel@redhat.com
---
 util/module.c            |  6 ++++++
 hw/display/Makefile.objs | 23 +++++++++++++----------
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/util/module.c b/util/module.c
index 7c76d2a84b94..a74214eac052 100644
--- a/util/module.c
+++ b/util/module.c
@@ -266,6 +266,12 @@ static struct {
     { "usb-redir",             "hw-", "usb-redirect"          },
     { "qxl-vga",               "hw-", "display-qxl"           },
     { "qxl",                   "hw-", "display-qxl"           },
+    { "virtio-gpu-device",     "hw-", "display-virtio-gpu"    },
+    { "virtio-gpu-pci",        "hw-", "display-virtio-gpu"    },
+    { "virtio-vga",            "hw-", "display-virtio-gpu"    },
+    { "vhost-user-gpu-device", "hw-", "display-virtio-gpu"    },
+    { "vhost-user-gpu-pci",    "hw-", "display-virtio-gpu"    },
+    { "vhost-user-vga",        "hw-", "display-virtio-gpu"    },
 };
 
 static bool module_loaded_qom_all;
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
index d619594ad4d3..e907f3182b0c 100644
--- a/hw/display/Makefile.objs
+++ b/hw/display/Makefile.objs
@@ -49,16 +49,19 @@ common-obj-m += qxl.mo
 qxl.mo-objs = qxl.o qxl-logger.o qxl-render.o
 endif
 
-common-obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o virtio-gpu-3d.o
-common-obj-$(CONFIG_VHOST_USER_GPU) += vhost-user-gpu.o
-common-obj-$(call land,$(CONFIG_VIRTIO_GPU),$(CONFIG_VIRTIO_PCI)) += virtio-gpu-pci.o
-common-obj-$(call land,$(CONFIG_VHOST_USER_GPU),$(CONFIG_VIRTIO_PCI)) += vhost-user-gpu-pci.o
-common-obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o
-common-obj-$(CONFIG_VHOST_USER_VGA) += vhost-user-vga.o
-virtio-gpu.o-cflags := $(VIRGL_CFLAGS)
-virtio-gpu.o-libs += $(VIRGL_LIBS)
-virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS)
-virtio-gpu-3d.o-libs += $(VIRGL_LIBS)
+ifeq ($(CONFIG_VIRTIO_GPU),y)
+common-obj-m += virtio-gpu.mo
+virtio-gpu-obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o virtio-gpu-3d.o
+virtio-gpu-obj-$(CONFIG_VHOST_USER_GPU) += vhost-user-gpu.o
+virtio-gpu-obj-$(call land,$(CONFIG_VIRTIO_GPU),$(CONFIG_VIRTIO_PCI)) += virtio-gpu-pci.o
+virtio-gpu-obj-$(call land,$(CONFIG_VHOST_USER_GPU),$(CONFIG_VIRTIO_PCI)) += vhost-user-gpu-pci.o
+virtio-gpu-obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o
+virtio-gpu-obj-$(CONFIG_VHOST_USER_VGA) += vhost-user-vga.o
+virtio-gpu.mo-objs := $(virtio-gpu-obj-y)
+virtio-gpu.mo-cflags := $(VIRGL_CFLAGS)
+virtio-gpu.mo-libs := $(VIRGL_LIBS)
+endif
+
 common-obj-$(CONFIG_DPCD) += dpcd.o
 common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx_dp.o
 
-- 
2.18.4



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

* [PULL 10/10] chardev: enable modules, use for braille
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
                   ` (8 preceding siblings ...)
  2020-07-02 12:20 ` [PULL 09/10] vga: build virtio-gpu as module Gerd Hoffmann
@ 2020-07-02 12:20 ` Gerd Hoffmann
  2020-07-03  8:54 ` [PULL 00/10] Modules 20200702 patches Peter Maydell
  2020-07-03  9:14 ` Claudio Fontana
  11 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-02 12:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Gerd Hoffmann, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

Removes brlapi library dependency from core qemu.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-11-kraxel@redhat.com
---
 Makefile.objs         | 1 +
 chardev/char.c        | 2 +-
 util/module.c         | 1 +
 chardev/Makefile.objs | 5 ++++-
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index 3d45492d8b46..d22b3b45d7b6 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -71,6 +71,7 @@ common-obj-$(CONFIG_TPM) += tpm.o
 
 common-obj-y += backends/
 common-obj-y += chardev/
+common-obj-m += chardev/
 
 common-obj-$(CONFIG_SECCOMP) += qemu-seccomp.o
 qemu-seccomp.o-cflags := $(SECCOMP_CFLAGS)
diff --git a/chardev/char.c b/chardev/char.c
index e3051295ac37..df697f3ce9e0 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -527,7 +527,7 @@ static const ChardevClass *char_get_class(const char *driver, Error **errp)
     const ChardevClass *cc;
     char *typename = g_strdup_printf("chardev-%s", driver);
 
-    oc = object_class_by_name(typename);
+    oc = module_object_class_by_name(typename);
     g_free(typename);
 
     if (!object_class_dynamic_cast(oc, TYPE_CHARDEV)) {
diff --git a/util/module.c b/util/module.c
index a74214eac052..32b0547b8266 100644
--- a/util/module.c
+++ b/util/module.c
@@ -272,6 +272,7 @@ static struct {
     { "vhost-user-gpu-device", "hw-", "display-virtio-gpu"    },
     { "vhost-user-gpu-pci",    "hw-", "display-virtio-gpu"    },
     { "vhost-user-vga",        "hw-", "display-virtio-gpu"    },
+    { "chardev-braille",       "chardev-", "baum"             },
 };
 
 static bool module_loaded_qom_all;
diff --git a/chardev/Makefile.objs b/chardev/Makefile.objs
index d68e1347f9af..3a58c9d329d6 100644
--- a/chardev/Makefile.objs
+++ b/chardev/Makefile.objs
@@ -18,8 +18,11 @@ chardev-obj-$(CONFIG_WIN32) += char-win.o
 chardev-obj-$(CONFIG_WIN32) += char-win-stdio.o
 
 common-obj-y += msmouse.o wctablet.o testdev.o
-common-obj-$(CONFIG_BRLAPI) += baum.o
+
+ifeq ($(CONFIG_BRLAPI),y)
+common-obj-m += baum.o
 baum.o-cflags := $(SDL_CFLAGS)
 baum.o-libs := $(BRLAPI_LIBS)
+endif
 
 common-obj-$(CONFIG_SPICE) += spice.o
-- 
2.18.4



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

* Re: [PULL 00/10] Modules 20200702 patches
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
                   ` (9 preceding siblings ...)
  2020-07-02 12:20 ` [PULL 10/10] chardev: enable modules, use for braille Gerd Hoffmann
@ 2020-07-03  8:54 ` Peter Maydell
  2020-07-03 10:39   ` Gerd Hoffmann
  2020-07-03  9:14 ` Claudio Fontana
  11 siblings, 1 reply; 23+ messages in thread
From: Peter Maydell @ 2020-07-03  8:54 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: Marc-André Lureau, Paolo Bonzini, Daniel P. Berrangé,
	QEMU Developers, Eduardo Habkost

On Thu, 2 Jul 2020 at 13:23, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> The following changes since commit fc1bff958998910ec8d25db86cd2f53ff125f7ab:
>
>   hw/misc/pca9552: Add missing TypeInfo::class_size field (2020-06-29 21:16:10 +0100)
>
> are available in the Git repository at:
>
>   git://git.kraxel.org/qemu tags/modules-20200702-pull-request
>
> for you to fetch changes up to 474a5d66036d18ee5ccaa88364660d05bf32127b:
>
>   chardev: enable modules, use for braille (2020-07-01 21:08:11 +0200)
>
> ----------------------------------------------------------------
> qom: add support for qom objects in modules.
> build some devices (qxl, virtio-gpu, ccid, usb-redir) as modules.
> build braille chardev as module.
>
> note: qemu doesn't rebuild objects on cflags changes (specifically
>       -fPIC being added when code is switched from builtin to module).
>       Workaround for resulting build errors: "make clean", rebuild.
>
> ----------------------------------------------------------------
>
> Gerd Hoffmann (10):
>   module: qom module support
>   object: qom module support
>   qdev: device module support
>   build: fix device module builds
>   ccid: build smartcard as module
>   usb: build usb-redir as module
>   vga: build qxl as module
>   vga: build virtio-gpu only once
>   vga: build virtio-gpu as module
>   chardev: enable modules, use for braille

No code review at all? :-(   In particular the "build: fix device module
builds" commit (as you note in your commit message) does not look at
all right. I would much prefer if we could get some code review
for these changes before applying them.

thanks
-- PMM


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

* Re: [PULL 04/10] build: fix device module builds
  2020-07-02 12:20 ` [PULL 04/10] build: fix device module builds Gerd Hoffmann
@ 2020-07-03  9:01   ` Claudio Fontana
  2020-07-03 10:25     ` Gerd Hoffmann
  0 siblings, 1 reply; 23+ messages in thread
From: Claudio Fontana @ 2020-07-03  9:01 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel
  Cc: Marc-André Lureau, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

On 7/2/20 2:20 PM, Gerd Hoffmann wrote:
> See comment.  Feels quite hackish.  Better ideas anyone?
> 


A better idea could be to investigate what and why gets into the variable.
I guess at this point we will need to revisit this later on.

CLaudio


> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> Message-id: 20200624131045.14512-5-kraxel@redhat.com
> ---
>  Makefile.target | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> 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 \
> 



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

* Re: [PULL 00/10] Modules 20200702 patches
  2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
                   ` (10 preceding siblings ...)
  2020-07-03  8:54 ` [PULL 00/10] Modules 20200702 patches Peter Maydell
@ 2020-07-03  9:14 ` Claudio Fontana
  2020-07-03 10:29   ` Gerd Hoffmann
  11 siblings, 1 reply; 23+ messages in thread
From: Claudio Fontana @ 2020-07-03  9:14 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel
  Cc: Marc-André Lureau, Daniel P. Berrangé,
	Eduardo Habkost, Paolo Bonzini

Hello Gerd,

I think in general the idea to make it easier to modularize things is great,
is this thought for devices only, or could I rework my changes to support modularizing per-target AccelClass types and all the related code on top of your design?

Thanks,

Claudio

On 7/2/20 2:20 PM, Gerd Hoffmann wrote:
> The following changes since commit fc1bff958998910ec8d25db86cd2f53ff125f7ab:
> 
>   hw/misc/pca9552: Add missing TypeInfo::class_size field (2020-06-29 21:16:10 +0100)
> 
> are available in the Git repository at:
> 
>   git://git.kraxel.org/qemu tags/modules-20200702-pull-request
> 
> for you to fetch changes up to 474a5d66036d18ee5ccaa88364660d05bf32127b:
> 
>   chardev: enable modules, use for braille (2020-07-01 21:08:11 +0200)
> 
> ----------------------------------------------------------------
> qom: add support for qom objects in modules.
> build some devices (qxl, virtio-gpu, ccid, usb-redir) as modules.
> build braille chardev as module.
> 
> note: qemu doesn't rebuild objects on cflags changes (specifically
>       -fPIC being added when code is switched from builtin to module).
>       Workaround for resulting build errors: "make clean", rebuild.
> 
> ----------------------------------------------------------------
> 
> Gerd Hoffmann (10):
>   module: qom module support
>   object: qom module support
>   qdev: device module support
>   build: fix device module builds
>   ccid: build smartcard as module
>   usb: build usb-redir as module
>   vga: build qxl as module
>   vga: build virtio-gpu only once
>   vga: build virtio-gpu as module
>   chardev: enable modules, use for braille
> 
>  Makefile.objs            |  2 ++
>  Makefile.target          |  7 +++++
>  include/qemu/module.h    |  2 ++
>  include/qom/object.h     | 12 +++++++
>  chardev/char.c           |  2 +-
>  hw/core/qdev.c           |  6 ++--
>  qdev-monitor.c           |  5 +--
>  qom/object.c             | 14 +++++++++
>  qom/qom-qmp-cmds.c       |  3 +-
>  softmmu/vl.c             |  4 +--
>  util/module.c            | 67 ++++++++++++++++++++++++++++++++++++++++
>  chardev/Makefile.objs    |  5 ++-
>  hw/Makefile.objs         |  2 ++
>  hw/display/Makefile.objs | 28 ++++++++++-------
>  hw/usb/Makefile.objs     | 13 +++++---
>  15 files changed, 148 insertions(+), 24 deletions(-)
> 



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

* Re: [PULL 04/10] build: fix device module builds
  2020-07-03  9:01   ` Claudio Fontana
@ 2020-07-03 10:25     ` Gerd Hoffmann
  2020-07-03 13:00       ` Claudio Fontana
  0 siblings, 1 reply; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-03 10:25 UTC (permalink / raw)
  To: Claudio Fontana
  Cc: Marc-André Lureau, Paolo Bonzini, Daniel P. Berrangé,
	qemu-devel, Eduardo Habkost

On Fri, Jul 03, 2020 at 11:01:43AM +0200, Claudio Fontana wrote:
> On 7/2/20 2:20 PM, Gerd Hoffmann wrote:
> > See comment.  Feels quite hackish.  Better ideas anyone?
> 
> A better idea could be to investigate what and why gets into the variable.

I see paths prefixed by "../", which seems to come from recursing into
target directories and not properly handling -m there.

I think this stop-gap will do the job fine as long as we don't have
target-specific modules.

With the pending switch to a meson-based build system which I hope
simplifies all this I didn't feel like investing too much effort into
finding the real root cause.  Debugging the Makefiles is a PITA ...

I'm open to any hints though.

take care,
  Gerd



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

* Re: [PULL 00/10] Modules 20200702 patches
  2020-07-03  9:14 ` Claudio Fontana
@ 2020-07-03 10:29   ` Gerd Hoffmann
  0 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-03 10:29 UTC (permalink / raw)
  To: Claudio Fontana
  Cc: Marc-André Lureau, Paolo Bonzini, Daniel P. Berrangé,
	qemu-devel, Eduardo Habkost

On Fri, Jul 03, 2020 at 11:14:27AM +0200, Claudio Fontana wrote:
> Hello Gerd,
> 
> I think in general the idea to make it easier to modularize things is great,

> is this thought for devices only, or could I rework my changes to
> support modularizing per-target AccelClass types and all the related
> code on top of your design?

It should help for any QOM object (see patch 10/10 for a chardev).

With AccelClass being per-target modules most likely we'll need
something better for 4/10 though.

take care,
  Gerd



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

* Re: [PULL 00/10] Modules 20200702 patches
  2020-07-03  8:54 ` [PULL 00/10] Modules 20200702 patches Peter Maydell
@ 2020-07-03 10:39   ` Gerd Hoffmann
  2020-07-03 12:05     ` Paolo Bonzini
  0 siblings, 1 reply; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-03 10:39 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Marc-André Lureau, Paolo Bonzini, Daniel P. Berrangé,
	QEMU Developers, Eduardo Habkost

On Fri, Jul 03, 2020 at 09:54:13AM +0100, Peter Maydell wrote:
> On Thu, 2 Jul 2020 at 13:23, Gerd Hoffmann <kraxel@redhat.com> wrote:
> >
> > The following changes since commit fc1bff958998910ec8d25db86cd2f53ff125f7ab:
> >
> >   hw/misc/pca9552: Add missing TypeInfo::class_size field (2020-06-29 21:16:10 +0100)
> >
> > are available in the Git repository at:
> >
> >   git://git.kraxel.org/qemu tags/modules-20200702-pull-request
> >
> > for you to fetch changes up to 474a5d66036d18ee5ccaa88364660d05bf32127b:
> >
> >   chardev: enable modules, use for braille (2020-07-01 21:08:11 +0200)
> >
> > ----------------------------------------------------------------
> > qom: add support for qom objects in modules.
> > build some devices (qxl, virtio-gpu, ccid, usb-redir) as modules.
> > build braille chardev as module.
> >
> > note: qemu doesn't rebuild objects on cflags changes (specifically
> >       -fPIC being added when code is switched from builtin to module).
> >       Workaround for resulting build errors: "make clean", rebuild.
> >
> > ----------------------------------------------------------------
> >
> > Gerd Hoffmann (10):
> >   module: qom module support
> >   object: qom module support
> >   qdev: device module support
> >   build: fix device module builds
> >   ccid: build smartcard as module
> >   usb: build usb-redir as module
> >   vga: build qxl as module
> >   vga: build virtio-gpu only once
> >   vga: build virtio-gpu as module
> >   chardev: enable modules, use for braille
> 
> No code review at all? :-(

Well, there have been 5 revisions on the list, partly due to bugs being
fixed, partly with changes as response to review comments.  So it got
some review (not much though) even though the v5 series (posted on June
22th, so there was more than a week time) didn't got any acks so far.

> In particular the "build: fix device module
> builds" commit (as you note in your commit message) does not look at
> all right.

I think this stop-gap will do fine as long as we don't have any
target-specific modules.

take care,
  Gerd



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

* Re: [PULL 00/10] Modules 20200702 patches
  2020-07-03 10:39   ` Gerd Hoffmann
@ 2020-07-03 12:05     ` Paolo Bonzini
  2020-07-06 13:20       ` Gerd Hoffmann
  2020-07-06 14:30       ` Claudio Fontana
  0 siblings, 2 replies; 23+ messages in thread
From: Paolo Bonzini @ 2020-07-03 12:05 UTC (permalink / raw)
  To: Gerd Hoffmann, Peter Maydell
  Cc: Marc-André Lureau, Daniel P. Berrangé,
	QEMU Developers, Eduardo Habkost

On 03/07/20 12:39, Gerd Hoffmann wrote:
> On Fri, Jul 03, 2020 at 09:54:13AM +0100, Peter Maydell wrote:
>> On Thu, 2 Jul 2020 at 13:23, Gerd Hoffmann <kraxel@redhat.com> wrote:
>>>
>>> The following changes since commit fc1bff958998910ec8d25db86cd2f53ff125f7ab:
>>>
>>>   hw/misc/pca9552: Add missing TypeInfo::class_size field (2020-06-29 21:16:10 +0100)
>>>
>>> are available in the Git repository at:
>>>
>>>   git://git.kraxel.org/qemu tags/modules-20200702-pull-request
>>>
>>> for you to fetch changes up to 474a5d66036d18ee5ccaa88364660d05bf32127b:
>>>
>>>   chardev: enable modules, use for braille (2020-07-01 21:08:11 +0200)
>>>
>>> ----------------------------------------------------------------
>>> qom: add support for qom objects in modules.
>>> build some devices (qxl, virtio-gpu, ccid, usb-redir) as modules.
>>> build braille chardev as module.
>>>
>>> note: qemu doesn't rebuild objects on cflags changes (specifically
>>>       -fPIC being added when code is switched from builtin to module).
>>>       Workaround for resulting build errors: "make clean", rebuild.
>>>
>>> ----------------------------------------------------------------
>>>
>>> Gerd Hoffmann (10):
>>>   module: qom module support
>>>   object: qom module support
>>>   qdev: device module support
>>>   build: fix device module builds
>>>   ccid: build smartcard as module
>>>   usb: build usb-redir as module
>>>   vga: build qxl as module
>>>   vga: build virtio-gpu only once
>>>   vga: build virtio-gpu as module
>>>   chardev: enable modules, use for braille
>>
>> No code review at all? :-(
> 
> Well, there have been 5 revisions on the list, partly due to bugs being
> fixed, partly with changes as response to review comments.  So it got
> some review (not much though) even though the v5 series (posted on June
> 22th, so there was more than a week time) didn't got any acks so far.
> 
>> In particular the "build: fix device module
>> builds" commit (as you note in your commit message) does not look at
>> all right.
> 
> I think this stop-gap will do fine as long as we don't have any
> target-specific modules.

Yeah, it's hackish but target-specific modules would be a huge
complication so I don't think we'd be having them anytime soon.  With
Meson removing the unnest-vars logic, the hack would also go away on its
own.  So I guess it's okay.

Paolo



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

* Re: [PULL 04/10] build: fix device module builds
  2020-07-03 10:25     ` Gerd Hoffmann
@ 2020-07-03 13:00       ` Claudio Fontana
  2020-07-06 13:14         ` Gerd Hoffmann
  0 siblings, 1 reply; 23+ messages in thread
From: Claudio Fontana @ 2020-07-03 13:00 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: Marc-André Lureau, Paolo Bonzini, Daniel P. Berrangé,
	qemu-devel, Eduardo Habkost

On 7/3/20 12:25 PM, Gerd Hoffmann wrote:
> On Fri, Jul 03, 2020 at 11:01:43AM +0200, Claudio Fontana wrote:
>> On 7/2/20 2:20 PM, Gerd Hoffmann wrote:
>>> See comment.  Feels quite hackish.  Better ideas anyone?
>>
>> A better idea could be to investigate what and why gets into the variable.
> 
> I see paths prefixed by "../", which seems to come from recursing into
> target directories and not properly handling -m there.
> 
> I think this stop-gap will do the job fine as long as we don't have
> target-specific modules.
> 
> With the pending switch to a meson-based build system which I hope
> simplifies all this I didn't feel like investing too much effort into
> finding the real root cause.  Debugging the Makefiles is a PITA ...
> 
> I'm open to any hints though.
> 
> take care,
>   Gerd
> 

Hi, if I recall correctly I encountered this.

It has to do with the convoluted rules in rules.mak for modules.

There are multiple specific problems there, beyond design issues.

one is

%$(DSOSUF): %.mo

this breaks and causes all sorts of misbehavior for make rules that do not require ./configure.

it can be worked around by providing a default definition in rules.mak for DSOSUF.

One other issue is the corresponding recipe

$(if $(findstring /,$@),$(call quiet-command,cp $@ $(subst /,-,$@),"CP","$(subst /,-,$@)"))

This causes more than one problem (for example, it is the reason qemu can "rebuild" stuff for no apparent reason after doing a full make).

In addition to that, this does not work well when called from the target dir.

If I remember correctly I solved this only building modules from a recursive build, ie my Makefile had:

commit 250cb13eb1fb4d4b29552acb0b768616321886ef
Author: Claudio Fontana <cfontana@suse.de>
Date:   Wed May 13 19:13:15 2020 +0200

    Makefile: add recurse-modules
    
    Signed-off-by: Claudio Fontana <cfontana@suse.de>

diff --git a/Makefile b/Makefile
index 34275f57c9..5ec1ff2c2f 100644
--- a/Makefile
+++ b/Makefile
@@ -479,7 +479,7 @@ dummy := $(call unnest-vars,, \
 
 include $(SRC_PATH)/tests/Makefile.include
 
-all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
+all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all recurse-modules $(vhost-user-json-y)
 
 qemu-version.h: FORCE
        $(call quiet-command, \
@@ -497,7 +497,7 @@ config-host.h-timestamp: config-host.mak
 qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
        $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
 
-TARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), $(TARGET_DIRS)))
+TARGET_DIRS_RULES := $(foreach t, all fuzz clean install modules, $(addsuffix /$(t), $(TARGET_DIRS)))
 
 SOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
 $(SOFTMMU_ALL_RULES): $(authz-obj-y)
@@ -580,8 +580,9 @@ ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
 $(ROM_DIRS_RULES):
        $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $
(notdir $@),)

-.PHONY: recurse-all recurse-clean recurse-install
+.PHONY: recurse-all recurse-modules recurse-clean recurse-install
 recurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
+recurse-modules: $(addsuffix /modules, $(TARGET_DIRS))
 recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
 recurse-install: $(addsuffix /install, $(TARGET_DIRS))
 $(addsuffix /install, $(TARGET_DIRS)): all
@@ -757,6 +758,8 @@ clean-coverage:
                "CLEAN", "coverage files")
 endif
 
+modules: recurse-modules
+
 clean: recurse-clean
 # avoid old build problems by removing potentially incorrect old files
        rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h


-----------------

and then my rules.mak had:

@@ -106,11 +111,12 @@ LINK = $(call quiet-command, $(LINKPROG) $(CFLAGS) $(QEMU_LDFLAGS) -o $@ \
 DSO_OBJ_CFLAGS := -fPIC -DBUILD_DSO
 module-common.o: CFLAGS += $(DSO_OBJ_CFLAGS)
 %$(DSOSUF): QEMU_LDFLAGS += $(LDFLAGS_SHARED)
-%$(DSOSUF): %.mo
+../%$(DSOSUF): DEST=$(subst /,-,$(subst ../,,$@))
+../%$(DSOSUF): ../%.mo
+       @# Link non-accelerator, non-target-specific modules
        $(call LINK,$^)
        @# Copy to build root so modules can be loaded when program started without install
-       $(if $(findstring /,$@),$(call quiet-command,cp $@ $(subst /,-,$@),"CP","$(subst /,-,$@)"))
-
+       $(call quiet-command,cp $@ ../$(DEST),"CP","$(DEST)")
 
 LD_REL := $(CC) -nostdlib $(LD_REL_FLAGS)
 
@@ -364,7 +370,7 @@ define unnest-vars
                    $(eval $($o-objs): CFLAGS += $(DSO_OBJ_CFLAGS))
                    $(eval $o: $($o-objs)))
              $(eval $(patsubst %-m,%-y,$v) += $($v))
-             $(eval modules: $($v:%.mo=%$(DSOSUF))),
+             $(if $(findstring accel-,$(v)),,$(eval modules: $($v:%.mo=%$(DSOSUF)))),
              $(eval $(patsubst %-m,%-y,$v) += $(call expand-objs, $($v)))))
 
     # Post-process all the unnested vars






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

* Re: [PULL 04/10] build: fix device module builds
  2020-07-03 13:00       ` Claudio Fontana
@ 2020-07-06 13:14         ` Gerd Hoffmann
  0 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-06 13:14 UTC (permalink / raw)
  To: Claudio Fontana
  Cc: Marc-André Lureau, Paolo Bonzini, Daniel P. Berrangé,
	qemu-devel, Eduardo Habkost

  Hi,

> Hi, if I recall correctly I encountered this.
> 
> It has to do with the convoluted rules in rules.mak for modules.
> 
> There are multiple specific problems there, beyond design issues.

I guess you just figured why there is a plan to replace the current
build system with a meson based one ;)

take care,
  Gerd



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

* Re: [PULL 00/10] Modules 20200702 patches
  2020-07-03 12:05     ` Paolo Bonzini
@ 2020-07-06 13:20       ` Gerd Hoffmann
  2020-07-06 14:30       ` Claudio Fontana
  1 sibling, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-06 13:20 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Peter Maydell, Daniel P. Berrangé,
	QEMU Developers, Eduardo Habkost, Marc-André Lureau

  Hi,

> >>>   build: fix device module builds

> >> No code review at all? :-(
> > 
> > Well, there have been 5 revisions on the list, partly due to bugs being
> > fixed, partly with changes as response to review comments.  So it got
> > some review (not much though) even though the v5 series (posted on June
> > 22th, so there was more than a week time) didn't got any acks so far.
> > 
> >> In particular the "build: fix device module
> >> builds" commit (as you note in your commit message) does not look at
> >> all right.
> > 
> > I think this stop-gap will do fine as long as we don't have any
> > target-specific modules.
> 
> Yeah, it's hackish but target-specific modules would be a huge
> complication so I don't think we'd be having them anytime soon.  With
> Meson removing the unnest-vars logic, the hack would also go away on its
> own.  So I guess it's okay.

OK, good.  So how to go forward now?

  (1) Merge pull req as-is?
  (2) Re-spin with discussion summary added to patch "4/10 build: fix
      device module builds".
  (3) Something else?

Any chance for an ack in case we go (2) or (3) ?

thanks & take care,
  Gerd



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

* Re: [PULL 00/10] Modules 20200702 patches
  2020-07-03 12:05     ` Paolo Bonzini
  2020-07-06 13:20       ` Gerd Hoffmann
@ 2020-07-06 14:30       ` Claudio Fontana
  1 sibling, 0 replies; 23+ messages in thread
From: Claudio Fontana @ 2020-07-06 14:30 UTC (permalink / raw)
  To: Paolo Bonzini, Gerd Hoffmann, Peter Maydell
  Cc: Marc-André Lureau, Daniel P. Berrangé,
	QEMU Developers, Eduardo Habkost

On 7/3/20 2:05 PM, Paolo Bonzini wrote:
> On 03/07/20 12:39, Gerd Hoffmann wrote:
>> On Fri, Jul 03, 2020 at 09:54:13AM +0100, Peter Maydell wrote:
>>> On Thu, 2 Jul 2020 at 13:23, Gerd Hoffmann <kraxel@redhat.com> wrote:
>>>>
>>>> The following changes since commit fc1bff958998910ec8d25db86cd2f53ff125f7ab:
>>>>
>>>>   hw/misc/pca9552: Add missing TypeInfo::class_size field (2020-06-29 21:16:10 +0100)
>>>>
>>>> are available in the Git repository at:
>>>>
>>>>   git://git.kraxel.org/qemu tags/modules-20200702-pull-request
>>>>
>>>> for you to fetch changes up to 474a5d66036d18ee5ccaa88364660d05bf32127b:
>>>>
>>>>   chardev: enable modules, use for braille (2020-07-01 21:08:11 +0200)
>>>>
>>>> ----------------------------------------------------------------
>>>> qom: add support for qom objects in modules.
>>>> build some devices (qxl, virtio-gpu, ccid, usb-redir) as modules.
>>>> build braille chardev as module.
>>>>
>>>> note: qemu doesn't rebuild objects on cflags changes (specifically
>>>>       -fPIC being added when code is switched from builtin to module).
>>>>       Workaround for resulting build errors: "make clean", rebuild.
>>>>
>>>> ----------------------------------------------------------------
>>>>
>>>> Gerd Hoffmann (10):
>>>>   module: qom module support
>>>>   object: qom module support
>>>>   qdev: device module support
>>>>   build: fix device module builds
>>>>   ccid: build smartcard as module
>>>>   usb: build usb-redir as module
>>>>   vga: build qxl as module
>>>>   vga: build virtio-gpu only once
>>>>   vga: build virtio-gpu as module
>>>>   chardev: enable modules, use for braille
>>>
>>> No code review at all? :-(
>>
>> Well, there have been 5 revisions on the list, partly due to bugs being
>> fixed, partly with changes as response to review comments.  So it got
>> some review (not much though) even though the v5 series (posted on June
>> 22th, so there was more than a week time) didn't got any acks so far.
>>
>>> In particular the "build: fix device module
>>> builds" commit (as you note in your commit message) does not look at
>>> all right.
>>
>> I think this stop-gap will do fine as long as we don't have any
>> target-specific modules.
> 
> Yeah, it's hackish but target-specific modules would be a huge
> complication so I don't think we'd be having them anytime soon.  With
> Meson removing the unnest-vars logic, the hack would also go away on its
> own.  So I guess it's okay.
> 
> Paolo
> 
> 

Hi Paolo,

well, since it is one of my main objectives behind lots of the refactoring work I have in progress,
and have been announcing this to the list since May:

https://lists.nongnu.org/archive/html/qemu-devel/2020-05/msg04628.html

I would disagree with the fact that target-specific modules are a huge complication in by themselves, as I got some initial promising results in building them.

Will work on the series and contribute it as soon as the basic requisite initial refactoring series are in,
so that the usefulness of target-specific modules can be demonstrated.

In my view modules could have been implemented differently, instead of the current design, in a way that would have made them easier to extend.

Probably meson is an interesting tool, I think however that good build designs will still be necessary,
and that bad ones will still result in difficult to extend build features.

Thanks & ciao,

Claudio



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

* [PULL 04/10] build: fix device module builds
  2020-07-07 13:42 [PULL 00/10] Modules 20200707 patches Gerd Hoffmann
@ 2020-07-07 13:42 ` Gerd Hoffmann
  0 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2020-07-07 13:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Daniel P. Berrangé,
	Gerd Hoffmann, Eduardo Habkost, Paolo Bonzini

Slightly hackish workaround, works ok as long as we don't
have target-specific modules.  meson will obsolete this.

See comment in the patch for the --verbose description.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200624131045.14512-5-kraxel@redhat.com

[ kraxel: updated comment from discussions ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 Makefile.target | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Makefile.target b/Makefile.target
index 8ed1eba95b9c..02bd9d7117dd 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -179,6 +179,20 @@ 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
+# unnest-vars recursing into target directories to fill obj-y and not
+# properly handling the -m case.
+#
+# Clear common-obj-m as workaround.  Fixes suspious dependency errors
+# when building devices as modules.  A bit hackish, but should be ok
+# as long as we do not have any target-specific modules.
+#
+# The meson-based build system currently in development doesn't need
+# unnest-vars and will obsolete this workaround.
+#
+common-obj-m :=
+
 include $(SRC_PATH)/Makefile.objs
 dummy := $(call unnest-vars,.., \
                authz-obj-y \
-- 
2.18.4



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

end of thread, other threads:[~2020-07-07 13:43 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02 12:20 [PULL 00/10] Modules 20200702 patches Gerd Hoffmann
2020-07-02 12:20 ` [PULL 01/10] module: qom module support Gerd Hoffmann
2020-07-02 12:20 ` [PULL 02/10] object: " Gerd Hoffmann
2020-07-02 12:20 ` [PULL 03/10] qdev: device " Gerd Hoffmann
2020-07-02 12:20 ` [PULL 04/10] build: fix device module builds Gerd Hoffmann
2020-07-03  9:01   ` Claudio Fontana
2020-07-03 10:25     ` Gerd Hoffmann
2020-07-03 13:00       ` Claudio Fontana
2020-07-06 13:14         ` Gerd Hoffmann
2020-07-02 12:20 ` [PULL 05/10] ccid: build smartcard as module Gerd Hoffmann
2020-07-02 12:20 ` [PULL 06/10] usb: build usb-redir " Gerd Hoffmann
2020-07-02 12:20 ` [PULL 07/10] vga: build qxl " Gerd Hoffmann
2020-07-02 12:20 ` [PULL 08/10] vga: build virtio-gpu only once Gerd Hoffmann
2020-07-02 12:20 ` [PULL 09/10] vga: build virtio-gpu as module Gerd Hoffmann
2020-07-02 12:20 ` [PULL 10/10] chardev: enable modules, use for braille Gerd Hoffmann
2020-07-03  8:54 ` [PULL 00/10] Modules 20200702 patches Peter Maydell
2020-07-03 10:39   ` Gerd Hoffmann
2020-07-03 12:05     ` Paolo Bonzini
2020-07-06 13:20       ` Gerd Hoffmann
2020-07-06 14:30       ` Claudio Fontana
2020-07-03  9:14 ` Claudio Fontana
2020-07-03 10:29   ` Gerd Hoffmann
2020-07-07 13:42 [PULL 00/10] Modules 20200707 patches Gerd Hoffmann
2020-07-07 13:42 ` [PULL 04/10] build: fix device module builds 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.