Skip to content

Commit f52965b

Browse files
author
Fabiano Rosas
committed
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 <[email protected]> Message-Id: <[email protected]> Signed-off-by: Fabiano Rosas <[email protected]>
1 parent 69d1f78 commit f52965b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

migration/vmstate-types.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static int put_nullptr(QEMUFile *f, void *pv, size_t size,
338338
}
339339

340340
const VMStateInfo vmstate_info_nullptr = {
341-
.name = "uint64",
341+
.name = "nullptr",
342342
.get = get_nullptr,
343343
.put = put_nullptr,
344344
};

scripts/analyze-migration.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,28 @@ def __init__(self, desc, file):
417417
super(VMSDFieldIntLE, self).__init__(desc, file)
418418
self.dtype = '<i%d' % self.size
419419

420+
class VMSDFieldNull(VMSDFieldGeneric):
421+
NULL_PTR_MARKER = b'0'
422+
423+
def __init__(self, desc, file):
424+
super(VMSDFieldNull, self).__init__(desc, file)
425+
426+
def __repr__(self):
427+
# A NULL pointer is encoded in the stream as a '0' to
428+
# disambiguate from a mere 0x0 value and avoid consumers
429+
# trying to follow the NULL pointer. Displaying '0', 0x30 or
430+
# 0x0 when analyzing the JSON debug stream could become
431+
# confusing, so use an explicit term instead.
432+
return "nullptr"
433+
434+
def __str__(self):
435+
return self.__repr__()
436+
437+
def read(self):
438+
super(VMSDFieldNull, self).read()
439+
assert(self.data == self.NULL_PTR_MARKER)
440+
return self.data
441+
420442
class VMSDFieldBool(VMSDFieldGeneric):
421443
def __init__(self, desc, file):
422444
super(VMSDFieldBool, self).__init__(desc, file)
@@ -558,6 +580,7 @@ def getDict(self):
558580
"bitmap" : VMSDFieldGeneric,
559581
"struct" : VMSDFieldStruct,
560582
"capability": VMSDFieldCap,
583+
"nullptr": VMSDFieldNull,
561584
"unknown" : VMSDFieldGeneric,
562585
}
563586

0 commit comments

Comments
 (0)