migration: Rename vmstate_info_nullptr

Rename vmstate_info_nullptr from "uint64_t" to "nullptr". This vmstate
actually reads and writes just a byte, so the proper name would be
uint8. However, since this is a marker for a NULL pointer, it's
convenient to have a more explicit name that can be identified by the
consumers of the JSON part of the stream.

Change the name to "nullptr" and add support for it in the
analyze-migration.py script. Arbitrarily use the name of the type as
the value of the field to avoid the script showing 0x30 or '0', which
could be confusing for readers.

Reviewed-by: Peter Xu <peterx@redhat.com>
Message-Id: <20250109185249.23952-5-farosas@suse.de>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
This commit is contained in:
Fabiano Rosas 2025-01-09 15:52:46 -03:00
parent 69d1f78456
commit f52965bf0e
2 changed files with 24 additions and 1 deletions

View file

@ -338,7 +338,7 @@ static int put_nullptr(QEMUFile *f, void *pv, size_t size,
} }
const VMStateInfo vmstate_info_nullptr = { const VMStateInfo vmstate_info_nullptr = {
.name = "uint64", .name = "nullptr",
.get = get_nullptr, .get = get_nullptr,
.put = put_nullptr, .put = put_nullptr,
}; };

View file

@ -417,6 +417,28 @@ class VMSDFieldIntLE(VMSDFieldInt):
super(VMSDFieldIntLE, self).__init__(desc, file) super(VMSDFieldIntLE, self).__init__(desc, file)
self.dtype = '<i%d' % self.size self.dtype = '<i%d' % self.size
class VMSDFieldNull(VMSDFieldGeneric):
NULL_PTR_MARKER = b'0'
def __init__(self, desc, file):
super(VMSDFieldNull, self).__init__(desc, file)
def __repr__(self):
# A NULL pointer is encoded in the stream as a '0' to
# disambiguate from a mere 0x0 value and avoid consumers
# trying to follow the NULL pointer. Displaying '0', 0x30 or
# 0x0 when analyzing the JSON debug stream could become
# confusing, so use an explicit term instead.
return "nullptr"
def __str__(self):
return self.__repr__()
def read(self):
super(VMSDFieldNull, self).read()
assert(self.data == self.NULL_PTR_MARKER)
return self.data
class VMSDFieldBool(VMSDFieldGeneric): class VMSDFieldBool(VMSDFieldGeneric):
def __init__(self, desc, file): def __init__(self, desc, file):
super(VMSDFieldBool, self).__init__(desc, file) super(VMSDFieldBool, self).__init__(desc, file)
@ -558,6 +580,7 @@ vmsd_field_readers = {
"bitmap" : VMSDFieldGeneric, "bitmap" : VMSDFieldGeneric,
"struct" : VMSDFieldStruct, "struct" : VMSDFieldStruct,
"capability": VMSDFieldCap, "capability": VMSDFieldCap,
"nullptr": VMSDFieldNull,
"unknown" : VMSDFieldGeneric, "unknown" : VMSDFieldGeneric,
} }