1 #ifndef SYSEMU_RUNSTATE_H 2 #define SYSEMU_RUNSTATE_H 3 4 #include "qapi/qapi-types-run-state.h" 5 #include "qemu/notify.h" 6 7 bool runstate_check(RunState state); 8 void runstate_set(RunState new_state); 9 RunState runstate_get(void); 10 bool runstate_is_running(void); 11 bool runstate_needs_reset(void); 12 13 typedef void VMChangeStateHandler(void *opaque, bool running, RunState state); 14 15 VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, 16 void *opaque); 17 VMChangeStateEntry *qemu_add_vm_change_state_handler_prio( 18 VMChangeStateHandler *cb, void *opaque, int priority); 19 VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev, 20 VMChangeStateHandler *cb, 21 void *opaque); 22 void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); 23 /** 24 * vm_state_notify: Notify the state of the VM 25 * 26 * @running: whether the VM is running or not. 27 * @state: the #RunState of the VM. 28 */ 29 void vm_state_notify(bool running, RunState state); 30 31 static inline bool shutdown_caused_by_guest(ShutdownCause cause) 32 { 33 return cause >= SHUTDOWN_CAUSE_GUEST_SHUTDOWN; 34 } 35 36 void vm_start(void); 37 38 /** 39 * vm_prepare_start: Prepare for starting/resuming the VM 40 * 41 * @step_pending: whether any of the CPUs is about to be single-stepped by gdb 42 */ 43 int vm_prepare_start(bool step_pending); 44 int vm_stop(RunState state); 45 int vm_stop_force_state(RunState state); 46 int vm_shutdown(void); 47 48 typedef enum WakeupReason { 49 /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */ 50 QEMU_WAKEUP_REASON_NONE = 0, 51 QEMU_WAKEUP_REASON_RTC, 52 QEMU_WAKEUP_REASON_PMTIMER, 53 QEMU_WAKEUP_REASON_OTHER, 54 } WakeupReason; 55 56 void qemu_system_reset_request(ShutdownCause reason); 57 void qemu_system_suspend_request(void); 58 void qemu_register_suspend_notifier(Notifier *notifier); 59 bool qemu_wakeup_suspend_enabled(void); 60 void qemu_system_wakeup_request(WakeupReason reason, Error **errp); 61 void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); 62 void qemu_register_wakeup_notifier(Notifier *notifier); 63 void qemu_register_wakeup_support(void); 64 void qemu_system_shutdown_request(ShutdownCause reason); 65 void qemu_system_powerdown_request(void); 66 void qemu_register_powerdown_notifier(Notifier *notifier); 67 void qemu_register_shutdown_notifier(Notifier *notifier); 68 void qemu_system_debug_request(void); 69 void qemu_system_vmstop_request(RunState reason); 70 void qemu_system_vmstop_request_prepare(void); 71 bool qemu_vmstop_requested(RunState *r); 72 ShutdownCause qemu_shutdown_requested_get(void); 73 ShutdownCause qemu_reset_requested_get(void); 74 void qemu_system_killed(int signal, pid_t pid); 75 void qemu_system_reset(ShutdownCause reason); 76 void qemu_system_guest_panicked(GuestPanicInformation *info); 77 void qemu_system_guest_crashloaded(GuestPanicInformation *info); 78 bool qemu_system_dump_in_progress(void); 79 80 #endif 81 82