On 28/8/26 09:53, marcandre.lureau--- via qemu development wrote:
From: Marc-André Lureau <[email protected]>
All allocation sites used g_new0() which zero-initializes fields.
However share_handle must be SHAREABLE_NONE (-1 on Unix, NULL on
Windows) and dmabuf_fd must be -1, not 0. Centralize allocation and
field initialization in new constructors fix this and reduce code
duplication.
This fixes -display dbus with virtio-gpu blob resources. The other
end is currently receiving qemu fd 0.
Signed-off-by: Marc-André Lureau <[email protected]>
---
v2: add virgl_gpu_virgl_resource_new()
---
hw/display/virtio-gpu-rutabaga.c | 20 +++++-------------
hw/display/virtio-gpu-virgl.c | 34 ++++++++++++++++++-------------
hw/display/virtio-gpu.c | 35 +++++++++++++++++++++-----------
include/hw/virtio/virtio-gpu.h | 4 ++++
4 files changed, 52 insertions(+), 41 deletions(-)
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 9bda572426b2..d32801c3893a 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -309,6 +309,23 @@ virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g,
}
#endif
+static struct virtio_gpu_virgl_resource *
+virtio_gpu_virgl_resource_new(uint32_t resource_id, uint32_t width,
+ uint32_t height, uint32_t format)
+{
+ struct virtio_gpu_virgl_resource *res = g_new0(struct
virtio_gpu_virgl_resource, 1);
+
+ res->base.share_handle = SHAREABLE_NONE;
+ res->base.dmabuf_fd = -1;
+
+ res->base.resource_id = resource_id;
+ res->base.width = width;
+ res->base.height = height;
+ res->base.format = format;
Seeing v2 maybe we should only add a virtio_gpu_virgl_resource_init().
+
+ return res;
+}