On 230627 1502, marcandre.lur...@redhat.com wrote: > From: Marc-André Lureau <marcandre.lur...@redhat.com> > > Allocate pixman bits for scanouts with qemu_win32_map_alloc() so we can > set a shareable handle on the associated display surface. > > Note: when bits are provided to pixman_image_create_bits(), you must also give > the rowstride (the argument is ignored when bits is NULL) > > Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > Message-Id: <20230606115658.677673-11-marcandre.lur...@redhat.com> > --- > include/hw/virtio/virtio-gpu.h | 3 +++ > hw/display/virtio-gpu.c | 46 +++++++++++++++++++++++++++++++--- > 2 files changed, 46 insertions(+), 3 deletions(-) > > diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h > index 2e28507efe..7a5f8056ea 100644 > --- a/include/hw/virtio/virtio-gpu.h > +++ b/include/hw/virtio/virtio-gpu.h > @@ -48,6 +48,9 @@ struct virtio_gpu_simple_resource { > unsigned int iov_cnt; > uint32_t scanout_bitmask; > pixman_image_t *image; > +#ifdef WIN32 > + HANDLE handle; > +#endif > uint64_t hostmem; > > uint64_t blob_size; > diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c > index 1f8a5b16c6..347e17d490 100644 > --- a/hw/display/virtio-gpu.c > +++ b/hw/display/virtio-gpu.c > @@ -258,6 +258,16 @@ static uint32_t calc_image_hostmem(pixman_format_code_t > pformat, > return height * stride; > } > > +#ifdef WIN32 > +static void > +win32_pixman_image_destroy(pixman_image_t *image, void *data) > +{ > + HANDLE handle = data; > + > + qemu_win32_map_free(pixman_image_get_data(image), handle, &error_warn); > +} > +#endif > + > static void virtio_gpu_resource_create_2d(VirtIOGPU *g, > struct virtio_gpu_ctrl_command > *cmd) > { > @@ -304,12 +314,27 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g, > > res->hostmem = calc_image_hostmem(pformat, c2d.width, c2d.height); > if (res->hostmem + g->hostmem < g->conf_max_hostmem) { > + void *bits = NULL; > +#ifdef WIN32 > + bits = qemu_win32_map_alloc(res->hostmem, &res->handle, &error_warn); > + if (!bits) { > + goto end; > + } > +#endif > res->image = pixman_image_create_bits(pformat, > c2d.width, > c2d.height, > - NULL, 0); > + bits, res->hostmem / > c2d.height);
Hello, This may lead to FPE when c2d.height is 0. https://gitlab.com/qemu-project/qemu/-/issues/1744 -Alex