From patchwork Thu May 23 17:44:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Bryant X-Patchwork-Id: 245995 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 220D52C029E for ; Fri, 24 May 2013 03:47:58 +1000 (EST) Received: from localhost ([::1]:56505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfZcK-0007eZ-Be for incoming@patchwork.ozlabs.org; Thu, 23 May 2013 13:47:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfZZW-0003SU-FZ for qemu-devel@nongnu.org; Thu, 23 May 2013 13:45:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfZZU-0006RY-Ua for qemu-devel@nongnu.org; Thu, 23 May 2013 13:45:02 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:59405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfZZU-0006RM-Ng for qemu-devel@nongnu.org; Thu, 23 May 2013 13:45:00 -0400 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 23 May 2013 11:45:00 -0600 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e39.co.us.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 23 May 2013 11:44:58 -0600 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 312C96E8067 for ; Thu, 23 May 2013 13:44:54 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4NHivio323338 for ; Thu, 23 May 2013 13:44:57 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4NHiu8i016306 for ; Thu, 23 May 2013 14:44:57 -0300 Received: from localhost ([9.80.101.134]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r4NHitIO016268; Thu, 23 May 2013 14:44:55 -0300 From: Corey Bryant To: qemu-devel@nongnu.org Date: Thu, 23 May 2013 13:44:45 -0400 Message-Id: <1369331087-22345-6-git-send-email-coreyb@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1369331087-22345-1-git-send-email-coreyb@linux.vnet.ibm.com> References: <1369331087-22345-1-git-send-email-coreyb@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13052317-3620-0000-0000-000002A7F1C1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.110.160 Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanb@linux.vnet.ibm.com, Corey Bryant , 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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Provides debug support that dumps the disk and in-memory VNVRAM contents to stderr. Signed-off-by: Corey Bryant --- 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; }