sysemu.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #ifndef SYSEMU_H
  2. #define SYSEMU_H
  3. /* Misc. things related to the system emulator. */
  4. #include "qemu-common.h"
  5. #include "qemu-option.h"
  6. #include "qemu-queue.h"
  7. #include "qemu-timer.h"
  8. #include "qapi-types.h"
  9. #include "notify.h"
  10. #include "main-loop.h"
  11. /* vl.c */
  12. extern const char *bios_name;
  13. extern const char *qemu_name;
  14. extern uint8_t qemu_uuid[];
  15. int qemu_uuid_parse(const char *str, uint8_t *uuid);
  16. #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
  17. void runstate_init(void);
  18. bool runstate_check(RunState state);
  19. void runstate_set(RunState new_state);
  20. int runstate_is_running(void);
  21. typedef struct vm_change_state_entry VMChangeStateEntry;
  22. typedef void VMChangeStateHandler(void *opaque, int running, RunState state);
  23. VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
  24. void *opaque);
  25. void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
  26. void vm_state_notify(int running, RunState state);
  27. #define VMRESET_SILENT false
  28. #define VMRESET_REPORT true
  29. void vm_start(void);
  30. void vm_stop(RunState state);
  31. void vm_stop_force_state(RunState state);
  32. typedef enum WakeupReason {
  33. QEMU_WAKEUP_REASON_OTHER = 0,
  34. QEMU_WAKEUP_REASON_RTC,
  35. QEMU_WAKEUP_REASON_PMTIMER,
  36. } WakeupReason;
  37. void qemu_system_reset_request(void);
  38. void qemu_system_suspend_request(void);
  39. void qemu_register_suspend_notifier(Notifier *notifier);
  40. void qemu_system_wakeup_request(WakeupReason reason);
  41. void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
  42. void qemu_register_wakeup_notifier(Notifier *notifier);
  43. void qemu_system_shutdown_request(void);
  44. void qemu_system_powerdown_request(void);
  45. void qemu_system_debug_request(void);
  46. void qemu_system_vmstop_request(RunState reason);
  47. int qemu_shutdown_requested_get(void);
  48. int qemu_reset_requested_get(void);
  49. int qemu_shutdown_requested(void);
  50. int qemu_reset_requested(void);
  51. int qemu_powerdown_requested(void);
  52. void qemu_system_killed(int signal, pid_t pid);
  53. void qemu_kill_report(void);
  54. extern qemu_irq qemu_system_powerdown;
  55. void qemu_system_reset(bool report);
  56. void qemu_add_exit_notifier(Notifier *notify);
  57. void qemu_remove_exit_notifier(Notifier *notify);
  58. void qemu_add_machine_init_done_notifier(Notifier *notify);
  59. void do_savevm(Monitor *mon, const QDict *qdict);
  60. int load_vmstate(const char *name);
  61. void do_delvm(Monitor *mon, const QDict *qdict);
  62. void do_info_snapshots(Monitor *mon);
  63. void qemu_announce_self(void);
  64. bool qemu_savevm_state_blocked(Error **errp);
  65. int qemu_savevm_state_begin(QEMUFile *f, int blk_enable, int shared);
  66. int qemu_savevm_state_iterate(QEMUFile *f);
  67. int qemu_savevm_state_complete(QEMUFile *f);
  68. void qemu_savevm_state_cancel(QEMUFile *f);
  69. int qemu_loadvm_state(QEMUFile *f);
  70. /* SLIRP */
  71. void do_info_slirp(Monitor *mon);
  72. typedef enum DisplayType
  73. {
  74. DT_DEFAULT,
  75. DT_CURSES,
  76. DT_SDL,
  77. DT_NOGRAPHIC,
  78. DT_NONE,
  79. } DisplayType;
  80. extern int autostart;
  81. extern int bios_size;
  82. typedef enum {
  83. VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
  84. } VGAInterfaceType;
  85. extern int vga_interface_type;
  86. #define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
  87. #define std_vga_enabled (vga_interface_type == VGA_STD)
  88. #define xenfb_enabled (vga_interface_type == VGA_XENFB)
  89. #define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
  90. #define qxl_enabled (vga_interface_type == VGA_QXL)
  91. extern int graphic_width;
  92. extern int graphic_height;
  93. extern int graphic_depth;
  94. extern DisplayType display_type;
  95. extern const char *keyboard_layout;
  96. extern int win2k_install_hack;
  97. extern int alt_grab;
  98. extern int ctrl_grab;
  99. extern int usb_enabled;
  100. extern int smp_cpus;
  101. extern int max_cpus;
  102. extern int cursor_hide;
  103. extern int graphic_rotate;
  104. extern int no_quit;
  105. extern int no_shutdown;
  106. extern int semihosting_enabled;
  107. extern int old_param;
  108. extern int boot_menu;
  109. extern uint8_t *boot_splash_filedata;
  110. extern int boot_splash_filedata_size;
  111. extern uint8_t qemu_extra_params_fw[2];
  112. extern QEMUClock *rtc_clock;
  113. #define MAX_NODES 64
  114. extern int nb_numa_nodes;
  115. extern uint64_t node_mem[MAX_NODES];
  116. extern uint64_t node_cpumask[MAX_NODES];
  117. #define MAX_OPTION_ROMS 16
  118. typedef struct QEMUOptionRom {
  119. const char *name;
  120. int32_t bootindex;
  121. } QEMUOptionRom;
  122. extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
  123. extern int nb_option_roms;
  124. #define MAX_PROM_ENVS 128
  125. extern const char *prom_envs[MAX_PROM_ENVS];
  126. extern unsigned int nb_prom_envs;
  127. /* pci-hotplug */
  128. void pci_device_hot_add(Monitor *mon, const QDict *qdict);
  129. int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
  130. DriveInfo *dinfo, int type);
  131. void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
  132. /* generic hotplug */
  133. void drive_hot_add(Monitor *mon, const QDict *qdict);
  134. /* pcie aer error injection */
  135. void pcie_aer_inject_error_print(Monitor *mon, const QObject *data);
  136. int do_pcie_aer_inject_error(Monitor *mon,
  137. const QDict *qdict, QObject **ret_data);
  138. /* serial ports */
  139. #define MAX_SERIAL_PORTS 4
  140. extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
  141. /* parallel ports */
  142. #define MAX_PARALLEL_PORTS 3
  143. extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
  144. void do_usb_add(Monitor *mon, const QDict *qdict);
  145. void do_usb_del(Monitor *mon, const QDict *qdict);
  146. void usb_info(Monitor *mon);
  147. void rtc_change_mon_event(struct tm *tm);
  148. void register_devices(void);
  149. void add_boot_device_path(int32_t bootindex, DeviceState *dev,
  150. const char *suffix);
  151. char *get_boot_devices_list(uint32_t *size);
  152. #endif