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 int runstate_is_running(void); 10 bool runstate_needs_reset(void); 11 bool runstate_store(char *str, size_t size); 12 13 typedef void VMChangeStateHandler(void *opaque, int 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 void vm_state_notify(int running, RunState state); 24 25 static inline bool shutdown_caused_by_guest(ShutdownCause cause) 26 { 27 return cause >= SHUTDOWN_CAUSE_GUEST_SHUTDOWN; 28 } 29 30 void vm_start(void); 31 int vm_prepare_start(void); 32 int vm_stop(RunState state); 33 int vm_stop_force_state(RunState state); 34 int vm_shutdown(void); 35 36 typedef enum WakeupReason { 37 /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */ 38 QEMU_WAKEUP_REASON_NONE = 0, 39 QEMU_WAKEUP_REASON_RTC, 40 QEMU_WAKEUP_REASON_PMTIMER, 41 QEMU_WAKEUP_REASON_OTHER, 42 } WakeupReason; 43 44 void qemu_exit_preconfig_request(void); 45 void qemu_system_reset_request(ShutdownCause reason); 46 void qemu_system_suspend_request(void); 47 void qemu_register_suspend_notifier(Notifier *notifier); 48 bool qemu_wakeup_suspend_enabled(void); 49 void qemu_system_wakeup_request(WakeupReason reason, Error **errp); 50 void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); 51 void qemu_register_wakeup_notifier(Notifier *notifier); 52 void qemu_register_wakeup_support(void); 53 void qemu_system_shutdown_request(ShutdownCause reason); 54 void qemu_system_powerdown_request(void); 55 void qemu_register_powerdown_notifier(Notifier *notifier); 56 void qemu_register_shutdown_notifier(Notifier *notifier); 57 void qemu_system_debug_request(void); 58 void qemu_system_vmstop_request(RunState reason); 59 void qemu_system_vmstop_request_prepare(void); 60 bool qemu_vmstop_requested(RunState *r); 61 ShutdownCause qemu_shutdown_requested_get(void); 62 ShutdownCause qemu_reset_requested_get(void); 63 void qemu_system_killed(int signal, pid_t pid); 64 void qemu_system_reset(ShutdownCause reason); 65 void qemu_system_guest_panicked(GuestPanicInformation *info); 66 void qemu_system_guest_crashloaded(GuestPanicInformation *info); 67 68 #endif 69 70