[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 4/7] migration: Rename vmstate_info_nullptr
From: |
Fabiano Rosas |
Subject: |
[PATCH v3 4/7] migration: Rename vmstate_info_nullptr |
Date: |
Thu, 9 Jan 2025 15:52:46 -0300 |
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.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/vmstate-types.c | 2 +-
scripts/analyze-migration.py | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c
index e83bfccb9e..d70d573dbd 100644
--- a/migration/vmstate-types.c
+++ b/migration/vmstate-types.c
@@ -338,7 +338,7 @@ static int put_nullptr(QEMUFile *f, void *pv, size_t size,
}
const VMStateInfo vmstate_info_nullptr = {
- .name = "uint64",
+ .name = "nullptr",
.get = get_nullptr,
.put = put_nullptr,
};
diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py
index fcda11f31d..923f174f1b 100755
--- a/scripts/analyze-migration.py
+++ b/scripts/analyze-migration.py
@@ -417,6 +417,28 @@ def __init__(self, desc, file):
super(VMSDFieldIntLE, self).__init__(desc, file)
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):
def __init__(self, desc, file):
super(VMSDFieldBool, self).__init__(desc, file)
@@ -558,6 +580,7 @@ def getDict(self):
"bitmap" : VMSDFieldGeneric,
"struct" : VMSDFieldStruct,
"capability": VMSDFieldCap,
+ "nullptr": VMSDFieldNull,
"unknown" : VMSDFieldGeneric,
}
--
2.35.3
- [PATCH v3 0/7] migration: Fix s390 regressions + migration script, Fabiano Rosas, 2025/01/09
- [PATCH v3 3/7] migration: Fix parsing of s390 stream, Fabiano Rosas, 2025/01/09
- [PATCH v3 1/7] migration: Add more error handling to analyze-migration.py, Fabiano Rosas, 2025/01/09
- [PATCH v3 4/7] migration: Rename vmstate_info_nullptr,
Fabiano Rosas <=
- [PATCH v3 6/7] migration: Fix arrays of pointers in JSON writer, Fabiano Rosas, 2025/01/09
- [PATCH v3 7/7] s390x: Fix CSS migration, Fabiano Rosas, 2025/01/09
- [PATCH v3 5/7] migration: Dump correct JSON format for nullptr replacement, Fabiano Rosas, 2025/01/09
- [PATCH v3 2/7] migration: Remove unused argument in vmsd_desc_field_end, Fabiano Rosas, 2025/01/09