@@ -122,6 +122,7 @@ struct VirtIOGPUBaseClass {
VirtioDeviceClass parent;
void (*gl_flushed)(VirtIOGPUBase *g);
+ bool (*register_dbus_listener)(VirtIOGPUBase *g, QemuConsole *con, int fd);
};
#define VIRTIO_GPU_BASE_PROPERTIES(_state, _conf) \
@@ -370,6 +370,38 @@ vhost_user_gpu_gl_flushed(VirtIOGPUBase *b)
vhost_user_gpu_update_blocked(VHOST_USER_GPU(g), false);
}
+static bool
+vhost_user_gpu_scanout_idx(VirtIOGPUBase *b, QemuConsole *con, uint8_t *idx)
+{
+ VhostUserGPU *g = VHOST_USER_GPU(b);
+ struct virtio_gpu_scanout *s;
+ uint8_t i;
+
+ for (i = 0; i < G_N_ELEMENTS(g->parent_obj.scanout); i++) {
+ s = &g->parent_obj.scanout[i];
+ if (s->con == con) {
+ *idx = i;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static bool
+vhost_user_gpu_do_register_dbus_listener(VirtIOGPUBase *b, QemuConsole *con, int fd)
+{
+ VhostUserGPU *g = VHOST_USER_GPU(b);
+ uint8_t idx = 0;
+
+ if (!vhost_user_gpu_scanout_idx(b, con, &idx)) {
+ error_report("Failed to find attached console %p", con);
+ return false;
+ }
+
+ return vhost_user_gpu_register_dbus_listener(&g->vhost->dev, idx, fd) == 0;
+}
+
static bool
vhost_user_gpu_do_set_socket(VhostUserGPU *g, Error **errp)
{
@@ -577,6 +609,7 @@ vhost_user_gpu_class_init(ObjectClass *klass, void *data)
VirtIOGPUBaseClass *vgc = VIRTIO_GPU_BASE_CLASS(klass);
vgc->gl_flushed = vhost_user_gpu_gl_flushed;
+ vgc->register_dbus_listener = vhost_user_gpu_do_register_dbus_listener;
vdc->realize = vhost_user_gpu_device_realize;
vdc->reset = vhost_user_gpu_reset;
@@ -141,6 +141,19 @@ virtio_gpu_get_flags(void *opaque)
return flags;
}
+static bool
+virtio_gpu_register_dbus_listener(void *opaque, QemuConsole *con, int fd)
+{
+ VirtIOGPUBase *g = opaque;
+ VirtIOGPUBaseClass *vgc = VIRTIO_GPU_BASE_GET_CLASS(g);
+
+ if (vgc->register_dbus_listener) {
+ return vgc->register_dbus_listener(g, con, fd);
+ }
+
+ return false;
+}
+
static const GraphicHwOps virtio_gpu_ops = {
.get_flags = virtio_gpu_get_flags,
.invalidate = virtio_gpu_invalidate_display,
@@ -148,6 +161,7 @@ static const GraphicHwOps virtio_gpu_ops = {
.text_update = virtio_gpu_text_update,
.ui_info = virtio_gpu_ui_info,
.gl_block = virtio_gpu_gl_block,
+ .register_dbus_listener = virtio_gpu_register_dbus_listener,
};
bool
@@ -76,6 +76,15 @@ static int virtio_vga_base_get_flags(void *opaque)
return g->hw_ops->get_flags(g);
}
+static bool virtio_vga_base_register_dbus_listener(void *opaque,
+ QemuConsole *con, int fd)
+{
+ VirtIOVGABase *vvga = opaque;
+ VirtIOGPUBase *g = vvga->vgpu;
+
+ return g->hw_ops->register_dbus_listener(g, con, fd);
+}
+
static const GraphicHwOps virtio_vga_base_ops = {
.get_flags = virtio_vga_base_get_flags,
.invalidate = virtio_vga_base_invalidate_display,
@@ -83,6 +92,7 @@ static const GraphicHwOps virtio_vga_base_ops = {
.text_update = virtio_vga_base_text_update,
.ui_info = virtio_vga_base_ui_info,
.gl_block = virtio_vga_base_gl_block,
+ .register_dbus_listener = virtio_vga_base_register_dbus_listener,
};
static const VMStateDescription vmstate_virtio_vga_base = {