qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Corey Bryant <coreyb@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, aliguori@us.ibm.com,
	stefanb@linux.vnet.ibm.com,
	Corey Bryant <coreyb@linux.vnet.ibm.com>,
	mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com,
	jschopp@linux.vnet.ibm.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 5/7] vnvram: VNVRAM additional debug support
Date: Thu, 23 May 2013 13:44:45 -0400	[thread overview]
Message-ID: <1369331087-22345-6-git-send-email-coreyb@linux.vnet.ibm.com> (raw)
In-Reply-To: <1369331087-22345-1-git-send-email-coreyb@linux.vnet.ibm.com>

Provides debug support that dumps the disk and in-memory VNVRAM
contents to stderr.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
---
 vnvram.c |   94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 94 insertions(+), 0 deletions(-)

diff --git a/vnvram.c b/vnvram.c
index 357923d..9c4f64f 100644
--- a/vnvram.c
+++ b/vnvram.c
@@ -19,6 +19,7 @@
 
 /*
 #define VNVRAM_DEBUG
+#define VNVRAM_DEBUG_DUMP
 */
 
 #ifdef VNVRAM_DEBUG
@@ -134,6 +135,47 @@ static uint64_t vnvram_get_size_kb(VNVRAM *);
 /* entries.                                                          */
 /*********************************************************************/
 
+#ifdef VNVRAM_DEBUG_DUMP
+static void vnvram_drv_dump(void)
+{
+    int rc, i, num_entries;
+    VNVRAM *vnvram;
+    VNVRAMDrvHdr hdr;
+    VNVRAMDrvEntry *drv_entries = NULL;
+
+    QLIST_FOREACH(vnvram, &vnvrams, list) {
+        rc = vnvram_drv_hdr_read(vnvram, (&hdr));
+        if (rc != 0) {
+            goto err_exit;
+        }
+
+        rc = vnvram_drv_entries_get(vnvram, (&hdr), &drv_entries, &num_entries);
+        if (rc != 0) {
+            goto err_exit;
+        }
+
+        DPRINTF("VNVRAM drv dump:\n");
+        DPRINTF("  version = %"PRIu16"\n", hdr.version);
+        DPRINTF("  magic = %"PRIu32"\n", hdr.magic);
+        DPRINTF("  num_entries = %"PRIu32"\n", hdr.num_entries);
+
+        for (i = 0; i < num_entries; i++) {
+            DPRINTF("    name = %s\n", drv_entries[i].name);
+            DPRINTF("    blob_offset = %"PRIu64"\n",
+                                       drv_entries[i].blob_offset);
+            DPRINTF("    cur_size = %"PRIu32"\n", drv_entries[i].cur_size);
+            DPRINTF("    max_size = %"PRIu32"\n", drv_entries[i].max_size);
+        }
+
+        g_free(drv_entries);
+        drv_entries = NULL;
+    }
+
+err_exit:
+    g_free(drv_entries);
+}
+#endif
+
 /*
  * Big-endian conversions
  */
@@ -526,6 +568,28 @@ static bool vnvram_drv_hdr_is_valid(VNVRAM *vnvram, VNVRAMDrvHdr *hdr)
 /* High-level VNVRAM functions that work with in-memory entries.     */
 /*********************************************************************/
 
+#ifdef VNVRAM_DEBUG_DUMP
+static void vnvram_dump(void)
+{
+    VNVRAM *vnvram;
+    const VNVRAMEntry *entry;
+
+    QLIST_FOREACH(vnvram, &vnvrams, list) {
+        DPRINTF("VNVRAM dump:\n");
+        DPRINTF("  drv_id = %s\n", vnvram->drv_id);
+        DPRINTF("  end_offset = %"PRIu64"\n", vnvram->end_offset);
+        DPRINTF("  bds = %p\n", vnvram->bds);
+
+        QLIST_FOREACH(entry, &vnvram->entries_head, next) {
+            DPRINTF("    name = %s\n", entry->name);
+            DPRINTF("    blob_offset = %"PRIu64"\n", entry->blob_offset);
+            DPRINTF("    cur_size = %"PRIu32"\n", entry->cur_size);
+            DPRINTF("    max_size = %"PRIu32"\n", entry->max_size);
+        }
+    }
+}
+#endif
+
 /*
  * Check if the specified vnvram has been created
  */
@@ -626,6 +690,11 @@ static int vnvram_sync_from_drv(VNVRAM *vnvram, VNVRAMDrvHdr *hdr)
     int rc = 0, num_entries = 0, i;
     VNVRAMDrvEntry *drv_entries = NULL;
 
+#ifdef VNVRAM_DEBUG_DUMP
+    vnvram_dump();
+    vnvram_drv_dump();
+#endif
+
     rc = vnvram_drv_entries_get(vnvram, hdr, &drv_entries, &num_entries);
     if (rc != 0) {
         return rc;
@@ -644,6 +713,11 @@ static int vnvram_sync_from_drv(VNVRAM *vnvram, VNVRAMDrvHdr *hdr)
 
     vnvram->end_offset = vnvram_get_size(vnvram);
 
+#ifdef VNVRAM_DEBUG_DUMP
+    vnvram_dump();
+    vnvram_drv_dump();
+#endif
+
 err_exit:
     g_free(drv_entries);
 
@@ -1007,6 +1081,11 @@ int vnvram_read_entry(VNVRAM *vnvram, const VNVRAMEntryName *entry_name,
     VNVRAMEntry *entry;
     VNVRAMRWRequest *rwr;
 
+#ifdef VNVRAM_DEBUG_DUMP
+    vnvram_dump();
+    vnvram_drv_dump();
+#endif
+
     *blob = NULL;
     *blob_size = 0;
 
@@ -1027,6 +1106,11 @@ int vnvram_read_entry(VNVRAM *vnvram, const VNVRAMEntryName *entry_name,
 
     g_free(rwr);
 
+#ifdef VNVRAM_DEBUG_DUMP
+    vnvram_dump();
+    vnvram_drv_dump();
+#endif
+
     return rc;
 }
 
@@ -1040,6 +1124,11 @@ int vnvram_write_entry(VNVRAM *vnvram, const VNVRAMEntryName *entry_name,
     VNVRAMEntry *entry;
     VNVRAMRWRequest *rwr;
 
+#ifdef VNVRAM_DEBUG_DUMP
+    vnvram_dump();
+    vnvram_drv_dump();
+#endif
+
     if (!vnvram_exists(vnvram)) {
         qerror_report(ERROR_CLASS_GENERIC_ERROR, "VNVRAM has not been created");
         return -EPERM;
@@ -1057,6 +1146,11 @@ int vnvram_write_entry(VNVRAM *vnvram, const VNVRAMEntryName *entry_name,
 
     g_free(rwr);
 
+#ifdef VNVRAM_DEBUG_DUMP
+    vnvram_dump();
+    vnvram_drv_dump();
+#endif
+
     return rc;
 }
 
-- 
1.7.1

  parent reply	other threads:[~2013-05-23 17:45 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 17:44 [Qemu-devel] [PATCH 0/7] VNVRAM persistent storage Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 1/7] vnvram: VNVRAM bdrv support Corey Bryant
2013-05-24 13:06   ` Kevin Wolf
2013-05-24 15:33     ` Corey Bryant
2013-05-24 15:37       ` Kevin Wolf
2013-05-24 15:47         ` Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 2/7] vnvram: VNVRAM in-memory support Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 3/7] vnvram: VNVRAM bottom-half r/w scheduling support Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 4/7] vnvram: VNVRAM internal APIs Corey Bryant
2013-05-23 17:44 ` Corey Bryant [this message]
2013-05-23 17:44 ` [Qemu-devel] [PATCH 6/7] main: Initialize VNVRAM Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 7/7] monitor: QMP/HMP support for retrieving VNVRAM details Corey Bryant
2013-05-23 17:59   ` Eric Blake
2013-05-23 18:43     ` Corey Bryant
2013-05-29 17:15   ` Luiz Capitulino
2013-05-29 17:34     ` Corey Bryant
2013-05-23 18:03 ` [Qemu-devel] [PATCH 0/7] VNVRAM persistent storage Anthony Liguori
2013-05-23 18:41   ` Corey Bryant
2013-05-23 19:15     ` Anthony Liguori
2013-05-24 15:27       ` Corey Bryant
2013-05-29 13:34         ` Anthony Liguori
2013-05-24  9:59 ` Stefan Hajnoczi
2013-05-24 12:13   ` Stefan Berger
2013-05-24 12:36     ` Stefan Hajnoczi
2013-05-24 15:39       ` Corey Bryant
2013-05-27  8:40         ` Stefan Hajnoczi

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=1369331087-22345-6-git-send-email-coreyb@linux.vnet.ibm.com \
    --to=coreyb@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=jschopp@linux.vnet.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=stefanha@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).