From: "Denis V. Lunev" Subject: [PATCH 11/12] cpu: Add crash_occurred flag into CPUState Date: Fri, 3 Jul 2015 15:01:44 +0300 Message-ID: <1435924905-8926-12-git-send-email-den@openvz.org> References: <1435924905-8926-1-git-send-email-den@openvz.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Andrey Smetanin , "Denis V. Lunev" , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= To: unlisted-recipients:; (no To-header on input) Return-path: Received: from mailhub.sw.ru ([195.214.232.25]:33091 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754746AbbGCMCR (ORCPT ); Fri, 3 Jul 2015 08:02:17 -0400 In-Reply-To: <1435924905-8926-1-git-send-email-den@openvz.org> Sender: kvm-owner@vger.kernel.org List-ID: =46rom: Andrey Smetanin 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 Signed-off-by: Denis V. Lunev CC: Paolo Bonzini CC: Andreas F=C3=A4rber --- exec.c | 19 +++++++++++++++++++ include/qom/cpu.h | 1 + qom/cpu.c | 1 + vl.c | 3 +++ 4 files changed, 24 insertions(+) diff --git a/exec.c b/exec.c index f7883d2..15c9a29 100644 --- a/exec.c +++ b/exec.c @@ -465,6 +465,24 @@ static const VMStateDescription vmstate_cpu_common= _exception_index =3D { } }; =20 +static bool cpu_common_crash_occurred_needed(void *opaque) +{ + CPUState *cpu =3D opaque; + + return cpu->crash_occurred; +} + +static const VMStateDescription vmstate_cpu_common_crash_occurred =3D = { + .name =3D "cpu_common/crash_occurred", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D cpu_common_crash_occurred_needed, + .fields =3D (VMStateField[]) { + VMSTATE_BOOL(crash_occurred, CPUState), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_cpu_common =3D { .name =3D "cpu_common", .version_id =3D 1, @@ -478,6 +496,7 @@ const VMStateDescription vmstate_cpu_common =3D { }, .subsections =3D (const VMStateDescription*[]) { &vmstate_cpu_common_exception_index, + &vmstate_cpu_common_crash_occurred, NULL } }; diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 39f0f19..aae05fd 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -263,6 +263,7 @@ struct CPUState { bool created; bool stop; bool stopped; + bool crash_occurred; volatile sig_atomic_t exit_request; uint32_t interrupt_request; int singlestep_enabled; diff --git a/qom/cpu.c b/qom/cpu.c index 108bfa2..c3c4674 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -249,6 +249,7 @@ static void cpu_common_reset(CPUState *cpu) cpu->icount_decr.u32 =3D 0; cpu->can_do_io =3D 0; cpu->exception_index =3D -1; + cpu->crash_occurred =3D false; memset(cpu->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *)); } =20 diff --git a/vl.c b/vl.c index 38eee1f..62bab42 100644 --- a/vl.c +++ b/vl.c @@ -1723,6 +1723,9 @@ void qemu_system_reset(bool report) =20 void qemu_system_guest_panicked(void) { + if (current_cpu) { + current_cpu->crash_occurred =3D true; + } qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_ab= ort); vm_stop(RUN_STATE_GUEST_PANICKED); } --=20 2.1.4