xref: /openbmc/qemu/include/sysemu/sysemu.h (revision 066e9b27)
19c17d615SPaolo Bonzini #ifndef SYSEMU_H
29c17d615SPaolo Bonzini #define SYSEMU_H
39c17d615SPaolo Bonzini /* Misc. things related to the system emulator.  */
49c17d615SPaolo Bonzini 
59c17d615SPaolo Bonzini #include "qemu/typedefs.h"
69c17d615SPaolo Bonzini #include "qemu/option.h"
79c17d615SPaolo Bonzini #include "qemu/queue.h"
89c17d615SPaolo Bonzini #include "qemu/timer.h"
99c17d615SPaolo Bonzini #include "qapi-types.h"
109c17d615SPaolo Bonzini #include "qemu/notify.h"
119c17d615SPaolo Bonzini #include "qemu/main-loop.h"
129c17d615SPaolo Bonzini 
139c17d615SPaolo Bonzini /* vl.c */
149c17d615SPaolo Bonzini 
159c17d615SPaolo Bonzini extern const char *bios_name;
169c17d615SPaolo Bonzini 
179c17d615SPaolo Bonzini extern const char *qemu_name;
189c17d615SPaolo Bonzini extern uint8_t qemu_uuid[];
199c17d615SPaolo Bonzini int qemu_uuid_parse(const char *str, uint8_t *uuid);
209c17d615SPaolo Bonzini #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
219c17d615SPaolo Bonzini 
229c17d615SPaolo Bonzini bool runstate_check(RunState state);
239c17d615SPaolo Bonzini void runstate_set(RunState new_state);
249c17d615SPaolo Bonzini int runstate_is_running(void);
25ede085b3SHu Tao bool runstate_needs_reset(void);
269c17d615SPaolo Bonzini typedef struct vm_change_state_entry VMChangeStateEntry;
279c17d615SPaolo Bonzini typedef void VMChangeStateHandler(void *opaque, int running, RunState state);
289c17d615SPaolo Bonzini 
299c17d615SPaolo Bonzini VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
309c17d615SPaolo Bonzini                                                      void *opaque);
319c17d615SPaolo Bonzini void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
329c17d615SPaolo Bonzini void vm_state_notify(int running, RunState state);
339c17d615SPaolo Bonzini 
349c17d615SPaolo Bonzini #define VMRESET_SILENT   false
359c17d615SPaolo Bonzini #define VMRESET_REPORT   true
369c17d615SPaolo Bonzini 
379c17d615SPaolo Bonzini void vm_start(void);
389c17d615SPaolo Bonzini void vm_stop(RunState state);
399c17d615SPaolo Bonzini void vm_stop_force_state(RunState state);
409c17d615SPaolo Bonzini 
419c17d615SPaolo Bonzini typedef enum WakeupReason {
429c17d615SPaolo Bonzini     QEMU_WAKEUP_REASON_OTHER = 0,
439c17d615SPaolo Bonzini     QEMU_WAKEUP_REASON_RTC,
449c17d615SPaolo Bonzini     QEMU_WAKEUP_REASON_PMTIMER,
459c17d615SPaolo Bonzini } WakeupReason;
469c17d615SPaolo Bonzini 
479c17d615SPaolo Bonzini void qemu_system_reset_request(void);
489c17d615SPaolo Bonzini void qemu_system_suspend_request(void);
499c17d615SPaolo Bonzini void qemu_register_suspend_notifier(Notifier *notifier);
509c17d615SPaolo Bonzini void qemu_system_wakeup_request(WakeupReason reason);
519c17d615SPaolo Bonzini void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
529c17d615SPaolo Bonzini void qemu_register_wakeup_notifier(Notifier *notifier);
539c17d615SPaolo Bonzini void qemu_system_shutdown_request(void);
549c17d615SPaolo Bonzini void qemu_system_powerdown_request(void);
559c17d615SPaolo Bonzini void qemu_register_powerdown_notifier(Notifier *notifier);
569c17d615SPaolo Bonzini void qemu_system_debug_request(void);
579c17d615SPaolo Bonzini void qemu_system_vmstop_request(RunState reason);
589c17d615SPaolo Bonzini int qemu_shutdown_requested_get(void);
599c17d615SPaolo Bonzini int qemu_reset_requested_get(void);
609c17d615SPaolo Bonzini void qemu_system_killed(int signal, pid_t pid);
619c17d615SPaolo Bonzini void qemu_devices_reset(void);
629c17d615SPaolo Bonzini void qemu_system_reset(bool report);
639c17d615SPaolo Bonzini 
649c17d615SPaolo Bonzini void qemu_add_exit_notifier(Notifier *notify);
659c17d615SPaolo Bonzini void qemu_remove_exit_notifier(Notifier *notify);
669c17d615SPaolo Bonzini 
679c17d615SPaolo Bonzini void qemu_add_machine_init_done_notifier(Notifier *notify);
689c17d615SPaolo Bonzini 
699c17d615SPaolo Bonzini void do_savevm(Monitor *mon, const QDict *qdict);
709c17d615SPaolo Bonzini int load_vmstate(const char *name);
719c17d615SPaolo Bonzini void do_delvm(Monitor *mon, const QDict *qdict);
7284f2d0eaSWenchao Xia void do_info_snapshots(Monitor *mon, const QDict *qdict);
739c17d615SPaolo Bonzini 
749c17d615SPaolo Bonzini void qemu_announce_self(void);
759c17d615SPaolo Bonzini 
769c17d615SPaolo Bonzini bool qemu_savevm_state_blocked(Error **errp);
7747c8c17aSPaolo Bonzini void qemu_savevm_state_begin(QEMUFile *f,
789c17d615SPaolo Bonzini                              const MigrationParams *params);
799c17d615SPaolo Bonzini int qemu_savevm_state_iterate(QEMUFile *f);
8047c8c17aSPaolo Bonzini void qemu_savevm_state_complete(QEMUFile *f);
816522773fSJuan Quintela void qemu_savevm_state_cancel(void);
82e4ed1541SJuan Quintela uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
839c17d615SPaolo Bonzini int qemu_loadvm_state(QEMUFile *f);
849c17d615SPaolo Bonzini 
859c17d615SPaolo Bonzini /* SLIRP */
869c17d615SPaolo Bonzini void do_info_slirp(Monitor *mon);
879c17d615SPaolo Bonzini 
889c17d615SPaolo Bonzini typedef enum DisplayType
899c17d615SPaolo Bonzini {
909c17d615SPaolo Bonzini     DT_DEFAULT,
919c17d615SPaolo Bonzini     DT_CURSES,
929c17d615SPaolo Bonzini     DT_SDL,
93a4ccabcfSAnthony Liguori     DT_GTK,
949c17d615SPaolo Bonzini     DT_NOGRAPHIC,
959c17d615SPaolo Bonzini     DT_NONE,
969c17d615SPaolo Bonzini } DisplayType;
979c17d615SPaolo Bonzini 
989c17d615SPaolo Bonzini extern int autostart;
999c17d615SPaolo Bonzini 
1009c17d615SPaolo Bonzini typedef enum {
1019c17d615SPaolo Bonzini     VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
1029c17d615SPaolo Bonzini } VGAInterfaceType;
1039c17d615SPaolo Bonzini 
1049c17d615SPaolo Bonzini extern int vga_interface_type;
1059c17d615SPaolo Bonzini #define xenfb_enabled (vga_interface_type == VGA_XENFB)
1069c17d615SPaolo Bonzini #define qxl_enabled (vga_interface_type == VGA_QXL)
1079c17d615SPaolo Bonzini 
1089c17d615SPaolo Bonzini extern int graphic_width;
1099c17d615SPaolo Bonzini extern int graphic_height;
1109c17d615SPaolo Bonzini extern int graphic_depth;
1119c17d615SPaolo Bonzini extern DisplayType display_type;
1129c17d615SPaolo Bonzini extern const char *keyboard_layout;
1139c17d615SPaolo Bonzini extern int win2k_install_hack;
1149c17d615SPaolo Bonzini extern int alt_grab;
1159c17d615SPaolo Bonzini extern int ctrl_grab;
1169c17d615SPaolo Bonzini extern int smp_cpus;
1179c17d615SPaolo Bonzini extern int max_cpus;
1189c17d615SPaolo Bonzini extern int cursor_hide;
1199c17d615SPaolo Bonzini extern int graphic_rotate;
1209c17d615SPaolo Bonzini extern int no_quit;
1219c17d615SPaolo Bonzini extern int no_shutdown;
1229c17d615SPaolo Bonzini extern int semihosting_enabled;
1239c17d615SPaolo Bonzini extern int old_param;
1249c17d615SPaolo Bonzini extern int boot_menu;
1259c17d615SPaolo Bonzini extern uint8_t *boot_splash_filedata;
126d09acb9bSMarkus Armbruster extern size_t boot_splash_filedata_size;
1279c17d615SPaolo Bonzini extern uint8_t qemu_extra_params_fw[2];
1289c17d615SPaolo Bonzini extern QEMUClock *rtc_clock;
1299c17d615SPaolo Bonzini 
1309c17d615SPaolo Bonzini #define MAX_NODES 64
1319c17d615SPaolo Bonzini #define MAX_CPUMASK_BITS 255
1329c17d615SPaolo Bonzini extern int nb_numa_nodes;
1339c17d615SPaolo Bonzini extern uint64_t node_mem[MAX_NODES];
1349c17d615SPaolo Bonzini extern unsigned long *node_cpumask[MAX_NODES];
1359c17d615SPaolo Bonzini 
1369c17d615SPaolo Bonzini #define MAX_OPTION_ROMS 16
1379c17d615SPaolo Bonzini typedef struct QEMUOptionRom {
1389c17d615SPaolo Bonzini     const char *name;
1399c17d615SPaolo Bonzini     int32_t bootindex;
1409c17d615SPaolo Bonzini } QEMUOptionRom;
1419c17d615SPaolo Bonzini extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
1429c17d615SPaolo Bonzini extern int nb_option_roms;
1439c17d615SPaolo Bonzini 
1449c17d615SPaolo Bonzini #define MAX_PROM_ENVS 128
1459c17d615SPaolo Bonzini extern const char *prom_envs[MAX_PROM_ENVS];
1469c17d615SPaolo Bonzini extern unsigned int nb_prom_envs;
1479c17d615SPaolo Bonzini 
1489c17d615SPaolo Bonzini /* pci-hotplug */
1499c17d615SPaolo Bonzini void pci_device_hot_add(Monitor *mon, const QDict *qdict);
1509c17d615SPaolo Bonzini int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo);
1519c17d615SPaolo Bonzini void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
1529c17d615SPaolo Bonzini 
1539c17d615SPaolo Bonzini /* generic hotplug */
1549c17d615SPaolo Bonzini void drive_hot_add(Monitor *mon, const QDict *qdict);
1559c17d615SPaolo Bonzini 
156*066e9b27SIgor Mammedov /* CPU hotplug */
157*066e9b27SIgor Mammedov void qemu_register_cpu_added_notifier(Notifier *notifier);
158*066e9b27SIgor Mammedov 
1599c17d615SPaolo Bonzini /* pcie aer error injection */
1609c17d615SPaolo Bonzini void pcie_aer_inject_error_print(Monitor *mon, const QObject *data);
1619c17d615SPaolo Bonzini int do_pcie_aer_inject_error(Monitor *mon,
1629c17d615SPaolo Bonzini                              const QDict *qdict, QObject **ret_data);
1639c17d615SPaolo Bonzini 
1649c17d615SPaolo Bonzini /* serial ports */
1659c17d615SPaolo Bonzini 
1669c17d615SPaolo Bonzini #define MAX_SERIAL_PORTS 4
1679c17d615SPaolo Bonzini 
1689c17d615SPaolo Bonzini extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
1699c17d615SPaolo Bonzini 
1709c17d615SPaolo Bonzini /* parallel ports */
1719c17d615SPaolo Bonzini 
1729c17d615SPaolo Bonzini #define MAX_PARALLEL_PORTS 3
1739c17d615SPaolo Bonzini 
1749c17d615SPaolo Bonzini extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
1759c17d615SPaolo Bonzini 
1769c17d615SPaolo Bonzini void do_usb_add(Monitor *mon, const QDict *qdict);
1779c17d615SPaolo Bonzini void do_usb_del(Monitor *mon, const QDict *qdict);
17884f2d0eaSWenchao Xia void usb_info(Monitor *mon, const QDict *qdict);
1799c17d615SPaolo Bonzini 
1809c17d615SPaolo Bonzini void rtc_change_mon_event(struct tm *tm);
1819c17d615SPaolo Bonzini 
1829c17d615SPaolo Bonzini void add_boot_device_path(int32_t bootindex, DeviceState *dev,
1839c17d615SPaolo Bonzini                           const char *suffix);
1840e7a7592SMarkus Armbruster char *get_boot_devices_list(size_t *size);
1859c17d615SPaolo Bonzini 
1867dc5af55SDominik Dingel DeviceState *get_boot_device(uint32_t position);
1877dc5af55SDominik Dingel 
1889c17d615SPaolo Bonzini bool usb_enabled(bool default_usb);
1899c17d615SPaolo Bonzini 
1904d454574SPaolo Bonzini extern QemuOptsList qemu_drive_opts;
1914d454574SPaolo Bonzini extern QemuOptsList qemu_chardev_opts;
1924d454574SPaolo Bonzini extern QemuOptsList qemu_device_opts;
1934d454574SPaolo Bonzini extern QemuOptsList qemu_netdev_opts;
1944d454574SPaolo Bonzini extern QemuOptsList qemu_net_opts;
1954d454574SPaolo Bonzini extern QemuOptsList qemu_global_opts;
1964d454574SPaolo Bonzini extern QemuOptsList qemu_mon_opts;
1974d454574SPaolo Bonzini 
1989c17d615SPaolo Bonzini #endif
199