[Crash-utility] [RFC 4/4] enhance devdump command to extract NT_VMCOREDD from KDUMP vmcore

Surendra Mobiya surendra at chelsio.com
Fri Apr 12 15:54:23 UTC 2019


Enhance devdump command to analyze and extract hardware specific
device dumps in KDUMP vmcore.

Signed-off-by: Surendra Mobiya <surendra at chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy at chelsio.com>
---
 defs.h     |  2 ++
 devdump.c  |  8 ++++++--
 diskdump.c | 33 ++++++++++++++++++++++++++++++++-
 3 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/defs.h b/defs.h
index 41ce61f..4dcb6db 100644
--- a/defs.h
+++ b/defs.h
@@ -6450,6 +6450,8 @@ void process_elf64_notes(void *, ulong);
 void dump_registers_for_compressed_kdump(void);
 int diskdump_kaslr_check(void);
 QEMUCPUState *diskdump_get_qemucpustate(int);
+void diskdump_device_dump_info(FILE *ofp);
+void diskdump_device_dump(int index, char *outfile, FILE *ofp);
 
 /*
  * devdump.c
diff --git a/devdump.c b/devdump.c
index 2b9cbe8..cda56ce 100644
--- a/devdump.c
+++ b/devdump.c
@@ -58,8 +58,10 @@ void cmd_devdump(void)
 	if (list) {
 		if (KDUMP_DUMPFILE())
 			kdump_device_dump_info(fp);
+		else if (DISKDUMP_DUMPFILE())
+			diskdump_device_dump_info(fp);
 		else
-			error(WARNING, "KDUMP flag not found");
+			error(WARNING, "KDUMP/DISKDUMP flag not found");
 	} else {
 		if (index == -1) {
 			error(INFO, "Index not provided");
@@ -73,8 +75,10 @@ void cmd_devdump(void)
 
 		if (KDUMP_DUMPFILE())
 			kdump_device_dump(index, outputfile, fp);
+		else if (DISKDUMP_DUMPFILE())
+			diskdump_device_dump(index, outputfile, fp);
 		else
-			error(WARNING, "KDUMP flag not found");
+			error(WARNING, "KDUMP/DISKDUMP flag not found");
 	}
 }
 
diff --git a/diskdump.c b/diskdump.c
index 6b7a91b..f0230e7 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -2099,7 +2099,6 @@ diskdump_memory_dump(FILE *fp)
 	return 0;
 }
 
-
 /*
  *  Get the switch_stack address of the passed-in task.  
  */
@@ -2538,3 +2537,35 @@ diskdump_get_qemucpustate(int cpu)
         return (QEMUCPUState *)dd->nt_qemucs_percpu[cpu];
 }
 #endif
+
+/*
+ * extract hardware specific device dumps from coredump.
+ */
+void
+diskdump_device_dump(int index, char *outfile, FILE *ofp)
+{
+	ulonglong offset;
+
+	if (index >= dd->num_vmcoredd_notes) {
+		error(WARNING, "No device dump found at index: %d", index);
+		return;
+	}
+
+	fprintf(ofp, "%d) ", index);
+	offset = dd->sub_header_kdump->offset_note +
+		((unsigned char *)dd->nt_vmcoredd_array[index] - dd->notes_buf);
+
+	devdump_extract(dd->nt_vmcoredd_array[index], offset, outfile, ofp);
+}
+
+/*
+ * list all hardware specific device dumps present in coredump.
+ */
+void
+diskdump_device_dump_info(FILE *ofp)
+{
+	int i;
+
+	for (i = 0; i < dd->num_vmcoredd_notes; i++)
+		diskdump_device_dump(i, NULL, ofp);
+}
-- 
1.8.3.1




More information about the Crash-utility mailing list