ui/vdagent: Use VMSTATE_GBYTEARRAY to safely migrate outbuf
Migrating a GLib GByteArray is now possible directly using the newly introduced VMSTATE_GBYTEARRAY. It uses the standard GLib API calls to create the array, or resize it. This is safer than implementing a C struct and manually updating the data and len fields. This commit uses the VMSTATE_GBYTEARRAY in vdagent to store the outbuf variable. 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-3-armenon@redhat.com Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Arun Menon committed
Apr 23, 2026 at 16:27 UTC
fc6ff3198ea1e78c396c868054221a26daae6f6f
1 file changed
+1
-12
ui/vdagent.c
+1
-12
@@ -964,17 +964,6 @@ static const VMStateDescription vmstate_chunk = {
964
}
965
};
966
967
-static const VMStateDescription vmstate_vdba = {
968
- .name = "vdagent/bytearray",
969
- .version_id = 0,
970
- .minimum_version_id = 0,
971
- .fields = (const VMStateField[]) {
972
- VMSTATE_UINT32(len, GByteArray),
973
- VMSTATE_VBUFFER_ALLOC_UINT32(data, GByteArray, 0, 0, len),
974
- VMSTATE_END_OF_LIST()
975
- }
976
-};
977
-
967
struct CBInfoArray {
968
uint32_t n;
969
QemuClipboardInfo cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT];
@@ -1064,7 +1053,7 @@ static const VMStateDescription vmstate_vdagent = {
1053
VMSTATE_UINT32(xsize, VDAgentChardev),
1054
VMSTATE_UINT32(xoff, VDAgentChardev),
1055
VMSTATE_VBUFFER_ALLOC_UINT32(xbuf, VDAgentChardev, 0, 0, xsize),
1067
- VMSTATE_STRUCT_POINTER(outbuf, VDAgentChardev, vmstate_vdba, GByteArray),
1056
+ VMSTATE_GBYTEARRAY(outbuf, VDAgentChardev, 0),
1057
VMSTATE_UINT32(mouse_x, VDAgentChardev),
1058
VMSTATE_UINT32(mouse_y, VDAgentChardev),
1059
VMSTATE_UINT32(mouse_btn, VDAgentChardev),