Add vhost-user-gpu
v7 cover Add vhost-user-gpu
Hi,
vhost-user allows to drive a virtio device in a seperate process. After vhost-user-net, we have seen vhost-user-{scsi,blk,crypto,input} added more recently.
This series, initially proposed ~3 years ago, time flies
(https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg01905.html)
contributes with vhost-user-gpu.
You may start a vhost-user-gpu with virgl rendering in a separate process like this:
$ ./vhost-user-gpu --virgl -s vgpu.sock & $ qemu... -chardev socket,id=chr,path=vgpu.sock -device vhost-user-vga,chardev=chr
Based-on: <[email protected]>
v7:
- add "framed" replies to the vhost-user-gpu protocol
- use GBM library instead of drm-vendor APIs
- added "virtio-gpu: add a pixman helper header"
v6:
- do not install vhost-user-input
- install vhost-user-gpu and json file following the spec
- fix the build when drm-intel-devel missing
- rebase (& resend without already applied patches)
v5:
- remove user-creatable version of vhost-user-backend
- remove optinal management of sub-process in vhost-user-backend
- removed daemonize/pid code
- drop introduction of new input & gpu messages for PCI config space handling, instead use VHOST_USER_PROTOCOL_F_CONFIG
- plain mem & udmabuf fallback for 2d rendering
- rebased, kconfig-ify, rst-ify
Marc-André Lureau (8):
vhost-user: add vhost_user_gpu_set_socket()
virtio-gpu: add bswap helpers header
virtio-gpu: add a pixman helper header
util: compile drm.o on Linux
contrib: add vhost-user-gpu
virtio-gpu: split virtio-gpu, introduce virtio-gpu-base
virtio-gpu: split virtio-gpu-pci & virtio-vga hw/display: add vhost-user-vga & gpu-pci
configure | 17 + contrib/libvhost-user/libvhost-user.h | 1 + contrib/vhost-user-gpu/virgl.h | 25 + contrib/vhost-user-gpu/vugbm.h | 67 ++ contrib/vhost-user-gpu/vugpu.h | 177 +++ hw/display/virtio-vga.h | 32 + include/hw/virtio/vhost-backend.h | 2 + include/hw/virtio/virtio-gpu-bswap.h | 61 + include/hw/virtio/virtio-gpu-pci.h | 40 + include/hw/virtio/virtio-gpu-pixman.h | 45 + include/hw/virtio/virtio-gpu.h | 92 +- contrib/libvhost-user/libvhost-user.c | 1 + contrib/vhost-user-gpu/main.c | 1185 ++++++++++++++++++++ contrib/vhost-user-gpu/virgl.c | 579 ++++++++++ contrib/vhost-user-gpu/vugbm.c | 331 ++++++ hw/display/vhost-user-gpu-pci.c | 51 + hw/display/vhost-user-gpu.c | 607 ++++++++++ hw/display/vhost-user-vga.c | 52 + hw/display/virtio-gpu-3d.c | 49 +- hw/display/virtio-gpu-base.c | 268 +++++ hw/display/virtio-gpu-pci.c | 55 +- hw/display/virtio-gpu.c | 444 ++------ hw/display/virtio-vga.c | 138 +-- hw/virtio/vhost-user.c | 11 + vl.c | 1 + MAINTAINERS | 10 +- Makefile | 24 +- Makefile.objs | 1 + contrib/vhost-user-gpu/50-qemu-gpu.json.in | 5 + contrib/vhost-user-gpu/Makefile.objs | 10 + docs/interop/index.rst | 2 +- docs/interop/vhost-user-gpu.rst | 243 ++++ docs/interop/vhost-user.txt | 9 + hw/display/Kconfig | 10 + hw/display/Makefile.objs | 5 +- rules.mak | 9 +- util/Makefile.objs | 2 +- 37 files changed, 4176 insertions(+), 485 deletions(-) create mode 100644 contrib/vhost-user-gpu/virgl.h create mode 100644 contrib/vhost-user-gpu/vugbm.h create mode 100644 contrib/vhost-user-gpu/vugpu.h create mode 100644 hw/display/virtio-vga.h create mode 100644 include/hw/virtio/virtio-gpu-bswap.h create mode 100644 include/hw/virtio/virtio-gpu-pci.h create mode 100644 include/hw/virtio/virtio-gpu-pixman.h create mode 100644 contrib/vhost-user-gpu/main.c create mode 100644 contrib/vhost-user-gpu/virgl.c create mode 100644 contrib/vhost-user-gpu/vugbm.c create mode 100644 hw/display/vhost-user-gpu-pci.c create mode 100644 hw/display/vhost-user-gpu.c create mode 100644 hw/display/vhost-user-vga.c create mode 100644 hw/display/virtio-gpu-base.c create mode 100644 contrib/vhost-user-gpu/50-qemu-gpu.json.in create mode 100644 contrib/vhost-user-gpu/Makefile.objs create mode 100644 docs/interop/vhost-user-gpu.rst
Signature · 1 line
2.21.0.777.g83232e3864
PATCH v7 1/8 vhost-user: add vhost_user_gpu_set_socket()
Add a new vhost-user message to give a unix socket to a vhost-user backend for GPU display updates.
Back when I started that work, I added a new GPU channel because the vhost-user protocol wasn't bidirectional. Since then, there is a vhost-user-slave channel for the slave to send requests to the master. We could extend it with GPU messages. However, the GPU protocol is quite orthogonal to vhost-user, thus I chose to have a new dedicated channel.
See vhost-user-gpu.rst for the protocol details.
--- contrib/libvhost-user/libvhost-user.h | 1 + include/hw/virtio/vhost-backend.h | 2 + contrib/libvhost-user/libvhost-user.c | 1 + hw/virtio/vhost-user.c | 11 ++ MAINTAINERS | 6 + docs/interop/index.rst | 2 +- docs/interop/vhost-user-gpu.rst | 243 ++++++++++++++++++++++++++ docs/interop/vhost-user.txt | 9 + 8 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 docs/interop/vhost-user-gpu.rst
contrib/libvhost-user/libvhost-user.h +1 -0
@@ -94,6 +94,7 @@ typedef enum VhostUserRequest {VHOST_USER_POSTCOPY_END =30 ,VHOST_USER_GET_INFLIGHT_FD =31 ,VHOST_USER_SET_INFLIGHT_FD =32 , +VHOST_USER_GPU_SET_SOCKET =33 , VHOST_USER_MAX } VhostUserRequest;
include/hw/virtio/vhost-backend.h +2 -0
@@ -170,4 +170,6 @@ int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev,int vhost_backend_handle_iotlb_msg (struct vhost_dev *dev,struct vhost_iotlb_msg *imsg); +int vhost_user_gpu_set_socket (struct vhost_dev *dev,int fd); +#endif /* VHOST_BACKEND_H */
contrib/libvhost-user/libvhost-user.c +1 -0
@@ -130,6 +130,7 @@ vu_request_to_string(unsigned int req)REQ (VHOST_USER_POSTCOPY_END ),REQ (VHOST_USER_GET_INFLIGHT_FD ),REQ (VHOST_USER_SET_INFLIGHT_FD ), +REQ (VHOST_USER_GPU_SET_SOCKET ), REQ(VHOST_USER_MAX), };#undef REQ
hw/virtio/vhost-user.c +11 -0
@@ -96,6 +96,7 @@ typedef enum VhostUserRequest {VHOST_USER_POSTCOPY_END =30 ,VHOST_USER_GET_INFLIGHT_FD =31 ,VHOST_USER_SET_INFLIGHT_FD =32 , +VHOST_USER_GPU_SET_SOCKET =33 , VHOST_USER_MAX } VhostUserRequest;
@@ -353,6 +354,16 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,return 0 ; } +int vhost_user_gpu_set_socket (struct vhost_dev *dev,int fd) +{ +VhostUserMsg msg = { + .hdr.request =VHOST_USER_GPU_SET_SOCKET , + .hdr.flags =VHOST_USER_VERSION , + }; + +return vhost_user_write (dev, &msg, &fd,1 ); +} +static int vhost_user_set_log_base (struct vhost_dev *dev,uint64_t base,struct vhost_log *log) {
MAINTAINERS +6 -0
@@ -1675,6 +1675,12 @@ F: hw/display/virtio-gpu* F: hw/display/virtio-vga.c F: include/hw/virtio/virtio-gpu.h +vhost-user-gpu +M: Marc-André Lureau <[email protected]> +M: Gerd Hoffmann <[email protected]> +S: Maintained +F: docs/interop/vhost-user-gpu.rst + Cirrus VGA M: Gerd Hoffmann <[email protected]> S: Odd Fixes
docs/interop/index.rst +1 -1
@@ -15,4 +15,4 @@ Contents: bitmaps live-block-operations pr-helper - + vhost-user-gpu
docs/interop/vhost-user-gpu.rst new file +243 -0
243 lines not on this page · raw message
docs/interop/vhost-user.txt +9 -0
@@ -1051,6 +1051,15 @@ Master message types the shared inflight buffer back to slave so that slave could get inflight I/O after a crash or restart. + * VHOST_USER_GPU_SET_SOCKET + Id: 33 + Master payload: N/A + Slave payload: N/A + + Sets the GPU protocol socket file descriptor, which is passed as + ancillary data. The GPU protocol is used to inform the master of + rendering state and updates. See vhost-user-gpu.rst for details. + Slave message types -------------------
Signature · 1 line
2.21.0.777.g83232e3864
Re: [Qemu-devel] [PATCH v7 1/8] vhost-user: add vhost_user_gpu_set_socket()
Hi,
docs/interop/vhost-user-gpu.rst line 82
Quoted 12 lines
docs/interop/vhost-user-gpu.rst new file +12
-0+VhostUserGpuCursorUpdate +^^^^^^^^^^^^^^^^^^^^^^^^ + ++-----+-------+-------+--------+ +| pos | hot_x | hot_y | cursor | ++-----+-------+-------+--------+ + +:pos: a ``VhostUserGpuCursorPos``, the cursor location + +:hot_x/hot_y: ``u32``, the cursor hot location + +:cursor: ``[u32; 64 * 64]``, 64x64 RGBA cursor data
Should clarify here what exactly RGBA is. (PIXMAN_a8r8g8b8 I guess).
docs/interop/vhost-user-gpu.rst line 107
Quoted 13 lines
docs/interop/vhost-user-gpu.rst new file +13
-0+VhostUserGpuUpdate +^^^^^^^^^^^^^^^^^^ + ++------------+---+---+---+---+------+ +| scanout-id | x | y | w | h | data | ++------------+---+---+---+---+------+ + +:scanout-id: ``u32``, the scanout content to update + +:x/y/w/h: ``u32``, region of the update + +:data: RGBA data (the size is computed based on the region size, and + the request type)
Likewise. Also: alpha channel for the framebuffer?
docs/interop/vhost-user-gpu.rst line 137
Quoted 11 lines
docs/interop/vhost-user-gpu.rst new file +11
-0+C structure +----------- + +In QEMU the vhost-user-gpu message is implemented with the following struct: + +.. code:: c + + typedef struct VhostUserGpuMsg { + uint32_t request; /* VhostUserGpuRequest */ + uint32_t flags; + uint32_t size; /* the following payload size */
uint32_t padding;
docs/interop/vhost-user-gpu.rst line 145
Quoted 8 lines
docs/interop/vhost-user-gpu.rst new file +8
-0+ union { + VhostUserGpuCursorPos cursor_pos; + VhostUserGpuCursorUpdate cursor_update; + VhostUserGpuScanout scanout; + VhostUserGpuUpdate update; + VhostUserGpuDMABUFScanout dmabuf_scanout; + struct virtio_gpu_resp_display_info display_info; + uint64_t u64;
... so this 64bit value will be aligned.
cheers,
Gerd
Re: [Qemu-devel] [PATCH v7 1/8] vhost-user: add vhost_user_gpu_set_socket()
Hi
Quoted 17 lines · Gerd Hoffmann
Hi,
docs/interop/vhost-user-gpu.rst line 82
Quoted 12 lines
docs/interop/vhost-user-gpu.rst new file +12
-0+VhostUserGpuCursorUpdate +^^^^^^^^^^^^^^^^^^^^^^^^ + ++-----+-------+-------+--------+ +| pos | hot_x | hot_y | cursor | ++-----+-------+-------+--------+ + +:pos: a ``VhostUserGpuCursorPos``, the cursor location + +:hot_x/hot_y: ``u32``, the cursor hot location + +:cursor: ``[u32; 64 * 64]``, 64x64 RGBA cursor dataShould clarify here what exactly RGBA is. (
PIXMAN_a8r8g8b8I guess).
ok
Quoted 16 lines
Quoted 4 lines
docs/interop/vhost-user-gpu.rst new file +3
-0+VhostUserGpuUpdate +^^^^^^^^^^^^^^^^^^ +docs/interop/vhost-user-gpu.rst line 107
Quoted 10 lines
docs/interop/vhost-user-gpu.rst new file +10
-0++------------+---+---+---+---+------+ +| scanout-id | x | y | w | h | data | ++------------+---+---+---+---+------+ + +:scanout-id: ``u32``, the scanout content to update + +:x/y/w/h: ``u32``, region of the update + +:data: RGBA data (the size is computed based on the region size, and + the request type)Likewise. Also: alpha channel for the framebuffer?
It is actually PIXMAN_x8r8g8b8, fixed
Quoted 24 lines
docs/interop/vhost-user-gpu.rst line 137
Quoted 12 lines
docs/interop/vhost-user-gpu.rst new file +11
-0+C structure +----------- + +In QEMU the vhost-user-gpu message is implemented with the following struct: + +.. code:: c + + typedef struct VhostUserGpuMsg { + uint32_t request; /* VhostUserGpuRequest */ + uint32_t flags; + uint32_t size; /* the following payload size */
uint32_tpadding;docs/interop/vhost-user-gpu.rst line 145
Quoted 8 lines
docs/interop/vhost-user-gpu.rst new file +8
-0+ union { + VhostUserGpuCursorPos cursor_pos; + VhostUserGpuCursorUpdate cursor_update; + VhostUserGpuScanout scanout; + VhostUserGpuUpdate update; + VhostUserGpuDMABUFScanout dmabuf_scanout; + struct virtio_gpu_resp_display_info display_info; + uint64_t u64;
Quoted 1 line
... so this 64bit value will be aligned.
vhost-user didn't bother. Should we?
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [PATCH v7 1/8] vhost-user: add vhost_user_gpu_set_socket()
Quoted 16 lines
Quoted 16 lines
docs/interop/vhost-user-gpu.rst line 137
Quoted 4 lines
docs/interop/vhost-user-gpu.rst new file +4
-0+ typedef struct VhostUserGpuMsg { + uint32_t request; /* VhostUserGpuRequest */ + uint32_t flags; + uint32_t size; /* the following payload size */
uint32_tpadding;Quoted 8 lines
docs/interop/vhost-user-gpu.rst new file +8
-0+ union { + VhostUserGpuCursorPos cursor_pos; + VhostUserGpuCursorUpdate cursor_update; + VhostUserGpuScanout scanout; + VhostUserGpuUpdate update; + VhostUserGpuDMABUFScanout dmabuf_scanout; + struct virtio_gpu_resp_display_info display_info; + uint64_t u64;
Quoted 3 lines
Quoted 1 line
... so this 64bit value will be aligned.
vhost-user didn't bother. Should we?
I think it is nicer, but given that the struct is declared as "packed" it'll work either way.
Matter of taste. Consider it a suggestion.
cheers,
Gerd
PATCH v7 2/8 virtio-gpu: add bswap helpers header
In reply to Marc-André LureauThe helper functions are useful to build the vhost-user-gpu backend.
--- include/hw/virtio/virtio-gpu-bswap.h | 61 ++++++++++++++++++++++++++++ hw/display/virtio-gpu.c | 43 +------------------- 2 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 include/hw/virtio/virtio-gpu-bswap.h
include/hw/virtio/virtio-gpu-bswap.h new file +61 -0
@@ -0,0 +1,61 @@ +/* +* Virtio GPU Device +* +* Copyright Red Hat, Inc. 2013-2014 +* +* Authors: +* Dave Airlie <[email protected]> +* Gerd Hoffmann <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_VIRTIO_GPU_BSWAP_H +#define HW_VIRTIO_GPU_BSWAP_H + +#include "qemu/bswap.h" + +static inline void +virtio_gpu_ctrl_hdr_bswap (struct virtio_gpu_ctrl_hdr *hdr) +{ +le32_to_cpus (&hdr->type); +le32_to_cpus (&hdr->flags); +le64_to_cpus (&hdr->fence_id); +le32_to_cpus (&hdr->ctx_id); +le32_to_cpus (&hdr->padding); +} + +static inline void +virtio_gpu_bswap_32 (void *ptr,size_t size) +{ +#ifdef HOST_WORDS_BIGENDIAN + +size_t i; +struct virtio_gpu_ctrl_hdr *hdr = (struct virtio_gpu_ctrl_hdr *) ptr; + +virtio_gpu_ctrl_hdr_bswap (hdr); + + i =sizeof (struct virtio_gpu_ctrl_hdr ); +while (i < size) { +le32_to_cpus ((uint32_t *)(ptr + i)); + i = i +sizeof (uint32_t ); + } + +#endif +} + +static inline void +virtio_gpu_t2d_bswap (struct virtio_gpu_transfer_to_host_2d *t2d) +{ +virtio_gpu_ctrl_hdr_bswap (&t2d->hdr); +le32_to_cpus (&t2d->r.x); +le32_to_cpus (&t2d->r.y); +le32_to_cpus (&t2d->r.width); +le32_to_cpus (&t2d->r.height); +le64_to_cpus (&t2d->offset); +le32_to_cpus (&t2d->resource_id); +le32_to_cpus (&t2d->padding); +} + +#endif
hw/display/virtio-gpu.c +1 -42
55 lines not on this page · raw message
Signature · 1 line
2.21.0.777.g83232e3864
PATCH v7 3/8 virtio-gpu: add a pixman helper header
In reply to Marc-André LureauThis will allow to share the format conversion function with vhost-user-gpu.
--- include/hw/virtio/virtio-gpu-pixman.h | 45 +++++++++++++++++++++++++++ hw/display/virtio-gpu.c | 29 ++--------------- 2 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 include/hw/virtio/virtio-gpu-pixman.h
include/hw/virtio/virtio-gpu-pixman.h new file +45 -0
@@ -0,0 +1,45 @@ +/* +* Virtio GPU Device +* +* Copyright Red Hat, Inc. 2013-2014 +* +* Authors: +* Dave Airlie <[email protected]> +* Gerd Hoffmann <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_VIRTIO_GPU_PIXMAN_H +#define HW_VIRTIO_GPU_PIXMAN_H + +#include "ui/qemu-pixman.h" +#include "standard-headers/linux/virtio_gpu.h" + +static inline pixman_format_code_t +virtio_gpu_get_pixman_format (uint32_t virtio_gpu_format) +{ +switch (virtio_gpu_format) { +case VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM : +return PIXMAN_BE_b8g8r8x8; +case VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM : +return PIXMAN_BE_b8g8r8a8; +case VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM : +return PIXMAN_BE_x8r8g8b8; +case VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM : +return PIXMAN_BE_a8r8g8b8; +case VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM : +return PIXMAN_BE_r8g8b8x8; +case VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM : +return PIXMAN_BE_r8g8b8a8; +case VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM : +return PIXMAN_BE_x8b8g8r8; +case VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM : +return PIXMAN_BE_a8b8g8r8; +default : +return 0 ; + } +} + +#endif
hw/display/virtio-gpu.c +3 -26
@@ -21,6 +21,7 @@#include "hw/virtio/virtio.h" #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-gpu-bswap.h" +#include "hw/virtio/virtio-gpu-pixman.h" #include "hw/virtio/virtio-bus.h" #include "hw/display/edid.h" #include "migration/blocker.h"
@@ -298,30 +299,6 @@ void virtio_gpu_get_edid(VirtIOGPU *g,virtio_gpu_ctrl_response (g, cmd, &edid.hdr,sizeof (edid)); } -static pixman_format_code_t get_pixman_format (uint32_t virtio_gpu_format) -{ -switch (virtio_gpu_format) { -case VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM : -return PIXMAN_BE_b8g8r8x8; -case VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM : -return PIXMAN_BE_b8g8r8a8; -case VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM : -return PIXMAN_BE_x8r8g8b8; -case VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM : -return PIXMAN_BE_a8r8g8b8; -case VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM : -return PIXMAN_BE_r8g8b8x8; -case VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM : -return PIXMAN_BE_r8g8b8a8; -case VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM : -return PIXMAN_BE_x8b8g8r8; -case VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM : -return PIXMAN_BE_a8b8g8r8; -default : -return 0 ; - } -} -static uint32_t calc_image_hostmem (pixman_format_code_t pformat,uint32_t width,uint32_t height) {
@@ -368,7 +345,7 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g, res->format = c2d.format; res->resource_id = c2d.resource_id; - pformat =get_pixman_format (c2d.format); + pformat =virtio_gpu_get_pixman_format (c2d.format);if (!pformat) { qemu_log_mask(LOG_GUEST_ERROR, "%s: host couldn't handle guest format %d\n",
@@ -1142,7 +1119,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size, res->iov_cnt =qemu_get_be32 (f);/* allocate */ - pformat =get_pixman_format (res->format); + pformat =virtio_gpu_get_pixman_format (res->format);if (!pformat) {g_free (res);return -EINVAL ;
Signature · 1 line
2.21.0.777.g83232e3864
PATCH v7 4/8 util: compile drm.o on Linux
In reply to Marc-André LureauOpenGL isn't required to use DRM rendernodes. The following patches uses it for 2d resources for ex.
--- util/Makefile.objs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
util/Makefile.objs +1 -1
@@ -53,6 +53,6 @@ util-obj-y += systemd.o util-obj-y += iova-tree.o util-obj-$(CONFIG_INOTIFY1) += filemonitor-inotify.o util-obj-$(CONFIG_LINUX) += vfio-helpers.o -util-obj-$(CONFIG_OPENGL) += drm.o +util-obj-$(CONFIG_LINUX) += drm.o stub-obj-y += filemonitor-stub.o
Signature · 1 line
2.21.0.777.g83232e3864
PATCH v7 5/8 contrib: add vhost-user-gpu
In reply to Marc-André LureauAdd a vhost-user gpu backend, based on virtio-gpu/3d device. It is to be associated with a vhost-user-gpu device.
Various TODO and nice to have items:
- multi-head support
- crash & resume handling
- accelerated rendering/display that avoids the waiting round trips
- edid support
--- configure | 17 + contrib/vhost-user-gpu/virgl.h | 25 + contrib/vhost-user-gpu/vugbm.h | 67 ++ contrib/vhost-user-gpu/vugpu.h | 177 +++ contrib/vhost-user-gpu/main.c | 1185 ++++++++++++++++++++ contrib/vhost-user-gpu/virgl.c | 579 ++++++++++ contrib/vhost-user-gpu/vugbm.c | 331 ++++++ MAINTAINERS | 2 + Makefile | 24 +- Makefile.objs | 1 + contrib/vhost-user-gpu/50-qemu-gpu.json.in | 5 + contrib/vhost-user-gpu/Makefile.objs | 10 + rules.mak | 9 +- 13 files changed, 2430 insertions(+), 2 deletions(-) create mode 100644 contrib/vhost-user-gpu/virgl.h create mode 100644 contrib/vhost-user-gpu/vugbm.h create mode 100644 contrib/vhost-user-gpu/vugpu.h create mode 100644 contrib/vhost-user-gpu/main.c create mode 100644 contrib/vhost-user-gpu/virgl.c create mode 100644 contrib/vhost-user-gpu/vugbm.c create mode 100644 contrib/vhost-user-gpu/50-qemu-gpu.json.in create mode 100644 contrib/vhost-user-gpu/Makefile.objs
configure +17 -0
@@ -4086,6 +4086,13 @@ libs_softmmu="$libs_softmmu $fdt_libs" ########################################## # opengl probe (for sdl2, gtk, milkymist-tmu2) +gbm="no" +if $pkg_config gbm; then + gbm_cflags="$($pkg_config --cflags gbm)" + gbm_libs="$($pkg_config --libs gbm)" + gbm="yes" +fi + if test "$opengl" != "no" ; then opengl_pkgs="epoxy gbm" if $pkg_config $opengl_pkgs; then
@@ -6935,6 +6942,13 @@ if test "$opengl" = "yes" ; then fi fi +if test "$gbm" = "yes" ; then + echo "CONFIG_GBM=y" >> $config_host_mak + echo "GBM_LIBS=$gbm_libs" >> $config_host_mak + echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak +fi + + if test "$malloc_trim" = "yes" ; then echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak fi
@@ -7828,6 +7842,9 @@ echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak done # for target in $targets +echo "PIXMAN_CFLAGS=$pixman_cflags" >> $config_host_mak +echo "PIXMAN_LIBS=$pixman_libs" >> $config_host_mak + if test -n "$enabled_cross_compilers"; then echo echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
contrib/vhost-user-gpu/virgl.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Virtio vhost-user GPU Device +* +* Copyright Red Hat, Inc. 2013-2018 +* +* Authors: +* Dave Airlie <[email protected]> +* Gerd Hoffmann <[email protected]> +* Marc-André Lureau <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ +#ifndef VUGPU_VIRGL_H_ +#define VUGPU_VIRGL_H_ + +#include "vugpu.h" + +bool vg_virgl_init (VuGpu *g); +uint32_t vg_virgl_get_num_capsets (void ); +void vg_virgl_process_cmd (VuGpu *vg,struct virtio_gpu_ctrl_command *cmd); +void vg_virgl_update_cursor_data (VuGpu *g,uint32_t resource_id, +gpointer data); + +#endif
contrib/vhost-user-gpu/vugbm.h new file +67 -0
67 lines not on this page · raw message
contrib/vhost-user-gpu/vugpu.h new file +177 -0
177 lines not on this page · raw message
contrib/vhost-user-gpu/main.c new file +1185 -0
1,185 lines not on this page · raw message
contrib/vhost-user-gpu/virgl.c new file +579 -0
579 lines not on this page · raw message
contrib/vhost-user-gpu/vugbm.c new file +331 -0
331 lines not on this page · raw message
MAINTAINERS +2 -0
@@ -1680,6 +1680,8 @@ M: Marc-André Lureau <[email protected]> M: Gerd Hoffmann <[email protected]> S: Maintained F: docs/interop/vhost-user-gpu.rst +F: contrib/vhost-user-gpu +F: hw/display/vhost-user-* Cirrus VGA M: Gerd Hoffmann <[email protected]>
Makefile +23 -1
@@ -312,8 +312,20 @@ $(call set-vpath, $(SRC_PATH)) LIBS+=-lz $(LIBS_TOOLS) +vhost-user-json-y = +HELPERS-y = + HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF) +ifdef CONFIG_LINUX +ifdef CONFIG_VIRGL +ifdef CONFIG_GBM +HELPERS-y += vhost-user-gpu$(EXESUF) +vhost-user-json-y += contrib/vhost-user-gpu/50-qemu-gpu.json +endif +endif +endif + ifdef BUILD_DOCS DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
@@ -407,6 +419,7 @@ dummy := $(call unnest-vars,, \ vhost-user-scsi-obj-y \ vhost-user-blk-obj-y \ vhost-user-input-obj-y \ + vhost-user-gpu-obj-y \ qga-vss-dll-obj-y \ block-obj-y \ block-obj-m \
@@ -424,7 +437,7 @@ dummy := $(call unnest-vars,, \ include $(SRC_PATH)/tests/Makefile.include -all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules +all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules $(vhost-user-json-y) qemu-version.h: FORCE $(call quiet-command, \
@@ -616,6 +629,9 @@ rdmacm-mux$(EXESUF): LIBS += "-libumad" rdmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS) $(call LINK, $^) +vhost-user-gpu$(EXESUF): $(vhost-user-gpu-obj-y) $(libvhost-user-obj-y) libqemuutil.a libqemustub.a + $(call LINK, $^) + ifdef CONFIG_VHOST_USER_INPUT ifdef CONFIG_LINUX vhost-user-input$(EXESUF): $(vhost-user-input-obj-y) libvhost-user.a libqemuutil.a
@@ -824,6 +840,12 @@ endif ifneq ($(HELPERS-y),) $(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir)) endif +ifneq ($(vhost-user-json-y),) + $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/vhost-user/" + for x in $(vhost-user-json-y); do \ + $(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)/vhost-user/"; \ + done +endif ifdef CONFIG_TRACE_SYSTEMTAP $(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir) endif
Makefile.objs +1 -0
@@ -123,6 +123,7 @@ vhost-user-scsi-obj-y = contrib/vhost-user-scsi/ vhost-user-blk-obj-y = contrib/vhost-user-blk/ rdmacm-mux-obj-y = contrib/rdmacm-mux/ vhost-user-input-obj-y = contrib/vhost-user-input/ +vhost-user-gpu-obj-y = contrib/vhost-user-gpu/ ###################################################################### trace-events-subdirs =
contrib/vhost-user-gpu/50-qemu-gpu.json.in new file +5 -0
@@ -0,0 +1,5 @@ +{ + "description": "QEMU vhost-user-gpu", + "type": "gpu", + "binary": "@libexecdir@/vhost-user-gpu", +}
contrib/vhost-user-gpu/Makefile.objs new file +10 -0
@@ -0,0 +1,10 @@ +vhost-user-gpu-obj-y = main.o virgl.o vugbm.o + +main.o-cflags := $(PIXMAN_CFLAGS) $(GBM_CFLAGS) +main.o-libs := $(PIXMAN_LIBS) + +virgl.o-cflags := $(VIRGL_CFLAGS) $(GBM_CFLAGS) +virgl.o-libs := $(VIRGL_LIBS) + +vugbm.o-cflags := $(GBM_CFLAGS) +vugbm.o-libs := $(GBM_LIBS)
rules.mak +8 -1
@@ -144,7 +144,7 @@ cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \ >/dev/null 2>&1 && echo OK), $2, $3) -VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc Kconfig% +VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc Kconfig% %.json.in set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) # install-prog list, dir
@@ -392,3 +392,10 @@ TEXI2MAN = $(call quiet-command, \ $(call TEXI2MAN) %.8: $(call TEXI2MAN) + +GEN_SUBST = $(call quiet-command, \ + sed -e "s!@libexecdir@!$(libexecdir)!g" < $< > $@, \ + "GEN","$@") + +%.json: %.json.in + $(call GEN_SUBST)
Signature · 1 line
2.21.0.777.g83232e3864
PATCH v7 6/8 virtio-gpu: split virtio-gpu, introduce virtio-gpu-base
In reply to Marc-André LureauAdd a base class that is common to virtio-gpu and vhost-user-gpu devices.
The VirtIOGPUBase base class provides common functionalities necessary for both virtio-gpu and vhost-user-gpu:
- common configuration (max-outputs, initial resolution, flags)
- virtio device initialization, including queue setup
- device pre-conditions checks (iommu)
- migration blocker
- virtio device callbacks
- hooking up to qemu display subsystem
- a few common helper functions to reset the device, retrieve display informations
- a class callback to unblock the rendering (for GL updates)
What is left to the virtio-gpu subdevice to take care of, in short, are all the virtio queues handling, command processing and migration.
--- include/hw/virtio/virtio-gpu.h | 73 +++++-- hw/display/virtio-gpu-3d.c | 49 +++-- hw/display/virtio-gpu-base.c | 268 ++++++++++++++++++++++++ hw/display/virtio-gpu-pci.c | 2 +- hw/display/virtio-gpu.c | 372 +++++++++------------------------ hw/display/virtio-vga.c | 11 +- hw/display/Makefile.objs | 2 +- 7 files changed, 458 insertions(+), 319 deletions(-) create mode 100644 hw/display/virtio-gpu-base.c
include/hw/virtio/virtio-gpu.h +56 -17
@@ -22,6 +22,14 @@#include "standard-headers/linux/virtio_gpu.h" +#define TYPE_VIRTIO_GPU_BASE "virtio-gpu-base" +#define VIRTIO_GPU_BASE (obj) \ + OBJECT_CHECK(VirtIOGPUBase, (obj), TYPE_VIRTIO_GPU_BASE) +#define VIRTIO_GPU_BASE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(VirtIOGPUBaseClass, obj, TYPE_VIRTIO_GPU_BASE) +#define VIRTIO_GPU_BASE_CLASS (klass) \ + OBJECT_CLASS_CHECK(VirtIOGPUBaseClass, klass, TYPE_VIRTIO_GPU_BASE) +#define TYPE_VIRTIO_GPU "virtio-gpu-device"#define VIRTIO_GPU (obj) \ OBJECT_CHECK(VirtIOGPU, (obj), TYPE_VIRTIO_GPU)
@@ -58,7 +66,7 @@ struct virtio_gpu_requested_state {int x, y; }; -enum virtio_gpu_conf_flags { +enum virtio_gpu_base_conf_flags {VIRTIO_GPU_FLAG_VIRGL_ENABLED =1 ,VIRTIO_GPU_FLAG_STATS_ENABLED ,VIRTIO_GPU_FLAG_EDID_ENABLED ,
@@ -71,8 +79,7 @@ enum virtio_gpu_conf_flags {#define virtio_gpu_edid_enabled (_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_EDID_ENABLED)) -struct virtio_gpu_conf { -uint64_t max_hostmem; +struct virtio_gpu_base_conf {uint32_t max_outputs;uint32_t flags;uint32_t xres;
@@ -88,31 +95,55 @@ struct virtio_gpu_ctrl_command {QTAILQ_ENTRY (virtio_gpu_ctrl_command) next; }; -typedef struct VirtIOGPU { +typedef struct VirtIOGPUBase {VirtIODevice parent_obj; - QEMUBH *ctrl_bh; - QEMUBH *cursor_bh; +Error *migration_blocker; + +struct virtio_gpu_base_conf conf; +struct virtio_gpu_config virtio_config; + +bool use_virgl_renderer; +int renderer_blocked; +int enable; + +struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS ]; + +int enabled_output_bitmask; +struct virtio_gpu_requested_state req_state[VIRTIO_GPU_MAX_SCANOUTS ]; +}VirtIOGPUBase ; + +typedef struct VirtIOGPUBaseClass { +VirtioDeviceClass parent; + +void (*gl_unblock)(VirtIOGPUBase *g); +}VirtIOGPUBaseClass ; + +#define VIRTIO_GPU_BASE_PROPERTIES (_state, _conf) \ + DEFINE_PROP_UINT32("max_outputs", _state, _conf.max_outputs, 1), \ + DEFINE_PROP_BIT("edid", _state, _conf.flags, \ + VIRTIO_GPU_FLAG_EDID_ENABLED, false), \ + DEFINE_PROP_UINT32("xres", _state, _conf.xres, 1024), \ + DEFINE_PROP_UINT32("yres", _state, _conf.yres, 768) + +typedef struct VirtIOGPU { + VirtIOGPUBase parent_obj; + + uint64_t conf_max_hostmem; + VirtQueue *ctrl_vq; VirtQueue *cursor_vq; - int enable; + QEMUBH *ctrl_bh; + QEMUBH *cursor_bh; QTAILQ_HEAD(, virtio_gpu_simple_resource) reslist; QTAILQ_HEAD(, virtio_gpu_ctrl_command) cmdq; QTAILQ_HEAD(, virtio_gpu_ctrl_command) fenceq; - struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; - struct virtio_gpu_requested_state req_state[VIRTIO_GPU_MAX_SCANOUTS]; - - struct virtio_gpu_conf conf; uint64_t hostmem; - int enabled_output_bitmask; - struct virtio_gpu_config virtio_config; - bool use_virgl_renderer; bool renderer_inited; - int renderer_blocked; bool renderer_reset; QEMUTimer *fence_poll; QEMUTimer *print_stats;
@@ -124,8 +155,6 @@ typedef struct VirtIOGPU {uint32_t req_3d;uint32_t bytes_3d; } stats; - -Error *migration_blocker; } VirtIOGPU;extern const GraphicHwOps virtio_gpu_ops;
@@ -148,6 +177,15 @@ extern const GraphicHwOps virtio_gpu_ops; } \ }while (0 ) +/* virtio-gpu-base.c */ +bool virtio_gpu_base_device_realize(DeviceState *qdev, + VirtIOHandleOutput ctrl_cb, + VirtIOHandleOutput cursor_cb, + Error **errp); +void virtio_gpu_base_reset (VirtIOGPUBase *g); +void virtio_gpu_base_fill_display_info (VirtIOGPUBase *g, +struct virtio_gpu_resp_display_info *dpy_info); +/* virtio-gpu.c */ void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd,
@@ -175,4 +213,5 @@ void virtio_gpu_virgl_fence_poll(VirtIOGPU *g);void virtio_gpu_virgl_reset (VirtIOGPU *g);int virtio_gpu_virgl_init (VirtIOGPU *g);int virtio_gpu_virgl_get_num_capsets (VirtIOGPU *g); +#endif
hw/display/virtio-gpu-3d.c +26 -23
131 lines not on this page · raw message
hw/display/virtio-gpu-base.c new file +268 -0
268 lines not on this page · raw message
hw/display/virtio-gpu-pci.c +1 -1
@@ -41,7 +41,7 @@ static Property virtio_gpu_pci_properties[] = {static void virtio_gpu_pci_realize (VirtIOPCIProxy *vpci_dev,Error **errp) {VirtIOGPUPCI *vgpu =VIRTIO_GPU_PCI (vpci_dev); -VirtIOGPU *g = &vgpu->vdev; +VirtIOGPUBase *g =VIRTIO_GPU_BASE (&vgpu->vdev);DeviceState *vdev =DEVICE (&vgpu->vdev);int i;Error *local_error =NULL ;
hw/display/virtio-gpu.c +99 -273
628 lines not on this page · raw message
hw/display/virtio-vga.c +7 -4
@@ -32,8 +32,9 @@ typedef struct VirtIOVGAClass {static void virtio_vga_invalidate_display (void *opaque) {VirtIOVGA *vvga = opaque; +VirtIOGPUBase *g =VIRTIO_GPU_BASE (&vvga->vdev); -if (vvga->vdev.enable) { +if (g->enable) { virtio_gpu_ops.invalidate (&vvga->vdev); }else { vvga->vga.hw_ops->invalidate (&vvga->vga);
@@ -43,8 +44,9 @@ static void virtio_vga_invalidate_display(void *opaque)static void virtio_vga_update_display (void *opaque) {VirtIOVGA *vvga = opaque; +VirtIOGPUBase *g =VIRTIO_GPU_BASE (&vvga->vdev); -if (vvga->vdev.enable) { +if (g->enable) { virtio_gpu_ops.gfx_update (&vvga->vdev); }else { vvga->vga.hw_ops->gfx_update (&vvga->vga);
@@ -54,8 +56,9 @@ static void virtio_vga_update_display(void *opaque)static void virtio_vga_text_update (void *opaque,console_ch_t *chardata) {VirtIOVGA *vvga = opaque; +VirtIOGPUBase *g =VIRTIO_GPU_BASE (&vvga->vdev); -if (vvga->vdev.enable) { +if (g->enable) {if (virtio_gpu_ops.text_update) { virtio_gpu_ops.text_update (&vvga->vdev, chardata); }
@@ -108,7 +111,7 @@ static const VMStateDescription vmstate_virtio_vga = {static void virtio_vga_realize (VirtIOPCIProxy *vpci_dev,Error **errp) {VirtIOVGA *vvga =VIRTIO_VGA (vpci_dev); -VirtIOGPU *g = &vvga->vdev; +VirtIOGPUBase *g =VIRTIO_GPU_BASE (&vvga->vdev);VGACommonState *vga = &vvga->vga;Error *err =NULL ;uint32_t offset;
hw/display/Makefile.objs +1 -1
@@ -43,7 +43,7 @@ obj-$(CONFIG_VGA) += vga.o common-obj-$(CONFIG_QXL) += qxl.o qxl-logger.o qxl-render.o -obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu.o virtio-gpu-3d.o +obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o virtio-gpu-3d.o obj-$(call land,$(CONFIG_VIRTIO_GPU),$(CONFIG_VIRTIO_PCI)) += virtio-gpu-pci.o obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o virtio-gpu.o-cflags := $(VIRGL_CFLAGS)
Signature · 1 line
2.21.0.777.g83232e3864
PATCH v7 7/8 virtio-gpu: split virtio-gpu-pci & virtio-vga
In reply to Marc-André LureauAdd base classes that are common to vhost-user-gpu-pci and vhost-user-vga.
--- hw/display/virtio-vga.h | 32 +++++++++ hw/display/virtio-gpu-pci.c | 52 +++++++++----- hw/display/virtio-vga.c | 135 ++++++++++++++++++------------------ MAINTAINERS | 2 +- 4 files changed, 137 insertions(+), 84 deletions(-) create mode 100644 hw/display/virtio-vga.h
hw/display/virtio-vga.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef VIRTIO_VGA_H_ +#define VIRTIO_VGA_H_ + +#include "hw/virtio/virtio-pci.h" +#include "vga_int.h" + +/* +* virtio-vga-base: This extends VirtioPCIProxy. +*/ +#define TYPE_VIRTIO_VGA_BASE "virtio-vga-base" +#define VIRTIO_VGA_BASE (obj) \ + OBJECT_CHECK(VirtIOVGABase, (obj), TYPE_VIRTIO_VGA_BASE) +#define VIRTIO_VGA_BASE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(VirtIOVGABaseClass, obj, TYPE_VIRTIO_VGA_BASE) +#define VIRTIO_VGA_BASE_CLASS (klass) \ + OBJECT_CLASS_CHECK(VirtIOVGABaseClass, klass, TYPE_VIRTIO_VGA_BASE) + +typedef struct VirtIOVGABase { +VirtIOPCIProxy parent_obj; + +VirtIOGPUBase *vgpu; +VGACommonState vga; +MemoryRegion vga_mrs[3 ]; +}VirtIOVGABase ; + +typedef struct VirtIOVGABaseClass { +VirtioPCIClass parent_class; + +DeviceReset parent_reset; +}VirtIOVGABaseClass ; + +#endif /* VIRTIO_VGA_H_ */
hw/display/virtio-gpu-pci.c +36 -16
102 lines not on this page · raw message
hw/display/virtio-vga.c +68 -67
248 lines not on this page · raw message
MAINTAINERS +1 -1
@@ -1672,7 +1672,7 @@ virtio-gpu M: Gerd Hoffmann <[email protected]> S: Maintained F: hw/display/virtio-gpu* -F: hw/display/virtio-vga.c +F: hw/display/virtio-vga.* F: include/hw/virtio/virtio-gpu.h vhost-user-gpu
Signature · 1 line
2.21.0.777.g83232e3864
PATCH v7 8/8 hw/display: add vhost-user-vga & gpu-pci
In reply to Marc-André LureauAdd 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
--- hw/display/virtio-vga.h | 2 +- include/hw/virtio/virtio-gpu-pci.h | 40 ++ include/hw/virtio/virtio-gpu.h | 19 +- hw/display/vhost-user-gpu-pci.c | 51 +++ hw/display/vhost-user-gpu.c | 607 +++++++++++++++++++++++++++++ hw/display/vhost-user-vga.c | 52 +++ hw/display/virtio-gpu-pci.c | 17 +- vl.c | 1 + hw/display/Kconfig | 10 + hw/display/Makefile.objs | 3 + 10 files changed, 779 insertions(+), 23 deletions(-) create mode 100644 include/hw/virtio/virtio-gpu-pci.h create mode 100644 hw/display/vhost-user-gpu-pci.c create mode 100644 hw/display/vhost-user-gpu.c create mode 100644 hw/display/vhost-user-vga.c
hw/display/virtio-vga.h +1 -1
@@ -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" /*
include/hw/virtio/virtio-gpu-pci.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Virtio GPU PCI Device +* +* Copyright Red Hat, Inc. 2013-2014 +* +* Authors: +* Dave Airlie <[email protected]> +* Gerd Hoffmann <[email protected]> +* +* 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 */
include/hw/virtio/virtio-gpu.h +13 -6
@@ -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 16struct 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; \
hw/display/vhost-user-gpu-pci.c new file +51 -0
51 lines not on this page · raw message
hw/display/vhost-user-gpu.c new file +607 -0
607 lines not on this page · raw message
hw/display/vhost-user-vga.c new file +52 -0
52 lines not on this page · raw message
hw/display/virtio-gpu-pci.c +1 -16
@@ -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),
vl.c +1 -0
@@ -238,6 +238,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 = {
hw/display/Kconfig +10 -0
@@ -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
hw/display/Makefile.objs +3 -0
@@ -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)
Signature · 1 line
2.21.0.777.g83232e3864