qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] object_initialize: try module load
@ 2020-09-07  9:47 Gerd Hoffmann
  2020-09-07  9:47 ` [PATCH 2/3] virtio-gpu: make virtio_gpu_ops static Gerd Hoffmann
  2020-09-07  9:47 ` [PATCH 3/3] virtio-gpu: build modular Gerd Hoffmann
  0 siblings, 2 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2020-09-07  9:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Daniel P. Berrangé, Gerd Hoffmann, Eduardo Habkost

Needed to allow virtio-gpu-pci initialize the
virtio-gpu-device child device.

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

diff --git a/qom/object.c b/qom/object.c
index 00fdf89b3b0a..f85740001520 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -518,6 +518,12 @@ void object_initialize(void *data, size_t size, const char *typename)
 {
     TypeImpl *type = type_get_by_name(typename);
 
+#ifdef CONFIG_MODULES
+    if (!type) {
+        module_load_qom_one(typename);
+        type = type_get_by_name(typename);
+    }
+#endif
     if (!type) {
         error_report("missing object type '%s'", typename);
         abort();
-- 
2.27.0



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

* [PATCH 2/3] virtio-gpu: make virtio_gpu_ops static
  2020-09-07  9:47 [PATCH 1/3] object_initialize: try module load Gerd Hoffmann
@ 2020-09-07  9:47 ` Gerd Hoffmann
  2020-09-08 12:06   ` Michael S. Tsirkin
  2020-09-07  9:47 ` [PATCH 3/3] virtio-gpu: build modular Gerd Hoffmann
  1 sibling, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2020-09-07  9:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Michael S. Tsirkin

Reference it via ops pointer instead, simliar to the vga one.
Removes hard symbol reference, needed to build virtio-gpu modular.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/virtio/virtio-gpu.h |  3 +--
 hw/display/virtio-gpu-base.c   |  3 ++-
 hw/display/virtio-vga.c        | 16 ++++++++--------
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 7517438e10aa..6c639a0e0272 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -107,6 +107,7 @@ typedef struct VirtIOGPUBase {
 
     struct virtio_gpu_base_conf conf;
     struct virtio_gpu_config virtio_config;
+    const GraphicHwOps *hw_ops;
 
     bool use_virgl_renderer;
     int renderer_blocked;
@@ -172,8 +173,6 @@ typedef struct VhostUserGPU {
     bool backend_blocked;
 } VhostUserGPU;
 
-extern const GraphicHwOps virtio_gpu_ops;
-
 #define VIRTIO_GPU_FILL_CMD(out) do {                                   \
         size_t s;                                                       \
         s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0,          \
diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index 796130860657..aeb87235420a 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -112,7 +112,7 @@ virtio_gpu_gl_block(void *opaque, bool block)
     }
 }
 
-const GraphicHwOps virtio_gpu_ops = {
+static const GraphicHwOps virtio_gpu_ops = {
     .invalidate = virtio_gpu_invalidate_display,
     .gfx_update = virtio_gpu_update_display,
     .text_update = virtio_gpu_text_update,
@@ -162,6 +162,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
     g->req_state[0].width = g->conf.xres;
     g->req_state[0].height = g->conf.yres;
 
+    g->hw_ops = &virtio_gpu_ops;
     for (i = 0; i < g->conf.max_outputs; i++) {
         g->scanout[i].con =
             graphic_console_init(DEVICE(g), i, &virtio_gpu_ops, g);
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index f533d7d1b415..28006d6e8224 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -12,7 +12,7 @@ static void virtio_vga_base_invalidate_display(void *opaque)
     VirtIOGPUBase *g = vvga->vgpu;
 
     if (g->enable) {
-        virtio_gpu_ops.invalidate(g);
+        g->hw_ops->invalidate(g);
     } else {
         vvga->vga.hw_ops->invalidate(&vvga->vga);
     }
@@ -24,7 +24,7 @@ static void virtio_vga_base_update_display(void *opaque)
     VirtIOGPUBase *g = vvga->vgpu;
 
     if (g->enable) {
-        virtio_gpu_ops.gfx_update(g);
+        g->hw_ops->gfx_update(g);
     } else {
         vvga->vga.hw_ops->gfx_update(&vvga->vga);
     }
@@ -36,8 +36,8 @@ static void virtio_vga_base_text_update(void *opaque, console_ch_t *chardata)
     VirtIOGPUBase *g = vvga->vgpu;
 
     if (g->enable) {
-        if (virtio_gpu_ops.text_update) {
-            virtio_gpu_ops.text_update(g, chardata);
+        if (g->hw_ops->text_update) {
+            g->hw_ops->text_update(g, chardata);
         }
     } else {
         if (vvga->vga.hw_ops->text_update) {
@@ -51,8 +51,8 @@ static int virtio_vga_base_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
     VirtIOVGABase *vvga = opaque;
     VirtIOGPUBase *g = vvga->vgpu;
 
-    if (virtio_gpu_ops.ui_info) {
-        return virtio_gpu_ops.ui_info(g, idx, info);
+    if (g->hw_ops->ui_info) {
+        return g->hw_ops->ui_info(g, idx, info);
     }
     return -1;
 }
@@ -62,8 +62,8 @@ static void virtio_vga_base_gl_block(void *opaque, bool block)
     VirtIOVGABase *vvga = opaque;
     VirtIOGPUBase *g = vvga->vgpu;
 
-    if (virtio_gpu_ops.gl_block) {
-        virtio_gpu_ops.gl_block(g, block);
+    if (g->hw_ops->gl_block) {
+        g->hw_ops->gl_block(g, block);
     }
 }
 
-- 
2.27.0



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

* [PATCH 3/3] virtio-gpu: build modular
  2020-09-07  9:47 [PATCH 1/3] object_initialize: try module load Gerd Hoffmann
  2020-09-07  9:47 ` [PATCH 2/3] virtio-gpu: make virtio_gpu_ops static Gerd Hoffmann
@ 2020-09-07  9:47 ` Gerd Hoffmann
  1 sibling, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2020-09-07  9:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Only build virtio-gpu-device modular (the code which actually depends on
the external virglrenderer library).  virtio-gpu-pci and virtio-vga are
compiled into core qemu still.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 util/module.c          |  2 ++
 hw/display/meson.build | 22 ++++++----------------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/util/module.c b/util/module.c
index 6e63006a8fb2..34772e7d87eb 100644
--- a/util/module.c
+++ b/util/module.c
@@ -265,6 +265,8 @@ static struct {
     { "usb-redir",             "hw-", "usb-redirect"          },
     { "qxl-vga",               "hw-", "display-qxl"           },
     { "qxl",                   "hw-", "display-qxl"           },
+    { "virtio-gpu-device",     "hw-", "display-virtio-gpu"    },
+    { "vhost-user-gpu",        "hw-", "display-virtio-gpu"    },
     { "chardev-braille",       "chardev-", "baum"             },
 };
 
diff --git a/hw/display/meson.build b/hw/display/meson.build
index ef8eb093acbb..a6756c25d66e 100644
--- a/hw/display/meson.build
+++ b/hw/display/meson.build
@@ -58,24 +58,14 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
   virtio_gpu_ss.add(when: 'CONFIG_VIRTIO_GPU',
                     if_true: [files('virtio-gpu-base.c', 'virtio-gpu.c', 'virtio-gpu-3d.c'), pixman, virgl])
   virtio_gpu_ss.add(when: 'CONFIG_VHOST_USER_GPU', if_true: files('vhost-user-gpu.c'))
-  virtio_gpu_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI'], if_true: files('virtio-gpu-pci.c'))
-  virtio_gpu_ss.add(when: ['CONFIG_VHOST_USER_GPU', 'CONFIG_VIRTIO_PCI'], if_true: files('vhost-user-gpu-pci.c'))
-  virtio_gpu_ss.add(when: 'CONFIG_VIRTIO_VGA', if_true: files('virtio-vga.c'))
-  virtio_gpu_ss.add(when: 'CONFIG_VHOST_USER_VGA', if_true: files('vhost-user-vga.c'))
-
-  # FIXME: this was attempted in the Makefile build system; it was then reverted
-  # as it would try to load all devices when the module is loaded, even if
-  # config_devices for this target only has some of them.  Since virtio-gpu-pci
-  # and virtio-vga both instantiate a virtio-gpu-device, fixing it probably does
-  # not even require a dependency system, just splitting the module in three
-  # for CONFIG_VIRTIO_GPU/CONFIG_VHOST_USER_GPU, CONFIG_VIRTIO_PCI and
-  # CONFIG_VIRTIO_VGA/CONFIG_VHOST_USER_VGA.
-  # Sourcesets are a dime a dozen, so keep it and just disable module builds.
-
-  #hw_display_modules += {'virtio-gpu': virtio_gpu_ss}
-  softmmu_ss.add_all(virtio_gpu_ss)
+  hw_display_modules += {'virtio-gpu': virtio_gpu_ss}
 endif
 
+softmmu_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI'], if_true: files('virtio-gpu-pci.c'))
+softmmu_ss.add(when: ['CONFIG_VHOST_USER_GPU', 'CONFIG_VIRTIO_PCI'], if_true: files('vhost-user-gpu-pci.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO_VGA', if_true: files('virtio-vga.c'))
+softmmu_ss.add(when: 'CONFIG_VHOST_USER_VGA', if_true: files('vhost-user-vga.c'))
+
 specific_ss.add(when: [x11, opengl, 'CONFIG_MILKYMIST_TMU2'], if_true: files('milkymist-tmu2.c'))
 specific_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_lcdc.c'))
 
-- 
2.27.0



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

* Re: [PATCH 2/3] virtio-gpu: make virtio_gpu_ops static
  2020-09-07  9:47 ` [PATCH 2/3] virtio-gpu: make virtio_gpu_ops static Gerd Hoffmann
@ 2020-09-08 12:06   ` Michael S. Tsirkin
  0 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2020-09-08 12:06 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

On Mon, Sep 07, 2020 at 11:47:18AM +0200, Gerd Hoffmann wrote:
> Reference it via ops pointer instead, simliar to the vga one.
> Removes hard symbol reference, needed to build virtio-gpu modular.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

Feel free to merge.

> ---
>  include/hw/virtio/virtio-gpu.h |  3 +--
>  hw/display/virtio-gpu-base.c   |  3 ++-
>  hw/display/virtio-vga.c        | 16 ++++++++--------
>  3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
> index 7517438e10aa..6c639a0e0272 100644
> --- a/include/hw/virtio/virtio-gpu.h
> +++ b/include/hw/virtio/virtio-gpu.h
> @@ -107,6 +107,7 @@ typedef struct VirtIOGPUBase {
>  
>      struct virtio_gpu_base_conf conf;
>      struct virtio_gpu_config virtio_config;
> +    const GraphicHwOps *hw_ops;
>  
>      bool use_virgl_renderer;
>      int renderer_blocked;
> @@ -172,8 +173,6 @@ typedef struct VhostUserGPU {
>      bool backend_blocked;
>  } VhostUserGPU;
>  
> -extern const GraphicHwOps virtio_gpu_ops;
> -
>  #define VIRTIO_GPU_FILL_CMD(out) do {                                   \
>          size_t s;                                                       \
>          s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, 0,          \
> diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
> index 796130860657..aeb87235420a 100644
> --- a/hw/display/virtio-gpu-base.c
> +++ b/hw/display/virtio-gpu-base.c
> @@ -112,7 +112,7 @@ virtio_gpu_gl_block(void *opaque, bool block)
>      }
>  }
>  
> -const GraphicHwOps virtio_gpu_ops = {
> +static const GraphicHwOps virtio_gpu_ops = {
>      .invalidate = virtio_gpu_invalidate_display,
>      .gfx_update = virtio_gpu_update_display,
>      .text_update = virtio_gpu_text_update,
> @@ -162,6 +162,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
>      g->req_state[0].width = g->conf.xres;
>      g->req_state[0].height = g->conf.yres;
>  
> +    g->hw_ops = &virtio_gpu_ops;
>      for (i = 0; i < g->conf.max_outputs; i++) {
>          g->scanout[i].con =
>              graphic_console_init(DEVICE(g), i, &virtio_gpu_ops, g);
> diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
> index f533d7d1b415..28006d6e8224 100644
> --- a/hw/display/virtio-vga.c
> +++ b/hw/display/virtio-vga.c
> @@ -12,7 +12,7 @@ static void virtio_vga_base_invalidate_display(void *opaque)
>      VirtIOGPUBase *g = vvga->vgpu;
>  
>      if (g->enable) {
> -        virtio_gpu_ops.invalidate(g);
> +        g->hw_ops->invalidate(g);
>      } else {
>          vvga->vga.hw_ops->invalidate(&vvga->vga);
>      }
> @@ -24,7 +24,7 @@ static void virtio_vga_base_update_display(void *opaque)
>      VirtIOGPUBase *g = vvga->vgpu;
>  
>      if (g->enable) {
> -        virtio_gpu_ops.gfx_update(g);
> +        g->hw_ops->gfx_update(g);
>      } else {
>          vvga->vga.hw_ops->gfx_update(&vvga->vga);
>      }
> @@ -36,8 +36,8 @@ static void virtio_vga_base_text_update(void *opaque, console_ch_t *chardata)
>      VirtIOGPUBase *g = vvga->vgpu;
>  
>      if (g->enable) {
> -        if (virtio_gpu_ops.text_update) {
> -            virtio_gpu_ops.text_update(g, chardata);
> +        if (g->hw_ops->text_update) {
> +            g->hw_ops->text_update(g, chardata);
>          }
>      } else {
>          if (vvga->vga.hw_ops->text_update) {
> @@ -51,8 +51,8 @@ static int virtio_vga_base_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
>      VirtIOVGABase *vvga = opaque;
>      VirtIOGPUBase *g = vvga->vgpu;
>  
> -    if (virtio_gpu_ops.ui_info) {
> -        return virtio_gpu_ops.ui_info(g, idx, info);
> +    if (g->hw_ops->ui_info) {
> +        return g->hw_ops->ui_info(g, idx, info);
>      }
>      return -1;
>  }
> @@ -62,8 +62,8 @@ static void virtio_vga_base_gl_block(void *opaque, bool block)
>      VirtIOVGABase *vvga = opaque;
>      VirtIOGPUBase *g = vvga->vgpu;
>  
> -    if (virtio_gpu_ops.gl_block) {
> -        virtio_gpu_ops.gl_block(g, block);
> +    if (g->hw_ops->gl_block) {
> +        g->hw_ops->gl_block(g, block);
>      }
>  }
>  
> -- 
> 2.27.0



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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07  9:47 [PATCH 1/3] object_initialize: try module load Gerd Hoffmann
2020-09-07  9:47 ` [PATCH 2/3] virtio-gpu: make virtio_gpu_ops static Gerd Hoffmann
2020-09-08 12:06   ` Michael S. Tsirkin
2020-09-07  9:47 ` [PATCH 3/3] virtio-gpu: build modular Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).