Re: [PATCH v3 1/2] drm/virtio: Add window server support
> > Yes. > > Would it make sense for virtio-gpu to map buffers to the guest via PCI BARs? > So we can use a single drm driver for both 2d and 3d. Should be doable. I'm wondering two things though: (1) Will shmem actually help avoiding a copy? virtio-gpu with virgl will (even if the guest doesn't use opengl) store the resources in gpu memory. So the VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D copy goes from guest memory directly to gpu memory, and if we export that as dma-buf and pass it to the wayland server it should be able to render it without doing another copy. How does the wl_shm_pool workflow look like inside the wayland server? Can it ask the gpu to render directly from the pool? Or is a copy to gpu memory needed here? If the latter we would effectively trade one copy for another ... (2) Could we handle the mapping without needing shmem? Possibly we could extend the vgem driver. So we pass in a iov (which qemu gets from guest via VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING), get back a drm object. Which effectively creates drm objects on the host which match the drm object in the guest (both backed by the same set of physical pages). cheers, Gerd
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On 02/12/2018 12:45 PM, Gerd Hoffmann wrote: 4. QEMU pops data+buffers from the virtqueue, looks up shmem FD for each resource, sends data + FDs to the compositor with SCM_RIGHTS >>> >>> BTW: Is there a 1:1 relationship between buffers and shmem blocks? Or >>> does the wayland protocol allow for offsets in buffer meta data, so you >>> can place multiple buffers in a single shmem block? >> >> The latter: >> https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_shm_pool > > Ah, good, that makes it alot easier. > > So, yes, using ivshmem would be one option. Tricky part here is the > buffer management though. It's just a raw piece of memory. The guest > proxy could mmap the pci bar and manage it. But then it is again either > unmodified guest + copying the data, or modified client (which requests > buffers from guest proxy) for zero-copy. What if at VIRTIO_GPU_CMD_RESOURCE_CREATE_2D time we created a ivshmem device to back that resource. The ivshmem device would in turn be backed by a hostmem device that wraps a shmem FD. The guest client can then export that resource/BO and pass the FD to the guest proxy. The guest proxy would import it and put the resource_id in the equivalent message in our protocol extension. QEMU would get that resource id from vsock, look up which hostmem device is associated with that resource, and pass its FD to the compositor. > We also need a solution for the keymap shmem block. I guess the keymap > doesn't change all that often, so maybe it is easiest to just copy it > over (host proxy -> guest proxy) instead of trying to map the host shmem > into the guest? Not sure if that would be much simpler than creating a ivshmem+hostmem combo that wraps the incoming shmem FD and then having virtio-gpu create a BO that imports it. Regards, Tomeu
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On 02/12/2018 12:45 PM, Gerd Hoffmann wrote: Hi, (a) software rendering: client allocates shared memory buffer, renders into it, then passes a file handle for that shmem block together with some meta data (size, format, ...) to the wayland server. (b) gpu rendering: client opens a render node, allocates a buffer, asks the cpu to renders into it, exports the buffer as dma-buf (DRM_IOCTL_PRIME_HANDLE_TO_FD), passes this to the wayland server (again including meta data of course). Is that correct? Both are correct descriptions of typical behaviors. But it isn't spec'ed anywhere who has to do the buffer allocation. Well, according to Pekka's reply it is spec'ed that way, for the existing buffer types. So for server allocated buffers you need (a) a wayland protocol extension and (b) support for the extension in the clients. That's to say that if we cannot come up with a zero-copy solution for unmodified clients, we should at least support zero-copy for cooperative clients. "cooperative clients" == "client which has support for the wayland protocol extension", correct? Guess it could be that, but I was rather thinking of clients that would allocate the buffer for wl_shm_pool with DRM_VIRTGPU_RESOURCE_CREATE or equivalent. Then that buffer would be exported and the fd passed using the standard wl_shm protocol. 4. QEMU maps that buffer to the guest's address space (KVM_SET_USER_MEMORY_REGION), passes the guest PFN to the virtio driver That part is problematic. The host can't simply allocate something in the physical address space, because most physical address space management is done by the guest. All pci bars are mapped by the guest firmware for example (or by the guest OS in case of hotplug). How can KVM_SET_USER_MEMORY_REGION ever be safely used then? I would have expected that callers of that ioctl have enough knowledge to be able to choose a physical address that won't conflict with the guest's kernel. Depends on the kind of region. Guest RAM is allocated and mapped by qemu, guest firmware can query qemu about RAM mappings using a special interface, then create a e820 memory map for the guest os. PCI device bars are mapped according to the pci config space registers, which in turn are initialized by the guest firmware, so it is basically in the guests hand where they show up. I see that the ivshmem device in QEMU registers the memory region in BAR 2 of a PCI device instead. Would that be better in your opinion? Yes. Would it make sense for virtio-gpu to map buffers to the guest via PCI BARs? So we can use a single drm driver for both 2d and 3d. 4. QEMU pops data+buffers from the virtqueue, looks up shmem FD for each resource, sends data + FDs to the compositor with SCM_RIGHTS BTW: Is there a 1:1 relationship between buffers and shmem blocks? Or does the wayland protocol allow for offsets in buffer meta data, so you can place multiple buffers in a single shmem block? The latter: https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_shm_pool Ah, good, that makes it alot easier. So, yes, using ivshmem would be one option. Tricky part here is the buffer management though. It's just a raw piece of memory. The guest proxy could mmap the pci bar and manage it. But then it is again either unmodified guest + copying the data, or modified client (which requests buffers from guest proxy) for zero-copy. Another idea would be extending stdvga. Basically qemu would have to use shmem as backing storage for vga memory instead of anonymous memory, so it would be very simliar to ivshmem on the host side. But on the guest side we have a drm driver for it (bochs-drm). So clients can allocate dumb drm buffers for software rendering, and the buffer would already be backed by a host shmem segment. Given that wayland already supports drm buffers for 3d rendering that could work without extending the wayland protocol. The client proxy would have to translate the drm buffer into an pci bar offset and pass it to the host side. The host proxy could register the pci bar as wl_shm_pool, then just pass through the offset to reference the individual buffers. Drawback of both approaches would be that software rendering and gpu rendering would use quite different code paths. Yeah, would be great if we could find a way to avoid that. We also need a solution for the keymap shmem block. I guess the keymap doesn't change all that often, so maybe it is easiest to just copy it over (host proxy -> guest proxy) instead of trying to map the host shmem into the guest? I think that should be fine for now. Something similar will have to happen for the clipboard, which currently uses pipes to exchange data. Thanks, Tomeu
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On Mon, 12 Feb 2018 12:45:40 +0100 Gerd Hoffmann wrote: > Hi, > > > >(a) software rendering: client allocates shared memory buffer, renders > > >into it, then passes a file handle for that shmem block together > > >with some meta data (size, format, ...) to the wayland server. > > > > > >(b) gpu rendering: client opens a render node, allocates a buffer, > > >asks the cpu to renders into it, exports the buffer as dma-buf > > >(DRM_IOCTL_PRIME_HANDLE_TO_FD), passes this to the wayland server > > >(again including meta data of course). > > > > > > Is that correct? > > > > Both are correct descriptions of typical behaviors. But it isn't spec'ed > > anywhere who has to do the buffer allocation. > > Well, according to Pekka's reply it is spec'ed that way, for the > existing buffer types. So for server allocated buffers you need > (a) a wayland protocol extension and (b) support for the extension > in the clients. Correct. Or simply a libEGL that uses such Wayland extension behind everyone's back. I believe such things did at least exist, but are probably not relevant for this discussion. (If there is a standard library, like libEGL, loaded and used by both a server and a client, that library can advertise custom private Wayland protocol extensions and the client side can take advantage of them, both without needing any code changes on either the server or the client.) > We also need a solution for the keymap shmem block. I guess the keymap > doesn't change all that often, so maybe it is easiest to just copy it > over (host proxy -> guest proxy) instead of trying to map the host shmem > into the guest? Yes, I believe that would be a perfectly valid solution for that particular case. Thanks, pq pgphPdhIqFpEn.pgp Description: OpenPGP digital signature
Re: [PATCH v3 1/2] drm/virtio: Add window server support
> > I was more thinking about a struct containing enough info to allow the > > proxy on the host side find the buffer, something like: > > > > struct { > >enum type { stdvga, virtio-cpu, ... } > >pcislot device; > >union { > > int stdvga_pcibar_offset; > > int virtio_gpu_resource_id; > >} > > } > > > > So when the guest proxy gets a message with a fd referencing a buffer it > > would have to figure where the buffer is, rewrite the message into the > > struct above for the host proxy. The host proxy would rewrite the > > message again for the server. > > What I don't understand yet is how we can keep the buffer descriptions > together with the protocol data that references them. > > With SCM_RIGHTS, the FDs are placed in the ancillary data that "travels" > together with the protocol data that references them. Place the buffer description into the wayland extension protocol messages? i.e. have some wl_virt_proxy protocol extension. Then, for the stdvga case: (1) client sends wl_drm/create_prime_buffer request to the guest proxy (2) guest proxy rewrites this into wl_virt_proxy/create_buffer, or maybe a create_stdvga_buffer request, carrying all the information listed above, and sends it to the host proxy. (3) host proxy rewrites it again into a wl_shm_pool/create_buffer and forwards it to the server. cheers, Gerd
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On 02/12/2018 03:27 PM, Gerd Hoffmann wrote: On Mon, Feb 12, 2018 at 03:00:24PM +0100, Tomeu Vizoso wrote: On 02/12/2018 12:52 PM, Gerd Hoffmann wrote: Hi, can we reach agreement on whether vsock should be involved in this? I think the best approach would be to have guest proxy and host proxy use vsock for the wayland protocol. Use a wayland protocol extension to reference the buffers in stdvga / ivshmem / virtio-gpu. Only the two proxies need to understand the extension, the client <=> guest proxy and host proxy <=> server communication would be standard wayland protocol. Thanks for the ideas. What I haven't understood yet is how you see the actual passing of buffers via vsock. Are you thinking of using ancillary data to pass FDs, or something else? I was more thinking about a struct containing enough info to allow the proxy on the host side find the buffer, something like: struct { enum type { stdvga, virtio-cpu, ... } pcislot device; union { int stdvga_pcibar_offset; int virtio_gpu_resource_id; } } So when the guest proxy gets a message with a fd referencing a buffer it would have to figure where the buffer is, rewrite the message into the struct above for the host proxy. The host proxy would rewrite the message again for the server. What I don't understand yet is how we can keep the buffer descriptions together with the protocol data that references them. With SCM_RIGHTS, the FDs are placed in the ancillary data that "travels" together with the protocol data that references them. With the present series, the DRM_IOCTL_VIRTGPU_WINSRV_TX ioctl struct has a field for the protocol data and an array of FDs. How are you proposing to pass instances of that struct from above along the protocol data that refers to them? Thanks, Tomeu
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On Mon, Feb 12, 2018 at 03:00:24PM +0100, Tomeu Vizoso wrote: > On 02/12/2018 12:52 PM, Gerd Hoffmann wrote: > >Hi, > > > > > can we reach agreement on whether vsock should be involved in this? > > > > I think the best approach would be to have guest proxy and host proxy > > use vsock for the wayland protocol. Use a wayland protocol extension to > > reference the buffers in stdvga / ivshmem / virtio-gpu. Only the two > > proxies need to understand the extension, the client <=> guest proxy and > > host proxy <=> server communication would be standard wayland protocol. > > Thanks for the ideas. What I haven't understood yet is how you see the > actual passing of buffers via vsock. Are you thinking of using ancillary > data to pass FDs, or something else? I was more thinking about a struct containing enough info to allow the proxy on the host side find the buffer, something like: struct { enum type { stdvga, virtio-cpu, ... } pcislot device; union { int stdvga_pcibar_offset; int virtio_gpu_resource_id; } } So when the guest proxy gets a message with a fd referencing a buffer it would have to figure where the buffer is, rewrite the message into the struct above for the host proxy. The host proxy would rewrite the message again for the server. cheers, Gerd
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On 02/12/2018 12:52 PM, Gerd Hoffmann wrote: Hi, can we reach agreement on whether vsock should be involved in this? I think the best approach would be to have guest proxy and host proxy use vsock for the wayland protocol. Use a wayland protocol extension to reference the buffers in stdvga / ivshmem / virtio-gpu. Only the two proxies need to understand the extension, the client <=> guest proxy and host proxy <=> server communication would be standard wayland protocol. Thanks for the ideas. What I haven't understood yet is how you see the actual passing of buffers via vsock. Are you thinking of using ancillary data to pass FDs, or something else? Thanks, Tomeu
Re: [PATCH v3 1/2] drm/virtio: Add window server support
Hi, > can we reach agreement on whether vsock should be involved in this? I think the best approach would be to have guest proxy and host proxy use vsock for the wayland protocol. Use a wayland protocol extension to reference the buffers in stdvga / ivshmem / virtio-gpu. Only the two proxies need to understand the extension, the client <=> guest proxy and host proxy <=> server communication would be standard wayland protocol. cheers, Gerd
Re: [PATCH v3 1/2] drm/virtio: Add window server support
Hi, > >(a) software rendering: client allocates shared memory buffer, renders > >into it, then passes a file handle for that shmem block together > >with some meta data (size, format, ...) to the wayland server. > > > >(b) gpu rendering: client opens a render node, allocates a buffer, > >asks the cpu to renders into it, exports the buffer as dma-buf > >(DRM_IOCTL_PRIME_HANDLE_TO_FD), passes this to the wayland server > >(again including meta data of course). > > > > Is that correct? > > Both are correct descriptions of typical behaviors. But it isn't spec'ed > anywhere who has to do the buffer allocation. Well, according to Pekka's reply it is spec'ed that way, for the existing buffer types. So for server allocated buffers you need (a) a wayland protocol extension and (b) support for the extension in the clients. > That's to say that if we cannot come up with a zero-copy solution for > unmodified clients, we should at least support zero-copy for cooperative > clients. "cooperative clients" == "client which has support for the wayland protocol extension", correct? > > > Creation of shareable buffer by guest > > > - > > > > > > 1. Client requests virtio driver to create a buffer suitable for sharing > > > with host (DRM_VIRTGPU_RESOURCE_CREATE) > > > > client or guest proxy? > > As per the above, the GUI toolkit could have been modified so the client > directly creates a shareable buffer, and renders directly to it without any > extra copies. > > If clients cannot be modified, then it's the guest proxy what has to create > the shareable buffer and keep it in sync with the client's non-shareable > buffer at the right times, by intercepting wl_surface.commit messages and > copying buffer contents. Ok. > > > 4. QEMU maps that buffer to the guest's address space > > > (KVM_SET_USER_MEMORY_REGION), passes the guest PFN to the virtio driver > > > > That part is problematic. The host can't simply allocate something in > > the physical address space, because most physical address space > > management is done by the guest. All pci bars are mapped by the guest > > firmware for example (or by the guest OS in case of hotplug). > > How can KVM_SET_USER_MEMORY_REGION ever be safely used then? I would have > expected that callers of that ioctl have enough knowledge to be able to > choose a physical address that won't conflict with the guest's kernel. Depends on the kind of region. Guest RAM is allocated and mapped by qemu, guest firmware can query qemu about RAM mappings using a special interface, then create a e820 memory map for the guest os. PCI device bars are mapped according to the pci config space registers, which in turn are initialized by the guest firmware, so it is basically in the guests hand where they show up. > I see that the ivshmem device in QEMU registers the memory region in BAR 2 > of a PCI device instead. Would that be better in your opinion? Yes. > > > 4. QEMU pops data+buffers from the virtqueue, looks up shmem FD for each > > > resource, sends data + FDs to the compositor with SCM_RIGHTS > > > > BTW: Is there a 1:1 relationship between buffers and shmem blocks? Or > > does the wayland protocol allow for offsets in buffer meta data, so you > > can place multiple buffers in a single shmem block? > > The latter: > https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_shm_pool Ah, good, that makes it alot easier. So, yes, using ivshmem would be one option. Tricky part here is the buffer management though. It's just a raw piece of memory. The guest proxy could mmap the pci bar and manage it. But then it is again either unmodified guest + copying the data, or modified client (which requests buffers from guest proxy) for zero-copy. Another idea would be extending stdvga. Basically qemu would have to use shmem as backing storage for vga memory instead of anonymous memory, so it would be very simliar to ivshmem on the host side. But on the guest side we have a drm driver for it (bochs-drm). So clients can allocate dumb drm buffers for software rendering, and the buffer would already be backed by a host shmem segment. Given that wayland already supports drm buffers for 3d rendering that could work without extending the wayland protocol. The client proxy would have to translate the drm buffer into an pci bar offset and pass it to the host side. The host proxy could register the pci bar as wl_shm_pool, then just pass through the offset to reference the individual buffers. Drawback of both approaches would be that software rendering and gpu rendering would use quite different code paths. We also need a solution for the keymap shmem block. I guess the keymap doesn't change all that often, so maybe it is easiest to just copy it over (host proxy -> guest proxy) instead of trying to map the host shmem into the guest? cheers, Gerd
Re: [PATCH v3 1/2] drm/virtio: Add window server support
Hi Gerd and Stefan, can we reach agreement on whether vsock should be involved in this? Thanks, Tomeu On 02/07/2018 10:49 AM, Tomeu Vizoso wrote: On 02/06/2018 03:23 PM, Gerd Hoffmann wrote: Hi, Hmm? I'm assuming the wayland client (in the guest) talks to the wayland proxy, using the wayland protocol, like it would talk to a wayland display server. Buffers must be passed from client to server/proxy somehow, probably using fd passing, so where is the problem? Or did I misunderstand the role of the proxy? Hi Gerd, it's starting to look to me that we're talking a bit past the other, so I have pasted below a few words describing my current plan regarding the 3 key scenarios that I'm addressing. You are describing the details, but I'm missing the big picture ... So, virtualization aside, how do buffers work in wayland? As far I know it goes like this: (a) software rendering: client allocates shared memory buffer, renders into it, then passes a file handle for that shmem block together with some meta data (size, format, ...) to the wayland server. (b) gpu rendering: client opens a render node, allocates a buffer, asks the cpu to renders into it, exports the buffer as dma-buf (DRM_IOCTL_PRIME_HANDLE_TO_FD), passes this to the wayland server (again including meta data of course). Is that correct? Both are correct descriptions of typical behaviors. But it isn't spec'ed anywhere who has to do the buffer allocation. In practical terms, the buffer allocation happens in either the 2D GUI toolkit (gtk+, for example), or the EGL implementation. Someone using this in a real product would most probably be interested in avoiding any extra copies and make sure that both allocate buffers via virtio-gpu, for example. Depending on the use case, they could be also interested in supporting unmodified clients with an extra copy per buffer presentation. That's to say that if we cannot come up with a zero-copy solution for unmodified clients, we should at least support zero-copy for cooperative clients. Now, with virtualization added to the mix it becomes a bit more complicated. Client and server are unmodified. The client talks to the guest proxy (wayland protocol). The guest proxy talks to the host proxy (protocol to be defined). The host proxy talks to the server (wayland protocol). Buffers must be managed along the way, and we want avoid copying around the buffers. The host proxy could be implemented directly in qemu, or as separate process which cooperates with qemu for buffer management. Fine so far? Yep. I really think that whatever we come up with needs to support 3D clients as well. Lets start with 3d clients, I think these are easier. They simply use virtio-gpu for 3d rendering as usual. When they are done the rendered buffer already lives in a host drm buffer (because virgl runs the actual rendering on the host gpu). So the client passes the dma-buf to the guest proxy, the guest proxy imports it to look up the resource-id, passes the resource-id to the host proxy, the host proxy looks up the drm buffer and exports it as dma-buf, then passes it to the server. Done, without any extra data copies. Yep. Creation of shareable buffer by guest - 1. Client requests virtio driver to create a buffer suitable for sharing with host (DRM_VIRTGPU_RESOURCE_CREATE) client or guest proxy? As per the above, the GUI toolkit could have been modified so the client directly creates a shareable buffer, and renders directly to it without any extra copies. If clients cannot be modified, then it's the guest proxy what has to create the shareable buffer and keep it in sync with the client's non-shareable buffer at the right times, by intercepting wl_surface.commit messages and copying buffer contents. 4. QEMU maps that buffer to the guest's address space (KVM_SET_USER_MEMORY_REGION), passes the guest PFN to the virtio driver That part is problematic. The host can't simply allocate something in the physical address space, because most physical address space management is done by the guest. All pci bars are mapped by the guest firmware for example (or by the guest OS in case of hotplug). How can KVM_SET_USER_MEMORY_REGION ever be safely used then? I would have expected that callers of that ioctl have enough knowledge to be able to choose a physical address that won't conflict with the guest's kernel. I see that the ivshmem device in QEMU registers the memory region in BAR 2 of a PCI device instead. Would that be better in your opinion? 4. QEMU pops data+buffers from the virtqueue, looks up shmem FD for each resource, sends data + FDs to the compositor with SCM_RIGHTS BTW: Is there a 1:1 relationship between buffers and shmem blocks? Or does the wayland protocol allow for offsets in buffer meta data, so you can place multiple buffers in a single shmem block? The lat
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On 02/06/2018 03:23 PM, Gerd Hoffmann wrote: Hi, Hmm? I'm assuming the wayland client (in the guest) talks to the wayland proxy, using the wayland protocol, like it would talk to a wayland display server. Buffers must be passed from client to server/proxy somehow, probably using fd passing, so where is the problem? Or did I misunderstand the role of the proxy? Hi Gerd, it's starting to look to me that we're talking a bit past the other, so I have pasted below a few words describing my current plan regarding the 3 key scenarios that I'm addressing. You are describing the details, but I'm missing the big picture ... So, virtualization aside, how do buffers work in wayland? As far I know it goes like this: (a) software rendering: client allocates shared memory buffer, renders into it, then passes a file handle for that shmem block together with some meta data (size, format, ...) to the wayland server. (b) gpu rendering: client opens a render node, allocates a buffer, asks the cpu to renders into it, exports the buffer as dma-buf (DRM_IOCTL_PRIME_HANDLE_TO_FD), passes this to the wayland server (again including meta data of course). Is that correct? Both are correct descriptions of typical behaviors. But it isn't spec'ed anywhere who has to do the buffer allocation. In practical terms, the buffer allocation happens in either the 2D GUI toolkit (gtk+, for example), or the EGL implementation. Someone using this in a real product would most probably be interested in avoiding any extra copies and make sure that both allocate buffers via virtio-gpu, for example. Depending on the use case, they could be also interested in supporting unmodified clients with an extra copy per buffer presentation. That's to say that if we cannot come up with a zero-copy solution for unmodified clients, we should at least support zero-copy for cooperative clients. Now, with virtualization added to the mix it becomes a bit more complicated. Client and server are unmodified. The client talks to the guest proxy (wayland protocol). The guest proxy talks to the host proxy (protocol to be defined). The host proxy talks to the server (wayland protocol). Buffers must be managed along the way, and we want avoid copying around the buffers. The host proxy could be implemented directly in qemu, or as separate process which cooperates with qemu for buffer management. Fine so far? Yep. I really think that whatever we come up with needs to support 3D clients as well. Lets start with 3d clients, I think these are easier. They simply use virtio-gpu for 3d rendering as usual. When they are done the rendered buffer already lives in a host drm buffer (because virgl runs the actual rendering on the host gpu). So the client passes the dma-buf to the guest proxy, the guest proxy imports it to look up the resource-id, passes the resource-id to the host proxy, the host proxy looks up the drm buffer and exports it as dma-buf, then passes it to the server. Done, without any extra data copies. Yep. Creation of shareable buffer by guest - 1. Client requests virtio driver to create a buffer suitable for sharing with host (DRM_VIRTGPU_RESOURCE_CREATE) client or guest proxy? As per the above, the GUI toolkit could have been modified so the client directly creates a shareable buffer, and renders directly to it without any extra copies. If clients cannot be modified, then it's the guest proxy what has to create the shareable buffer and keep it in sync with the client's non-shareable buffer at the right times, by intercepting wl_surface.commit messages and copying buffer contents. 4. QEMU maps that buffer to the guest's address space (KVM_SET_USER_MEMORY_REGION), passes the guest PFN to the virtio driver That part is problematic. The host can't simply allocate something in the physical address space, because most physical address space management is done by the guest. All pci bars are mapped by the guest firmware for example (or by the guest OS in case of hotplug). How can KVM_SET_USER_MEMORY_REGION ever be safely used then? I would have expected that callers of that ioctl have enough knowledge to be able to choose a physical address that won't conflict with the guest's kernel. I see that the ivshmem device in QEMU registers the memory region in BAR 2 of a PCI device instead. Would that be better in your opinion? 4. QEMU pops data+buffers from the virtqueue, looks up shmem FD for each resource, sends data + FDs to the compositor with SCM_RIGHTS BTW: Is there a 1:1 relationship between buffers and shmem blocks? Or does the wayland protocol allow for offsets in buffer meta data, so you can place multiple buffers in a single shmem block? The latter: https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_shm_pool Regards, Tomeu
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On 02/07/2018 02:09 AM, Michael S. Tsirkin wrote: On Tue, Feb 06, 2018 at 03:23:02PM +0100, Gerd Hoffmann wrote: Creation of shareable buffer by guest - 1. Client requests virtio driver to create a buffer suitable for sharing with host (DRM_VIRTGPU_RESOURCE_CREATE) client or guest proxy? 4. QEMU maps that buffer to the guest's address space (KVM_SET_USER_MEMORY_REGION), passes the guest PFN to the virtio driver That part is problematic. The host can't simply allocate something in the physical address space, because most physical address space management is done by the guest. All pci bars are mapped by the guest firmware for example (or by the guest OS in case of hotplug). 4. QEMU pops data+buffers from the virtqueue, looks up shmem FD for each resource, sends data + FDs to the compositor with SCM_RIGHTS If you squint hard, this sounds a bit like a use-case for vhost-user-gpu, does it not? Can you extend on what makes you think that? As an aside, crosvm runs the virtio-gpu device in a separate, jailed process, among other virtual devices. https://chromium.googlesource.com/chromiumos/platform/crosvm/ Regards, Tomeu
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On Tue, Feb 06, 2018 at 03:23:02PM +0100, Gerd Hoffmann wrote: > > Creation of shareable buffer by guest > > - > > > > 1. Client requests virtio driver to create a buffer suitable for sharing > > with host (DRM_VIRTGPU_RESOURCE_CREATE) > > client or guest proxy? > > > 4. QEMU maps that buffer to the guest's address space > > (KVM_SET_USER_MEMORY_REGION), passes the guest PFN to the virtio driver > > That part is problematic. The host can't simply allocate something in > the physical address space, because most physical address space > management is done by the guest. All pci bars are mapped by the guest > firmware for example (or by the guest OS in case of hotplug). > > > 4. QEMU pops data+buffers from the virtqueue, looks up shmem FD for each > > resource, sends data + FDs to the compositor with SCM_RIGHTS If you squint hard, this sounds a bit like a use-case for vhost-user-gpu, does it not? > BTW: Is there a 1:1 relationship between buffers and shmem blocks? Or > does the wayland protocol allow for offsets in buffer meta data, so you > can place multiple buffers in a single shmem block? > > cheers, > Gerd
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On Mon, 5 Feb 2018 17:03:22 +0100 Gerd Hoffmann wrote: > On Mon, Feb 05, 2018 at 03:46:17PM +0100, Tomeu Vizoso wrote: > > On 02/05/2018 01:20 PM, Gerd Hoffmann wrote: > > >Hi, > > > > > Hmm. I allways assumed the wayland client allocates the buffers, not > the server. Is that wrong? Hi Gerd, a fly-by comment here: The standard operation mode on Wayland indeed is that the client allocates any pixel buffers. It is not the whole story though. Server allocated buffers passed to a client also exist: - core protocol uses this to pass keymaps to clients - people are not forbidden from writing Wayland extensions that do this for whatever reason The latter server-allocated case could probably be overlooked, but the keymap case not really. Furthermore, copy&paste and drag&drop protocol pass pipe file descriptors via Wayland to establish client-to-client pipes. Thanks, pq pgpUdAITFHPdr.pgp Description: OpenPGP digital signature
Re: [PATCH v3 1/2] drm/virtio: Add window server support
Hi, > > Hmm? I'm assuming the wayland client (in the guest) talks to the > > wayland proxy, using the wayland protocol, like it would talk to a > > wayland display server. Buffers must be passed from client to > > server/proxy somehow, probably using fd passing, so where is the > > problem? > > > > Or did I misunderstand the role of the proxy? > > Hi Gerd, > > it's starting to look to me that we're talking a bit past the other, so I > have pasted below a few words describing my current plan regarding the 3 key > scenarios that I'm addressing. You are describing the details, but I'm missing the big picture ... So, virtualization aside, how do buffers work in wayland? As far I know it goes like this: (a) software rendering: client allocates shared memory buffer, renders into it, then passes a file handle for that shmem block together with some meta data (size, format, ...) to the wayland server. (b) gpu rendering: client opens a render node, allocates a buffer, asks the cpu to renders into it, exports the buffer as dma-buf (DRM_IOCTL_PRIME_HANDLE_TO_FD), passes this to the wayland server (again including meta data of course). Is that correct? Now, with virtualization added to the mix it becomes a bit more complicated. Client and server are unmodified. The client talks to the guest proxy (wayland protocol). The guest proxy talks to the host proxy (protocol to be defined). The host proxy talks to the server (wayland protocol). Buffers must be managed along the way, and we want avoid copying around the buffers. The host proxy could be implemented directly in qemu, or as separate process which cooperates with qemu for buffer management. Fine so far? > I really think that whatever we come up with needs to support 3D clients as > well. Lets start with 3d clients, I think these are easier. They simply use virtio-gpu for 3d rendering as usual. When they are done the rendered buffer already lives in a host drm buffer (because virgl runs the actual rendering on the host gpu). So the client passes the dma-buf to the guest proxy, the guest proxy imports it to look up the resource-id, passes the resource-id to the host proxy, the host proxy looks up the drm buffer and exports it as dma-buf, then passes it to the server. Done, without any extra data copies. > Creation of shareable buffer by guest > - > > 1. Client requests virtio driver to create a buffer suitable for sharing > with host (DRM_VIRTGPU_RESOURCE_CREATE) client or guest proxy? > 4. QEMU maps that buffer to the guest's address space > (KVM_SET_USER_MEMORY_REGION), passes the guest PFN to the virtio driver That part is problematic. The host can't simply allocate something in the physical address space, because most physical address space management is done by the guest. All pci bars are mapped by the guest firmware for example (or by the guest OS in case of hotplug). > 4. QEMU pops data+buffers from the virtqueue, looks up shmem FD for each > resource, sends data + FDs to the compositor with SCM_RIGHTS BTW: Is there a 1:1 relationship between buffers and shmem blocks? Or does the wayland protocol allow for offsets in buffer meta data, so you can place multiple buffers in a single shmem block? cheers, Gerd
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On 02/05/2018 05:03 PM, Gerd Hoffmann wrote: On Mon, Feb 05, 2018 at 03:46:17PM +0100, Tomeu Vizoso wrote: On 02/05/2018 01:20 PM, Gerd Hoffmann wrote: Hi, Why not use virtio-vsock to run the wayland protocol? I don't like the idea to duplicate something with very simliar functionality in virtio-gpu. The reason for abandoning that approach was the type of objects that could be shared via virtio-vsock would be extremely limited. Besides that being potentially confusing to users, it would mean from the implementation side that either virtio-vsock would gain a dependency on the drm subsystem, or an appropriate abstraction for shareable buffers would need to be added for little gain. Well, no. The idea is that virtio-vsock and virtio-gpu are used largely as-is, without knowing about each other. The guest wayland proxy which does the buffer management talks to both devices. Note that the proxy won't know anything about buffers if clients opt-in for zero-copy support (they allocate the buffers in a way that allows for sharing with the host). Hmm? I'm assuming the wayland client (in the guest) talks to the wayland proxy, using the wayland protocol, like it would talk to a wayland display server. Buffers must be passed from client to server/proxy somehow, probably using fd passing, so where is the problem? Or did I misunderstand the role of the proxy? Hi Gerd, it's starting to look to me that we're talking a bit past the other, so I have pasted below a few words describing my current plan regarding the 3 key scenarios that I'm addressing. I mention below KVM_SET_USER_MEMORY_REGION, but I guess we can discuss alternatives such as the one you are proposing using PCI BARs at a later stage. I really think that whatever we come up with needs to support 3D clients as well. Creation of shareable buffer by guest - 1. Client requests virtio driver to create a buffer suitable for sharing with host (DRM_VIRTGPU_RESOURCE_CREATE) 2. Virtio driver creates a new resource ID and passes the request to QEMU (VIRTIO_GPU_CMD_RESOURCE_CREATE_2D) 3. QEMU creates a shmem file (for example with mkostemp), associates that FD with the ID of this resource 4. QEMU maps that buffer to the guest's address space (KVM_SET_USER_MEMORY_REGION), passes the guest PFN to the virtio driver 5. DRM_VIRTGPU_RESOURCE_CREATE returns the resource id just created 6. Client mmaps it with DRM_IOCTL_VIRTGPU_MAP+mmap and can render to it 7. Gets a FD with DRM_IOCTL_PRIME_HANDLE_TO_FD that can be sent around Send of shareable buffer by guest - 1. Client sends the host a message that refers to this buffer, passing the FD using SCM_RIGHTS 2. Guest proxy passes the message (serialized data + FDs) on to the virtio driver responsable for winsrv support 3. virtio driver puts the data and the resource ids corresponding to the FDs in a virtqueue, kicks it 4. QEMU pops data+buffers from the virtqueue, looks up shmem FD for each resource, sends data + FDs to the compositor with SCM_RIGHTS Reception of buffer from the compositor - 1. QEMU reads from the socket and gets a FD via SCM_RIGHTS 2. QEMU mmaps the FD and maps the resulting pointer to the guest via KVM_SET_USER_MEMORY_REGION 3. QEMU sends the guest PFN along the presentation data to the virtio driver (VIRTIO_GPU_CMD_WINSRV_RX) 4. Virtio driver wraps a FD around that PFN, puts it in a queue 5. Guest proxy calls DRM_IOCTL_VIRTGPU_WINSRV_RX and gets data plus that FD 6. Guest proxy sends that data + FD to the client via SCM_RIGHTS 7. Client gets FD, mmaps it and reads the data from the compositor Thanks, Tomeu If you have a guest proxy anyway using virtio-sock for the protocol stream and virtio-gpu for buffer sharing (and some day 3d rendering too) should work fine I think. If I understand correctly your proposal, virtio-gpu would be used for creating buffers that could be shared across domains, but something equivalent to SCM_RIGHTS would still be needed in virtio-vsock? Yes, the proxy would send a reference to the buffer over virtio-vsock. I was more thinking about a struct specifying something like "ressource-id 42 on virtio-gpu-pci device in slot 1:23.0" instead of using SCM_RIGHTS. Can you extend on this? I'm having trouble figuring out how this could work in a way that keeps protocol data together with the resources it refers to. Don't know much about the wayland protocol. Assuming you are passing buffers as file handles, together with some information what kind of buffer this is (sysv shm, dma-buf, ...). We have a proxy on both ends. One running in the guest, one on the host (be it qemu or some external one). So these two have to agree on how to pass buffers from one to the other. One way would be to have them talk a simple meta protocol to each other, with "here comes a c
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On Mon, Feb 05, 2018 at 03:46:17PM +0100, Tomeu Vizoso wrote: > On 02/05/2018 01:20 PM, Gerd Hoffmann wrote: > >Hi, > > > > > > Why not use virtio-vsock to run the wayland protocol? I don't like > > > > the idea to duplicate something with very simliar functionality in > > > > virtio-gpu. > > > > > > The reason for abandoning that approach was the type of objects that > > > could be shared via virtio-vsock would be extremely limited. Besides > > > that being potentially confusing to users, it would mean from the > > > implementation side that either virtio-vsock would gain a dependency on > > > the drm subsystem, or an appropriate abstraction for shareable buffers > > > would need to be added for little gain. > > > > Well, no. The idea is that virtio-vsock and virtio-gpu are used largely > > as-is, without knowing about each other. The guest wayland proxy which > > does the buffer management talks to both devices. > > Note that the proxy won't know anything about buffers if clients opt-in for > zero-copy support (they allocate the buffers in a way that allows for > sharing with the host). Hmm? I'm assuming the wayland client (in the guest) talks to the wayland proxy, using the wayland protocol, like it would talk to a wayland display server. Buffers must be passed from client to server/proxy somehow, probably using fd passing, so where is the problem? Or did I misunderstand the role of the proxy? > > > > If you have a guest proxy anyway using virtio-sock for the protocol > > > > stream and virtio-gpu for buffer sharing (and some day 3d rendering > > > > too) should work fine I think. > > > > > > If I understand correctly your proposal, virtio-gpu would be used for > > > creating buffers that could be shared across domains, but something > > > equivalent to SCM_RIGHTS would still be needed in virtio-vsock? > > > > Yes, the proxy would send a reference to the buffer over virtio-vsock. > > I was more thinking about a struct specifying something like > > "ressource-id 42 on virtio-gpu-pci device in slot 1:23.0" instead of > > using SCM_RIGHTS. > > Can you extend on this? I'm having trouble figuring out how this could work > in a way that keeps protocol data together with the resources it refers to. Don't know much about the wayland protocol. Assuming you are passing buffers as file handles, together with some information what kind of buffer this is (sysv shm, dma-buf, ...). We have a proxy on both ends. One running in the guest, one on the host (be it qemu or some external one). So these two have to agree on how to pass buffers from one to the other. One way would be to have them talk a simple meta protocol to each other, with "here comes a chunk wayland protocol to pass along" and "here is a buffer mgmt message". Possibly it is better to extend the wayland protocol to also cover this new kind of buffer, so you don't need the meta protocol. The proxies would talk normal wayland protocol to the client (in the guest) and the server (on the host). They will have to transform the buffer into something they can pass along using the wayland protocol. > > > > What is the plan for the host side? I see basically two options. Either > > > > implement the host wayland proxy directly in qemu. Or > > > > implement it as separate process, which then needs some help from > > > > qemu to get access to the buffers. The later would allow qemu running > > > > independant from the desktop session. > > > > > > Regarding synchronizing buffers, this will stop becoming needed in > > > subsequent commits as all shared memory is allocated in the host and > > > mapped to the guest via KVM_SET_USER_MEMORY_REGION. > > > > --verbose please. The qemu patches linked from the cover letter not > > exactly helpful in understanding how all this is supposed to work. > > A client will allocate a buffer with DRM_VIRTGPU_RESOURCE_CREATE, export it > and pass the FD to the compositor (via the proxy). > > During resource creation, QEMU would allocate a shmem buffer and map it into > the guest with KVM_SET_USER_MEMORY_REGION. So the buffer magically shows up somewhere in the physical address space of the guest? That kind if magic usually isn't a very good idea. > When a FD comes from the compositor, QEMU mmaps it and maps that virtual > address to the guest via KVM_SET_USER_MEMORY_REGION. > > When the guest proxy reads from the winsrv socket, it will get a FD that > wraps the buffer referenced above. > > When the client reads from the guest proxy, it would get a FD that > references that same buffer and would mmap it. At that point, the client is > reading from the same physical pages where the compositor wrote to. Hmm. I allways assumed the wayland client allocates the buffers, not the server. Is that wrong? What is your plan for 3d acceleration support? > To be clear, I'm not against solving this via some form of restricted FD > passing in virtio-vsock, but Stefan (added to CC) thought that it would be > cle
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On 02/05/2018 01:20 PM, Gerd Hoffmann wrote: Hi, Why not use virtio-vsock to run the wayland protocol? I don't like the idea to duplicate something with very simliar functionality in virtio-gpu. The reason for abandoning that approach was the type of objects that could be shared via virtio-vsock would be extremely limited. Besides that being potentially confusing to users, it would mean from the implementation side that either virtio-vsock would gain a dependency on the drm subsystem, or an appropriate abstraction for shareable buffers would need to be added for little gain. Well, no. The idea is that virtio-vsock and virtio-gpu are used largely as-is, without knowing about each other. The guest wayland proxy which does the buffer management talks to both devices. Note that the proxy won't know anything about buffers if clients opt-in for zero-copy support (they allocate the buffers in a way that allows for sharing with the host). If you have a guest proxy anyway using virtio-sock for the protocol stream and virtio-gpu for buffer sharing (and some day 3d rendering too) should work fine I think. If I understand correctly your proposal, virtio-gpu would be used for creating buffers that could be shared across domains, but something equivalent to SCM_RIGHTS would still be needed in virtio-vsock? Yes, the proxy would send a reference to the buffer over virtio-vsock. I was more thinking about a struct specifying something like "ressource-id 42 on virtio-gpu-pci device in slot 1:23.0" instead of using SCM_RIGHTS. Can you extend on this? I'm having trouble figuring out how this could work in a way that keeps protocol data together with the resources it refers to. If the mechanics of passing presentation data were very complex, I think this approach would have more merit. But as you can see from the code, it isn't that bad. Well, the devil is in the details. If you have multiple connections you don't want one being able to stall the others for example. There are reasons took quite a while to bring virtio-vsock to the state where it is today. Yes, but at the same time there are use cases that virtio-vsock has to support but aren't important in this scenario. What is the plan for the host side? I see basically two options. Either implement the host wayland proxy directly in qemu. Or implement it as separate process, which then needs some help from qemu to get access to the buffers. The later would allow qemu running independant from the desktop session. Regarding synchronizing buffers, this will stop becoming needed in subsequent commits as all shared memory is allocated in the host and mapped to the guest via KVM_SET_USER_MEMORY_REGION. --verbose please. The qemu patches linked from the cover letter not exactly helpful in understanding how all this is supposed to work. A client will allocate a buffer with DRM_VIRTGPU_RESOURCE_CREATE, export it and pass the FD to the compositor (via the proxy). During resource creation, QEMU would allocate a shmem buffer and map it into the guest with KVM_SET_USER_MEMORY_REGION. The client would mmap that resource and render to it. Because it's backed by host memory, the compositor would be able to read it without any further copies. This is already the case for buffers passed from the compositor to the clients (see patch 2/2), and I'm working on the equivalent for buffers from the guest to the host (clients still have to create buffers with DRM_VIRTGPU_RESOURCE_CREATE but they will be only backend by host memory so no calls to DRM_VIRTGPU_TRANSFER_TO_HOST are needed). Same here. --verbose please. When a FD comes from the compositor, QEMU mmaps it and maps that virtual address to the guest via KVM_SET_USER_MEMORY_REGION. When the guest proxy reads from the winsrv socket, it will get a FD that wraps the buffer referenced above. When the client reads from the guest proxy, it would get a FD that references that same buffer and would mmap it. At that point, the client is reading from the same physical pages where the compositor wrote to. To be clear, I'm not against solving this via some form of restricted FD passing in virtio-vsock, but Stefan (added to CC) thought that it would be cleaner to do it all within virtio-gpu. This is the thread where it was discussed: https://lkml.kernel.org/r/<2d73a3e1-af70-83a1-0e84-98b5932ea...@collabora.com> Thanks, Tomeu
Re: [PATCH v3 1/2] drm/virtio: Add window server support
Hi, > > Why not use virtio-vsock to run the wayland protocol? I don't like > > the idea to duplicate something with very simliar functionality in > > virtio-gpu. > > The reason for abandoning that approach was the type of objects that > could be shared via virtio-vsock would be extremely limited. Besides > that being potentially confusing to users, it would mean from the > implementation side that either virtio-vsock would gain a dependency on > the drm subsystem, or an appropriate abstraction for shareable buffers > would need to be added for little gain. Well, no. The idea is that virtio-vsock and virtio-gpu are used largely as-is, without knowing about each other. The guest wayland proxy which does the buffer management talks to both devices. > > If you have a guest proxy anyway using virtio-sock for the protocol > > stream and virtio-gpu for buffer sharing (and some day 3d rendering > > too) should work fine I think. > > If I understand correctly your proposal, virtio-gpu would be used for > creating buffers that could be shared across domains, but something > equivalent to SCM_RIGHTS would still be needed in virtio-vsock? Yes, the proxy would send a reference to the buffer over virtio-vsock. I was more thinking about a struct specifying something like "ressource-id 42 on virtio-gpu-pci device in slot 1:23.0" instead of using SCM_RIGHTS. > If the mechanics of passing presentation data were very complex, I think > this approach would have more merit. But as you can see from the code, > it isn't that bad. Well, the devil is in the details. If you have multiple connections you don't want one being able to stall the others for example. There are reasons took quite a while to bring virtio-vsock to the state where it is today. > > What is the plan for the host side? I see basically two options. Either > > implement the host wayland proxy directly in qemu. Or > > implement it as separate process, which then needs some help from > > qemu to get access to the buffers. The later would allow qemu running > > independant from the desktop session. > > Regarding synchronizing buffers, this will stop becoming needed in > subsequent commits as all shared memory is allocated in the host and > mapped to the guest via KVM_SET_USER_MEMORY_REGION. --verbose please. The qemu patches linked from the cover letter not exactly helpful in understanding how all this is supposed to work. > This is already the case for buffers passed from the compositor to the > clients (see patch 2/2), and I'm working on the equivalent for buffers > from the guest to the host (clients still have to create buffers with > DRM_VIRTGPU_RESOURCE_CREATE but they will be only backend by host memory > so no calls to DRM_VIRTGPU_TRANSFER_TO_HOST are needed). Same here. --verbose please. cheers, Gerd
Re: [PATCH v3 1/2] drm/virtio: Add window server support
On 1 February 2018 at 17:36, Gerd Hoffmann wrote: Hi, Sorry for joining the party late. Had a broken finger and was offline for a bunch of weeks (and a buif backlog afterwards ...). Hi, no problem, hope it's fine now. This is to allow clients running within VMs to be able to communicate with a compositor in the host. Clients will use the communication protocol that the compositor supports, and virtio-gpu will assist with making buffers available in both sides, and copying content as needed. Why not use virtio-vsock to run the wayland protocol? I don't like the idea to duplicate something with very simliar functionality in virtio-gpu. The reason for abandoning that approach was the type of objects that could be shared via virtio-vsock would be extremely limited. Besides that being potentially confusing to users, it would mean from the implementation side that either virtio-vsock would gain a dependency on the drm subsystem, or an appropriate abstraction for shareable buffers would need to be added for little gain. Another factor that was taken into account was that the complexity required for implementing passing protocol data around was very small when compared with the buffer sharing mechanism. It is expected that a service in the guest will act as a proxy, interacting with virtio-gpu to support unmodified clients. If you have a guest proxy anyway using virtio-sock for the protocol stream and virtio-gpu for buffer sharing (and some day 3d rendering too) should work fine I think. If I understand correctly your proposal, virtio-gpu would be used for creating buffers that could be shared across domains, but something equivalent to SCM_RIGHTS would still be needed in virtio-vsock? If so, that's what was planned initially, with the concern being that we would be adding a bunch of complexity to virtio-vsock that would be only used in this specific use case. Then we would also need to figure out how virtio-vsock would be able to work with buffers from virtio-gpu (either direct dependency or a new abstraction). If the mechanics of passing presentation data were very complex, I think this approach would have more merit. But as you can see from the code, it isn't that bad. When the client notifies the compositor that it can read from that buffer, the proxy should copy the contents from the SHM region to the virtio-gpu resource and call DRM_VIRTGPU_TRANSFER_TO_HOST. What is the plan for the host side? I see basically two options. Either implement the host wayland proxy directly in qemu. Or implement it as separate process, which then needs some help from qemu to get access to the buffers. The later would allow qemu running independant from the desktop session. Regarding synchronizing buffers, this will stop becoming needed in subsequent commits as all shared memory is allocated in the host and mapped to the guest via KVM_SET_USER_MEMORY_REGION. This is already the case for buffers passed from the compositor to the clients (see patch 2/2), and I'm working on the equivalent for buffers from the guest to the host (clients still have to create buffers with DRM_VIRTGPU_RESOURCE_CREATE but they will be only backend by host memory so no calls to DRM_VIRTGPU_TRANSFER_TO_HOST are needed). But in the case that we still need a proxy for some reason on the host side, I think it would be better to have it in the same process where virtio-gpu is implemented. In crosvm's case it would be in a process separate from the main VMM, as device processes are isolated from each other with minijail (see https://chromium.googlesource.com/chromiumos/platform/crosvm/ ). Regards, Tomeu
Re: [PATCH v3 1/2] drm/virtio: Add window server support
Hi, Sorry for joining the party late. Had a broken finger and was offline for a bunch of weeks (and a buif backlog afterwards ...). > This is to allow clients running within VMs to be able to communicate > with a compositor in the host. Clients will use the communication > protocol that the compositor supports, and virtio-gpu will assist with > making buffers available in both sides, and copying content as needed. Why not use virtio-vsock to run the wayland protocol? I don't like the idea to duplicate something with very simliar functionality in virtio-gpu. > It is expected that a service in the guest will act as a proxy, > interacting with virtio-gpu to support unmodified clients. If you have a guest proxy anyway using virtio-sock for the protocol stream and virtio-gpu for buffer sharing (and some day 3d rendering too) should work fine I think. > When the client notifies the compositor that it can read from that buffer, > the proxy should copy the contents from the SHM region to the virtio-gpu > resource and call DRM_VIRTGPU_TRANSFER_TO_HOST. What is the plan for the host side? I see basically two options. Either implement the host wayland proxy directly in qemu. Or implement it as separate process, which then needs some help from qemu to get access to the buffers. The later would allow qemu running independant from the desktop session. cheers, Gerd