3 /* Misc. things related to the system emulator. */
5 #include "qemu-common.h"
6 #include "qemu-option.h"
7 #include "qemu-queue.h"
8 #include "qemu-timer.h"
15 RSTATE_DEBUG, /* qemu is running under gdb */
16 RSTATE_IN_MIGRATE, /* paused waiting for an incoming migration */
17 RSTATE_PANICKED, /* paused due to an internal error */
18 RSTATE_IO_ERROR, /* paused due to an I/O error */
19 RSTATE_PAUSED, /* paused by the user (ie. the 'stop' command) */
20 RSTATE_POST_MIGRATE, /* paused following a successful migration */
21 RSTATE_PRE_LAUNCH, /* qemu was started with -S and haven't started */
22 RSTATE_PRE_MIGRATE, /* paused preparing to finish migrate */
23 RSTATE_RESTORE, /* paused restoring the VM state */
24 RSTATE_RUNNING, /* qemu is running */
25 RSTATE_SAVEVM, /* paused saving VM state */
26 RSTATE_SHUTDOWN, /* guest shut down and -no-shutdown is in use */
27 RSTATE_WATCHDOG, /* watchdog fired and qemu is configured to pause */
31 extern const char *bios_name;
33 extern int vm_running;
34 extern const char *qemu_name;
35 extern uint8_t qemu_uuid[];
36 int qemu_uuid_parse(const char *str, uint8_t *uuid);
37 #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
39 void runstate_init(void);
40 bool runstate_check(RunState state);
41 void runstate_set(RunState new_state);
42 typedef struct vm_change_state_entry VMChangeStateEntry;
43 typedef void VMChangeStateHandler(void *opaque, int running, RunState state);
45 VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
47 void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
48 void vm_state_notify(int running, RunState state);
50 #define VMRESET_SILENT false
51 #define VMRESET_REPORT true
54 void vm_stop(RunState state);
56 void qemu_system_reset_request(void);
57 void qemu_system_shutdown_request(void);
58 void qemu_system_powerdown_request(void);
59 void qemu_system_debug_request(void);
60 void qemu_system_vmstop_request(RunState reason);
61 int qemu_shutdown_requested_get(void);
62 int qemu_reset_requested_get(void);
63 int qemu_shutdown_requested(void);
64 int qemu_reset_requested(void);
65 int qemu_powerdown_requested(void);
66 void qemu_system_killed(int signal, pid_t pid);
67 void qemu_kill_report(void);
68 extern qemu_irq qemu_system_powerdown;
69 void qemu_system_reset(bool report);
71 void qemu_add_exit_notifier(Notifier *notify);
72 void qemu_remove_exit_notifier(Notifier *notify);
74 void qemu_add_machine_init_done_notifier(Notifier *notify);
76 void do_savevm(Monitor *mon, const QDict *qdict);
77 int load_vmstate(const char *name);
78 void do_delvm(Monitor *mon, const QDict *qdict);
79 void do_info_snapshots(Monitor *mon);
81 void qemu_announce_self(void);
83 int main_loop_wait(int nonblocking);
85 bool qemu_savevm_state_blocked(Monitor *mon);
86 int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
88 int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f);
89 int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f);
90 void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f);
91 int qemu_loadvm_state(QEMUFile *f);
94 void do_info_slirp(Monitor *mon);
96 typedef enum DisplayType
105 extern int autostart;
106 extern int bios_size;
109 VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
112 extern int vga_interface_type;
113 #define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
114 #define std_vga_enabled (vga_interface_type == VGA_STD)
115 #define xenfb_enabled (vga_interface_type == VGA_XENFB)
116 #define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
117 #define qxl_enabled (vga_interface_type == VGA_QXL)
119 extern int graphic_width;
120 extern int graphic_height;
121 extern int graphic_depth;
122 extern uint8_t irq0override;
123 extern DisplayType display_type;
124 extern const char *keyboard_layout;
125 extern int win2k_install_hack;
126 extern int rtc_td_hack;
128 extern int ctrl_grab;
129 extern int usb_enabled;
132 extern int cursor_hide;
133 extern int graphic_rotate;
135 extern int no_shutdown;
136 extern int semihosting_enabled;
137 extern int old_param;
138 extern int boot_menu;
139 extern uint8_t *boot_splash_filedata;
140 extern int boot_splash_filedata_size;
141 extern uint8_t qemu_extra_params_fw[2];
142 extern QEMUClock *rtc_clock;
145 extern int nb_numa_nodes;
146 extern uint64_t node_mem[MAX_NODES];
147 extern uint64_t node_cpumask[MAX_NODES];
149 #define MAX_OPTION_ROMS 16
150 typedef struct QEMUOptionRom {
154 extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
155 extern int nb_option_roms;
157 #define MAX_PROM_ENVS 128
158 extern const char *prom_envs[MAX_PROM_ENVS];
159 extern unsigned int nb_prom_envs;
162 void pci_device_hot_add(Monitor *mon, const QDict *qdict);
163 void drive_hot_add(Monitor *mon, const QDict *qdict);
164 void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
166 /* pcie aer error injection */
167 void pcie_aer_inject_error_print(Monitor *mon, const QObject *data);
168 int do_pcie_aer_inejct_error(Monitor *mon,
169 const QDict *qdict, QObject **ret_data);
173 #define MAX_SERIAL_PORTS 4
175 extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
179 #define MAX_PARALLEL_PORTS 3
181 extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
183 void do_usb_add(Monitor *mon, const QDict *qdict);
184 void do_usb_del(Monitor *mon, const QDict *qdict);
185 void usb_info(Monitor *mon);
187 void rtc_change_mon_event(struct tm *tm);
189 void register_devices(void);
191 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
193 char *get_boot_devices_list(uint32_t *size);