@samitouri / QOSamiQemu / commits / 0fa3e1823b

hw/display/virtio-gpu: Fix empty blob discrimination

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> Message-ID: <20260725-image-v1-1-4698a805afde@rsg.ci.i.u-tokyo.ac.jp>

Akihiko Odaki committed Jul 25, 2026 at 16:12 UTC 0fa3e1823b9b9ae1fc1ea0d290849578907a770b
1 file changed +9 -9
hw/display/virtio-gpu.c
+9 -9
@@ -56,18 +56,18 @@ void virtio_gpu_update_cursor_data(VirtIOGPU *g,
56 return;
57 }
58
59 - if (res->blob_size) {
60 - if (res->blob_size < (s->current_cursor->width *
61 - s->current_cursor->height * 4)) {
62 - return;
63 - }
64 - data = res->blob;
65 - } else {
59 + if (res->image) {
60 if (pixman_image_get_width(res->image) != s->current_cursor->width ||
61 pixman_image_get_height(res->image) != s->current_cursor->height) {
62 return;
63 }
64 data = pixman_image_get_data(res->image);
65 + } else {
66 + if (res->blob_size < (s->current_cursor->width *
67 + s->current_cursor->height * 4)) {
68 + return;
69 + }
70 + data = res->blob;
71 }
72
73 pixels = s->current_cursor->width * s->current_cursor->height;
@@ -1286,7 +1286,7 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size,
1286 assert(QTAILQ_EMPTY(&g->cmdq));
1287
1288 QTAILQ_FOREACH(res, &g->reslist, next) {
1289 - if (res->blob_size) {
1289 + if (!res->image) {
1290 continue;
1291 }
1292 qemu_put_be32(f, res->resource_id);
@@ -1437,7 +1437,7 @@ static int virtio_gpu_blob_save(QEMUFile *f, void *opaque, size_t size,
1437 assert(QTAILQ_EMPTY(&g->cmdq));
1438
1439 QTAILQ_FOREACH(res, &g->reslist, next) {
1440 - if (!res->blob_size) {
1440 + if (res->image) {
1441 continue;
1442 }
1443 assert(!res->image);