2019-08-12 07:23:59 +02:00
|
|
|
#ifndef SYSEMU_RUNSTATE_H
|
|
|
|
#define SYSEMU_RUNSTATE_H
|
|
|
|
|
|
|
|
#include "qapi/qapi-types-run-state.h"
|
|
|
|
#include "qemu/notify.h"
|
|
|
|
|
|
|
|
bool runstate_check(RunState state);
|
|
|
|
void runstate_set(RunState new_state);
|
2023-05-17 14:37:48 +02:00
|
|
|
RunState runstate_get(void);
|
2021-01-11 16:20:19 +01:00
|
|
|
bool runstate_is_running(void);
|
2019-08-12 07:23:59 +02:00
|
|
|
bool runstate_needs_reset(void);
|
|
|
|
|
2021-01-11 16:20:20 +01:00
|
|
|
typedef void VMChangeStateHandler(void *opaque, bool running, RunState state);
|
2019-08-12 07:23:59 +02:00
|
|
|
|
|
|
|
VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
|
|
|
|
void *opaque);
|
|
|
|
VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
|
|
|
|
VMChangeStateHandler *cb, void *opaque, int priority);
|
2023-08-02 10:14:45 +02:00
|
|
|
VMChangeStateEntry *
|
|
|
|
qemu_add_vm_change_state_handler_prio_full(VMChangeStateHandler *cb,
|
|
|
|
VMChangeStateHandler *prepare_cb,
|
|
|
|
void *opaque, int priority);
|
2019-08-12 07:23:59 +02:00
|
|
|
VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev,
|
|
|
|
VMChangeStateHandler *cb,
|
|
|
|
void *opaque);
|
2023-08-02 10:14:46 +02:00
|
|
|
VMChangeStateEntry *qdev_add_vm_change_state_handler_full(
|
|
|
|
DeviceState *dev, VMChangeStateHandler *cb,
|
|
|
|
VMChangeStateHandler *prepare_cb, void *opaque);
|
2019-08-12 07:23:59 +02:00
|
|
|
void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
|
2021-01-11 16:20:20 +01:00
|
|
|
/**
|
|
|
|
* vm_state_notify: Notify the state of the VM
|
|
|
|
*
|
|
|
|
* @running: whether the VM is running or not.
|
|
|
|
* @state: the #RunState of the VM.
|
|
|
|
*/
|
|
|
|
void vm_state_notify(bool running, RunState state);
|
2019-08-12 07:23:59 +02:00
|
|
|
|
|
|
|
static inline bool shutdown_caused_by_guest(ShutdownCause cause)
|
|
|
|
{
|
|
|
|
return cause >= SHUTDOWN_CAUSE_GUEST_SHUTDOWN;
|
|
|
|
}
|
|
|
|
|
2024-01-03 21:05:31 +01:00
|
|
|
/*
|
|
|
|
* In a "live" state, the vcpu clock is ticking, and the runstate notifiers
|
|
|
|
* think we are running.
|
|
|
|
*/
|
|
|
|
static inline bool runstate_is_live(RunState state)
|
|
|
|
{
|
|
|
|
return state == RUN_STATE_RUNNING || state == RUN_STATE_SUSPENDED;
|
|
|
|
}
|
|
|
|
|
2019-08-12 07:23:59 +02:00
|
|
|
void vm_start(void);
|
2022-03-03 02:28:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* vm_prepare_start: Prepare for starting/resuming the VM
|
|
|
|
*
|
|
|
|
* @step_pending: whether any of the CPUs is about to be single-stepped by gdb
|
|
|
|
*/
|
|
|
|
int vm_prepare_start(bool step_pending);
|
2019-08-12 07:23:59 +02:00
|
|
|
int vm_stop(RunState state);
|
|
|
|
int vm_stop_force_state(RunState state);
|
|
|
|
int vm_shutdown(void);
|
2024-01-03 21:05:30 +01:00
|
|
|
void vm_set_suspended(bool suspended);
|
|
|
|
bool vm_get_suspended(void);
|
2019-08-12 07:23:59 +02:00
|
|
|
|
|
|
|
typedef enum WakeupReason {
|
|
|
|
/* Always keep QEMU_WAKEUP_REASON_NONE = 0 */
|
|
|
|
QEMU_WAKEUP_REASON_NONE = 0,
|
|
|
|
QEMU_WAKEUP_REASON_RTC,
|
|
|
|
QEMU_WAKEUP_REASON_PMTIMER,
|
|
|
|
QEMU_WAKEUP_REASON_OTHER,
|
|
|
|
} WakeupReason;
|
|
|
|
|
|
|
|
void qemu_system_reset_request(ShutdownCause reason);
|
|
|
|
void qemu_system_suspend_request(void);
|
|
|
|
void qemu_register_suspend_notifier(Notifier *notifier);
|
|
|
|
bool qemu_wakeup_suspend_enabled(void);
|
|
|
|
void qemu_system_wakeup_request(WakeupReason reason, Error **errp);
|
|
|
|
void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
|
|
|
|
void qemu_register_wakeup_notifier(Notifier *notifier);
|
|
|
|
void qemu_register_wakeup_support(void);
|
2023-10-03 09:14:23 +02:00
|
|
|
void qemu_system_shutdown_request_with_code(ShutdownCause reason,
|
|
|
|
int exit_code);
|
2019-08-12 07:23:59 +02:00
|
|
|
void qemu_system_shutdown_request(ShutdownCause reason);
|
|
|
|
void qemu_system_powerdown_request(void);
|
|
|
|
void qemu_register_powerdown_notifier(Notifier *notifier);
|
|
|
|
void qemu_register_shutdown_notifier(Notifier *notifier);
|
|
|
|
void qemu_system_debug_request(void);
|
|
|
|
void qemu_system_vmstop_request(RunState reason);
|
|
|
|
void qemu_system_vmstop_request_prepare(void);
|
|
|
|
bool qemu_vmstop_requested(RunState *r);
|
|
|
|
ShutdownCause qemu_shutdown_requested_get(void);
|
|
|
|
ShutdownCause qemu_reset_requested_get(void);
|
|
|
|
void qemu_system_killed(int signal, pid_t pid);
|
|
|
|
void qemu_system_reset(ShutdownCause reason);
|
|
|
|
void qemu_system_guest_panicked(GuestPanicInformation *info);
|
2020-01-14 03:31:02 +01:00
|
|
|
void qemu_system_guest_crashloaded(GuestPanicInformation *info);
|
2022-03-23 16:57:31 +01:00
|
|
|
bool qemu_system_dump_in_progress(void);
|
2019-08-12 07:23:59 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|