]> 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>
Mon, 13 Jan 2025 08:25:57 +0000 (11:25 +0300)
commit46f2af3e3917b3aa8b65fdabcff79c2ce52b9e7f
treead2bf84f56fed636e525fd4d6454c9511ca40ba3
parent3ba6e1164a45f3345816921fec76d7bd12ed215a
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