> (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 Allocating from guest ram would work most of the time, but I think it's insufficient for many use cases. It doesn't really support things such as contiguous allocations, allocations from carveouts or <4GB, protected buffers, etc. > properties to carry metadata, some fixed (id, size, application), but What exactly do you mean by application? > also allow free form (name = value, framebuffers would have > width/height/stride/format for example). Is this approach expected to handle allocating buffers with hardware-specific constraints such as stride/height alignment or tiling? Or would there need to be some alternative channel for determining those values and then calculating the appropriate buffer size? -David On Tue, Nov 5, 2019 at 7:55 PM Gerd Hoffmann <kraxel@xxxxxxxxxx> 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/qemu-devel@xxxxxxxxxx/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: > > > (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). > > > (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. > > > (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. > > > commments? > > cheers, > Gerd >