*/
#include "qemu/osdep.h"
+#include "qemu/error-report.h"
+#include "qemu/sockets.h"
+#include "hw/qdev-properties.h"
#include "hw/virtio/virtio-gpu.h"
#include "chardev/char-fe.h"
#include "qapi/error.h"
#include "migration/blocker.h"
-#define VHOST_USER_GPU(obj) \
- OBJECT_CHECK(VhostUserGPU, (obj), TYPE_VHOST_USER_GPU)
-
typedef enum VhostUserGpuRequest {
VHOST_USER_GPU_NONE = 0,
VHOST_USER_GPU_GET_PROTOCOL_FEATURES,
s = &g->parent_obj.scanout[m->scanout_id];
con = s->con;
- if (m->scanout_id == 0 && m->width == 0) {
- s->ds = qemu_create_message_surface(640, 480,
- "Guest disabled display.");
- dpy_gfx_replace_surface(con, s->ds);
+ if (m->width == 0) {
+ dpy_gfx_replace_surface(con, NULL);
} else {
s->ds = qemu_create_displaysurface(m->width, m->height);
/* replace surface on next update */
close(dmabuf->fd);
dmabuf->fd = -1;
}
- if (!console_has_gl_dmabuf(con)) {
- /* it would be nice to report that error earlier */
- error_report("console doesn't support dmabuf!");
- break;
- }
dpy_gl_release_dmabuf(con, dmabuf);
if (fd == -1) {
dpy_gl_scanout_disable(con);
vhost_user_gpu_unblock(g);
break;
}
- dpy_gl_update(con, m->x, m->y, m->width, m->height);
g->backend_blocked = true;
+ dpy_gl_update(con, m->x, m->y, m->width, m->height);
break;
}
case VHOST_USER_GPU_UPDATE: {
}
msg = g_malloc(VHOST_USER_GPU_HDR_SIZE + size);
- g_return_if_fail(msg != NULL);
r = qemu_chr_fe_read_all(&g->vhost_chr,
(uint8_t *)&msg->payload, size);
}
static void
-vhost_user_gpu_gl_unblock(VirtIOGPUBase *b)
+vhost_user_gpu_gl_flushed(VirtIOGPUBase *b)
{
VhostUserGPU *g = VHOST_USER_GPU(b);
Chardev *chr;
int sv[2];
- if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
+ if (qemu_socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
error_setg_errno(errp, errno, "socketpair() failed");
return false;
}
VirtIOGPUBase *b = VIRTIO_GPU_BASE(vdev);
struct virtio_gpu_config *vgconfig =
(struct virtio_gpu_config *)config_data;
+ Error *local_err = NULL;
int ret;
memset(config_data, 0, sizeof(struct virtio_gpu_config));
ret = vhost_dev_get_config(&g->vhost->dev,
- config_data, sizeof(struct virtio_gpu_config));
+ config_data, sizeof(struct virtio_gpu_config),
+ &local_err);
if (ret) {
- error_report("vhost-user-gpu: get device config space failed");
+ error_report_err(local_err);
return;
}
{
VhostUserGPU *g = VHOST_USER_GPU(vdev);
+ /*
+ * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
+ * as the Marco of configure interrupt's IDX, If this driver does not
+ * support, the function will return
+ */
+
+ if (idx == VIRTIO_CONFIG_IRQ_IDX) {
+ return false;
+ }
return vhost_virtqueue_pending(&g->vhost->dev, idx);
}
{
VhostUserGPU *g = VHOST_USER_GPU(vdev);
+ /*
+ * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
+ * as the Marco of configure interrupt's IDX, If this driver does not
+ * support, the function will return
+ */
+
+ if (idx == VIRTIO_CONFIG_IRQ_IDX) {
+ return;
+ }
vhost_virtqueue_mask(&g->vhost->dev, vdev, idx, mask);
}
g->vhost = VHOST_USER_BACKEND(object_new(TYPE_VHOST_USER_BACKEND));
object_property_add_alias(obj, "chardev",
- OBJECT(g->vhost), "chardev", &error_abort);
+ OBJECT(g->vhost), "chardev");
}
static void
return;
}
+ /* existing backend may send DMABUF, so let's add that requirement */
+ g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED;
if (virtio_has_feature(g->vhost->dev.features, VIRTIO_GPU_F_VIRGL)) {
g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_VIRGL_ENABLED;
}
+ if (virtio_has_feature(g->vhost->dev.features, VIRTIO_GPU_F_EDID)) {
+ g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_EDID_ENABLED;
+ } else {
+ error_report("EDID requested but the backend doesn't support it.");
+ g->parent_obj.conf.flags &= ~(1 << VIRTIO_GPU_FLAG_EDID_ENABLED);
+ }
if (!virtio_gpu_base_device_realize(qdev, NULL, NULL, errp)) {
return;
g->vhost_gpu_fd = -1;
}
+static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev)
+{
+ VhostUserGPU *g = VHOST_USER_GPU(vdev);
+ return &g->vhost->dev;
+}
+
static Property vhost_user_gpu_properties[] = {
VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf),
DEFINE_PROP_END_OF_LIST(),
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
VirtIOGPUBaseClass *vgc = VIRTIO_GPU_BASE_CLASS(klass);
- vgc->gl_unblock = vhost_user_gpu_gl_unblock;
+ vgc->gl_flushed = vhost_user_gpu_gl_flushed;
vdc->realize = vhost_user_gpu_device_realize;
vdc->reset = vhost_user_gpu_reset;
vdc->guest_notifier_pending = vhost_user_gpu_guest_notifier_pending;
vdc->get_config = vhost_user_gpu_get_config;
vdc->set_config = vhost_user_gpu_set_config;
+ vdc->get_vhost = vhost_user_gpu_get_vhost;
- dc->props = vhost_user_gpu_properties;
+ device_class_set_props(dc, vhost_user_gpu_properties);
}
static const TypeInfo vhost_user_gpu_info = {
.instance_finalize = vhost_user_gpu_instance_finalize,
.class_init = vhost_user_gpu_class_init,
};
+module_obj(TYPE_VHOST_USER_GPU);
+module_kconfig(VHOST_USER_GPU);
static void vhost_user_gpu_register_types(void)
{