hw/display: add vhost-user-vga & gpu-pci

Add new virtio-gpu devices with a "vhost-user" property. The
associated vhost-user backend is used to handle the virtio rings and
provide rendering results thanks to the vhost-user-gpu protocol.

Example usage:
-object vhost-user-backend,id=vug,cmd="./vhost-user-gpu"
-device vhost-user-vga,vhost-user=vug

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 20190524130946.31736-10-marcandre.lureau@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Marc-André Lureau
2019-05-29 06:30:45 +02:00
committed by Gerd Hoffmann
parent c68082c43a
commit 267f664658
10 changed files with 779 additions and 23 deletions
+10
View File
@@ -111,6 +111,16 @@ config VIRTIO_VGA
depends on VIRTIO_PCI
select VGA
config VHOST_USER_GPU
bool
default y
depends on VIRTIO_GPU && VHOST_USER
config VHOST_USER_VGA
bool
default y
depends on VIRTIO_VGA && VHOST_USER_GPU
config DPCD
bool
select AUX
+3
View File
@@ -44,8 +44,11 @@ obj-$(CONFIG_VGA) += vga.o
common-obj-$(CONFIG_QXL) += qxl.o qxl-logger.o qxl-render.o
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
virtio-gpu.o-cflags := $(VIRGL_CFLAGS)
virtio-gpu.o-libs += $(VIRGL_LIBS)
virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS)
+51
View File
@@ -0,0 +1,51 @@
/*
* vhost-user GPU PCI device
*
* Copyright Red Hat, Inc. 2018
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "hw/virtio/virtio-gpu-pci.h"
#define TYPE_VHOST_USER_GPU_PCI "vhost-user-gpu-pci"
#define VHOST_USER_GPU_PCI(obj) \
OBJECT_CHECK(VhostUserGPUPCI, (obj), TYPE_VHOST_USER_GPU_PCI)
typedef struct VhostUserGPUPCI {
VirtIOGPUPCIBase parent_obj;
VhostUserGPU vdev;
} VhostUserGPUPCI;
static void vhost_user_gpu_pci_initfn(Object *obj)
{
VhostUserGPUPCI *dev = VHOST_USER_GPU_PCI(obj);
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VHOST_USER_GPU);
VIRTIO_GPU_PCI_BASE(obj)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
object_property_add_alias(obj, "chardev",
OBJECT(&dev->vdev), "chardev",
&error_abort);
}
static const VirtioPCIDeviceTypeInfo vhost_user_gpu_pci_info = {
.generic_name = TYPE_VHOST_USER_GPU_PCI,
.parent = TYPE_VIRTIO_GPU_PCI_BASE,
.instance_size = sizeof(VhostUserGPUPCI),
.instance_init = vhost_user_gpu_pci_initfn,
};
static void vhost_user_gpu_pci_register_types(void)
{
virtio_pci_types_register(&vhost_user_gpu_pci_info);
}
type_init(vhost_user_gpu_pci_register_types)
File diff suppressed because it is too large Load Diff
+52
View File
@@ -0,0 +1,52 @@
/*
* vhost-user VGA device
*
* Copyright Red Hat, Inc. 2018
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "virtio-vga.h"
#define TYPE_VHOST_USER_VGA "vhost-user-vga"
#define VHOST_USER_VGA(obj) \
OBJECT_CHECK(VhostUserVGA, (obj), TYPE_VHOST_USER_VGA)
typedef struct VhostUserVGA {
VirtIOVGABase parent_obj;
VhostUserGPU vdev;
} VhostUserVGA;
static void vhost_user_vga_inst_initfn(Object *obj)
{
VhostUserVGA *dev = VHOST_USER_VGA(obj);
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
TYPE_VHOST_USER_GPU);
VIRTIO_VGA_BASE(dev)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
object_property_add_alias(obj, "chardev",
OBJECT(&dev->vdev), "chardev",
&error_abort);
}
static const VirtioPCIDeviceTypeInfo vhost_user_vga_info = {
.generic_name = TYPE_VHOST_USER_VGA,
.parent = TYPE_VIRTIO_VGA_BASE,
.instance_size = sizeof(struct VhostUserVGA),
.instance_init = vhost_user_vga_inst_initfn,
};
static void vhost_user_vga_register_types(void)
{
virtio_pci_types_register(&vhost_user_vga_info);
}
type_init(vhost_user_vga_register_types)
+1 -16
View File
@@ -16,22 +16,7 @@
#include "hw/pci/pci.h"
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-bus.h"
#include "hw/virtio/virtio-pci.h"
#include "hw/virtio/virtio-gpu.h"
typedef struct VirtIOGPUPCIBase VirtIOGPUPCIBase;
/*
* virtio-gpu-pci-base: This extends VirtioPCIProxy.
*/
#define TYPE_VIRTIO_GPU_PCI_BASE "virtio-gpu-pci-base"
#define VIRTIO_GPU_PCI_BASE(obj) \
OBJECT_CHECK(VirtIOGPUPCIBase, (obj), TYPE_VIRTIO_GPU_PCI_BASE)
struct VirtIOGPUPCIBase {
VirtIOPCIProxy parent_obj;
VirtIOGPUBase *vgpu;
};
#include "hw/virtio/virtio-gpu-pci.h"
static Property virtio_gpu_pci_base_properties[] = {
DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef VIRTIO_VGA_H_
#define VIRTIO_VGA_H_
#include "hw/virtio/virtio-pci.h"
#include "hw/virtio/virtio-gpu-pci.h"
#include "vga_int.h"
/*
+40
View File
@@ -0,0 +1,40 @@
/*
* Virtio GPU PCI Device
*
* Copyright Red Hat, Inc. 2013-2014
*
* Authors:
* Dave Airlie <airlied@redhat.com>
* Gerd Hoffmann <kraxel@redhat.com>
*
* This work is licensed under the terms of the GNU GPL, version 2.
* See the COPYING file in the top-level directory.
*/
#ifndef HW_VIRTIO_GPU_PCI_H
#define HW_VIRTIO_GPU_PCI_H
#include "hw/virtio/virtio-pci.h"
#include "hw/virtio/virtio-gpu.h"
typedef struct VirtIOGPUPCIBase VirtIOGPUPCIBase;
/*
* virtio-gpu-pci-base: This extends VirtioPCIProxy.
*/
#define TYPE_VIRTIO_GPU_PCI_BASE "virtio-gpu-pci-base"
#define VIRTIO_GPU_PCI_BASE(obj) \
OBJECT_CHECK(VirtIOGPUPCIBase, (obj), TYPE_VIRTIO_GPU_PCI_BASE)
struct VirtIOGPUPCIBase {
VirtIOPCIProxy parent_obj;
VirtIOGPUBase *vgpu;
};
/* to share between PCI and VGA */
#define DEFINE_VIRTIO_GPU_PCI_PROPERTIES(_state) \
DEFINE_PROP_BIT("ioeventfd", _state, flags, \
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false), \
DEFINE_PROP_UINT32("vectors", _state, nvectors, 3)
#endif /* HW_VIRTIO_GPU_PCI_H */
+13 -6
View File
@@ -19,6 +19,7 @@
#include "ui/console.h"
#include "hw/virtio/virtio.h"
#include "qemu/log.h"
#include "sysemu/vhost-user-backend.h"
#include "standard-headers/linux/virtio_gpu.h"
@@ -34,6 +35,8 @@
#define VIRTIO_GPU(obj) \
OBJECT_CHECK(VirtIOGPU, (obj), TYPE_VIRTIO_GPU)
#define TYPE_VHOST_USER_GPU "vhost-user-gpu"
#define VIRTIO_ID_GPU 16
struct virtio_gpu_simple_resource {
@@ -157,13 +160,17 @@ typedef struct VirtIOGPU {
} stats;
} VirtIOGPU;
extern const GraphicHwOps virtio_gpu_ops;
typedef struct VhostUserGPU {
VirtIOGPUBase parent_obj;
/* to share between PCI and VGA */
#define DEFINE_VIRTIO_GPU_PCI_PROPERTIES(_state) \
DEFINE_PROP_BIT("ioeventfd", _state, flags, \
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false), \
DEFINE_PROP_UINT32("vectors", _state, nvectors, 3)
VhostUserBackend *vhost;
int vhost_gpu_fd; /* closed by the chardev */
CharBackend vhost_chr;
QemuDmaBuf dmabuf[VIRTIO_GPU_MAX_SCANOUTS];
bool backend_blocked;
} VhostUserGPU;
extern const GraphicHwOps virtio_gpu_ops;
#define VIRTIO_GPU_FILL_CMD(out) do { \
size_t s; \
+1
View File
@@ -239,6 +239,7 @@ static struct {
{ .driver = "qxl-vga", .flag = &default_vga },
{ .driver = "virtio-vga", .flag = &default_vga },
{ .driver = "ati-vga", .flag = &default_vga },
{ .driver = "vhost-user-vga", .flag = &default_vga },
};
static QemuOptsList qemu_rtc_opts = {