]> git.ipfire.org Git - thirdparty/qemu.git/commit
migration: Dump correct JSON format for nullptr replacement
authorPeter Xu <peterx@redhat.com>
Thu, 9 Jan 2025 18:52:47 +0000 (15:52 -0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Sat, 18 Jan 2025 10:43:13 +0000 (13:43 +0300)
commit15efc4a0ddaea3387b45525f4dabd100d5d82e0f
tree914128d17b8bec8467a6b0a728f26f110d61ac2c
parent575ed2e688dc434d13608140d80ae2b7d0da62c7
migration: Dump correct JSON format for nullptr replacement

QEMU plays a trick with null pointers inside an array of pointers in a VMSD
field.  See 07d4e69147 ("migration/vmstate: fix array of ptr with
nullptrs") for more details on why.  The idea makes sense in general, but
it may overlooked the JSON writer where it could write nothing in a
"struct" in the JSON hints section.

We hit some analyze-migration.py issues on s390 recently, showing that some
of the struct field contains nothing, like:

{"name": "css", "array_len": 256, "type": "struct", "struct": {}, "size": 1}

As described in details by Fabiano:

https://lore.kernel.org/r/87pll37cin.fsf@suse.de

It could be that we hit some null pointers there, and JSON was gone when
they're null pointers.

To fix it, instead of hacking around only at VMStateInfo level, do that
from VMStateField level, so that JSON writer can also be involved.  In this
case, JSON writer will replace the pointer array (which used to be a
"struct") to be the real representation of the nullptr field.

Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20250109185249.23952-6-farosas@suse.de>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
(cherry picked from commit 9867c3a7ced12dd7519155c047eb2c0098a11c5f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
migration/vmstate.c