Skip to contentSkip to conversation

hw/display/virtio-gpu: set share_handle for udmabuf blob resources

PATCH In review [email protected] 3 participants 3 messages Aug 27 – Aug 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/display/virtio-gpu: set share_handle for udmabuf blob resources

From: Marc-André Lureau <[email protected]>

When a blob resource is backed by udmabuf, the dmabuf fd was never propagated to res->share_handle. This meant the D-Bus display listener could not share the buffer mapping with remote clients, falling back to copying pixel data instead.

Set share_handle to the dmabuf fd after successful udmabuf creation, and reset it to SHAREABLE_NONE on teardown.

---
 hw/display/virtio-gpu-udmabuf.c | 3 +++
 1 file changed, 3 insertions(+)
hw/display/virtio-gpu-udmabuf.c +3 -0
index c230509852ff..5d6daa1f7afc 100644
@@ -91,6 +91,7 @@ static void virtio_gpu_destroy_udmabuf(struct virtio_gpu_simple_resource *res)
     if (res->dmabuf_fd >= 0) {
         close(res->dmabuf_fd);
         res->dmabuf_fd = -1;
+        res->share_handle = SHAREABLE_NONE;
     }
 }
 
@@ -149,6 +150,7 @@ bool virtio_gpu_init_udmabuf(struct virtio_gpu_simple_resource *res)
             virtio_gpu_destroy_udmabuf(res);
             return false;
         }
+        res->share_handle = res->dmabuf_fd;
         pdata = res->remapped;
     }
 
@@ -182,6 +184,7 @@ void virtio_gpu_fini_udmabuf(VirtIOGPU *g, struct virtio_gpu_simple_resource *re
             res->dmabuf_fd != -1) {
             qemu_dmabuf_close(dmabuf->buf);
             res->dmabuf_fd = -1;
+            res->share_handle = SHAREABLE_NONE;
         }
     }
 
Signature · 1 line
2.55.0.543.g5ebe2ebe4ea8
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Thu, Aug 27, 2026 at 11:10:13AM +0400, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

When a blob resource is backed by udmabuf, the dmabuf fd was never propagated to res->share_handle. This meant the D-Bus display listener could not share the buffer mapping with remote clients, falling back to copying pixel data instead.

Quoted 7 lines

Set share_handle to the dmabuf fd after successful udmabuf creation, and reset it to SHAREABLE_NONE on teardown.

---
 hw/display/virtio-gpu-udmabuf.c | 3 +++
 1 file changed, 3 insertions(+)

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 10 lines · On 2026/08/27 16:10, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

When a blob resource is backed by udmabuf, the dmabuf fd was never propagated to res->share_handle. This meant the D-Bus display listener could not share the buffer mapping with remote clients, falling back to copying pixel data instead.

Set share_handle to the dmabuf fd after successful udmabuf creation, and reset it to SHAREABLE_NONE on teardown.

Quoted 1 line

Please add:

Fixes 5f899c34af1d ("virtio-gpu: allocate shareable 2d resources on !win32")

With the Fixes tag:

Regards,
Akihiko Odaki

Quoted 32 lines
---
  hw/display/virtio-gpu-udmabuf.c | 3 +++
  1 file changed, 3 insertions(+)
hw/display/virtio-gpu-udmabuf.c +3 -0
index c230509852ff..5d6daa1f7afc 100644
@@ -91,6 +91,7 @@ static void virtio_gpu_destroy_udmabuf(struct virtio_gpu_simple_resource *res)
      if (res->dmabuf_fd >= 0) {
          close(res->dmabuf_fd);
          res->dmabuf_fd = -1;
+        res->share_handle = SHAREABLE_NONE;
      }
  }
 
@@ -149,6 +150,7 @@ bool virtio_gpu_init_udmabuf(struct virtio_gpu_simple_resource *res)
              virtio_gpu_destroy_udmabuf(res);
              return false;
          }
+        res->share_handle = res->dmabuf_fd;
          pdata = res->remapped;
      }
 
@@ -182,6 +184,7 @@ void virtio_gpu_fini_udmabuf(VirtIOGPU *g, struct virtio_gpu_simple_resource *re
              res->dmabuf_fd != -1) {
              qemu_dmabuf_close(dmabuf->buf);
              res->dmabuf_fd = -1;
+            res->share_handle = SHAREABLE_NONE;
          }
      }