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 bool runstate_check(RunState state
);
40 void runstate_set(RunState new_state
);
41 typedef struct vm_change_state_entry VMChangeStateEntry
;
42 typedef void VMChangeStateHandler(void *opaque
, int running
, RunState state
);
44 VMChangeStateEntry
*qemu_add_vm_change_state_handler(VMChangeStateHandler
*cb
,
46 void qemu_del_vm_change_state_handler(VMChangeStateEntry
*e
);
47 void vm_state_notify(int running
, RunState state
);
49 #define VMRESET_SILENT false
50 #define VMRESET_REPORT true
53 void vm_stop(RunState state
);
55 void qemu_system_reset_request(void);
56 void qemu_system_shutdown_request(void);
57 void qemu_system_powerdown_request(void);
58 void qemu_system_debug_request(void);
59 void qemu_system_vmstop_request(RunState reason
);
60 int qemu_shutdown_requested_get(void);
61 int qemu_reset_requested_get(void);
62 int qemu_shutdown_requested(void);
63 int qemu_reset_requested(void);
64 int qemu_powerdown_requested(void);
65 void qemu_system_killed(int signal
, pid_t pid
);
66 void qemu_kill_report(void);
67 extern qemu_irq qemu_system_powerdown
;
68 void qemu_system_reset(bool report
);
70 void qemu_add_exit_notifier(Notifier
*notify
);
71 void qemu_remove_exit_notifier(Notifier
*notify
);
73 void qemu_add_machine_init_done_notifier(Notifier
*notify
);
75 void do_savevm(Monitor
*mon
, const QDict
*qdict
);
76 int load_vmstate(const char *name
);
77 void do_delvm(Monitor
*mon
, const QDict
*qdict
);
78 void do_info_snapshots(Monitor
*mon
);
80 void qemu_announce_self(void);
82 int main_loop_wait(int nonblocking
);
84 bool qemu_savevm_state_blocked(Monitor
*mon
);
85 int qemu_savevm_state_begin(Monitor
*mon
, QEMUFile
*f
, int blk_enable
,
87 int qemu_savevm_state_iterate(Monitor
*mon
, QEMUFile
*f
);
88 int qemu_savevm_state_complete(Monitor
*mon
, QEMUFile
*f
);
89 void qemu_savevm_state_cancel(Monitor
*mon
, QEMUFile
*f
);
90 int qemu_loadvm_state(QEMUFile
*f
);
93 void do_info_slirp(Monitor
*mon
);
95 typedef enum DisplayType
104 extern int autostart
;
105 extern int bios_size
;
108 VGA_NONE
, VGA_STD
, VGA_CIRRUS
, VGA_VMWARE
, VGA_XENFB
, VGA_QXL
,
111 extern int vga_interface_type
;
112 #define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
113 #define std_vga_enabled (vga_interface_type == VGA_STD)
114 #define xenfb_enabled (vga_interface_type == VGA_XENFB)
115 #define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
116 #define qxl_enabled (vga_interface_type == VGA_QXL)
118 extern int graphic_width
;
119 extern int graphic_height
;
120 extern int graphic_depth
;
121 extern uint8_t irq0override
;
122 extern DisplayType display_type
;
123 extern const char *keyboard_layout
;
124 extern int win2k_install_hack
;
125 extern int rtc_td_hack
;
127 extern int ctrl_grab
;
128 extern int usb_enabled
;
131 extern int cursor_hide
;
132 extern int graphic_rotate
;
134 extern int no_shutdown
;
135 extern int semihosting_enabled
;
136 extern int old_param
;
137 extern int boot_menu
;
138 extern uint8_t *boot_splash_filedata
;
139 extern int boot_splash_filedata_size
;
140 extern uint8_t qemu_extra_params_fw
[2];
141 extern QEMUClock
*rtc_clock
;
144 extern int nb_numa_nodes
;
145 extern uint64_t node_mem
[MAX_NODES
];
146 extern uint64_t node_cpumask
[MAX_NODES
];
148 #define MAX_OPTION_ROMS 16
149 typedef struct QEMUOptionRom
{
153 extern QEMUOptionRom option_rom
[MAX_OPTION_ROMS
];
154 extern int nb_option_roms
;
156 #define MAX_PROM_ENVS 128
157 extern const char *prom_envs
[MAX_PROM_ENVS
];
158 extern unsigned int nb_prom_envs
;
161 void pci_device_hot_add(Monitor
*mon
, const QDict
*qdict
);
162 void drive_hot_add(Monitor
*mon
, const QDict
*qdict
);
163 void do_pci_device_hot_remove(Monitor
*mon
, const QDict
*qdict
);
165 /* pcie aer error injection */
166 void pcie_aer_inject_error_print(Monitor
*mon
, const QObject
*data
);
167 int do_pcie_aer_inejct_error(Monitor
*mon
,
168 const QDict
*qdict
, QObject
**ret_data
);
172 #define MAX_SERIAL_PORTS 4
174 extern CharDriverState
*serial_hds
[MAX_SERIAL_PORTS
];
178 #define MAX_PARALLEL_PORTS 3
180 extern CharDriverState
*parallel_hds
[MAX_PARALLEL_PORTS
];
182 void do_usb_add(Monitor
*mon
, const QDict
*qdict
);
183 void do_usb_del(Monitor
*mon
, const QDict
*qdict
);
184 void usb_info(Monitor
*mon
);
186 void rtc_change_mon_event(struct tm
*tm
);
188 void register_devices(void);
190 void add_boot_device_path(int32_t bootindex
, DeviceState
*dev
,
192 char *get_boot_devices_list(uint32_t *size
);