* [PATCH v2] hw/display/virtio-gpu: Reject non-migratable large blobs
@ 2026-07-27 9:23 Akihiko Odaki
2026-07-27 9:30 ` Daniel P. Berrangé
0 siblings, 1 reply; 2+ messages in thread
From: Akihiko Odaki @ 2026-07-27 9:23 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Dmitry Osipenko, Michael S. Tsirkin,
Akihiko Odaki
The blob size is encoded as a 64-bit integer in the virtio protocol, but
it is encoded as a 32-bit integer in the migration stream, and
a large blob whose size cannot be expressed in a 32-bit integer will
be corrupted after migration. Deny creating such large blobs.
Fixes: f66767f75c9c ("virtio-gpu: add virtio-gpu/blob vmstate subsection")
Fixes: 10b9ddbc83b9 ("Revert "virtio-gpu: block migration of VMs with blob=true"")
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
Changes in v2:
- Add the Fixes: tag for f66767f75c9c.
- Add a TODO to encode blob_size as 64 bits in virtio-gpu/blob
VMState version 2.
- Link to v1: https://lore.kernel.org/qemu-devel/20260725-blob-v1-1-f643fbd76398@rsg.ci.i.u-tokyo.ac.jp
---
hw/display/virtio-gpu.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 718ba3039290..987b1b3ea860 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -352,6 +352,14 @@ static void virtio_gpu_resource_create_blob(VirtIOGPU *g,
return;
}
+ if (cblob.size > UINT32_MAX) {
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "%s: blob too large (%" PRIu64 "> %" PRIu32 ")\n",
+ __func__, cblob.size, UINT32_MAX);
+ cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;
+ return;
+ }
+
if (virtio_gpu_find_resource(g, cblob.resource_id)) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n",
__func__, cblob.resource_id);
@@ -1435,7 +1443,14 @@ static int virtio_gpu_blob_save(QEMUFile *f, void *opaque, size_t size,
}
assert(!res->image);
qemu_put_be32(f, res->resource_id);
+
+ /*
+ * The migration stream encodes blob_size as a 32-bit integer for
+ * compatibility though virtio encodes it as a 64-bit integer. A newer
+ * version of the migration stream should encode it as a 64-bit integer.
+ */
qemu_put_be32(f, res->blob_size);
+
qemu_put_be32(f, res->iov_cnt);
for (i = 0; i < res->iov_cnt; i++) {
qemu_put_be64(f, res->addrs[i]);
---
base-commit: 006a22cb26998998385b104db1ff9466ef2f3153
change-id: 20260725-blob-8a6a1a85601a
Best regards,
--
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] hw/display/virtio-gpu: Reject non-migratable large blobs
2026-07-27 9:23 [PATCH v2] hw/display/virtio-gpu: Reject non-migratable large blobs Akihiko Odaki
@ 2026-07-27 9:30 ` Daniel P. Berrangé
0 siblings, 0 replies; 2+ messages in thread
From: Daniel P. Berrangé @ 2026-07-27 9:30 UTC (permalink / raw)
To: Akihiko Odaki
Cc: qemu-devel, Alex Bennée, Dmitry Osipenko, Michael S. Tsirkin
On Mon, Jul 27, 2026 at 06:23:25PM +0900, Akihiko Odaki wrote:
> The blob size is encoded as a 64-bit integer in the virtio protocol, but
> it is encoded as a 32-bit integer in the migration stream, and
> a large blob whose size cannot be expressed in a 32-bit integer will
> be corrupted after migration. Deny creating such large blobs.
Is there a valid use case for such large blobs ? If so, rather than
rejecting the blob, we could dynamically add a migration blocker.
That would allow the valid use cases, while preventing the migration
problem.
>
> Fixes: f66767f75c9c ("virtio-gpu: add virtio-gpu/blob vmstate subsection")
> Fixes: 10b9ddbc83b9 ("Revert "virtio-gpu: block migration of VMs with blob=true"")
> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
> ---
> Changes in v2:
> - Add the Fixes: tag for f66767f75c9c.
> - Add a TODO to encode blob_size as 64 bits in virtio-gpu/blob
> VMState version 2.
> - Link to v1: https://lore.kernel.org/qemu-devel/20260725-blob-v1-1-f643fbd76398@rsg.ci.i.u-tokyo.ac.jp
> ---
> hw/display/virtio-gpu.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 718ba3039290..987b1b3ea860 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -352,6 +352,14 @@ static void virtio_gpu_resource_create_blob(VirtIOGPU *g,
> return;
> }
>
> + if (cblob.size > UINT32_MAX) {
> + qemu_log_mask(LOG_GUEST_ERROR,
> + "%s: blob too large (%" PRIu64 "> %" PRIu32 ")\n",
> + __func__, cblob.size, UINT32_MAX);
> + cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;
> + return;
> + }
> +
> if (virtio_gpu_find_resource(g, cblob.resource_id)) {
> qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n",
> __func__, cblob.resource_id);
> @@ -1435,7 +1443,14 @@ static int virtio_gpu_blob_save(QEMUFile *f, void *opaque, size_t size,
> }
> assert(!res->image);
> qemu_put_be32(f, res->resource_id);
> +
> + /*
> + * The migration stream encodes blob_size as a 32-bit integer for
> + * compatibility though virtio encodes it as a 64-bit integer. A newer
> + * version of the migration stream should encode it as a 64-bit integer.
> + */
> qemu_put_be32(f, res->blob_size);
> +
> qemu_put_be32(f, res->iov_cnt);
> for (i = 0; i < res->iov_cnt; i++) {
> qemu_put_be64(f, res->addrs[i]);
>
> ---
> base-commit: 006a22cb26998998385b104db1ff9466ef2f3153
> change-id: 20260725-blob-8a6a1a85601a
>
> Best regards,
> --
> Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
>
>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-27 9:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 9:23 [PATCH v2] hw/display/virtio-gpu: Reject non-migratable large blobs Akihiko Odaki
2026-07-27 9:30 ` Daniel P. Berrangé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.