Commit be61c0eb80 for qemu.org
commit be61c0eb800db6a82546a695592c218acac7f2a8
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date: Wed Aug 26 23:59:19 2026 +0400
hw/display/virtio-gpu: set share_handle for udmabuf blob resources
Set share_handle to the dmabuf fd after successful udmabuf creation,
and reset it to SHAREABLE_NONE on teardown.
Fixes: 5f899c34af1d ("virtio-gpu: allocate shareable 2d resources on !win32")
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.c
index 03f0b29754..fc63f2c4ec 100644
--- a/hw/display/virtio-gpu-udmabuf.c
+++ b/hw/display/virtio-gpu-udmabuf.c
@@ -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;
}
res->blob = NULL;
}
@@ -150,6 +151,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;
}
@@ -183,6 +185,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;
}
}