When the host knows the guest is panicked, it will set exit_reason to KVM_EXIT_GUEST_PANICKED. So if qemu receive this exit_reason, we can send a event to tell management application that the guest is panicked and set the guest status to RUN_STATE_PANICKED. Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx> --- kvm-all.c | 4 ++++ monitor.c | 3 +++ monitor.h | 1 + qapi-schema.json | 2 +- qmp.c | 3 ++- vl.c | 1 + 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 77eadf6..01062af 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1290,6 +1290,10 @@ int kvm_cpu_exec(CPUState *env) (uint64_t)run->hw.hardware_exit_reason); ret = -1; break; + case KVM_EXIT_GUEST_PANICKED: + monitor_protocol_event(QEVENT_GUEST_PANICKED, NULL); + vm_stop(RUN_STATE_PANICKED); + break; case KVM_EXIT_INTERNAL_ERROR: ret = kvm_handle_internal_error(env, run); break; diff --git a/monitor.c b/monitor.c index cbdfbad..a0ad0a9 100644 --- a/monitor.c +++ b/monitor.c @@ -494,6 +494,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) case QEVENT_WAKEUP: event_name = "WAKEUP"; break; + case QEVENT_GUEST_PANICKED: + event_name = "GUEST_PANICKED"; + break; default: abort(); break; diff --git a/monitor.h b/monitor.h index 0d49800..94e8a3c 100644 --- a/monitor.h +++ b/monitor.h @@ -41,6 +41,7 @@ typedef enum MonitorEvent { QEVENT_DEVICE_TRAY_MOVED, QEVENT_SUSPEND, QEVENT_WAKEUP, + QEVENT_GUEST_PANICKED, QEVENT_MAX, } MonitorEvent; diff --git a/qapi-schema.json b/qapi-schema.json index 5f293c4..4f1ae20 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -121,7 +121,7 @@ { 'enum': 'RunState', 'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused', 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm', - 'running', 'save-vm', 'shutdown', 'watchdog' ] } + 'running', 'save-vm', 'shutdown', 'watchdog', 'panicked' ] } ## # @StatusInfo: diff --git a/qmp.c b/qmp.c index a182b51..e535969 100644 --- a/qmp.c +++ b/qmp.c @@ -148,7 +148,8 @@ void qmp_cont(Error **errp) error_set(errp, QERR_MIGRATION_EXPECTED); return; } else if (runstate_check(RUN_STATE_INTERNAL_ERROR) || - runstate_check(RUN_STATE_SHUTDOWN)) { + runstate_check(RUN_STATE_SHUTDOWN) || + runstate_check(RUN_STATE_PANICKED)) { error_set(errp, QERR_RESET_REQUIRED); return; } diff --git a/vl.c b/vl.c index 97ab2b9..65390fa 100644 --- a/vl.c +++ b/vl.c @@ -359,6 +359,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_PANICKED }, { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html