]> git.proxmox.com Git - mirror_qemu.git/blob - include/sysemu/sysemu.h
Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2018-02-07-v4' into staging
[mirror_qemu.git] / include / sysemu / sysemu.h
1 #ifndef SYSEMU_H
2 #define SYSEMU_H
3 /* Misc. things related to the system emulator. */
4
5 #include "qemu/queue.h"
6 #include "qemu/timer.h"
7 #include "qemu/notify.h"
8 #include "qemu/main-loop.h"
9 #include "qemu/bitmap.h"
10 #include "qemu/uuid.h"
11 #include "qom/object.h"
12
13 /* vl.c */
14
15 extern const char *bios_name;
16 extern const char *qemu_name;
17 extern QemuUUID qemu_uuid;
18 extern bool qemu_uuid_set;
19
20 bool runstate_check(RunState state);
21 void runstate_set(RunState new_state);
22 int runstate_is_running(void);
23 bool runstate_needs_reset(void);
24 bool runstate_store(char *str, size_t size);
25 typedef struct vm_change_state_entry VMChangeStateEntry;
26 typedef void VMChangeStateHandler(void *opaque, int running, RunState state);
27
28 VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
29 void *opaque);
30 void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
31 void vm_state_notify(int running, RunState state);
32
33 /* Enumeration of various causes for shutdown. */
34 typedef enum ShutdownCause {
35 SHUTDOWN_CAUSE_NONE, /* No shutdown request pending */
36 SHUTDOWN_CAUSE_HOST_ERROR, /* An error prevents further use of guest */
37 SHUTDOWN_CAUSE_HOST_QMP, /* Reaction to a QMP command, like 'quit' */
38 SHUTDOWN_CAUSE_HOST_SIGNAL, /* Reaction to a signal, such as SIGINT */
39 SHUTDOWN_CAUSE_HOST_UI, /* Reaction to UI event, like window close */
40 SHUTDOWN_CAUSE_GUEST_SHUTDOWN,/* Guest shutdown/suspend request, via
41 ACPI or other hardware-specific means */
42 SHUTDOWN_CAUSE_GUEST_RESET, /* Guest reset request, and command line
43 turns that into a shutdown */
44 SHUTDOWN_CAUSE_GUEST_PANIC, /* Guest panicked, and command line turns
45 that into a shutdown */
46 SHUTDOWN_CAUSE__MAX,
47 } ShutdownCause;
48
49 static inline bool shutdown_caused_by_guest(ShutdownCause cause)
50 {
51 return cause >= SHUTDOWN_CAUSE_GUEST_SHUTDOWN;
52 }
53
54 void vm_start(void);
55 int vm_prepare_start(void);
56 int vm_stop(RunState state);
57 int vm_stop_force_state(RunState state);
58
59 typedef enum WakeupReason {
60 /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */
61 QEMU_WAKEUP_REASON_NONE = 0,
62 QEMU_WAKEUP_REASON_RTC,
63 QEMU_WAKEUP_REASON_PMTIMER,
64 QEMU_WAKEUP_REASON_OTHER,
65 } WakeupReason;
66
67 void qemu_system_reset_request(ShutdownCause reason);
68 void qemu_system_suspend_request(void);
69 void qemu_register_suspend_notifier(Notifier *notifier);
70 void qemu_system_wakeup_request(WakeupReason reason);
71 void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
72 void qemu_register_wakeup_notifier(Notifier *notifier);
73 void qemu_system_shutdown_request(ShutdownCause reason);
74 void qemu_system_powerdown_request(void);
75 void qemu_register_powerdown_notifier(Notifier *notifier);
76 void qemu_system_debug_request(void);
77 void qemu_system_vmstop_request(RunState reason);
78 void qemu_system_vmstop_request_prepare(void);
79 bool qemu_vmstop_requested(RunState *r);
80 ShutdownCause qemu_shutdown_requested_get(void);
81 ShutdownCause qemu_reset_requested_get(void);
82 void qemu_system_killed(int signal, pid_t pid);
83 void qemu_system_reset(ShutdownCause reason);
84 void qemu_system_guest_panicked(GuestPanicInformation *info);
85
86 void qemu_add_exit_notifier(Notifier *notify);
87 void qemu_remove_exit_notifier(Notifier *notify);
88
89 void qemu_add_machine_init_done_notifier(Notifier *notify);
90 void qemu_remove_machine_init_done_notifier(Notifier *notify);
91
92 void qemu_announce_self(void);
93
94 extern int autostart;
95
96 typedef enum {
97 VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
98 VGA_TCX, VGA_CG3, VGA_DEVICE, VGA_VIRTIO,
99 VGA_TYPE_MAX,
100 } VGAInterfaceType;
101
102 extern int vga_interface_type;
103 #define xenfb_enabled (vga_interface_type == VGA_XENFB)
104
105 extern int graphic_width;
106 extern int graphic_height;
107 extern int graphic_depth;
108 extern int display_opengl;
109 extern const char *keyboard_layout;
110 extern int win2k_install_hack;
111 extern int alt_grab;
112 extern int ctrl_grab;
113 extern int no_frame;
114 extern int smp_cpus;
115 extern unsigned int max_cpus;
116 extern int cursor_hide;
117 extern int graphic_rotate;
118 extern int no_quit;
119 extern int no_shutdown;
120 extern int old_param;
121 extern int boot_menu;
122 extern bool boot_strict;
123 extern uint8_t *boot_splash_filedata;
124 extern size_t boot_splash_filedata_size;
125 extern bool enable_mlock;
126 extern uint8_t qemu_extra_params_fw[2];
127 extern QEMUClockType rtc_clock;
128 extern const char *mem_path;
129 extern int mem_prealloc;
130
131 #define MAX_NODES 128
132 #define NUMA_NODE_UNASSIGNED MAX_NODES
133 #define NUMA_DISTANCE_MIN 10
134 #define NUMA_DISTANCE_DEFAULT 20
135 #define NUMA_DISTANCE_MAX 254
136 #define NUMA_DISTANCE_UNREACHABLE 255
137
138 #define MAX_OPTION_ROMS 16
139 typedef struct QEMUOptionRom {
140 const char *name;
141 int32_t bootindex;
142 } QEMUOptionRom;
143 extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
144 extern int nb_option_roms;
145
146 #define MAX_PROM_ENVS 128
147 extern const char *prom_envs[MAX_PROM_ENVS];
148 extern unsigned int nb_prom_envs;
149
150 /* generic hotplug */
151 void hmp_drive_add(Monitor *mon, const QDict *qdict);
152
153 /* pcie aer error injection */
154 void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
155
156 /* serial ports */
157
158 #define MAX_SERIAL_PORTS 4
159
160 extern Chardev *serial_hds[MAX_SERIAL_PORTS];
161
162 /* parallel ports */
163
164 #define MAX_PARALLEL_PORTS 3
165
166 extern Chardev *parallel_hds[MAX_PARALLEL_PORTS];
167
168 void hmp_info_usb(Monitor *mon, const QDict *qdict);
169
170 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
171 const char *suffix);
172 char *get_boot_devices_list(size_t *size, bool ignore_suffixes);
173
174 DeviceState *get_boot_device(uint32_t position);
175 void check_boot_index(int32_t bootindex, Error **errp);
176 void del_boot_device_path(DeviceState *dev, const char *suffix);
177 void device_add_bootindex_property(Object *obj, int32_t *bootindex,
178 const char *name, const char *suffix,
179 DeviceState *dev, Error **errp);
180 void restore_boot_order(void *opaque);
181 void validate_bootdevices(const char *devices, Error **errp);
182
183 /* handler to set the boot_device order for a specific type of MachineClass */
184 typedef void QEMUBootSetHandler(void *opaque, const char *boot_order,
185 Error **errp);
186 void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
187 void qemu_boot_set(const char *boot_order, Error **errp);
188
189 QemuOpts *qemu_get_machine_opts(void);
190
191 bool defaults_enabled(void);
192
193 extern QemuOptsList qemu_legacy_drive_opts;
194 extern QemuOptsList qemu_common_drive_opts;
195 extern QemuOptsList qemu_drive_opts;
196 extern QemuOptsList bdrv_runtime_opts;
197 extern QemuOptsList qemu_chardev_opts;
198 extern QemuOptsList qemu_device_opts;
199 extern QemuOptsList qemu_netdev_opts;
200 extern QemuOptsList qemu_net_opts;
201 extern QemuOptsList qemu_global_opts;
202 extern QemuOptsList qemu_mon_opts;
203
204 #endif