qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guest / host buffer sharing ...


From: Geoffrey McRae
Subject: Re: guest / host buffer sharing ...
Date: Tue, 05 Nov 2019 22:35:51 +1100
User-agent: Roundcube Webmail/1.2.3

Hi Gerd.

On 2019-11-05 21:54, Gerd Hoffmann wrote:
Hi folks,

The issue of sharing buffers between guests and hosts keeps poping
up again and again in different contexts.  Most recently here:

https://www.mail-archive.com/address@hidden/msg656685.html

So, I'm grabbing the recipient list of the virtio-vdec thread and some
more people I know might be interested in this, hoping to have everyone
included.

Reason is:  Meanwhile I'm wondering whenever "just use virtio-gpu
resources" is really a good answer for all the different use cases
we have collected over time.  Maybe it is better to have a dedicated
buffer sharing virtio device?  Here is the rough idea:


This would be the ultimate solution to this, it would also make it the defacto device, possibly even leading to the deprecation of the IVSHMEM device.


(1) The virtio device
=====================

Has a single virtio queue, so the guest can send commands to register
and unregister buffers. Buffers are allocated in guest ram. Each buffer
has a list of memory ranges for the data.  Each buffer also has some
properties to carry metadata, some fixed (id, size, application), but
also allow free form (name = value, framebuffers would have
width/height/stride/format for example).


Perfect, however since it's to be a generic device there also needs to be a method in the guest to identify which device is the one the application is
interested in without opening the device. Since windows makes the
subsystem vendor ID and device ID available to the userspace application,
I suggest these be used for this purpose.

To avoid clashes a simple text file to track reservations of subsystem IDs
for applications/protocols would be recommended.

The device should also support a reset feature allowing the guest to
notify the host application that all buffers have become invalid such as
on abnormal termination of the guest application that is using the device.

Conversely, qemu on unix socket disconnect should notify the guest of this
event also, allowing each end to properly syncronize.


(2) The linux guest implementation
==================================

I guess I'd try to make it a drm driver, so we can re-use drm
infrastructure (shmem helpers for example).  Buffers are dumb drm
buffers.  dma-buf import and export is supported (shmem helpers
get us that for free).  Some device-specific ioctls to get/set
properties and to register/unregister the buffers on the host.


I would be happy to do what I can to implement the windows driver for this
if nobody else is interested in doing so, however, my abilities in this
field is rather limited and the results may not be that great :)


(3) The qemu host implementation
================================

qemu (likewise other vmms) can use the udmabuf driver to create
host-side dma-bufs for the buffers.  The dma-bufs can be passed to
anyone interested, inside and outside qemu.  We'll need some protocol
for communication between qemu and external users interested in those
buffers, to receive dma-bufs (via unix file descriptor passing) and
update notifications.  Dispatching updates could be done based on the
application property, which could be "virtio-vdec" or "wayland-proxy"
for example.

I don't know enough about udmabuf to really comment on this except to ask
a question. Would this make guest to guest transfers without an
intermediate buffer possible?

-Geoff



commments?

cheers,
  Gerd



reply via email to

[Prev in Thread] Current Thread [Next in Thread]