blob: 19088aa2dd5fdd7b818aa547966f0ee870f050db [file] [log] [blame]
pbrook87ecb682007-11-17 17:14:51 +00001#ifndef SYSEMU_H
2#define SYSEMU_H
3/* Misc. things related to the system emulator. */
4
aliguori376253e2009-03-05 23:01:23 +00005#include "qemu-common.h"
Gerd Hoffmann62c58022009-07-22 16:43:00 +02006#include "qemu-option.h"
Blue Swirl72cf2d42009-09-12 07:36:22 +00007#include "qemu-queue.h"
Jan Kiszka68752042009-09-15 13:36:04 +02008#include "qemu-timer.h"
Gerd Hoffmannfd42dee2010-06-04 14:08:07 +02009#include "notify.h"
aliguori376253e2009-03-05 23:01:23 +000010
pbrook87ecb682007-11-17 17:14:51 +000011/* vl.c */
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030012
13typedef enum {
14 RSTATE_NO_STATE,
15 RSTATE_DEBUG, /* qemu is running under gdb */
Luiz Capitulinof5bbfba2011-07-29 15:04:45 -030016 RSTATE_IN_MIGRATE, /* paused waiting for an incoming migration */
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030017 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) */
Luiz Capitulinof5bbfba2011-07-29 15:04:45 -030020 RSTATE_POST_MIGRATE, /* paused following a successful migration */
21 RSTATE_PRE_LAUNCH, /* qemu was started with -S and haven't started */
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030022 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 */
Luiz Capitulinof5bbfba2011-07-29 15:04:45 -030027 RSTATE_WATCHDOG, /* watchdog fired and qemu is configured to pause */
28 RSTATE_MAX
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030029} RunState;
30
pbrook87ecb682007-11-17 17:14:51 +000031extern const char *bios_name;
Paul Brook5cea8592009-05-30 00:52:44 +010032
pbrook87ecb682007-11-17 17:14:51 +000033extern int vm_running;
34extern const char *qemu_name;
blueswir18fcb1b92008-09-18 18:29:08 +000035extern uint8_t qemu_uuid[];
aliguoric4be29f2009-04-17 18:58:14 +000036int qemu_uuid_parse(const char *str, uint8_t *uuid);
blueswir18fcb1b92008-09-18 18:29:08 +000037#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
pbrook87ecb682007-11-17 17:14:51 +000038
Luiz Capitulinof5bbfba2011-07-29 15:04:45 -030039bool runstate_check(RunState state);
40void runstate_set(RunState new_state);
pbrook87ecb682007-11-17 17:14:51 +000041typedef struct vm_change_state_entry VMChangeStateEntry;
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030042typedef void VMChangeStateHandler(void *opaque, int running, RunState state);
pbrook87ecb682007-11-17 17:14:51 +000043
44VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
45 void *opaque);
46void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030047void vm_state_notify(int running, RunState state);
Jan Kiszkae07bbac2011-02-09 16:29:40 +010048
Jan Kiszkae063eb12011-06-14 18:29:43 +020049#define VMRESET_SILENT false
50#define VMRESET_REPORT true
51
pbrook87ecb682007-11-17 17:14:51 +000052void vm_start(void);
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030053void vm_stop(RunState state);
pbrook87ecb682007-11-17 17:14:51 +000054
pbrook87ecb682007-11-17 17:14:51 +000055void qemu_system_reset_request(void);
56void qemu_system_shutdown_request(void);
57void qemu_system_powerdown_request(void);
Jan Kiszka8cf71712011-02-07 12:19:16 +010058void qemu_system_debug_request(void);
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030059void qemu_system_vmstop_request(RunState reason);
Anthony PERARD1291eb32010-07-22 15:52:48 +010060int qemu_shutdown_requested_get(void);
61int qemu_reset_requested_get(void);
aurel32cf7a2fe2008-03-18 06:53:05 +000062int qemu_shutdown_requested(void);
63int qemu_reset_requested(void);
64int qemu_powerdown_requested(void);
Gleb Natapovf64622c2011-03-15 13:56:04 +020065void qemu_system_killed(int signal, pid_t pid);
66void qemu_kill_report(void);
Blue Swirld9c32312009-08-09 08:42:19 +000067extern qemu_irq qemu_system_powerdown;
Jan Kiszkae063eb12011-06-14 18:29:43 +020068void qemu_system_reset(bool report);
pbrook87ecb682007-11-17 17:14:51 +000069
Gerd Hoffmannfd42dee2010-06-04 14:08:07 +020070void qemu_add_exit_notifier(Notifier *notify);
71void qemu_remove_exit_notifier(Notifier *notify);
72
Gleb Natapov4cab9462010-12-08 13:35:08 +020073void qemu_add_machine_init_done_notifier(Notifier *notify);
74
Luiz Capitulinod54908a2009-08-28 15:27:13 -030075void do_savevm(Monitor *mon, const QDict *qdict);
Markus Armbruster03cd4652010-02-17 16:24:10 +010076int load_vmstate(const char *name);
Luiz Capitulinod54908a2009-08-28 15:27:13 -030077void do_delvm(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +000078void do_info_snapshots(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +000079
aliguori210f41b2008-10-13 03:13:12 +000080void qemu_announce_self(void);
81
Jan Kiszkac9f711a2011-08-22 17:46:02 +020082int main_loop_wait(int nonblocking);
pbrook87ecb682007-11-17 17:14:51 +000083
Alex Williamsondc912122011-01-11 14:39:43 -070084bool qemu_savevm_state_blocked(Monitor *mon);
Jan Kiszkaf327aa02009-11-30 18:21:21 +010085int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
86 int shared);
87int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f);
88int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f);
89void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f);
aliguori9366f412008-10-06 14:53:52 +000090int qemu_loadvm_state(QEMUFile *f);
91
pbrook87ecb682007-11-17 17:14:51 +000092/* SLIRP */
aliguori376253e2009-03-05 23:01:23 +000093void do_info_slirp(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +000094
Anthony Liguori993fbfd2009-05-21 16:54:00 -050095typedef enum DisplayType
96{
97 DT_DEFAULT,
98 DT_CURSES,
99 DT_SDL,
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500100 DT_NOGRAPHIC,
Jes Sorensen4171d322011-03-16 13:33:32 +0100101 DT_NONE,
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500102} DisplayType;
103
Paolo Bonzinid399f672009-07-27 23:17:51 +0200104extern int autostart;
pbrook87ecb682007-11-17 17:14:51 +0000105extern int bios_size;
Zachary Amsden86176752009-07-30 00:15:02 -1000106
107typedef enum {
Gerd Hoffmanna19cbfb2010-04-27 11:50:11 +0200108 VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
Zachary Amsden86176752009-07-30 00:15:02 -1000109} VGAInterfaceType;
110
111extern 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)
Gerd Hoffmanna19cbfb2010-04-27 11:50:11 +0200116#define qxl_enabled (vga_interface_type == VGA_QXL)
Zachary Amsden86176752009-07-30 00:15:02 -1000117
pbrook87ecb682007-11-17 17:14:51 +0000118extern int graphic_width;
119extern int graphic_height;
120extern int graphic_depth;
Jes Sorensen6b35e7b2009-08-06 16:25:50 +0200121extern uint8_t irq0override;
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500122extern DisplayType display_type;
pbrook87ecb682007-11-17 17:14:51 +0000123extern const char *keyboard_layout;
124extern int win2k_install_hack;
aliguori73822ec2009-01-15 20:11:34 +0000125extern int rtc_td_hack;
pbrook87ecb682007-11-17 17:14:51 +0000126extern int alt_grab;
Dustin Kirkland0ca9f8a2009-09-17 15:48:04 -0500127extern int ctrl_grab;
pbrook87ecb682007-11-17 17:14:51 +0000128extern int usb_enabled;
129extern int smp_cpus;
Jes Sorensen6be68d72009-07-23 17:03:42 +0200130extern int max_cpus;
pbrook87ecb682007-11-17 17:14:51 +0000131extern int cursor_hide;
132extern int graphic_rotate;
133extern int no_quit;
Luiz Capitulinoa691d412010-05-11 18:07:04 -0300134extern int no_shutdown;
pbrook87ecb682007-11-17 17:14:51 +0000135extern int semihosting_enabled;
pbrook87ecb682007-11-17 17:14:51 +0000136extern int old_param;
Jan Kiszka95387492009-07-02 00:19:02 +0200137extern int boot_menu;
wayne3d3b8302011-07-27 18:04:55 +0800138extern uint8_t *boot_splash_filedata;
139extern int boot_splash_filedata_size;
140extern uint8_t qemu_extra_params_fw[2];
Jan Kiszka68752042009-09-15 13:36:04 +0200141extern QEMUClock *rtc_clock;
pbrook87ecb682007-11-17 17:14:51 +0000142
aliguori268a3622009-04-21 22:30:27 +0000143#define MAX_NODES 64
144extern int nb_numa_nodes;
145extern uint64_t node_mem[MAX_NODES];
Blue Swirl075cd322009-09-13 08:32:39 +0000146extern uint64_t node_cpumask[MAX_NODES];
aliguori268a3622009-04-21 22:30:27 +0000147
pbrook87ecb682007-11-17 17:14:51 +0000148#define MAX_OPTION_ROMS 16
Gleb Natapov2e55e842010-12-08 13:35:07 +0200149typedef struct QEMUOptionRom {
150 const char *name;
151 int32_t bootindex;
152} QEMUOptionRom;
153extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
pbrook87ecb682007-11-17 17:14:51 +0000154extern int nb_option_roms;
155
pbrook87ecb682007-11-17 17:14:51 +0000156#define MAX_PROM_ENVS 128
157extern const char *prom_envs[MAX_PROM_ENVS];
158extern unsigned int nb_prom_envs;
pbrook87ecb682007-11-17 17:14:51 +0000159
aliguori6f338c32009-02-11 15:21:54 +0000160/* pci-hotplug */
Markus Armbruster6c6a58a2010-05-12 10:53:00 +0200161void pci_device_hot_add(Monitor *mon, const QDict *qdict);
Luiz Capitulinof18c16d2009-08-28 15:27:14 -0300162void drive_hot_add(Monitor *mon, const QDict *qdict);
Markus Armbrusterb752daf2010-05-12 10:53:01 +0200163void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
aliguori6f338c32009-02-11 15:21:54 +0000164
Isaku Yamahata2ae63bd2010-12-24 12:14:14 +0900165/* pcie aer error injection */
166void pcie_aer_inject_error_print(Monitor *mon, const QObject *data);
167int do_pcie_aer_inejct_error(Monitor *mon,
168 const QDict *qdict, QObject **ret_data);
169
pbrook87ecb682007-11-17 17:14:51 +0000170/* serial ports */
171
172#define MAX_SERIAL_PORTS 4
173
174extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
175
176/* parallel ports */
177
178#define MAX_PARALLEL_PORTS 3
179
180extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
181
Luiz Capitulinod54908a2009-08-28 15:27:13 -0300182void do_usb_add(Monitor *mon, const QDict *qdict);
183void do_usb_del(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +0000184void usb_info(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +0000185
Luiz Capitulino80cd3472010-02-25 12:11:44 -0300186void rtc_change_mon_event(struct tm *tm);
187
Paul Brookaae94602009-05-14 22:35:06 +0100188void register_devices(void);
189
Gleb Natapov1ca4d092010-12-08 13:35:05 +0200190void add_boot_device_path(int32_t bootindex, DeviceState *dev,
191 const char *suffix);
Gleb Natapov962630f2010-12-08 13:35:09 +0200192char *get_boot_devices_list(uint32_t *size);
pbrook87ecb682007-11-17 17:14:51 +0000193#endif