]> git.proxmox.com Git - mirror_qemu.git/commitdiff
cpu: Add crash_occurred flag into CPUState
authorAndrey Smetanin <asmetanin@virtuozzo.com>
Fri, 3 Jul 2015 12:01:44 +0000 (15:01 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 16 Sep 2015 15:33:32 +0000 (17:33 +0200)
CPUState::crash_occurred field inside CPUState marks
that guest crash occurred. This value is added into
cpu common migration subsection.

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Andreas Färber <afaerber@suse.de>
Message-Id: <1435924905-8926-12-git-send-email-den@openvz.org>
[Document the new field. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
exec.c
include/qom/cpu.h
qom/cpu.c
vl.c

diff --git a/exec.c b/exec.c
index b61126cb76a1243a6ea94387d10aa45e163ee927..07dfeae4d802f69348bcfb2b498cbf2969c83421 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -478,6 +478,24 @@ static const VMStateDescription vmstate_cpu_common_exception_index = {
     }
 };
 
+static bool cpu_common_crash_occurred_needed(void *opaque)
+{
+    CPUState *cpu = opaque;
+
+    return cpu->crash_occurred;
+}
+
+static const VMStateDescription vmstate_cpu_common_crash_occurred = {
+    .name = "cpu_common/crash_occurred",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = cpu_common_crash_occurred_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_BOOL(crash_occurred, CPUState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_cpu_common = {
     .name = "cpu_common",
     .version_id = 1,
@@ -491,6 +509,7 @@ const VMStateDescription vmstate_cpu_common = {
     },
     .subsections = (const VMStateDescription*[]) {
         &vmstate_cpu_common_exception_index,
+        &vmstate_cpu_common_crash_occurred,
         NULL
     }
 };
index c3d610b98885ff91b9fcf60a170e5646bb7ad397..302673dbad9f6d79a5550ffbcb0ab2a303d51c37 100644 (file)
@@ -223,6 +223,7 @@ struct kvm_run;
  * @halted: Nonzero if the CPU is in suspended state.
  * @stop: Indicates a pending stop request.
  * @stopped: Indicates the CPU has been artificially stopped.
+ * @crash_occurred: Indicates the OS reported a crash (panic) for this CPU
  * @tcg_exit_req: Set to force TCG to stop executing linked TBs for this
  *           CPU and return to its top level loop.
  * @singlestep_enabled: Flags for single-stepping.
@@ -269,6 +270,7 @@ struct CPUState {
     bool created;
     bool stop;
     bool stopped;
+    bool crash_occurred;
     bool exit_request;
     uint32_t interrupt_request;
     int singlestep_enabled;
index 3841f0de5b2e2c5a60259676e2c977959af8306e..fb80d13a3f491b5a2e283f21b2427ff1e2c6ce5f 100644 (file)
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -251,6 +251,7 @@ static void cpu_common_reset(CPUState *cpu)
     cpu->icount_decr.u32 = 0;
     cpu->can_do_io = 1;
     cpu->exception_index = -1;
+    cpu->crash_occurred = false;
     memset(cpu->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *));
 }
 
diff --git a/vl.c b/vl.c
index 066a080db5203e29dd27164ecd6ea0a9b7f2559f..3c6480dadf794e77aee2cb58ff165fcc69a38e9b 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1747,6 +1747,9 @@ void qemu_system_reset(bool report)
 
 void qemu_system_guest_panicked(void)
 {
+    if (current_cpu) {
+        current_cpu->crash_occurred = true;
+    }
     qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort);
     vm_stop(RUN_STATE_GUEST_PANICKED);
 }