Message ID | 20200907094719.12850-2-kraxel@redhat.com |
---|---|
State | Superseded |
Headers | show |
Series | [1/3] object_initialize: try module load | expand |
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
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); } }
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(-)