* [Qemu-devel] [RFC] vmstate: Add info vmstate HMP command (WIP)
@ 2013-10-24 15:34 Andreas Färber
2013-11-01 14:32 ` Luiz Capitulino
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Färber @ 2013-10-24 15:34 UTC (permalink / raw)
To: amit.shah, qemu-devel
Cc: Luiz Capitulino, agraf, Andreas Färber, quintela
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(+)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 9d09e60..70c325c 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -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
diff --git a/monitor.c b/monitor.c
index 74f3f1b..7265748 100644
--- a/monitor.c
+++ b/monitor.c
@@ -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",
diff --git a/savevm.c b/savevm.c
index 2f631d4..5de76db 100644
--- a/savevm.c
+++ b/savevm.c
@@ -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;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [RFC] vmstate: Add info vmstate HMP command (WIP)
2013-10-24 15:34 [Qemu-devel] [RFC] vmstate: Add info vmstate HMP command (WIP) Andreas Färber
@ 2013-11-01 14:32 ` Luiz Capitulino
0 siblings, 0 replies; 2+ messages in thread
From: Luiz Capitulino @ 2013-11-01 14:32 UTC (permalink / raw)
To: Andreas Färber; +Cc: amit.shah, quintela, qemu-devel, agraf
On Thu, 24 Oct 2013 16:34:50 +0100
Andreas Färber <afaerber@suse.de> wrote:
> 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.
We had a discussion in the past about prefixing such QMP commands with
x- or adding a special vendor extension for them. I don't remember the
conclusion there, although I see that we do have x-rdma-pin-all in the
schema.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-01 14:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-24 15:34 [Qemu-devel] [RFC] vmstate: Add info vmstate HMP command (WIP) Andreas Färber
2013-11-01 14:32 ` Luiz Capitulino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).