From 52e890517f8e5be8e9d260a6c47b2fa4fd48d81d Mon Sep 17 00:00:00 2001 Message-Id: <52e890517f8e5be8e9d260a6c47b2fa4fd48d81d.1369899578.git.minovotn@redhat.com> In-Reply-To: <1d7d27453d05521b09c5b709aa6f00c682ab81dc.1369899578.git.minovotn@redhat.com> References: <1d7d27453d05521b09c5b709aa6f00c682ab81dc.1369899578.git.minovotn@redhat.com> From: Laszlo Ersek Date: Wed, 22 May 2013 11:31:05 +0200 Subject: [PATCH 06/15] add a new runstate: RUN_STATE_GUEST_PANICKED RH-Author: Laszlo Ersek Message-id: <1369222273-3298-2-git-send-email-lersek@redhat.com> Patchwork-id: 51520 O-Subject: [RHEL-6.5 qemu-kvm PATCH v2 1/9] add a new runstate: RUN_STATE_GUEST_PANICKED Bugzilla: 833530 RH-Acked-by: Andrew Jones RH-Acked-by: Paolo Bonzini RH-Acked-by: Gerd Hoffmann The guest will be in this state when it is panicked. Signed-off-by: Wen Congyang Signed-off-by: Hu Tao Reviewed-by: Markus Armbruster Message-id: 0255f263ffdc2a3716f73e89098b96fd79a235b3.1366945969.git.hutao@cn.fujitsu.com Signed-off-by: Anthony Liguori RHEL-6 notes: - Manual port of upstream commit ede085b3fedfde36cb566968c4efcfbad4845af1. - We don't generate the RunState enum from qapi-schema.json, hence adding the new enum constant and its textual representation manually. Otherwise we'd need at least commit 1fa9a5e4aea36b4d21e42323ae43879c908af576 Author: Luiz Capitulino Date: Mon Sep 12 17:54:20 2011 -0300 qapi: Convert query-status Please, note that the RunState type as defined in sysemu.h and its runstate_as_string() function are being dropped in favor of the RunState type generated by the QAPI. Signed-off-by: Anthony Liguori Signed-off-by: Luiz Capitulino and any followup as dependencies; this seems too intrusive. - Regarding qmp_cont()/do_cont(): we haven't backported commit e42e818bf45f2f70cdd88a3864efcc3964039f37 Author: Luiz Capitulino Date: Tue Nov 22 17:58:31 2011 -0200 qapi: Convert cont Signed-off-by: Anthony Liguori Signed-off-by: Luiz Capitulino and still have old style error reporting here. - Reflected the "(INTERNAL_ERROR || SHUTDOWN) --> needs-reset" change in both main_loop() [vl.c] and kvm_main_loop() [qemu-kvm.c]. Any code querying either RUN_STATE_INTERNAL_ERROR or RUN_STATE_SHUTDOWN now goes through runstate_needs_reset() (verified with "git grep -E -H -n 'RUN_STATE_(INTERNAL_ERROR|SHUTDOWN)'" and checking each location). Signed-off-by: Laszlo Ersek --- sysemu.h | 2 ++ monitor.c | 3 +-- qemu-kvm.c | 3 +-- vl.c | 14 ++++++++++++-- 4 files changed, 16 insertions(+), 6 deletions(-) Signed-off-by: Michal Novotny --- monitor.c | 3 +-- qemu-kvm.c | 3 +-- sysemu.h | 2 ++ vl.c | 14 ++++++++++++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/monitor.c b/monitor.c index 15b2928..8f88c2d 100644 --- a/monitor.c +++ b/monitor.c @@ -1600,8 +1600,7 @@ static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data) if (runstate_check(RUN_STATE_INMIGRATE)) { qerror_report(QERR_MIGRATION_EXPECTED); return -1; - } else if (runstate_check(RUN_STATE_INTERNAL_ERROR) || - runstate_check(RUN_STATE_SHUTDOWN)) { + } else if (runstate_needs_reset()) { qerror_report(QERR_RESET_REQUIRED); return -1; } diff --git a/qemu-kvm.c b/qemu-kvm.c index 1cc462b..380dd31 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -2256,8 +2256,7 @@ int kvm_main_loop(void) qemu_irq_raise(qemu_system_powerdown); } else if (qemu_reset_requested()) { qemu_kvm_system_reset(VMRESET_REPORT); - if (runstate_check(RUN_STATE_INTERNAL_ERROR) || - runstate_check(RUN_STATE_SHUTDOWN)) { + if (runstate_needs_reset()) { runstate_set(RUN_STATE_PAUSED); } } else if (qemu_wakeup_requested()) { diff --git a/sysemu.h b/sysemu.h index e9dda5d..1180946 100644 --- a/sysemu.h +++ b/sysemu.h @@ -34,6 +34,7 @@ typedef enum { RUN_STATE_SAVE_VM, /* paused saving VM state */ RUN_STATE_SHUTDOWN, /* guest shut down and -no-shutdown is in use */ RUN_STATE_WATCHDOG, /* watchdog fired and qemu is configured to pause */ + RUN_STATE_GUEST_PANICKED, /* guest has been panicked as a result of guest OS panic */ RUN_STATE_MAX } RunState; @@ -52,6 +53,7 @@ void runstate_init(void); bool runstate_check(RunState state); void runstate_set(RunState new_state); int runstate_is_running(void); +bool runstate_needs_reset(void); const char *runstate_as_string(void); typedef struct vm_change_state_entry VMChangeStateEntry; typedef void VMChangeStateHandler(void *opaque, int running, RunState state); diff --git a/vl.c b/vl.c index 2f85cd1..e20f112 100644 --- a/vl.c +++ b/vl.c @@ -411,6 +411,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_RUNNING, RUN_STATE_SAVE_VM }, { RUN_STATE_RUNNING, RUN_STATE_SHUTDOWN }, { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG }, + { RUN_STATE_RUNNING, RUN_STATE_GUEST_PANICKED }, { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, @@ -420,6 +421,8 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_GUEST_PANICKED, RUN_STATE_PAUSED }, + { RUN_STATE_MAX, RUN_STATE_MAX }, }; @@ -438,6 +441,7 @@ static const char *const runstate_name_tbl[RUN_STATE_MAX] = { [RUN_STATE_RUNNING] = "running", [RUN_STATE_SAVE_VM] = "save-vm", [RUN_STATE_SHUTDOWN] = "shutdown", + [RUN_STATE_GUEST_PANICKED] = "guest-panicked", [RUN_STATE_WATCHDOG] = "watchdog", }; @@ -486,6 +490,13 @@ int runstate_is_running(void) return runstate_check(RUN_STATE_RUNNING); } +bool runstate_needs_reset(void) +{ + return runstate_check(RUN_STATE_INTERNAL_ERROR) || + runstate_check(RUN_STATE_SHUTDOWN) || + runstate_check(RUN_STATE_GUEST_PANICKED); +} + /***********************************************************/ void hw_error(const char *fmt, ...) { @@ -4275,8 +4286,7 @@ static void main_loop(void) pause_all_vcpus(); qemu_system_reset(VMRESET_REPORT); resume_all_vcpus(); - if (runstate_check(RUN_STATE_INTERNAL_ERROR) || - runstate_check(RUN_STATE_SHUTDOWN)) { + if (runstate_needs_reset()) { runstate_set(RUN_STATE_PAUSED); } } -- 1.7.11.7