@@ -750,4 +750,6 @@ void vmstate_register_ram(struct MemoryRegion *memory, DeviceState *dev);
void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev);
void vmstate_register_ram_global(struct MemoryRegion *memory);
+void vmstate_info(Monitor *mon);
+
#endif
@@ -2039,6 +2039,11 @@ static void do_info_profile(Monitor *mon, const QDict *qdict)
}
#endif
+static void do_info_vmstate(Monitor *mon, const QDict *qdict)
+{
+ vmstate_info(mon);
+}
+
/* Capture support */
static QLIST_HEAD (capture_list_head, CaptureState) capture_head;
@@ -2846,6 +2851,13 @@ static mon_cmd_t info_cmds[] = {
.help = "show the vnc server status",
.mhandler.cmd = hmp_info_vnc,
},
+ {
+ .name = "vmstate",
+ .args_type = "",
+ .params = "",
+ .help = "show the VMState structure",
+ .mhandler.cmd = do_info_vmstate,
+ },
#if defined(CONFIG_SPICE)
{
.name = "spice",
@@ -1482,6 +1482,64 @@ static QTAILQ_HEAD(savevm_handlers, SaveStateEntry) savevm_handlers =
QTAILQ_HEAD_INITIALIZER(savevm_handlers);
static int global_section_id;
+static void vmstate_info_vmsd(Monitor *mon, const VMStateDescription *vmsd, int indent);
+
+static void vmstate_info_vmsf(Monitor *mon, const VMStateField *field, int indent)
+{
+ monitor_printf(mon, "%*s%s:\n", indent, "", field->name);
+ indent += 2;
+ monitor_printf(mon, "%*sversion_id: %d%s\n", indent, "", field->version_id,
+ field->field_exists ? " (??\?)" : "");
+ monitor_printf(mon, "%*ssize: %zu\n", indent, "", field->size);
+ if (field->vmsd != NULL) {
+ vmstate_info_vmsd(mon, field->vmsd, indent);
+ }
+}
+
+static void vmstate_info_vmss(Monitor *mon, const VMStateSubsection *subsection, int indent)
+{
+ if (subsection->vmsd != NULL) {
+ vmstate_info_vmsd(mon, subsection->vmsd, indent);
+ }
+}
+
+static void vmstate_info_vmsd(Monitor *mon, const VMStateDescription *vmsd, int indent)
+{
+ monitor_printf(mon, "%*s%s:\n", indent, "", vmsd->name);
+ indent += 2;
+ monitor_printf(mon, "%*sversion_id: %d\n", indent, "", vmsd->version_id);
+ if (vmsd->fields != NULL) {
+ const VMStateField *field = vmsd->fields;
+ monitor_printf(mon, "%*sFields:\n", indent, "");
+ while (field->name != NULL) {
+ vmstate_info_vmsf(mon, field, indent + 2);
+ field++;
+ }
+ }
+ if (vmsd->subsections != NULL) {
+ const VMStateSubsection *subsection = vmsd->subsections;
+ monitor_printf(mon, "%*sSubsections:\n", indent, "");
+ while (subsection->vmsd != NULL) {
+ vmstate_info_vmss(mon, subsection, indent + 2);
+ subsection++;
+ }
+ }
+}
+
+void vmstate_info(Monitor *mon)
+{
+ SaveStateEntry *se;
+
+ QTAILQ_FOREACH(se, &savevm_handlers, entry) {
+ int indent = 2;
+ monitor_printf(mon, "%s\n", se->idstr);
+ monitor_printf(mon, "%*sversion_id: %d\n", indent, "", se->version_id);
+ if (se->vmsd != NULL) {
+ vmstate_info_vmsd(mon, se->vmsd, indent);
+ }
+ }
+}
+
static int calculate_new_instance_id(const char *idstr)
{
SaveStateEntry *se;
This adds a command "info vmstate" for dumping a textual representation of the currently registered VMStateDescriptions. Being purely for debugging, intentionally no QMP schema is set in stone. Drawback is that conversations from savevm to VMState show up as differences when comparing outputs and require manual code review. Signed-off-by: Andreas Färber <afaerber@suse.de> --- Hi Amit, Here's my previous work, as promised at your KVM Forum talk. Regards, Andreas include/migration/vmstate.h | 2 ++ monitor.c | 12 ++++++++++ savevm.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+)