qemu/include/sysemu/runstate.h
<<
>>
Prefs
   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
   7bool runstate_check(RunState state);
   8void runstate_set(RunState new_state);
   9bool runstate_is_running(void);
  10bool runstate_needs_reset(void);
  11bool runstate_store(char *str, size_t size);
  12
  13typedef void VMChangeStateHandler(void *opaque, bool running, RunState state);
  14
  15VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
  16                                                     void *opaque);
  17VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
  18        VMChangeStateHandler *cb, void *opaque, int priority);
  19VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev,
  20                                                     VMChangeStateHandler *cb,
  21                                                     void *opaque);
  22void 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 */
  29void vm_state_notify(bool running, RunState state);
  30
  31static inline bool shutdown_caused_by_guest(ShutdownCause cause)
  32{
  33    return cause >= SHUTDOWN_CAUSE_GUEST_SHUTDOWN;
  34}
  35
  36void vm_start(void);
  37int vm_prepare_start(void);
  38int vm_stop(RunState state);
  39int vm_stop_force_state(RunState state);
  40int vm_shutdown(void);
  41
  42typedef 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
  50void qemu_system_reset_request(ShutdownCause reason);
  51void qemu_system_suspend_request(void);
  52void qemu_register_suspend_notifier(Notifier *notifier);
  53bool qemu_wakeup_suspend_enabled(void);
  54void qemu_system_wakeup_request(WakeupReason reason, Error **errp);
  55void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
  56void qemu_register_wakeup_notifier(Notifier *notifier);
  57void qemu_register_wakeup_support(void);
  58void qemu_system_shutdown_request(ShutdownCause reason);
  59void qemu_system_powerdown_request(void);
  60void qemu_register_powerdown_notifier(Notifier *notifier);
  61void qemu_register_shutdown_notifier(Notifier *notifier);
  62void qemu_system_debug_request(void);
  63void qemu_system_vmstop_request(RunState reason);
  64void qemu_system_vmstop_request_prepare(void);
  65bool qemu_vmstop_requested(RunState *r);
  66ShutdownCause qemu_shutdown_requested_get(void);
  67ShutdownCause qemu_reset_requested_get(void);
  68void qemu_system_killed(int signal, pid_t pid);
  69void qemu_system_reset(ShutdownCause reason);
  70void qemu_system_guest_panicked(GuestPanicInformation *info);
  71void qemu_system_guest_crashloaded(GuestPanicInformation *info);
  72
  73#endif
  74
  75