Files
qemu/migration
Arun Menon 1d9688c074 migration/vmstate: Add VMState support for GByteArray
In GLib, GByteArray is an object managed by the library. Currently,
migrating a GByteArray requires treating it as a raw C struct and using
VMSTATE_VBUFFER_ALLOC_UINT32. For example, see vmstate_vdba in
ui/vdagent.c

QEMU cannot pretend that GByteArray is a C struct and simply use
VMS_ALLOC to g_malloc() the buffer. This is because, VMS_ALLOC blindly
overwrites the data pointer with a newly allocated buffer, thereby
leaking the previous memory. Besides, GLib tracks the array's capacity
in a hidden alloc field. Bypassing GLib APIs leave this capacity out of
sync with the newly allocated buffer, potentially leading to heap buffer
overflows during subsequent g_byte_array_append() calls.

This commit introduces VMSTATE_GBYTEARRAY which uses specific library
API calls (g_byte_array_set_size()) to safely resize and populate the
buffer.

Signed-off-by: Arun Menon <armenon@redhat.com>
Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260423105733.113046-2-armenon@redhat.com
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-06-01 19:32:49 +00:00
..
2026-05-20 15:49:10 -04:00
2026-01-17 10:46:31 +11:00
2024-12-20 17:44:56 +01:00
2026-03-09 08:53:32 -03:00
2026-03-09 08:53:32 -03:00
2026-03-09 08:53:32 -03:00
2026-03-09 08:53:32 -03:00
2025-12-27 10:11:09 +01:00
2026-01-23 11:32:18 -03:00
2026-01-23 11:32:18 -03:00
2025-09-02 17:57:05 +02:00
2025-09-02 17:57:05 +02:00