qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: amit.shah@redhat.com, qemu-devel@nongnu.org
Cc: "Luiz Capitulino" <lcapitulino@redhat.com>,
	agraf@suse.de, "Andreas Färber" <afaerber@suse.de>,
	quintela@redhat.com
Subject: [Qemu-devel] [RFC] vmstate: Add info vmstate HMP command (WIP)
Date: Thu, 24 Oct 2013 16:34:50 +0100	[thread overview]
Message-ID: <1382628890-3701-1-git-send-email-afaerber@suse.de> (raw)

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

             reply	other threads:[~2013-10-24 15:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-24 15:34 Andreas Färber [this message]
2013-11-01 14:32 ` [Qemu-devel] [RFC] vmstate: Add info vmstate HMP command (WIP) Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1382628890-3701-1-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=amit.shah@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).