blob: 109304672dc26db05476a655a0122ff4d16166e8 [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"
Luiz Capitulino1fa9a5e2011-09-12 17:54:20 -03009#include "qapi-types.h"
Gerd Hoffmannfd42dee2010-06-04 14:08:07 +020010#include "notify.h"
Paolo Bonzini44a9b352011-09-12 16:44:30 +020011#include "main-loop.h"
aliguori376253e2009-03-05 23:01:23 +000012
pbrook87ecb682007-11-17 17:14:51 +000013/* vl.c */
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030014
pbrook87ecb682007-11-17 17:14:51 +000015extern const char *bios_name;
Paul Brook5cea8592009-05-30 00:52:44 +010016
pbrook87ecb682007-11-17 17:14:51 +000017extern const char *qemu_name;
blueswir18fcb1b92008-09-18 18:29:08 +000018extern uint8_t qemu_uuid[];
aliguoric4be29f2009-04-17 18:58:14 +000019int qemu_uuid_parse(const char *str, uint8_t *uuid);
blueswir18fcb1b92008-09-18 18:29:08 +000020#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 +000021
Luiz Capitulino5db9d4d2011-09-05 16:36:31 -030022void runstate_init(void);
Luiz Capitulinof5bbfba2011-07-29 15:04:45 -030023bool runstate_check(RunState state);
24void runstate_set(RunState new_state);
Luiz Capitulino13548692011-07-29 15:36:43 -030025int runstate_is_running(void);
pbrook87ecb682007-11-17 17:14:51 +000026typedef struct vm_change_state_entry VMChangeStateEntry;
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030027typedef void VMChangeStateHandler(void *opaque, int running, RunState state);
pbrook87ecb682007-11-17 17:14:51 +000028
29VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
30 void *opaque);
31void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030032void vm_state_notify(int running, RunState state);
Jan Kiszkae07bbac2011-02-09 16:29:40 +010033
Jan Kiszkae063eb12011-06-14 18:29:43 +020034#define VMRESET_SILENT false
35#define VMRESET_REPORT true
36
pbrook87ecb682007-11-17 17:14:51 +000037void vm_start(void);
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030038void vm_stop(RunState state);
Luiz Capitulino8a9236f2011-10-14 11:18:09 -030039void vm_stop_force_state(RunState state);
pbrook87ecb682007-11-17 17:14:51 +000040
Gerd Hoffmann95b363b2012-02-23 13:45:19 +010041typedef enum WakeupReason {
42 QEMU_WAKEUP_REASON_OTHER = 0,
Gerd Hoffmann62aeb0f2012-02-23 13:45:24 +010043 QEMU_WAKEUP_REASON_RTC,
Gerd Hoffmann6595abc2012-02-23 13:45:25 +010044 QEMU_WAKEUP_REASON_PMTIMER,
Gerd Hoffmann95b363b2012-02-23 13:45:19 +010045} WakeupReason;
46
pbrook87ecb682007-11-17 17:14:51 +000047void qemu_system_reset_request(void);
Gerd Hoffmann95b363b2012-02-23 13:45:19 +010048void qemu_system_suspend_request(void);
49void qemu_register_suspend_notifier(Notifier *notifier);
50void qemu_system_wakeup_request(WakeupReason reason);
51void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
52void qemu_register_wakeup_notifier(Notifier *notifier);
pbrook87ecb682007-11-17 17:14:51 +000053void qemu_system_shutdown_request(void);
54void qemu_system_powerdown_request(void);
Igor Mammedova9552c82012-09-05 23:06:21 +020055void qemu_register_powerdown_notifier(Notifier *notifier);
Jan Kiszka8cf71712011-02-07 12:19:16 +010056void qemu_system_debug_request(void);
Luiz Capitulino1dfb4dd2011-07-29 14:26:33 -030057void qemu_system_vmstop_request(RunState reason);
Anthony PERARD1291eb32010-07-22 15:52:48 +010058int qemu_shutdown_requested_get(void);
59int qemu_reset_requested_get(void);
aurel32cf7a2fe2008-03-18 06:53:05 +000060int qemu_shutdown_requested(void);
61int qemu_reset_requested(void);
62int qemu_powerdown_requested(void);
Gleb Natapovf64622c2011-03-15 13:56:04 +020063void qemu_system_killed(int signal, pid_t pid);
64void qemu_kill_report(void);
David Gibsonbe522022012-08-07 16:41:51 +100065void qemu_devices_reset(void);
Jan Kiszkae063eb12011-06-14 18:29:43 +020066void qemu_system_reset(bool report);
pbrook87ecb682007-11-17 17:14:51 +000067
Gerd Hoffmannfd42dee2010-06-04 14:08:07 +020068void qemu_add_exit_notifier(Notifier *notify);
69void qemu_remove_exit_notifier(Notifier *notify);
70
Gleb Natapov4cab9462010-12-08 13:35:08 +020071void qemu_add_machine_init_done_notifier(Notifier *notify);
72
Luiz Capitulinod54908a2009-08-28 15:27:13 -030073void do_savevm(Monitor *mon, const QDict *qdict);
Markus Armbruster03cd4652010-02-17 16:24:10 +010074int load_vmstate(const char *name);
Luiz Capitulinod54908a2009-08-28 15:27:13 -030075void do_delvm(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +000076void do_info_snapshots(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +000077
aliguori210f41b2008-10-13 03:13:12 +000078void qemu_announce_self(void);
79
Luiz Capitulinoe1c37d02011-12-05 14:48:01 -020080bool qemu_savevm_state_blocked(Error **errp);
Isaku Yamahata6607ae22012-06-19 18:43:09 +030081int qemu_savevm_state_begin(QEMUFile *f,
82 const MigrationParams *params);
Luiz Capitulino539de122011-12-05 14:06:56 -020083int qemu_savevm_state_iterate(QEMUFile *f);
84int qemu_savevm_state_complete(QEMUFile *f);
85void qemu_savevm_state_cancel(QEMUFile *f);
aliguori9366f412008-10-06 14:53:52 +000086int qemu_loadvm_state(QEMUFile *f);
87
pbrook87ecb682007-11-17 17:14:51 +000088/* SLIRP */
aliguori376253e2009-03-05 23:01:23 +000089void do_info_slirp(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +000090
Anthony Liguori993fbfd2009-05-21 16:54:00 -050091typedef enum DisplayType
92{
93 DT_DEFAULT,
94 DT_CURSES,
95 DT_SDL,
Anthony Liguori993fbfd2009-05-21 16:54:00 -050096 DT_NOGRAPHIC,
Jes Sorensen4171d322011-03-16 13:33:32 +010097 DT_NONE,
Anthony Liguori993fbfd2009-05-21 16:54:00 -050098} DisplayType;
99
Paolo Bonzinid399f672009-07-27 23:17:51 +0200100extern int autostart;
pbrook87ecb682007-11-17 17:14:51 +0000101extern int bios_size;
Zachary Amsden86176752009-07-30 00:15:02 -1000102
103typedef enum {
Gerd Hoffmanna19cbfb2010-04-27 11:50:11 +0200104 VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
Zachary Amsden86176752009-07-30 00:15:02 -1000105} VGAInterfaceType;
106
107extern int vga_interface_type;
108#define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
109#define std_vga_enabled (vga_interface_type == VGA_STD)
110#define xenfb_enabled (vga_interface_type == VGA_XENFB)
111#define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
Gerd Hoffmanna19cbfb2010-04-27 11:50:11 +0200112#define qxl_enabled (vga_interface_type == VGA_QXL)
Zachary Amsden86176752009-07-30 00:15:02 -1000113
pbrook87ecb682007-11-17 17:14:51 +0000114extern int graphic_width;
115extern int graphic_height;
116extern int graphic_depth;
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500117extern DisplayType display_type;
pbrook87ecb682007-11-17 17:14:51 +0000118extern const char *keyboard_layout;
119extern int win2k_install_hack;
120extern int alt_grab;
Dustin Kirkland0ca9f8a2009-09-17 15:48:04 -0500121extern int ctrl_grab;
pbrook87ecb682007-11-17 17:14:51 +0000122extern int usb_enabled;
123extern int smp_cpus;
Jes Sorensen6be68d72009-07-23 17:03:42 +0200124extern int max_cpus;
pbrook87ecb682007-11-17 17:14:51 +0000125extern int cursor_hide;
126extern int graphic_rotate;
127extern int no_quit;
Luiz Capitulinoa691d412010-05-11 18:07:04 -0300128extern int no_shutdown;
pbrook87ecb682007-11-17 17:14:51 +0000129extern int semihosting_enabled;
pbrook87ecb682007-11-17 17:14:51 +0000130extern int old_param;
Jan Kiszka95387492009-07-02 00:19:02 +0200131extern int boot_menu;
wayne3d3b8302011-07-27 18:04:55 +0800132extern uint8_t *boot_splash_filedata;
133extern int boot_splash_filedata_size;
134extern uint8_t qemu_extra_params_fw[2];
Jan Kiszka68752042009-09-15 13:36:04 +0200135extern QEMUClock *rtc_clock;
pbrook87ecb682007-11-17 17:14:51 +0000136
aliguori268a3622009-04-21 22:30:27 +0000137#define MAX_NODES 64
Chegu Vinodee785fe2012-07-16 21:31:30 -0700138#define MAX_CPUMASK_BITS 255
aliguori268a3622009-04-21 22:30:27 +0000139extern int nb_numa_nodes;
140extern uint64_t node_mem[MAX_NODES];
Chegu Vinodee785fe2012-07-16 21:31:30 -0700141extern unsigned long *node_cpumask[MAX_NODES];
aliguori268a3622009-04-21 22:30:27 +0000142
pbrook87ecb682007-11-17 17:14:51 +0000143#define MAX_OPTION_ROMS 16
Gleb Natapov2e55e842010-12-08 13:35:07 +0200144typedef struct QEMUOptionRom {
145 const char *name;
146 int32_t bootindex;
147} QEMUOptionRom;
148extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
pbrook87ecb682007-11-17 17:14:51 +0000149extern int nb_option_roms;
150
pbrook87ecb682007-11-17 17:14:51 +0000151#define MAX_PROM_ENVS 128
152extern const char *prom_envs[MAX_PROM_ENVS];
153extern unsigned int nb_prom_envs;
pbrook87ecb682007-11-17 17:14:51 +0000154
aliguori6f338c32009-02-11 15:21:54 +0000155/* pci-hotplug */
Markus Armbruster6c6a58a2010-05-12 10:53:00 +0200156void pci_device_hot_add(Monitor *mon, const QDict *qdict);
Alexander Grafdd97aa82010-08-23 23:43:10 +0200157int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
158 DriveInfo *dinfo, int type);
Markus Armbrusterb752daf2010-05-12 10:53:01 +0200159void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
aliguori6f338c32009-02-11 15:21:54 +0000160
Alexander Grafdd97aa82010-08-23 23:43:10 +0200161/* generic hotplug */
162void drive_hot_add(Monitor *mon, const QDict *qdict);
163
Isaku Yamahata2ae63bd2010-12-24 12:14:14 +0900164/* pcie aer error injection */
165void pcie_aer_inject_error_print(Monitor *mon, const QObject *data);
Zhi Yong Wu1f3392b2011-11-30 12:39:47 +0800166int do_pcie_aer_inject_error(Monitor *mon,
Isaku Yamahata2ae63bd2010-12-24 12:14:14 +0900167 const QDict *qdict, QObject **ret_data);
168
pbrook87ecb682007-11-17 17:14:51 +0000169/* serial ports */
170
171#define MAX_SERIAL_PORTS 4
172
173extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
174
175/* parallel ports */
176
177#define MAX_PARALLEL_PORTS 3
178
179extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
180
Luiz Capitulinod54908a2009-08-28 15:27:13 -0300181void do_usb_add(Monitor *mon, const QDict *qdict);
182void do_usb_del(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +0000183void usb_info(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +0000184
Luiz Capitulino80cd3472010-02-25 12:11:44 -0300185void rtc_change_mon_event(struct tm *tm);
186
Paul Brookaae94602009-05-14 22:35:06 +0100187void register_devices(void);
188
Gleb Natapov1ca4d092010-12-08 13:35:05 +0200189void add_boot_device_path(int32_t bootindex, DeviceState *dev,
190 const char *suffix);
Gleb Natapov962630f2010-12-08 13:35:09 +0200191char *get_boot_devices_list(uint32_t *size);
pbrook87ecb682007-11-17 17:14:51 +0000192#endif