[PATCH v3 2/3] dump: add crash_occurred flag to QEMUCPUState

Zhengrong Li <[email protected]>
Newsgroups gmane.comp.emulators.qemu
Message-ID <[email protected]>
Add is_crash_occurred_cpu field to the local QEMUCPUState in
arch_dump.c so that dump-guest-memory can record which CPU
triggered the guest panic.

The new field is appended after kernel_gs_base, so older tools
safely ignore the extra bytes in newer dumps, and newer tools
detect its absence in older dumps by checking the 'size' field.

Signed-off-by: Zhengrong Li <[email protected]>
---
 target/i386/arch_dump.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c
index 16e47c4747..8ce2c7e9bb 100644
--- a/target/i386/arch_dump.c
+++ b/target/i386/arch_dump.c
@@ -264,6 +264,8 @@ struct QEMUCPUState {
      * by checking 'size' field.
      */
     uint64_t kernel_gs_base;
+    uint8_t  is_crash_occurred_cpu;
+    uint8_t  pad[7];
 };
 
 typedef struct QEMUCPUState QEMUCPUState;
@@ -279,6 +281,7 @@ static void copy_segment(QEMUCPUSegment *d, SegmentCache *s)
 
 static void qemu_get_cpustate(QEMUCPUState *s, CPUX86State *env)
 {
+    CPUState *cs = env_cpu(env);
     memset(s, 0, sizeof(QEMUCPUState));
 
     s->version = QEMUCPUSTATE_VERSION;
@@ -325,6 +328,9 @@ static void qemu_get_cpustate(QEMUCPUState *s, CPUX86State *env)
 #ifdef TARGET_X86_64
     s->kernel_gs_base = env->kernelgsbase;
 #endif
+    if (cs->crash_occurred) {
+        s->is_crash_occurred_cpu = 1;
+    }
 }
 
 static inline int cpu_write_qemu_note(WriteCoreDumpFunction f,
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.