Merge tag 'or1k-pull-request-20220515' of https://github.com/stffrdhrn/qemu into...
[qemu.git] / include / sysemu / runstate.h
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 bool 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, 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 int vm_prepare_start(void);
38 int vm_stop(RunState state);
39 int vm_stop_force_state(RunState state);
40 int vm_shutdown(void);
41
42 typedef enum WakeupReason {
43 /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */
44 QEMU_WAKEUP_REASON_NONE = 0,
45 QEMU_WAKEUP_REASON_RTC,
46 QEMU_WAKEUP_REASON_PMTIMER,
47 QEMU_WAKEUP_REASON_OTHER,
48 } WakeupReason;
49
50 void qemu_system_reset_request(ShutdownCause reason);
51 void qemu_system_suspend_request(void);
52 void qemu_register_suspend_notifier(Notifier *notifier);
53 bool qemu_wakeup_suspend_enabled(void);
54 void qemu_system_wakeup_request(WakeupReason reason, Error **errp);
55 void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
56 void qemu_register_wakeup_notifier(Notifier *notifier);
57 void qemu_register_wakeup_support(void);
58 void qemu_system_shutdown_request(ShutdownCause reason);
59 void qemu_system_powerdown_request(void);
60 void qemu_register_powerdown_notifier(Notifier *notifier);
61 void qemu_register_shutdown_notifier(Notifier *notifier);
62 void qemu_system_debug_request(void);
63 void qemu_system_vmstop_request(RunState reason);
64 void qemu_system_vmstop_request_prepare(void);
65 bool qemu_vmstop_requested(RunState *r);
66 ShutdownCause qemu_shutdown_requested_get(void);
67 ShutdownCause qemu_reset_requested_get(void);
68 void qemu_system_killed(int signal, pid_t pid);
69 void qemu_system_reset(ShutdownCause reason);
70 void qemu_system_guest_panicked(GuestPanicInformation *info);
71 void qemu_system_guest_crashloaded(GuestPanicInformation *info);
72
73 #endif
74