From: Arun Menon <armenon@redhat.com>
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 vdaagent
to store the outbuf variable.
Signed-off-by: Arun Menon <armenon@redhat.com>
Fix-Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/vdagent.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/ui/vdagent.c b/ui/vdagent.c
index bb0c4aa14c..9206e47000 100644
--- a/ui/vdagent.c
+++ b/ui/vdagent.c
@@ -967,17 +967,6 @@ static const VMStateDescription vmstate_chunk = {
}
};
-static const VMStateDescription vmstate_vdba = {
- .name = "vdagent/bytearray",
- .version_id = 0,
- .minimum_version_id = 0,
- .fields = (const VMStateField[]) {
- VMSTATE_UINT32(len, GByteArray),
- VMSTATE_VBUFFER_ALLOC_UINT32(data, GByteArray, 0, 0, len),
- VMSTATE_END_OF_LIST()
- }
-};
-
struct CBInfoArray {
uint32_t n;
QemuClipboardInfo cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT];
@@ -1067,7 +1056,7 @@ static const VMStateDescription vmstate_vdagent = {
VMSTATE_UINT32(xsize, VDAgentChardev),
VMSTATE_UINT32(xoff, VDAgentChardev),
VMSTATE_VBUFFER_ALLOC_UINT32(xbuf, VDAgentChardev, 0, 0, xsize),
- VMSTATE_STRUCT_POINTER(outbuf, VDAgentChardev, vmstate_vdba, GByteArray),
+ VMSTATE_GBYTEARRAY(outbuf, VDAgentChardev, 0),
VMSTATE_UINT32(mouse_x, VDAgentChardev),
VMSTATE_UINT32(mouse_y, VDAgentChardev),
VMSTATE_UINT32(mouse_btn, VDAgentChardev),
--
2.53.0
Hi
On Mon, Apr 6, 2026 at 3:53 PM Arun Menon <armenon@redhat.com> wrote:
>
> From: Arun Menon <armenon@redhat.com>
>
> 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 vdaagent
vdagent
> to store the outbuf variable.
>
> Signed-off-by: Arun Menon <armenon@redhat.com>
> Fix-Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
It seems to be produce compatible migration streams, so
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/vdagent.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/ui/vdagent.c b/ui/vdagent.c
> index bb0c4aa14c..9206e47000 100644
> --- a/ui/vdagent.c
> +++ b/ui/vdagent.c
> @@ -967,17 +967,6 @@ static const VMStateDescription vmstate_chunk = {
> }
> };
>
> -static const VMStateDescription vmstate_vdba = {
> - .name = "vdagent/bytearray",
> - .version_id = 0,
> - .minimum_version_id = 0,
> - .fields = (const VMStateField[]) {
> - VMSTATE_UINT32(len, GByteArray),
> - VMSTATE_VBUFFER_ALLOC_UINT32(data, GByteArray, 0, 0, len),
> - VMSTATE_END_OF_LIST()
> - }
> -};
> -
> struct CBInfoArray {
> uint32_t n;
> QemuClipboardInfo cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT];
> @@ -1067,7 +1056,7 @@ static const VMStateDescription vmstate_vdagent = {
> VMSTATE_UINT32(xsize, VDAgentChardev),
> VMSTATE_UINT32(xoff, VDAgentChardev),
> VMSTATE_VBUFFER_ALLOC_UINT32(xbuf, VDAgentChardev, 0, 0, xsize),
> - VMSTATE_STRUCT_POINTER(outbuf, VDAgentChardev, vmstate_vdba, GByteArray),
> + VMSTATE_GBYTEARRAY(outbuf, VDAgentChardev, 0),
> VMSTATE_UINT32(mouse_x, VDAgentChardev),
> VMSTATE_UINT32(mouse_y, VDAgentChardev),
> VMSTATE_UINT32(mouse_btn, VDAgentChardev),
> --
> 2.53.0
>
© 2016 - 2026 Red Hat, Inc.