[PATCH] hw/display/virtio-gpu: Fix empty blob discrimination

Akihiko Odaki posted 1 patch 1 day, 2 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260725-image-v1-1-4698a805afde@rsg.ci.i.u-tokyo.ac.jp
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Dmitry Osipenko <dmitry.osipenko@collabora.com>
hw/display/virtio-gpu.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
[PATCH] hw/display/virtio-gpu: Fix empty blob discrimination
Posted by Akihiko Odaki 1 day, 2 hours ago
Discriminating blobs by checking whether blob_size is nonzero fails for
empty blobs. Identify 2D resources by their non-NULL image instead.

Fixes: bdd53f739273 ("virtio-gpu: Update cursor data using blob")
Fixes: f66767f75c9c ("virtio-gpu: add virtio-gpu/blob vmstate subsection")
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
 hw/display/virtio-gpu.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 718ba3039290..6413df029b8e 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -56,18 +56,18 @@ void virtio_gpu_update_cursor_data(VirtIOGPU *g,
         return;
     }
 
-    if (res->blob_size) {
-        if (res->blob_size < (s->current_cursor->width *
-                              s->current_cursor->height * 4)) {
-            return;
-        }
-        data = res->blob;
-    } else {
+    if (res->image) {
         if (pixman_image_get_width(res->image)  != s->current_cursor->width ||
             pixman_image_get_height(res->image) != s->current_cursor->height) {
             return;
         }
         data = pixman_image_get_data(res->image);
+    } else {
+        if (res->blob_size < (s->current_cursor->width *
+                              s->current_cursor->height * 4)) {
+            return;
+        }
+        data = res->blob;
     }
 
     pixels = s->current_cursor->width * s->current_cursor->height;
@@ -1279,7 +1279,7 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size,
     assert(QTAILQ_EMPTY(&g->cmdq));
 
     QTAILQ_FOREACH(res, &g->reslist, next) {
-        if (res->blob_size) {
+        if (!res->image) {
             continue;
         }
         qemu_put_be32(f, res->resource_id);
@@ -1430,7 +1430,7 @@ static int virtio_gpu_blob_save(QEMUFile *f, void *opaque, size_t size,
     assert(QTAILQ_EMPTY(&g->cmdq));
 
     QTAILQ_FOREACH(res, &g->reslist, next) {
-        if (!res->blob_size) {
+        if (res->image) {
             continue;
         }
         assert(!res->image);

---
base-commit: 006a22cb26998998385b104db1ff9466ef2f3153
change-id: 20260725-image-6c8566fb1253

Best regards,
--  
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Re: [PATCH] hw/display/virtio-gpu: Fix empty blob discrimination
Posted by Marc-André Lureau 20 hours ago
On Sat, Jul 25, 2026 at 11:13 AM Akihiko Odaki
<odaki@rsg.ci.i.u-tokyo.ac.jp> wrote:
>
> Discriminating blobs by checking whether blob_size is nonzero fails for
> empty blobs. Identify 2D resources by their non-NULL image instead.
>
> Fixes: bdd53f739273 ("virtio-gpu: Update cursor data using blob")
> Fixes: f66767f75c9c ("virtio-gpu: add virtio-gpu/blob vmstate subsection")
> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  hw/display/virtio-gpu.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 718ba3039290..6413df029b8e 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -56,18 +56,18 @@ void virtio_gpu_update_cursor_data(VirtIOGPU *g,
>          return;
>      }
>
> -    if (res->blob_size) {
> -        if (res->blob_size < (s->current_cursor->width *
> -                              s->current_cursor->height * 4)) {
> -            return;
> -        }
> -        data = res->blob;
> -    } else {
> +    if (res->image) {
>          if (pixman_image_get_width(res->image)  != s->current_cursor->width ||
>              pixman_image_get_height(res->image) != s->current_cursor->height) {
>              return;
>          }
>          data = pixman_image_get_data(res->image);
> +    } else {
> +        if (res->blob_size < (s->current_cursor->width *
> +                              s->current_cursor->height * 4)) {
> +            return;
> +        }
> +        data = res->blob;
>      }
>
>      pixels = s->current_cursor->width * s->current_cursor->height;
> @@ -1279,7 +1279,7 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size,
>      assert(QTAILQ_EMPTY(&g->cmdq));
>
>      QTAILQ_FOREACH(res, &g->reslist, next) {
> -        if (res->blob_size) {
> +        if (!res->image) {
>              continue;
>          }
>          qemu_put_be32(f, res->resource_id);
> @@ -1430,7 +1430,7 @@ static int virtio_gpu_blob_save(QEMUFile *f, void *opaque, size_t size,
>      assert(QTAILQ_EMPTY(&g->cmdq));
>
>      QTAILQ_FOREACH(res, &g->reslist, next) {
> -        if (!res->blob_size) {
> +        if (res->image) {
>              continue;
>          }
>          assert(!res->image);
>
> ---
> base-commit: 006a22cb26998998385b104db1ff9466ef2f3153
> change-id: 20260725-image-6c8566fb1253
>
> Best regards,
> --
> Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
>
>


-- 
Marc-André Lureau