root / vl.c @ f53f81e0
History | View | Annotate | Download (122.9 kB)
1 | 0824d6fc | bellard | /*
|
---|---|---|---|
2 | 80cabfad | bellard | * QEMU System Emulator
|
3 | 5fafdf24 | ths | *
|
4 | 68d0f70e | bellard | * Copyright (c) 2003-2008 Fabrice Bellard
|
5 | 5fafdf24 | ths | *
|
6 | 1df912cf | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 1df912cf | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | 1df912cf | bellard | * in the Software without restriction, including without limitation the rights
|
9 | 1df912cf | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 1df912cf | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | 1df912cf | bellard | * furnished to do so, subject to the following conditions:
|
12 | 1df912cf | bellard | *
|
13 | 1df912cf | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | 1df912cf | bellard | * all copies or substantial portions of the Software.
|
15 | 1df912cf | bellard | *
|
16 | 1df912cf | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 1df912cf | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 1df912cf | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 1df912cf | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 1df912cf | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 1df912cf | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 1df912cf | bellard | * THE SOFTWARE.
|
23 | 0824d6fc | bellard | */
|
24 | 0824d6fc | bellard | #include <unistd.h> |
25 | 0824d6fc | bellard | #include <fcntl.h> |
26 | 0824d6fc | bellard | #include <signal.h> |
27 | 0824d6fc | bellard | #include <time.h> |
28 | 0824d6fc | bellard | #include <errno.h> |
29 | 67b915a5 | bellard | #include <sys/time.h> |
30 | 67b915a5 | bellard | |
31 | d40cdb10 | blueswir1 | #include "config-host.h" |
32 | d40cdb10 | blueswir1 | |
33 | 452dfbef | Eduardo Otubo | #ifdef CONFIG_SECCOMP
|
34 | 9c17d615 | Paolo Bonzini | #include "sysemu/seccomp.h" |
35 | 452dfbef | Eduardo Otubo | #endif
|
36 | 452dfbef | Eduardo Otubo | |
37 | 8a16d273 | ths | #if defined(CONFIG_VDE)
|
38 | 8a16d273 | ths | #include <libvdeplug.h> |
39 | 8a16d273 | ths | #endif
|
40 | 8a16d273 | ths | |
41 | 73332e5c | bellard | #ifdef CONFIG_SDL
|
42 | 59a36a2f | Stefan Weil | #if defined(__APPLE__) || defined(main)
|
43 | 6693665a | Stefan Weil | #include <SDL.h> |
44 | 880fec5d | malc | int qemu_main(int argc, char **argv, char **envp); |
45 | 880fec5d | malc | int main(int argc, char **argv) |
46 | 880fec5d | malc | { |
47 | 59a36a2f | Stefan Weil | return qemu_main(argc, argv, NULL); |
48 | 880fec5d | malc | } |
49 | 880fec5d | malc | #undef main
|
50 | 880fec5d | malc | #define main qemu_main
|
51 | 96bcd4f8 | bellard | #endif
|
52 | 73332e5c | bellard | #endif /* CONFIG_SDL */ |
53 | 0824d6fc | bellard | |
54 | 5b0753e0 | bellard | #ifdef CONFIG_COCOA
|
55 | 5b0753e0 | bellard | #undef main
|
56 | 5b0753e0 | bellard | #define main qemu_main
|
57 | 5b0753e0 | bellard | #endif /* CONFIG_COCOA */ |
58 | 5b0753e0 | bellard | |
59 | 69e5bb68 | Anthony Liguori | #include <glib.h> |
60 | 69e5bb68 | Anthony Liguori | |
61 | 511d2b14 | blueswir1 | #include "hw/hw.h" |
62 | 511d2b14 | blueswir1 | #include "hw/boards.h" |
63 | 511d2b14 | blueswir1 | #include "hw/usb.h" |
64 | 511d2b14 | blueswir1 | #include "hw/pcmcia.h" |
65 | 0d09e41a | Paolo Bonzini | #include "hw/i386/pc.h" |
66 | 0d09e41a | Paolo Bonzini | #include "hw/isa/isa.h" |
67 | 511d2b14 | blueswir1 | #include "hw/bt.h" |
68 | 0d09e41a | Paolo Bonzini | #include "sysemu/watchdog.h" |
69 | 0d09e41a | Paolo Bonzini | #include "hw/i386/smbios.h" |
70 | 0d09e41a | Paolo Bonzini | #include "hw/xen/xen.h" |
71 | bd3c948d | Gerd Hoffmann | #include "hw/qdev.h" |
72 | 45a50b16 | Gerd Hoffmann | #include "hw/loader.h" |
73 | b4a42f81 | Paolo Bonzini | #include "monitor/qdev.h" |
74 | dccfcd0e | Paolo Bonzini | #include "sysemu/bt.h" |
75 | 1422e32d | Paolo Bonzini | #include "net/net.h" |
76 | 68ac40d2 | Mark McLoughlin | #include "net/slirp.h" |
77 | 83c9089e | Paolo Bonzini | #include "monitor/monitor.h" |
78 | 28ecbaee | Paolo Bonzini | #include "ui/console.h" |
79 | 9c17d615 | Paolo Bonzini | #include "sysemu/sysemu.h" |
80 | 022c62cb | Paolo Bonzini | #include "exec/gdbstub.h" |
81 | 1de7afc9 | Paolo Bonzini | #include "qemu/timer.h" |
82 | dccfcd0e | Paolo Bonzini | #include "sysemu/char.h" |
83 | b33276a7 | Michael Tokarev | #include "qemu/bitmap.h" |
84 | 1de7afc9 | Paolo Bonzini | #include "qemu/cache-utils.h" |
85 | 9c17d615 | Paolo Bonzini | #include "sysemu/blockdev.h" |
86 | 0d09e41a | Paolo Bonzini | #include "hw/block/block.h" |
87 | caf71f86 | Paolo Bonzini | #include "migration/block.h" |
88 | bdee56f5 | Paolo Bonzini | #include "sysemu/tpm.h" |
89 | 9c17d615 | Paolo Bonzini | #include "sysemu/dma.h" |
90 | 511d2b14 | blueswir1 | #include "audio/audio.h" |
91 | caf71f86 | Paolo Bonzini | #include "migration/migration.h" |
92 | 9c17d615 | Paolo Bonzini | #include "sysemu/kvm.h" |
93 | 7b1b5d19 | Paolo Bonzini | #include "qapi/qmp/qjson.h" |
94 | 1de7afc9 | Paolo Bonzini | #include "qemu/option.h" |
95 | 1de7afc9 | Paolo Bonzini | #include "qemu/config-file.h" |
96 | 59a5264b | Jes Sorensen | #include "qemu-options.h" |
97 | 1fa9a5e4 | Luiz Capitulino | #include "qmp-commands.h" |
98 | 1de7afc9 | Paolo Bonzini | #include "qemu/main-loop.h" |
99 | 758e8e38 | Venkateswararao Jujjuri (JV) | #ifdef CONFIG_VIRTFS
|
100 | 74db920c | Gautham R Shenoy | #include "fsdev/qemu-fsdev.h" |
101 | 74db920c | Gautham R Shenoy | #endif
|
102 | 9c17d615 | Paolo Bonzini | #include "sysemu/qtest.h" |
103 | 511d2b14 | blueswir1 | |
104 | 76cad711 | Paolo Bonzini | #include "disas/disas.h" |
105 | fc01f7e7 | bellard | |
106 | 1de7afc9 | Paolo Bonzini | #include "qemu/sockets.h" |
107 | 511d2b14 | blueswir1 | |
108 | d918f23e | Jan Kiszka | #include "slirp/libslirp.h" |
109 | 511d2b14 | blueswir1 | |
110 | 94b0b5ff | Stefan Hajnoczi | #include "trace.h" |
111 | e4858974 | Lluís | #include "trace/control.h" |
112 | 1de7afc9 | Paolo Bonzini | #include "qemu/queue.h" |
113 | 9c17d615 | Paolo Bonzini | #include "sysemu/cpus.h" |
114 | 9c17d615 | Paolo Bonzini | #include "sysemu/arch_init.h" |
115 | 1de7afc9 | Paolo Bonzini | #include "qemu/osdep.h" |
116 | 72cf2d4f | Blue Swirl | |
117 | 29b0040b | Gerd Hoffmann | #include "ui/qemu-spice.h" |
118 | 68d98d3e | Anthony Liguori | #include "qapi/string-input-visitor.h" |
119 | 269e09f3 | Igor Mammedov | #include "qom/object_interfaces.h" |
120 | 29b0040b | Gerd Hoffmann | |
121 | 1bfe856e | bellard | #define DEFAULT_RAM_SIZE 128 |
122 | 313aa567 | bellard | |
123 | 98b19252 | Amit Shah | #define MAX_VIRTIO_CONSOLES 1 |
124 | 3ef669e1 | Alexander Graf | #define MAX_SCLP_CONSOLES 1 |
125 | 98b19252 | Amit Shah | |
126 | 4524051c | Gerd Hoffmann | static const char *data_dir[16]; |
127 | 4524051c | Gerd Hoffmann | static int data_dir_idx; |
128 | 1192dad8 | j_mayer | const char *bios_name = NULL; |
129 | cb5a7aa8 | malc | enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
|
130 | 993fbfdb | Anthony Liguori | DisplayType display_type = DT_DEFAULT; |
131 | 4fdcac0e | Blue Swirl | static int display_remote; |
132 | 3d11d0eb | bellard | const char* keyboard_layout = NULL; |
133 | c227f099 | Anthony Liguori | ram_addr_t ram_size; |
134 | c902760f | Marcelo Tosatti | const char *mem_path = NULL; |
135 | c902760f | Marcelo Tosatti | int mem_prealloc = 0; /* force preallocation of physical target memory */ |
136 | c4b1fcc0 | bellard | int nb_nics;
|
137 | 7c9d8e07 | bellard | NICInfo nd_table[MAX_NICS]; |
138 | d399f677 | Paolo Bonzini | int autostart;
|
139 | f6503059 | balrog | static int rtc_utc = 1; |
140 | f6503059 | balrog | static int rtc_date_offset = -1; /* -1 means no change */ |
141 | 884f17c2 | Alex Bligh | QEMUClockType rtc_clock; |
142 | 64465297 | Gerd Hoffmann | int vga_interface_type = VGA_NONE;
|
143 | dbed7e40 | blueswir1 | static int full_screen = 0; |
144 | dbed7e40 | blueswir1 | static int no_frame = 0; |
145 | 667accab | ths | int no_quit = 0; |
146 | 8d11df9e | bellard | CharDriverState *serial_hds[MAX_SERIAL_PORTS]; |
147 | 6508fe59 | bellard | CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; |
148 | 9ede2fde | aliguori | CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; |
149 | 3ef669e1 | Alexander Graf | CharDriverState *sclp_hds[MAX_SCLP_CONSOLES]; |
150 | a09db21f | bellard | int win2k_install_hack = 0; |
151 | 1b530a6d | aurel32 | int singlestep = 0; |
152 | 6a00d601 | bellard | int smp_cpus = 1; |
153 | 6be68d7e | Jes Sorensen | int max_cpus = 0; |
154 | dc6b1c09 | Andre Przywara | int smp_cores = 1; |
155 | dc6b1c09 | Andre Przywara | int smp_threads = 1; |
156 | 821601ea | Jes Sorensen | #ifdef CONFIG_VNC
|
157 | 73fc9742 | ths | const char *vnc_display; |
158 | 821601ea | Jes Sorensen | #endif
|
159 | 6515b203 | bellard | int acpi_enabled = 1; |
160 | 16b29ae1 | aliguori | int no_hpet = 0; |
161 | 52ca8d6a | bellard | int fd_bootchk = 1; |
162 | 4fdcac0e | Blue Swirl | static int no_reboot; |
163 | b2f76161 | aurel32 | int no_shutdown = 0; |
164 | 9467cd46 | balrog | int cursor_hide = 1; |
165 | a171fe39 | balrog | int graphic_rotate = 0; |
166 | 09aaa160 | Markus Armbruster | const char *watchdog; |
167 | 2e55e842 | Gleb Natapov | QEMUOptionRom option_rom[MAX_OPTION_ROMS]; |
168 | 9ae02555 | ths | int nb_option_roms;
|
169 | 8e71621f | pbrook | int semihosting_enabled = 0; |
170 | 2b8f2d41 | balrog | int old_param = 0; |
171 | c35734b2 | ths | const char *qemu_name; |
172 | 3780e197 | ths | int alt_grab = 0; |
173 | 0ca9f8a4 | Dustin Kirkland | int ctrl_grab = 0; |
174 | 66508601 | blueswir1 | unsigned int nb_prom_envs = 0; |
175 | 66508601 | blueswir1 | const char *prom_envs[MAX_PROM_ENVS]; |
176 | 95387491 | Jan Kiszka | int boot_menu;
|
177 | 6f2bfda3 | Michael Tokarev | static bool boot_strict; |
178 | 3d3b8303 | wayne | uint8_t *boot_splash_filedata; |
179 | d09acb9b | Markus Armbruster | size_t boot_splash_filedata_size; |
180 | 3d3b8303 | wayne | uint8_t qemu_extra_params_fw[2];
|
181 | 0824d6fc | bellard | |
182 | 1ca4d09a | Gleb Natapov | typedef struct FWBootEntry FWBootEntry; |
183 | 1ca4d09a | Gleb Natapov | |
184 | 1ca4d09a | Gleb Natapov | struct FWBootEntry {
|
185 | 1ca4d09a | Gleb Natapov | QTAILQ_ENTRY(FWBootEntry) link; |
186 | 1ca4d09a | Gleb Natapov | int32_t bootindex; |
187 | 1ca4d09a | Gleb Natapov | DeviceState *dev; |
188 | 1ca4d09a | Gleb Natapov | char *suffix;
|
189 | 1ca4d09a | Gleb Natapov | }; |
190 | 1ca4d09a | Gleb Natapov | |
191 | 4fdcac0e | Blue Swirl | static QTAILQ_HEAD(, FWBootEntry) fw_boot_order =
|
192 | 4fdcac0e | Blue Swirl | QTAILQ_HEAD_INITIALIZER(fw_boot_order); |
193 | 1ca4d09a | Gleb Natapov | |
194 | 268a362c | aliguori | int nb_numa_nodes;
|
195 | 268a362c | aliguori | uint64_t node_mem[MAX_NODES]; |
196 | ee785fed | Chegu Vinod | unsigned long *node_cpumask[MAX_NODES]; |
197 | 268a362c | aliguori | |
198 | 8fcb1b90 | blueswir1 | uint8_t qemu_uuid[16];
|
199 | fc3b3295 | Markus Armbruster | bool qemu_uuid_set;
|
200 | 8fcb1b90 | blueswir1 | |
201 | 76e30d0f | Jan Kiszka | static QEMUBootSetHandler *boot_set_handler;
|
202 | 76e30d0f | Jan Kiszka | static void *boot_set_opaque; |
203 | 76e30d0f | Jan Kiszka | |
204 | fd42deeb | Gerd Hoffmann | static NotifierList exit_notifiers =
|
205 | fd42deeb | Gerd Hoffmann | NOTIFIER_LIST_INITIALIZER(exit_notifiers); |
206 | fd42deeb | Gerd Hoffmann | |
207 | 4cab946a | Gleb Natapov | static NotifierList machine_init_done_notifiers =
|
208 | 4cab946a | Gleb Natapov | NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); |
209 | 4cab946a | Gleb Natapov | |
210 | d5286af5 | liguang | static bool tcg_allowed = true; |
211 | d5286af5 | liguang | bool xen_allowed;
|
212 | d745bef8 | Blue Swirl | uint32_t xen_domid; |
213 | d745bef8 | Blue Swirl | enum xen_mode xen_mode = XEN_EMULATE;
|
214 | d5ab9713 | Jan Kiszka | static int tcg_tb_size; |
215 | d745bef8 | Blue Swirl | |
216 | 998bbd74 | Gerd Hoffmann | static int default_serial = 1; |
217 | 6a5e8b0e | Gerd Hoffmann | static int default_parallel = 1; |
218 | 986c5f78 | Gerd Hoffmann | static int default_virtcon = 1; |
219 | 3ef669e1 | Alexander Graf | static int default_sclp = 1; |
220 | abdeed06 | Gerd Hoffmann | static int default_monitor = 1; |
221 | ac33f8fa | Gerd Hoffmann | static int default_floppy = 1; |
222 | ac33f8fa | Gerd Hoffmann | static int default_cdrom = 1; |
223 | ac33f8fa | Gerd Hoffmann | static int default_sdcard = 1; |
224 | 7f1b17f2 | Paolo Bonzini | static int default_vga = 1; |
225 | 998bbd74 | Gerd Hoffmann | |
226 | 998bbd74 | Gerd Hoffmann | static struct { |
227 | 998bbd74 | Gerd Hoffmann | const char *driver; |
228 | 998bbd74 | Gerd Hoffmann | int *flag;
|
229 | 998bbd74 | Gerd Hoffmann | } default_list[] = { |
230 | 6a5e8b0e | Gerd Hoffmann | { .driver = "isa-serial", .flag = &default_serial },
|
231 | 6a5e8b0e | Gerd Hoffmann | { .driver = "isa-parallel", .flag = &default_parallel },
|
232 | d8bcbabf | Gerd Hoffmann | { .driver = "isa-fdc", .flag = &default_floppy },
|
233 | af6bf132 | Markus Armbruster | { .driver = "ide-cd", .flag = &default_cdrom },
|
234 | af6bf132 | Markus Armbruster | { .driver = "ide-hd", .flag = &default_cdrom },
|
235 | d8bcbabf | Gerd Hoffmann | { .driver = "ide-drive", .flag = &default_cdrom },
|
236 | af6bf132 | Markus Armbruster | { .driver = "scsi-cd", .flag = &default_cdrom },
|
237 | 392ecf54 | Amit Shah | { .driver = "virtio-serial-pci", .flag = &default_virtcon },
|
238 | 392ecf54 | Amit Shah | { .driver = "virtio-serial-s390", .flag = &default_virtcon },
|
239 | 392ecf54 | Amit Shah | { .driver = "virtio-serial", .flag = &default_virtcon },
|
240 | 7f1b17f2 | Paolo Bonzini | { .driver = "VGA", .flag = &default_vga },
|
241 | 7f1b17f2 | Paolo Bonzini | { .driver = "isa-vga", .flag = &default_vga },
|
242 | 7f1b17f2 | Paolo Bonzini | { .driver = "cirrus-vga", .flag = &default_vga },
|
243 | 7f1b17f2 | Paolo Bonzini | { .driver = "isa-cirrus-vga", .flag = &default_vga },
|
244 | 7f1b17f2 | Paolo Bonzini | { .driver = "vmware-svga", .flag = &default_vga },
|
245 | 7f1b17f2 | Paolo Bonzini | { .driver = "qxl-vga", .flag = &default_vga },
|
246 | 998bbd74 | Gerd Hoffmann | }; |
247 | 998bbd74 | Gerd Hoffmann | |
248 | 4d454574 | Paolo Bonzini | static QemuOptsList qemu_rtc_opts = {
|
249 | 4d454574 | Paolo Bonzini | .name = "rtc",
|
250 | 4d454574 | Paolo Bonzini | .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head), |
251 | 4d454574 | Paolo Bonzini | .desc = { |
252 | 4d454574 | Paolo Bonzini | { |
253 | 4d454574 | Paolo Bonzini | .name = "base",
|
254 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
255 | 4d454574 | Paolo Bonzini | },{ |
256 | 4d454574 | Paolo Bonzini | .name = "clock",
|
257 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
258 | 4d454574 | Paolo Bonzini | },{ |
259 | 4d454574 | Paolo Bonzini | .name = "driftfix",
|
260 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
261 | 4d454574 | Paolo Bonzini | }, |
262 | 4d454574 | Paolo Bonzini | { /* end of list */ }
|
263 | 4d454574 | Paolo Bonzini | }, |
264 | 4d454574 | Paolo Bonzini | }; |
265 | 4d454574 | Paolo Bonzini | |
266 | 4d454574 | Paolo Bonzini | static QemuOptsList qemu_sandbox_opts = {
|
267 | 4d454574 | Paolo Bonzini | .name = "sandbox",
|
268 | 4d454574 | Paolo Bonzini | .implied_opt_name = "enable",
|
269 | 4d454574 | Paolo Bonzini | .head = QTAILQ_HEAD_INITIALIZER(qemu_sandbox_opts.head), |
270 | 4d454574 | Paolo Bonzini | .desc = { |
271 | 4d454574 | Paolo Bonzini | { |
272 | 4d454574 | Paolo Bonzini | .name = "enable",
|
273 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_BOOL, |
274 | 4d454574 | Paolo Bonzini | }, |
275 | 4d454574 | Paolo Bonzini | { /* end of list */ }
|
276 | 4d454574 | Paolo Bonzini | }, |
277 | 4d454574 | Paolo Bonzini | }; |
278 | 4d454574 | Paolo Bonzini | |
279 | 4d454574 | Paolo Bonzini | static QemuOptsList qemu_trace_opts = {
|
280 | 4d454574 | Paolo Bonzini | .name = "trace",
|
281 | 4d454574 | Paolo Bonzini | .implied_opt_name = "trace",
|
282 | 4d454574 | Paolo Bonzini | .head = QTAILQ_HEAD_INITIALIZER(qemu_trace_opts.head), |
283 | 4d454574 | Paolo Bonzini | .desc = { |
284 | 4d454574 | Paolo Bonzini | { |
285 | 4d454574 | Paolo Bonzini | .name = "events",
|
286 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
287 | 4d454574 | Paolo Bonzini | },{ |
288 | 4d454574 | Paolo Bonzini | .name = "file",
|
289 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
290 | 4d454574 | Paolo Bonzini | }, |
291 | 4d454574 | Paolo Bonzini | { /* end of list */ }
|
292 | 4d454574 | Paolo Bonzini | }, |
293 | 4d454574 | Paolo Bonzini | }; |
294 | 4d454574 | Paolo Bonzini | |
295 | 4d454574 | Paolo Bonzini | static QemuOptsList qemu_option_rom_opts = {
|
296 | 4d454574 | Paolo Bonzini | .name = "option-rom",
|
297 | 4d454574 | Paolo Bonzini | .implied_opt_name = "romfile",
|
298 | 4d454574 | Paolo Bonzini | .head = QTAILQ_HEAD_INITIALIZER(qemu_option_rom_opts.head), |
299 | 4d454574 | Paolo Bonzini | .desc = { |
300 | 4d454574 | Paolo Bonzini | { |
301 | 4d454574 | Paolo Bonzini | .name = "bootindex",
|
302 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_NUMBER, |
303 | 4d454574 | Paolo Bonzini | }, { |
304 | 4d454574 | Paolo Bonzini | .name = "romfile",
|
305 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
306 | 4d454574 | Paolo Bonzini | }, |
307 | 4d454574 | Paolo Bonzini | { /* end of list */ }
|
308 | 4d454574 | Paolo Bonzini | }, |
309 | 4d454574 | Paolo Bonzini | }; |
310 | 4d454574 | Paolo Bonzini | |
311 | 4d454574 | Paolo Bonzini | static QemuOptsList qemu_machine_opts = {
|
312 | 4d454574 | Paolo Bonzini | .name = "machine",
|
313 | 4d454574 | Paolo Bonzini | .implied_opt_name = "type",
|
314 | 4d454574 | Paolo Bonzini | .merge_lists = true,
|
315 | 4d454574 | Paolo Bonzini | .head = QTAILQ_HEAD_INITIALIZER(qemu_machine_opts.head), |
316 | 4d454574 | Paolo Bonzini | .desc = { |
317 | 4d454574 | Paolo Bonzini | { |
318 | 4d454574 | Paolo Bonzini | .name = "type",
|
319 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
320 | 4d454574 | Paolo Bonzini | .help = "emulated machine"
|
321 | 4d454574 | Paolo Bonzini | }, { |
322 | 4d454574 | Paolo Bonzini | .name = "accel",
|
323 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
324 | 4d454574 | Paolo Bonzini | .help = "accelerator list",
|
325 | 4d454574 | Paolo Bonzini | }, { |
326 | 4d454574 | Paolo Bonzini | .name = "kernel_irqchip",
|
327 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_BOOL, |
328 | 4d454574 | Paolo Bonzini | .help = "use KVM in-kernel irqchip",
|
329 | 4d454574 | Paolo Bonzini | }, { |
330 | 4d454574 | Paolo Bonzini | .name = "kvm_shadow_mem",
|
331 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_SIZE, |
332 | 4d454574 | Paolo Bonzini | .help = "KVM shadow MMU size",
|
333 | 4d454574 | Paolo Bonzini | }, { |
334 | 4d454574 | Paolo Bonzini | .name = "kernel",
|
335 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
336 | 4d454574 | Paolo Bonzini | .help = "Linux kernel image file",
|
337 | 4d454574 | Paolo Bonzini | }, { |
338 | 4d454574 | Paolo Bonzini | .name = "initrd",
|
339 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
340 | 4d454574 | Paolo Bonzini | .help = "Linux initial ramdisk file",
|
341 | 4d454574 | Paolo Bonzini | }, { |
342 | 4d454574 | Paolo Bonzini | .name = "append",
|
343 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
344 | 4d454574 | Paolo Bonzini | .help = "Linux kernel command line",
|
345 | 4d454574 | Paolo Bonzini | }, { |
346 | 4d454574 | Paolo Bonzini | .name = "dtb",
|
347 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
348 | 4d454574 | Paolo Bonzini | .help = "Linux kernel device tree file",
|
349 | 4d454574 | Paolo Bonzini | }, { |
350 | 4d454574 | Paolo Bonzini | .name = "dumpdtb",
|
351 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
352 | 4d454574 | Paolo Bonzini | .help = "Dump current dtb to a file and quit",
|
353 | 4d454574 | Paolo Bonzini | }, { |
354 | 4d454574 | Paolo Bonzini | .name = "phandle_start",
|
355 | c1b71b0c | Markus Armbruster | .type = QEMU_OPT_NUMBER, |
356 | 4d454574 | Paolo Bonzini | .help = "The first phandle ID we may generate dynamically",
|
357 | 4d454574 | Paolo Bonzini | }, { |
358 | 4d454574 | Paolo Bonzini | .name = "dt_compatible",
|
359 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
360 | 4d454574 | Paolo Bonzini | .help = "Overrides the \"compatible\" property of the dt root node",
|
361 | 4d454574 | Paolo Bonzini | }, { |
362 | 4d454574 | Paolo Bonzini | .name = "dump-guest-core",
|
363 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_BOOL, |
364 | 4d454574 | Paolo Bonzini | .help = "Include guest memory in a core dump",
|
365 | 4d454574 | Paolo Bonzini | }, { |
366 | 4d454574 | Paolo Bonzini | .name = "mem-merge",
|
367 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_BOOL, |
368 | 4d454574 | Paolo Bonzini | .help = "enable/disable memory merge support",
|
369 | 4d454574 | Paolo Bonzini | },{ |
370 | 4d454574 | Paolo Bonzini | .name = "usb",
|
371 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_BOOL, |
372 | 4d454574 | Paolo Bonzini | .help = "Set on/off to enable/disable usb",
|
373 | 1442d3e6 | Gerd Hoffmann | },{ |
374 | 1442d3e6 | Gerd Hoffmann | .name = "firmware",
|
375 | 1442d3e6 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
376 | 1442d3e6 | Gerd Hoffmann | .help = "firmware image",
|
377 | 135a129a | Aneesh Kumar K.V | },{ |
378 | 135a129a | Aneesh Kumar K.V | .name = "kvm-type",
|
379 | 135a129a | Aneesh Kumar K.V | .type = QEMU_OPT_STRING, |
380 | 135a129a | Aneesh Kumar K.V | .help = "Specifies the KVM virtualization mode (HV, PR)",
|
381 | 4d454574 | Paolo Bonzini | }, |
382 | 4d454574 | Paolo Bonzini | { /* End of list */ }
|
383 | 4d454574 | Paolo Bonzini | }, |
384 | 4d454574 | Paolo Bonzini | }; |
385 | 4d454574 | Paolo Bonzini | |
386 | 4d454574 | Paolo Bonzini | static QemuOptsList qemu_boot_opts = {
|
387 | 4d454574 | Paolo Bonzini | .name = "boot-opts",
|
388 | 6ef4716c | Markus Armbruster | .implied_opt_name = "order",
|
389 | 6ef4716c | Markus Armbruster | .merge_lists = true,
|
390 | 4d454574 | Paolo Bonzini | .head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head), |
391 | 4d454574 | Paolo Bonzini | .desc = { |
392 | 4d454574 | Paolo Bonzini | { |
393 | 4d454574 | Paolo Bonzini | .name = "order",
|
394 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
395 | 4d454574 | Paolo Bonzini | }, { |
396 | 4d454574 | Paolo Bonzini | .name = "once",
|
397 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
398 | 4d454574 | Paolo Bonzini | }, { |
399 | 4d454574 | Paolo Bonzini | .name = "menu",
|
400 | 6ef4716c | Markus Armbruster | .type = QEMU_OPT_BOOL, |
401 | 4d454574 | Paolo Bonzini | }, { |
402 | 4d454574 | Paolo Bonzini | .name = "splash",
|
403 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
404 | 4d454574 | Paolo Bonzini | }, { |
405 | 4d454574 | Paolo Bonzini | .name = "splash-time",
|
406 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
407 | 4d454574 | Paolo Bonzini | }, { |
408 | 4d454574 | Paolo Bonzini | .name = "reboot-timeout",
|
409 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
410 | c8a6ae8b | Amos Kong | }, { |
411 | c8a6ae8b | Amos Kong | .name = "strict",
|
412 | e5187b56 | Amos Kong | .type = QEMU_OPT_BOOL, |
413 | 4d454574 | Paolo Bonzini | }, |
414 | 4d454574 | Paolo Bonzini | { /*End of list */ }
|
415 | 4d454574 | Paolo Bonzini | }, |
416 | 4d454574 | Paolo Bonzini | }; |
417 | 4d454574 | Paolo Bonzini | |
418 | 4d454574 | Paolo Bonzini | static QemuOptsList qemu_add_fd_opts = {
|
419 | 4d454574 | Paolo Bonzini | .name = "add-fd",
|
420 | 4d454574 | Paolo Bonzini | .head = QTAILQ_HEAD_INITIALIZER(qemu_add_fd_opts.head), |
421 | 4d454574 | Paolo Bonzini | .desc = { |
422 | 4d454574 | Paolo Bonzini | { |
423 | 4d454574 | Paolo Bonzini | .name = "fd",
|
424 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_NUMBER, |
425 | 4d454574 | Paolo Bonzini | .help = "file descriptor of which a duplicate is added to fd set",
|
426 | 4d454574 | Paolo Bonzini | },{ |
427 | 4d454574 | Paolo Bonzini | .name = "set",
|
428 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_NUMBER, |
429 | 4d454574 | Paolo Bonzini | .help = "ID of the fd set to add fd to",
|
430 | 4d454574 | Paolo Bonzini | },{ |
431 | 4d454574 | Paolo Bonzini | .name = "opaque",
|
432 | 4d454574 | Paolo Bonzini | .type = QEMU_OPT_STRING, |
433 | 4d454574 | Paolo Bonzini | .help = "free-form string used to describe fd",
|
434 | 4d454574 | Paolo Bonzini | }, |
435 | 4d454574 | Paolo Bonzini | { /* end of list */ }
|
436 | 4d454574 | Paolo Bonzini | }, |
437 | 4d454574 | Paolo Bonzini | }; |
438 | 4d454574 | Paolo Bonzini | |
439 | 4d454574 | Paolo Bonzini | static QemuOptsList qemu_object_opts = {
|
440 | 4d454574 | Paolo Bonzini | .name = "object",
|
441 | 4d454574 | Paolo Bonzini | .implied_opt_name = "qom-type",
|
442 | 4d454574 | Paolo Bonzini | .head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head), |
443 | 4d454574 | Paolo Bonzini | .desc = { |
444 | 4d454574 | Paolo Bonzini | { } |
445 | 4d454574 | Paolo Bonzini | }, |
446 | 4d454574 | Paolo Bonzini | }; |
447 | 4d454574 | Paolo Bonzini | |
448 | d1a0cf73 | Stefan Berger | static QemuOptsList qemu_tpmdev_opts = {
|
449 | d1a0cf73 | Stefan Berger | .name = "tpmdev",
|
450 | d1a0cf73 | Stefan Berger | .implied_opt_name = "type",
|
451 | d1a0cf73 | Stefan Berger | .head = QTAILQ_HEAD_INITIALIZER(qemu_tpmdev_opts.head), |
452 | d1a0cf73 | Stefan Berger | .desc = { |
453 | bb716238 | Stefan Berger | /* options are defined in the TPM backends */
|
454 | d1a0cf73 | Stefan Berger | { /* end of list */ }
|
455 | d1a0cf73 | Stefan Berger | }, |
456 | d1a0cf73 | Stefan Berger | }; |
457 | d1a0cf73 | Stefan Berger | |
458 | 888a6bc6 | Satoru Moriya | static QemuOptsList qemu_realtime_opts = {
|
459 | 888a6bc6 | Satoru Moriya | .name = "realtime",
|
460 | 888a6bc6 | Satoru Moriya | .head = QTAILQ_HEAD_INITIALIZER(qemu_realtime_opts.head), |
461 | 888a6bc6 | Satoru Moriya | .desc = { |
462 | 888a6bc6 | Satoru Moriya | { |
463 | 888a6bc6 | Satoru Moriya | .name = "mlock",
|
464 | 888a6bc6 | Satoru Moriya | .type = QEMU_OPT_BOOL, |
465 | 888a6bc6 | Satoru Moriya | }, |
466 | 888a6bc6 | Satoru Moriya | { /* end of list */ }
|
467 | 888a6bc6 | Satoru Moriya | }, |
468 | 888a6bc6 | Satoru Moriya | }; |
469 | 888a6bc6 | Satoru Moriya | |
470 | 5e2ac519 | Seiji Aguchi | static QemuOptsList qemu_msg_opts = {
|
471 | 5e2ac519 | Seiji Aguchi | .name = "msg",
|
472 | 5e2ac519 | Seiji Aguchi | .head = QTAILQ_HEAD_INITIALIZER(qemu_msg_opts.head), |
473 | 5e2ac519 | Seiji Aguchi | .desc = { |
474 | 5e2ac519 | Seiji Aguchi | { |
475 | 5e2ac519 | Seiji Aguchi | .name = "timestamp",
|
476 | 5e2ac519 | Seiji Aguchi | .type = QEMU_OPT_BOOL, |
477 | 5e2ac519 | Seiji Aguchi | }, |
478 | 5e2ac519 | Seiji Aguchi | { /* end of list */ }
|
479 | 5e2ac519 | Seiji Aguchi | }, |
480 | 5e2ac519 | Seiji Aguchi | }; |
481 | 5e2ac519 | Seiji Aguchi | |
482 | 7f9d6e54 | Markus Armbruster | /**
|
483 | 7f9d6e54 | Markus Armbruster | * Get machine options
|
484 | 7f9d6e54 | Markus Armbruster | *
|
485 | 7f9d6e54 | Markus Armbruster | * Returns: machine options (never null).
|
486 | 7f9d6e54 | Markus Armbruster | */
|
487 | 7f9d6e54 | Markus Armbruster | QemuOpts *qemu_get_machine_opts(void)
|
488 | 7f9d6e54 | Markus Armbruster | { |
489 | 7f9d6e54 | Markus Armbruster | QemuOptsList *list; |
490 | 7f9d6e54 | Markus Armbruster | QemuOpts *opts; |
491 | 7f9d6e54 | Markus Armbruster | |
492 | 7f9d6e54 | Markus Armbruster | list = qemu_find_opts("machine");
|
493 | 7f9d6e54 | Markus Armbruster | assert(list); |
494 | 7f9d6e54 | Markus Armbruster | opts = qemu_opts_find(list, NULL);
|
495 | 7f9d6e54 | Markus Armbruster | if (!opts) {
|
496 | 87ea75d5 | Peter Crosthwaite | opts = qemu_opts_create(list, NULL, 0, &error_abort); |
497 | 7f9d6e54 | Markus Armbruster | } |
498 | 7f9d6e54 | Markus Armbruster | return opts;
|
499 | 7f9d6e54 | Markus Armbruster | } |
500 | 7f9d6e54 | Markus Armbruster | |
501 | 31459f46 | Ronnie Sahlberg | const char *qemu_get_vm_name(void) |
502 | 31459f46 | Ronnie Sahlberg | { |
503 | 31459f46 | Ronnie Sahlberg | return qemu_name;
|
504 | 31459f46 | Ronnie Sahlberg | } |
505 | 31459f46 | Ronnie Sahlberg | |
506 | 3d3b8303 | wayne | static void res_free(void) |
507 | 3d3b8303 | wayne | { |
508 | 3d3b8303 | wayne | if (boot_splash_filedata != NULL) { |
509 | 7267c094 | Anthony Liguori | g_free(boot_splash_filedata); |
510 | 3d3b8303 | wayne | boot_splash_filedata = NULL;
|
511 | 3d3b8303 | wayne | } |
512 | 3d3b8303 | wayne | } |
513 | 3d3b8303 | wayne | |
514 | 998bbd74 | Gerd Hoffmann | static int default_driver_check(QemuOpts *opts, void *opaque) |
515 | 998bbd74 | Gerd Hoffmann | { |
516 | 998bbd74 | Gerd Hoffmann | const char *driver = qemu_opt_get(opts, "driver"); |
517 | 998bbd74 | Gerd Hoffmann | int i;
|
518 | 998bbd74 | Gerd Hoffmann | |
519 | 998bbd74 | Gerd Hoffmann | if (!driver)
|
520 | 998bbd74 | Gerd Hoffmann | return 0; |
521 | 998bbd74 | Gerd Hoffmann | for (i = 0; i < ARRAY_SIZE(default_list); i++) { |
522 | 998bbd74 | Gerd Hoffmann | if (strcmp(default_list[i].driver, driver) != 0) |
523 | 998bbd74 | Gerd Hoffmann | continue;
|
524 | 998bbd74 | Gerd Hoffmann | *(default_list[i].flag) = 0;
|
525 | 998bbd74 | Gerd Hoffmann | } |
526 | 998bbd74 | Gerd Hoffmann | return 0; |
527 | 998bbd74 | Gerd Hoffmann | } |
528 | 998bbd74 | Gerd Hoffmann | |
529 | 0824d6fc | bellard | /***********************************************************/
|
530 | f5bbfba1 | Luiz Capitulino | /* QEMU state */
|
531 | f5bbfba1 | Luiz Capitulino | |
532 | 0461d5a6 | Luiz Capitulino | static RunState current_run_state = RUN_STATE_PRELAUNCH;
|
533 | f5bbfba1 | Luiz Capitulino | |
534 | 5db9d4d1 | Luiz Capitulino | typedef struct { |
535 | 5db9d4d1 | Luiz Capitulino | RunState from; |
536 | 5db9d4d1 | Luiz Capitulino | RunState to; |
537 | 5db9d4d1 | Luiz Capitulino | } RunStateTransition; |
538 | 5db9d4d1 | Luiz Capitulino | |
539 | 5db9d4d1 | Luiz Capitulino | static const RunStateTransition runstate_transitions_def[] = { |
540 | 5db9d4d1 | Luiz Capitulino | /* from -> to */
|
541 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_DEBUG, RUN_STATE_RUNNING }, |
542 | eca01d3a | Paolo Bonzini | { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE }, |
543 | 5db9d4d1 | Luiz Capitulino | |
544 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_INMIGRATE, RUN_STATE_RUNNING }, |
545 | 29ed72f1 | Paolo Bonzini | { RUN_STATE_INMIGRATE, RUN_STATE_PAUSED }, |
546 | 5db9d4d1 | Luiz Capitulino | |
547 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED }, |
548 | 8a9236f1 | Luiz Capitulino | { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE }, |
549 | 5db9d4d1 | Luiz Capitulino | |
550 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING }, |
551 | 8a9236f1 | Luiz Capitulino | { RUN_STATE_IO_ERROR, RUN_STATE_FINISH_MIGRATE }, |
552 | 5db9d4d1 | Luiz Capitulino | |
553 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_PAUSED, RUN_STATE_RUNNING }, |
554 | 8a9236f1 | Luiz Capitulino | { RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE }, |
555 | 5db9d4d1 | Luiz Capitulino | |
556 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, |
557 | 8a9236f1 | Luiz Capitulino | { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, |
558 | 5db9d4d1 | Luiz Capitulino | |
559 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, |
560 | 8a9236f1 | Luiz Capitulino | { RUN_STATE_PRELAUNCH, RUN_STATE_FINISH_MIGRATE }, |
561 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, |
562 | 5db9d4d1 | Luiz Capitulino | |
563 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING }, |
564 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE }, |
565 | 5db9d4d1 | Luiz Capitulino | |
566 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, |
567 | 5db9d4d1 | Luiz Capitulino | |
568 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, |
569 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR }, |
570 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_RUNNING, RUN_STATE_IO_ERROR }, |
571 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_RUNNING, RUN_STATE_PAUSED }, |
572 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_RUNNING, RUN_STATE_FINISH_MIGRATE }, |
573 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_RUNNING, RUN_STATE_RESTORE_VM }, |
574 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_RUNNING, RUN_STATE_SAVE_VM }, |
575 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_RUNNING, RUN_STATE_SHUTDOWN }, |
576 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG }, |
577 | ede085b3 | Hu Tao | { RUN_STATE_RUNNING, RUN_STATE_GUEST_PANICKED }, |
578 | 5db9d4d1 | Luiz Capitulino | |
579 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, |
580 | 5db9d4d1 | Luiz Capitulino | |
581 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED }, |
582 | 8a9236f1 | Luiz Capitulino | { RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE }, |
583 | 5db9d4d1 | Luiz Capitulino | |
584 | ad02b96a | Luiz Capitulino | { RUN_STATE_DEBUG, RUN_STATE_SUSPENDED }, |
585 | ad02b96a | Luiz Capitulino | { RUN_STATE_RUNNING, RUN_STATE_SUSPENDED }, |
586 | ad02b96a | Luiz Capitulino | { RUN_STATE_SUSPENDED, RUN_STATE_RUNNING }, |
587 | ad02b96a | Luiz Capitulino | { RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE }, |
588 | ad02b96a | Luiz Capitulino | |
589 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, |
590 | 8a9236f1 | Luiz Capitulino | { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, |
591 | 5db9d4d1 | Luiz Capitulino | |
592 | df390768 | Paolo Bonzini | { RUN_STATE_GUEST_PANICKED, RUN_STATE_RUNNING }, |
593 | fd2a2e1c | Hu Tao | { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE }, |
594 | ede085b3 | Hu Tao | |
595 | 0461d5a6 | Luiz Capitulino | { RUN_STATE_MAX, RUN_STATE_MAX }, |
596 | 5db9d4d1 | Luiz Capitulino | }; |
597 | 5db9d4d1 | Luiz Capitulino | |
598 | 0461d5a6 | Luiz Capitulino | static bool runstate_valid_transitions[RUN_STATE_MAX][RUN_STATE_MAX]; |
599 | 0461d5a6 | Luiz Capitulino | |
600 | f5bbfba1 | Luiz Capitulino | bool runstate_check(RunState state)
|
601 | f5bbfba1 | Luiz Capitulino | { |
602 | f5bbfba1 | Luiz Capitulino | return current_run_state == state;
|
603 | f5bbfba1 | Luiz Capitulino | } |
604 | f5bbfba1 | Luiz Capitulino | |
605 | 4fdcac0e | Blue Swirl | static void runstate_init(void) |
606 | 5db9d4d1 | Luiz Capitulino | { |
607 | 5db9d4d1 | Luiz Capitulino | const RunStateTransition *p;
|
608 | 5db9d4d1 | Luiz Capitulino | |
609 | 5db9d4d1 | Luiz Capitulino | memset(&runstate_valid_transitions, 0, sizeof(runstate_valid_transitions)); |
610 | 5db9d4d1 | Luiz Capitulino | |
611 | 0461d5a6 | Luiz Capitulino | for (p = &runstate_transitions_def[0]; p->from != RUN_STATE_MAX; p++) { |
612 | 5db9d4d1 | Luiz Capitulino | runstate_valid_transitions[p->from][p->to] = true;
|
613 | 5db9d4d1 | Luiz Capitulino | } |
614 | 5db9d4d1 | Luiz Capitulino | } |
615 | 5db9d4d1 | Luiz Capitulino | |
616 | 5db9d4d1 | Luiz Capitulino | /* This function will abort() on invalid state transitions */
|
617 | f5bbfba1 | Luiz Capitulino | void runstate_set(RunState new_state)
|
618 | f5bbfba1 | Luiz Capitulino | { |
619 | 207c5cd2 | Luiz Capitulino | assert(new_state < RUN_STATE_MAX); |
620 | 207c5cd2 | Luiz Capitulino | |
621 | 207c5cd2 | Luiz Capitulino | if (!runstate_valid_transitions[current_run_state][new_state]) {
|
622 | 207c5cd2 | Luiz Capitulino | fprintf(stderr, "ERROR: invalid runstate transition: '%s' -> '%s'\n",
|
623 | 207c5cd2 | Luiz Capitulino | RunState_lookup[current_run_state], |
624 | 207c5cd2 | Luiz Capitulino | RunState_lookup[new_state]); |
625 | 5db9d4d1 | Luiz Capitulino | abort(); |
626 | 5db9d4d1 | Luiz Capitulino | } |
627 | 7e866003 | Kazuya Saito | trace_runstate_set(new_state); |
628 | f5bbfba1 | Luiz Capitulino | current_run_state = new_state; |
629 | f5bbfba1 | Luiz Capitulino | } |
630 | f5bbfba1 | Luiz Capitulino | |
631 | 1fa9a5e4 | Luiz Capitulino | int runstate_is_running(void) |
632 | 9e37b9dc | Luiz Capitulino | { |
633 | 1fa9a5e4 | Luiz Capitulino | return runstate_check(RUN_STATE_RUNNING);
|
634 | 9e37b9dc | Luiz Capitulino | } |
635 | 9e37b9dc | Luiz Capitulino | |
636 | ede085b3 | Hu Tao | bool runstate_needs_reset(void) |
637 | ede085b3 | Hu Tao | { |
638 | ede085b3 | Hu Tao | return runstate_check(RUN_STATE_INTERNAL_ERROR) ||
|
639 | df390768 | Paolo Bonzini | runstate_check(RUN_STATE_SHUTDOWN); |
640 | ede085b3 | Hu Tao | } |
641 | ede085b3 | Hu Tao | |
642 | 1fa9a5e4 | Luiz Capitulino | StatusInfo *qmp_query_status(Error **errp) |
643 | 1354869c | Luiz Capitulino | { |
644 | 1fa9a5e4 | Luiz Capitulino | StatusInfo *info = g_malloc0(sizeof(*info));
|
645 | 1fa9a5e4 | Luiz Capitulino | |
646 | 1fa9a5e4 | Luiz Capitulino | info->running = runstate_is_running(); |
647 | 1fa9a5e4 | Luiz Capitulino | info->singlestep = singlestep; |
648 | 1fa9a5e4 | Luiz Capitulino | info->status = current_run_state; |
649 | 1fa9a5e4 | Luiz Capitulino | |
650 | 1fa9a5e4 | Luiz Capitulino | return info;
|
651 | 1354869c | Luiz Capitulino | } |
652 | 1354869c | Luiz Capitulino | |
653 | f5bbfba1 | Luiz Capitulino | /***********************************************************/
|
654 | 8f0056b7 | Paolo Bonzini | /* real time host monotonic timer */
|
655 | 09b26c5e | bellard | |
656 | c4b1fcc0 | bellard | /***********************************************************/
|
657 | f6503059 | balrog | /* host time/date access */
|
658 | f6503059 | balrog | void qemu_get_timedate(struct tm *tm, int offset) |
659 | f6503059 | balrog | { |
660 | f6503059 | balrog | time_t ti; |
661 | f6503059 | balrog | |
662 | f6503059 | balrog | time(&ti); |
663 | f6503059 | balrog | ti += offset; |
664 | f6503059 | balrog | if (rtc_date_offset == -1) { |
665 | f6503059 | balrog | if (rtc_utc)
|
666 | eb7ff6fb | Stefan Weil | gmtime_r(&ti, tm); |
667 | f6503059 | balrog | else
|
668 | eb7ff6fb | Stefan Weil | localtime_r(&ti, tm); |
669 | f6503059 | balrog | } else {
|
670 | f6503059 | balrog | ti -= rtc_date_offset; |
671 | eb7ff6fb | Stefan Weil | gmtime_r(&ti, tm); |
672 | f6503059 | balrog | } |
673 | f6503059 | balrog | } |
674 | f6503059 | balrog | |
675 | f6503059 | balrog | int qemu_timedate_diff(struct tm *tm) |
676 | f6503059 | balrog | { |
677 | f6503059 | balrog | time_t seconds; |
678 | f6503059 | balrog | |
679 | f6503059 | balrog | if (rtc_date_offset == -1) |
680 | f6503059 | balrog | if (rtc_utc)
|
681 | f6503059 | balrog | seconds = mktimegm(tm); |
682 | f54c556c | Gleb Natapov | else {
|
683 | f54c556c | Gleb Natapov | struct tm tmp = *tm;
|
684 | f54c556c | Gleb Natapov | tmp.tm_isdst = -1; /* use timezone to figure it out */ |
685 | f54c556c | Gleb Natapov | seconds = mktime(&tmp); |
686 | f54c556c | Gleb Natapov | } |
687 | f6503059 | balrog | else
|
688 | f6503059 | balrog | seconds = mktimegm(tm) + rtc_date_offset; |
689 | f6503059 | balrog | |
690 | f6503059 | balrog | return seconds - time(NULL); |
691 | f6503059 | balrog | } |
692 | f6503059 | balrog | |
693 | 80cd3478 | Luiz Capitulino | void rtc_change_mon_event(struct tm *tm) |
694 | 80cd3478 | Luiz Capitulino | { |
695 | 80cd3478 | Luiz Capitulino | QObject *data; |
696 | 80cd3478 | Luiz Capitulino | |
697 | 80cd3478 | Luiz Capitulino | data = qobject_from_jsonf("{ 'offset': %d }", qemu_timedate_diff(tm));
|
698 | 80cd3478 | Luiz Capitulino | monitor_protocol_event(QEVENT_RTC_CHANGE, data); |
699 | 80cd3478 | Luiz Capitulino | qobject_decref(data); |
700 | 80cd3478 | Luiz Capitulino | } |
701 | 80cd3478 | Luiz Capitulino | |
702 | 1ed2fc1f | Jan Kiszka | static void configure_rtc_date_offset(const char *startdate, int legacy) |
703 | 1ed2fc1f | Jan Kiszka | { |
704 | 1ed2fc1f | Jan Kiszka | time_t rtc_start_date; |
705 | 1ed2fc1f | Jan Kiszka | struct tm tm;
|
706 | 1ed2fc1f | Jan Kiszka | |
707 | 1ed2fc1f | Jan Kiszka | if (!strcmp(startdate, "now") && legacy) { |
708 | 1ed2fc1f | Jan Kiszka | rtc_date_offset = -1;
|
709 | 1ed2fc1f | Jan Kiszka | } else {
|
710 | 1ed2fc1f | Jan Kiszka | if (sscanf(startdate, "%d-%d-%dT%d:%d:%d", |
711 | 1ed2fc1f | Jan Kiszka | &tm.tm_year, |
712 | 1ed2fc1f | Jan Kiszka | &tm.tm_mon, |
713 | 1ed2fc1f | Jan Kiszka | &tm.tm_mday, |
714 | 1ed2fc1f | Jan Kiszka | &tm.tm_hour, |
715 | 1ed2fc1f | Jan Kiszka | &tm.tm_min, |
716 | 1ed2fc1f | Jan Kiszka | &tm.tm_sec) == 6) {
|
717 | 1ed2fc1f | Jan Kiszka | /* OK */
|
718 | 1ed2fc1f | Jan Kiszka | } else if (sscanf(startdate, "%d-%d-%d", |
719 | 1ed2fc1f | Jan Kiszka | &tm.tm_year, |
720 | 1ed2fc1f | Jan Kiszka | &tm.tm_mon, |
721 | 1ed2fc1f | Jan Kiszka | &tm.tm_mday) == 3) {
|
722 | 1ed2fc1f | Jan Kiszka | tm.tm_hour = 0;
|
723 | 1ed2fc1f | Jan Kiszka | tm.tm_min = 0;
|
724 | 1ed2fc1f | Jan Kiszka | tm.tm_sec = 0;
|
725 | 1ed2fc1f | Jan Kiszka | } else {
|
726 | 1ed2fc1f | Jan Kiszka | goto date_fail;
|
727 | 1ed2fc1f | Jan Kiszka | } |
728 | 1ed2fc1f | Jan Kiszka | tm.tm_year -= 1900;
|
729 | 1ed2fc1f | Jan Kiszka | tm.tm_mon--; |
730 | 1ed2fc1f | Jan Kiszka | rtc_start_date = mktimegm(&tm); |
731 | 1ed2fc1f | Jan Kiszka | if (rtc_start_date == -1) { |
732 | 1ed2fc1f | Jan Kiszka | date_fail:
|
733 | 1ed2fc1f | Jan Kiszka | fprintf(stderr, "Invalid date format. Valid formats are:\n"
|
734 | 1ed2fc1f | Jan Kiszka | "'2006-06-17T16:01:21' or '2006-06-17'\n");
|
735 | 1ed2fc1f | Jan Kiszka | exit(1);
|
736 | 1ed2fc1f | Jan Kiszka | } |
737 | 1ed2fc1f | Jan Kiszka | rtc_date_offset = time(NULL) - rtc_start_date;
|
738 | 1ed2fc1f | Jan Kiszka | } |
739 | 1ed2fc1f | Jan Kiszka | } |
740 | 1ed2fc1f | Jan Kiszka | |
741 | 1ed2fc1f | Jan Kiszka | static void configure_rtc(QemuOpts *opts) |
742 | 1ed2fc1f | Jan Kiszka | { |
743 | 1ed2fc1f | Jan Kiszka | const char *value; |
744 | 1ed2fc1f | Jan Kiszka | |
745 | 1ed2fc1f | Jan Kiszka | value = qemu_opt_get(opts, "base");
|
746 | 1ed2fc1f | Jan Kiszka | if (value) {
|
747 | 1ed2fc1f | Jan Kiszka | if (!strcmp(value, "utc")) { |
748 | 1ed2fc1f | Jan Kiszka | rtc_utc = 1;
|
749 | 1ed2fc1f | Jan Kiszka | } else if (!strcmp(value, "localtime")) { |
750 | 1ed2fc1f | Jan Kiszka | rtc_utc = 0;
|
751 | 1ed2fc1f | Jan Kiszka | } else {
|
752 | 1ed2fc1f | Jan Kiszka | configure_rtc_date_offset(value, 0);
|
753 | 1ed2fc1f | Jan Kiszka | } |
754 | 1ed2fc1f | Jan Kiszka | } |
755 | 6875204c | Jan Kiszka | value = qemu_opt_get(opts, "clock");
|
756 | 6875204c | Jan Kiszka | if (value) {
|
757 | 6875204c | Jan Kiszka | if (!strcmp(value, "host")) { |
758 | 884f17c2 | Alex Bligh | rtc_clock = QEMU_CLOCK_HOST; |
759 | 78808141 | Paolo Bonzini | } else if (!strcmp(value, "rt")) { |
760 | 884f17c2 | Alex Bligh | rtc_clock = QEMU_CLOCK_REALTIME; |
761 | 6875204c | Jan Kiszka | } else if (!strcmp(value, "vm")) { |
762 | 884f17c2 | Alex Bligh | rtc_clock = QEMU_CLOCK_VIRTUAL; |
763 | 6875204c | Jan Kiszka | } else {
|
764 | 6875204c | Jan Kiszka | fprintf(stderr, "qemu: invalid option value '%s'\n", value);
|
765 | 6875204c | Jan Kiszka | exit(1);
|
766 | 6875204c | Jan Kiszka | } |
767 | 6875204c | Jan Kiszka | } |
768 | 1ed2fc1f | Jan Kiszka | value = qemu_opt_get(opts, "driftfix");
|
769 | 1ed2fc1f | Jan Kiszka | if (value) {
|
770 | 7e4c0336 | Blue Swirl | if (!strcmp(value, "slew")) { |
771 | 433acf0d | Jan Kiszka | static GlobalProperty slew_lost_ticks[] = {
|
772 | 433acf0d | Jan Kiszka | { |
773 | 433acf0d | Jan Kiszka | .driver = "mc146818rtc",
|
774 | 433acf0d | Jan Kiszka | .property = "lost_tick_policy",
|
775 | 433acf0d | Jan Kiszka | .value = "slew",
|
776 | 433acf0d | Jan Kiszka | }, |
777 | 433acf0d | Jan Kiszka | { /* end of list */ }
|
778 | 433acf0d | Jan Kiszka | }; |
779 | 433acf0d | Jan Kiszka | |
780 | 433acf0d | Jan Kiszka | qdev_prop_register_global_list(slew_lost_ticks); |
781 | 7e4c0336 | Blue Swirl | } else if (!strcmp(value, "none")) { |
782 | 433acf0d | Jan Kiszka | /* discard is default */
|
783 | 1ed2fc1f | Jan Kiszka | } else {
|
784 | 1ed2fc1f | Jan Kiszka | fprintf(stderr, "qemu: invalid option value '%s'\n", value);
|
785 | 1ed2fc1f | Jan Kiszka | exit(1);
|
786 | 1ed2fc1f | Jan Kiszka | } |
787 | 1ed2fc1f | Jan Kiszka | } |
788 | 1ed2fc1f | Jan Kiszka | } |
789 | 1ed2fc1f | Jan Kiszka | |
790 | 1ae26a18 | balrog | /***********************************************************/
|
791 | 1ae26a18 | balrog | /* Bluetooth support */
|
792 | 1ae26a18 | balrog | static int nb_hcis; |
793 | 1ae26a18 | balrog | static int cur_hci; |
794 | 1ae26a18 | balrog | static struct HCIInfo *hci_table[MAX_NICS]; |
795 | dc72ac14 | balrog | |
796 | 1ae26a18 | balrog | struct HCIInfo *qemu_next_hci(void) |
797 | 1ae26a18 | balrog | { |
798 | 1ae26a18 | balrog | if (cur_hci == nb_hcis)
|
799 | 1ae26a18 | balrog | return &null_hci;
|
800 | 1ae26a18 | balrog | |
801 | 1ae26a18 | balrog | return hci_table[cur_hci++];
|
802 | 1ae26a18 | balrog | } |
803 | 1ae26a18 | balrog | |
804 | dc72ac14 | balrog | static int bt_hci_parse(const char *str) |
805 | dc72ac14 | balrog | { |
806 | dc72ac14 | balrog | struct HCIInfo *hci;
|
807 | c227f099 | Anthony Liguori | bdaddr_t bdaddr; |
808 | dc72ac14 | balrog | |
809 | dc72ac14 | balrog | if (nb_hcis >= MAX_NICS) {
|
810 | dc72ac14 | balrog | fprintf(stderr, "qemu: Too many bluetooth HCIs (max %i).\n", MAX_NICS);
|
811 | dc72ac14 | balrog | return -1; |
812 | dc72ac14 | balrog | } |
813 | dc72ac14 | balrog | |
814 | dc72ac14 | balrog | hci = hci_init(str); |
815 | dc72ac14 | balrog | if (!hci)
|
816 | dc72ac14 | balrog | return -1; |
817 | dc72ac14 | balrog | |
818 | dc72ac14 | balrog | bdaddr.b[0] = 0x52; |
819 | dc72ac14 | balrog | bdaddr.b[1] = 0x54; |
820 | dc72ac14 | balrog | bdaddr.b[2] = 0x00; |
821 | dc72ac14 | balrog | bdaddr.b[3] = 0x12; |
822 | dc72ac14 | balrog | bdaddr.b[4] = 0x34; |
823 | dc72ac14 | balrog | bdaddr.b[5] = 0x56 + nb_hcis; |
824 | dc72ac14 | balrog | hci->bdaddr_set(hci, bdaddr.b); |
825 | dc72ac14 | balrog | |
826 | dc72ac14 | balrog | hci_table[nb_hcis++] = hci; |
827 | dc72ac14 | balrog | |
828 | dc72ac14 | balrog | return 0; |
829 | dc72ac14 | balrog | } |
830 | dc72ac14 | balrog | |
831 | dc72ac14 | balrog | static void bt_vhci_add(int vlan_id) |
832 | dc72ac14 | balrog | { |
833 | dc72ac14 | balrog | struct bt_scatternet_s *vlan = qemu_find_bt_vlan(vlan_id);
|
834 | dc72ac14 | balrog | |
835 | dc72ac14 | balrog | if (!vlan->slave)
|
836 | dc72ac14 | balrog | fprintf(stderr, "qemu: warning: adding a VHCI to "
|
837 | dc72ac14 | balrog | "an empty scatternet %i\n", vlan_id);
|
838 | dc72ac14 | balrog | |
839 | dc72ac14 | balrog | bt_vhci_init(bt_new_hci(vlan)); |
840 | dc72ac14 | balrog | } |
841 | dc72ac14 | balrog | |
842 | dc72ac14 | balrog | static struct bt_device_s *bt_device_add(const char *opt) |
843 | dc72ac14 | balrog | { |
844 | dc72ac14 | balrog | struct bt_scatternet_s *vlan;
|
845 | dc72ac14 | balrog | int vlan_id = 0; |
846 | dc72ac14 | balrog | char *endp = strstr(opt, ",vlan="); |
847 | dc72ac14 | balrog | int len = (endp ? endp - opt : strlen(opt)) + 1; |
848 | dc72ac14 | balrog | char devname[10]; |
849 | dc72ac14 | balrog | |
850 | dc72ac14 | balrog | pstrcpy(devname, MIN(sizeof(devname), len), opt);
|
851 | dc72ac14 | balrog | |
852 | dc72ac14 | balrog | if (endp) {
|
853 | dc72ac14 | balrog | vlan_id = strtol(endp + 6, &endp, 0); |
854 | dc72ac14 | balrog | if (*endp) {
|
855 | dc72ac14 | balrog | fprintf(stderr, "qemu: unrecognised bluetooth vlan Id\n");
|
856 | dc72ac14 | balrog | return 0; |
857 | dc72ac14 | balrog | } |
858 | dc72ac14 | balrog | } |
859 | dc72ac14 | balrog | |
860 | dc72ac14 | balrog | vlan = qemu_find_bt_vlan(vlan_id); |
861 | dc72ac14 | balrog | |
862 | dc72ac14 | balrog | if (!vlan->slave)
|
863 | dc72ac14 | balrog | fprintf(stderr, "qemu: warning: adding a slave device to "
|
864 | dc72ac14 | balrog | "an empty scatternet %i\n", vlan_id);
|
865 | dc72ac14 | balrog | |
866 | dc72ac14 | balrog | if (!strcmp(devname, "keyboard")) |
867 | dc72ac14 | balrog | return bt_keyboard_init(vlan);
|
868 | dc72ac14 | balrog | |
869 | dc72ac14 | balrog | fprintf(stderr, "qemu: unsupported bluetooth device `%s'\n", devname);
|
870 | dc72ac14 | balrog | return 0; |
871 | dc72ac14 | balrog | } |
872 | dc72ac14 | balrog | |
873 | dc72ac14 | balrog | static int bt_parse(const char *opt) |
874 | dc72ac14 | balrog | { |
875 | dc72ac14 | balrog | const char *endp, *p; |
876 | dc72ac14 | balrog | int vlan;
|
877 | dc72ac14 | balrog | |
878 | dc72ac14 | balrog | if (strstart(opt, "hci", &endp)) { |
879 | dc72ac14 | balrog | if (!*endp || *endp == ',') { |
880 | dc72ac14 | balrog | if (*endp)
|
881 | dc72ac14 | balrog | if (!strstart(endp, ",vlan=", 0)) |
882 | dc72ac14 | balrog | opt = endp + 1;
|
883 | dc72ac14 | balrog | |
884 | dc72ac14 | balrog | return bt_hci_parse(opt);
|
885 | dc72ac14 | balrog | } |
886 | dc72ac14 | balrog | } else if (strstart(opt, "vhci", &endp)) { |
887 | dc72ac14 | balrog | if (!*endp || *endp == ',') { |
888 | dc72ac14 | balrog | if (*endp) {
|
889 | dc72ac14 | balrog | if (strstart(endp, ",vlan=", &p)) { |
890 | dc72ac14 | balrog | vlan = strtol(p, (char **) &endp, 0); |
891 | dc72ac14 | balrog | if (*endp) {
|
892 | dc72ac14 | balrog | fprintf(stderr, "qemu: bad scatternet '%s'\n", p);
|
893 | dc72ac14 | balrog | return 1; |
894 | dc72ac14 | balrog | } |
895 | dc72ac14 | balrog | } else {
|
896 | dc72ac14 | balrog | fprintf(stderr, "qemu: bad parameter '%s'\n", endp + 1); |
897 | dc72ac14 | balrog | return 1; |
898 | dc72ac14 | balrog | } |
899 | dc72ac14 | balrog | } else
|
900 | dc72ac14 | balrog | vlan = 0;
|
901 | dc72ac14 | balrog | |
902 | dc72ac14 | balrog | bt_vhci_add(vlan); |
903 | dc72ac14 | balrog | return 0; |
904 | dc72ac14 | balrog | } |
905 | dc72ac14 | balrog | } else if (strstart(opt, "device:", &endp)) |
906 | dc72ac14 | balrog | return !bt_device_add(endp);
|
907 | dc72ac14 | balrog | |
908 | dc72ac14 | balrog | fprintf(stderr, "qemu: bad bluetooth parameter '%s'\n", opt);
|
909 | dc72ac14 | balrog | return 1; |
910 | dc72ac14 | balrog | } |
911 | dc72ac14 | balrog | |
912 | 7d76ad4f | Eduardo Otubo | static int parse_sandbox(QemuOpts *opts, void *opaque) |
913 | 7d76ad4f | Eduardo Otubo | { |
914 | 7d76ad4f | Eduardo Otubo | /* FIXME: change this to true for 1.3 */
|
915 | 7d76ad4f | Eduardo Otubo | if (qemu_opt_get_bool(opts, "enable", false)) { |
916 | 7d76ad4f | Eduardo Otubo | #ifdef CONFIG_SECCOMP
|
917 | 7d76ad4f | Eduardo Otubo | if (seccomp_start() < 0) { |
918 | 7d76ad4f | Eduardo Otubo | qerror_report(ERROR_CLASS_GENERIC_ERROR, |
919 | 7d76ad4f | Eduardo Otubo | "failed to install seccomp syscall filter in the kernel");
|
920 | 7d76ad4f | Eduardo Otubo | return -1; |
921 | 7d76ad4f | Eduardo Otubo | } |
922 | 7d76ad4f | Eduardo Otubo | #else
|
923 | 7d76ad4f | Eduardo Otubo | qerror_report(ERROR_CLASS_GENERIC_ERROR, |
924 | 7d76ad4f | Eduardo Otubo | "sandboxing request but seccomp is not compiled into this build");
|
925 | 7d76ad4f | Eduardo Otubo | return -1; |
926 | 7d76ad4f | Eduardo Otubo | #endif
|
927 | 7d76ad4f | Eduardo Otubo | } |
928 | 7d76ad4f | Eduardo Otubo | |
929 | 7d76ad4f | Eduardo Otubo | return 0; |
930 | 7d76ad4f | Eduardo Otubo | } |
931 | 7d76ad4f | Eduardo Otubo | |
932 | 094b287f | zhlcindy@gmail.com | bool usb_enabled(bool default_usb) |
933 | 094b287f | zhlcindy@gmail.com | { |
934 | 2ff3de68 | Markus Armbruster | return qemu_opt_get_bool(qemu_get_machine_opts(), "usb", default_usb); |
935 | 094b287f | zhlcindy@gmail.com | } |
936 | 094b287f | zhlcindy@gmail.com | |
937 | 587ed6be | Corey Bryant | #ifndef _WIN32
|
938 | 587ed6be | Corey Bryant | static int parse_add_fd(QemuOpts *opts, void *opaque) |
939 | 587ed6be | Corey Bryant | { |
940 | 587ed6be | Corey Bryant | int fd, dupfd, flags;
|
941 | 587ed6be | Corey Bryant | int64_t fdset_id; |
942 | 587ed6be | Corey Bryant | const char *fd_opaque = NULL; |
943 | 587ed6be | Corey Bryant | |
944 | 587ed6be | Corey Bryant | fd = qemu_opt_get_number(opts, "fd", -1); |
945 | 587ed6be | Corey Bryant | fdset_id = qemu_opt_get_number(opts, "set", -1); |
946 | 587ed6be | Corey Bryant | fd_opaque = qemu_opt_get(opts, "opaque");
|
947 | 587ed6be | Corey Bryant | |
948 | 587ed6be | Corey Bryant | if (fd < 0) { |
949 | 587ed6be | Corey Bryant | qerror_report(ERROR_CLASS_GENERIC_ERROR, |
950 | 587ed6be | Corey Bryant | "fd option is required and must be non-negative");
|
951 | 587ed6be | Corey Bryant | return -1; |
952 | 587ed6be | Corey Bryant | } |
953 | 587ed6be | Corey Bryant | |
954 | 587ed6be | Corey Bryant | if (fd <= STDERR_FILENO) {
|
955 | 587ed6be | Corey Bryant | qerror_report(ERROR_CLASS_GENERIC_ERROR, |
956 | 587ed6be | Corey Bryant | "fd cannot be a standard I/O stream");
|
957 | 587ed6be | Corey Bryant | return -1; |
958 | 587ed6be | Corey Bryant | } |
959 | 587ed6be | Corey Bryant | |
960 | 587ed6be | Corey Bryant | /*
|
961 | 587ed6be | Corey Bryant | * All fds inherited across exec() necessarily have FD_CLOEXEC
|
962 | 587ed6be | Corey Bryant | * clear, while qemu sets FD_CLOEXEC on all other fds used internally.
|
963 | 587ed6be | Corey Bryant | */
|
964 | 587ed6be | Corey Bryant | flags = fcntl(fd, F_GETFD); |
965 | 587ed6be | Corey Bryant | if (flags == -1 || (flags & FD_CLOEXEC)) { |
966 | 587ed6be | Corey Bryant | qerror_report(ERROR_CLASS_GENERIC_ERROR, |
967 | 587ed6be | Corey Bryant | "fd is not valid or already in use");
|
968 | 587ed6be | Corey Bryant | return -1; |
969 | 587ed6be | Corey Bryant | } |
970 | 587ed6be | Corey Bryant | |
971 | 587ed6be | Corey Bryant | if (fdset_id < 0) { |
972 | 587ed6be | Corey Bryant | qerror_report(ERROR_CLASS_GENERIC_ERROR, |
973 | 587ed6be | Corey Bryant | "set option is required and must be non-negative");
|
974 | 587ed6be | Corey Bryant | return -1; |
975 | 587ed6be | Corey Bryant | } |
976 | 587ed6be | Corey Bryant | |
977 | 587ed6be | Corey Bryant | #ifdef F_DUPFD_CLOEXEC
|
978 | 587ed6be | Corey Bryant | dupfd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
|
979 | 587ed6be | Corey Bryant | #else
|
980 | 587ed6be | Corey Bryant | dupfd = dup(fd); |
981 | 587ed6be | Corey Bryant | if (dupfd != -1) { |
982 | 587ed6be | Corey Bryant | qemu_set_cloexec(dupfd); |
983 | 587ed6be | Corey Bryant | } |
984 | 587ed6be | Corey Bryant | #endif
|
985 | 587ed6be | Corey Bryant | if (dupfd == -1) { |
986 | 587ed6be | Corey Bryant | qerror_report(ERROR_CLASS_GENERIC_ERROR, |
987 | 587ed6be | Corey Bryant | "Error duplicating fd: %s", strerror(errno));
|
988 | 587ed6be | Corey Bryant | return -1; |
989 | 587ed6be | Corey Bryant | } |
990 | 587ed6be | Corey Bryant | |
991 | 587ed6be | Corey Bryant | /* add the duplicate fd, and optionally the opaque string, to the fd set */
|
992 | 587ed6be | Corey Bryant | monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false, |
993 | 587ed6be | Corey Bryant | fd_opaque, NULL);
|
994 | 587ed6be | Corey Bryant | |
995 | 587ed6be | Corey Bryant | return 0; |
996 | 587ed6be | Corey Bryant | } |
997 | 587ed6be | Corey Bryant | |
998 | 587ed6be | Corey Bryant | static int cleanup_add_fd(QemuOpts *opts, void *opaque) |
999 | 587ed6be | Corey Bryant | { |
1000 | 587ed6be | Corey Bryant | int fd;
|
1001 | 587ed6be | Corey Bryant | |
1002 | 587ed6be | Corey Bryant | fd = qemu_opt_get_number(opts, "fd", -1); |
1003 | 587ed6be | Corey Bryant | close(fd); |
1004 | 587ed6be | Corey Bryant | |
1005 | 587ed6be | Corey Bryant | return 0; |
1006 | 587ed6be | Corey Bryant | } |
1007 | 587ed6be | Corey Bryant | #endif
|
1008 | 587ed6be | Corey Bryant | |
1009 | 1ae26a18 | balrog | /***********************************************************/
|
1010 | 1ae26a18 | balrog | /* QEMU Block devices */
|
1011 | 1ae26a18 | balrog | |
1012 | 2292ddae | Markus Armbruster | #define HD_OPTS "media=disk" |
1013 | 2292ddae | Markus Armbruster | #define CDROM_OPTS "media=cdrom" |
1014 | 2292ddae | Markus Armbruster | #define FD_OPTS "" |
1015 | 2292ddae | Markus Armbruster | #define PFLASH_OPTS "" |
1016 | 2292ddae | Markus Armbruster | #define MTD_OPTS "" |
1017 | 2292ddae | Markus Armbruster | #define SD_OPTS "" |
1018 | e4bcb14c | ths | |
1019 | 9dfd7c7a | Gerd Hoffmann | static int drive_init_func(QemuOpts *opts, void *opaque) |
1020 | 9dfd7c7a | Gerd Hoffmann | { |
1021 | 2d0d2837 | Christian Borntraeger | BlockInterfaceType *block_default_type = opaque; |
1022 | 9dfd7c7a | Gerd Hoffmann | |
1023 | 2d0d2837 | Christian Borntraeger | return drive_init(opts, *block_default_type) == NULL; |
1024 | 9dfd7c7a | Gerd Hoffmann | } |
1025 | 9dfd7c7a | Gerd Hoffmann | |
1026 | 9dfd7c7a | Gerd Hoffmann | static int drive_enable_snapshot(QemuOpts *opts, void *opaque) |
1027 | 9dfd7c7a | Gerd Hoffmann | { |
1028 | 9dfd7c7a | Gerd Hoffmann | if (NULL == qemu_opt_get(opts, "snapshot")) { |
1029 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(opts, "snapshot", "on"); |
1030 | 9dfd7c7a | Gerd Hoffmann | } |
1031 | 9dfd7c7a | Gerd Hoffmann | return 0; |
1032 | 9dfd7c7a | Gerd Hoffmann | } |
1033 | 9dfd7c7a | Gerd Hoffmann | |
1034 | 3c42ea66 | Christian Borntraeger | static void default_drive(int enable, int snapshot, BlockInterfaceType type, |
1035 | 3c42ea66 | Christian Borntraeger | int index, const char *optstr) |
1036 | 4e5d9b57 | Markus Armbruster | { |
1037 | 4e5d9b57 | Markus Armbruster | QemuOpts *opts; |
1038 | 4e5d9b57 | Markus Armbruster | |
1039 | 4e5d9b57 | Markus Armbruster | if (!enable || drive_get_by_index(type, index)) {
|
1040 | 4e5d9b57 | Markus Armbruster | return;
|
1041 | 4e5d9b57 | Markus Armbruster | } |
1042 | 4e5d9b57 | Markus Armbruster | |
1043 | 4e5d9b57 | Markus Armbruster | opts = drive_add(type, index, NULL, optstr);
|
1044 | 4e5d9b57 | Markus Armbruster | if (snapshot) {
|
1045 | 4e5d9b57 | Markus Armbruster | drive_enable_snapshot(opts, NULL);
|
1046 | 4e5d9b57 | Markus Armbruster | } |
1047 | 2d0d2837 | Christian Borntraeger | if (!drive_init(opts, type)) {
|
1048 | 4e5d9b57 | Markus Armbruster | exit(1);
|
1049 | 4e5d9b57 | Markus Armbruster | } |
1050 | 4e5d9b57 | Markus Armbruster | } |
1051 | 4e5d9b57 | Markus Armbruster | |
1052 | 76e30d0f | Jan Kiszka | void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque) |
1053 | 76e30d0f | Jan Kiszka | { |
1054 | 76e30d0f | Jan Kiszka | boot_set_handler = func; |
1055 | 76e30d0f | Jan Kiszka | boot_set_opaque = opaque; |
1056 | 76e30d0f | Jan Kiszka | } |
1057 | 76e30d0f | Jan Kiszka | |
1058 | 083b79c9 | Markus Armbruster | int qemu_boot_set(const char *boot_order) |
1059 | 76e30d0f | Jan Kiszka | { |
1060 | 76e30d0f | Jan Kiszka | if (!boot_set_handler) {
|
1061 | 76e30d0f | Jan Kiszka | return -EINVAL;
|
1062 | 76e30d0f | Jan Kiszka | } |
1063 | 083b79c9 | Markus Armbruster | return boot_set_handler(boot_set_opaque, boot_order);
|
1064 | 76e30d0f | Jan Kiszka | } |
1065 | 76e30d0f | Jan Kiszka | |
1066 | 6ef4716c | Markus Armbruster | static void validate_bootdevices(const char *devices) |
1067 | ef3adf68 | Jan Kiszka | { |
1068 | ef3adf68 | Jan Kiszka | /* We just do some generic consistency checks */
|
1069 | ef3adf68 | Jan Kiszka | const char *p; |
1070 | ef3adf68 | Jan Kiszka | int bitmap = 0; |
1071 | ef3adf68 | Jan Kiszka | |
1072 | ef3adf68 | Jan Kiszka | for (p = devices; *p != '\0'; p++) { |
1073 | ef3adf68 | Jan Kiszka | /* Allowed boot devices are:
|
1074 | ef3adf68 | Jan Kiszka | * a-b: floppy disk drives
|
1075 | ef3adf68 | Jan Kiszka | * c-f: IDE disk drives
|
1076 | 07f35073 | Dong Xu Wang | * g-m: machine implementation dependent drives
|
1077 | ef3adf68 | Jan Kiszka | * n-p: network devices
|
1078 | ef3adf68 | Jan Kiszka | * It's up to each machine implementation to check if the given boot
|
1079 | ef3adf68 | Jan Kiszka | * devices match the actual hardware implementation and firmware
|
1080 | ef3adf68 | Jan Kiszka | * features.
|
1081 | ef3adf68 | Jan Kiszka | */
|
1082 | ef3adf68 | Jan Kiszka | if (*p < 'a' || *p > 'p') { |
1083 | ef3adf68 | Jan Kiszka | fprintf(stderr, "Invalid boot device '%c'\n", *p);
|
1084 | ef3adf68 | Jan Kiszka | exit(1);
|
1085 | ef3adf68 | Jan Kiszka | } |
1086 | ef3adf68 | Jan Kiszka | if (bitmap & (1 << (*p - 'a'))) { |
1087 | ef3adf68 | Jan Kiszka | fprintf(stderr, "Boot device '%c' was given twice\n", *p);
|
1088 | ef3adf68 | Jan Kiszka | exit(1);
|
1089 | ef3adf68 | Jan Kiszka | } |
1090 | ef3adf68 | Jan Kiszka | bitmap |= 1 << (*p - 'a'); |
1091 | ef3adf68 | Jan Kiszka | } |
1092 | ef3adf68 | Jan Kiszka | } |
1093 | ef3adf68 | Jan Kiszka | |
1094 | 083b79c9 | Markus Armbruster | static void restore_boot_order(void *opaque) |
1095 | e0f084bf | Jan Kiszka | { |
1096 | 083b79c9 | Markus Armbruster | char *normal_boot_order = opaque;
|
1097 | 37905d6a | Alex Williamson | static int first = 1; |
1098 | 37905d6a | Alex Williamson | |
1099 | 37905d6a | Alex Williamson | /* Restore boot order and remove ourselves after the first boot */
|
1100 | 37905d6a | Alex Williamson | if (first) {
|
1101 | 37905d6a | Alex Williamson | first = 0;
|
1102 | 37905d6a | Alex Williamson | return;
|
1103 | 37905d6a | Alex Williamson | } |
1104 | e0f084bf | Jan Kiszka | |
1105 | 083b79c9 | Markus Armbruster | qemu_boot_set(normal_boot_order); |
1106 | e0f084bf | Jan Kiszka | |
1107 | 083b79c9 | Markus Armbruster | qemu_unregister_reset(restore_boot_order, normal_boot_order); |
1108 | 083b79c9 | Markus Armbruster | g_free(normal_boot_order); |
1109 | e0f084bf | Jan Kiszka | } |
1110 | e0f084bf | Jan Kiszka | |
1111 | 1ca4d09a | Gleb Natapov | void add_boot_device_path(int32_t bootindex, DeviceState *dev,
|
1112 | 1ca4d09a | Gleb Natapov | const char *suffix) |
1113 | 1ca4d09a | Gleb Natapov | { |
1114 | 1ca4d09a | Gleb Natapov | FWBootEntry *node, *i; |
1115 | 1ca4d09a | Gleb Natapov | |
1116 | 1ca4d09a | Gleb Natapov | if (bootindex < 0) { |
1117 | 1ca4d09a | Gleb Natapov | return;
|
1118 | 1ca4d09a | Gleb Natapov | } |
1119 | 1ca4d09a | Gleb Natapov | |
1120 | 1ca4d09a | Gleb Natapov | assert(dev != NULL || suffix != NULL); |
1121 | 1ca4d09a | Gleb Natapov | |
1122 | 7267c094 | Anthony Liguori | node = g_malloc0(sizeof(FWBootEntry));
|
1123 | 1ca4d09a | Gleb Natapov | node->bootindex = bootindex; |
1124 | 7f303adc | Dong Xu Wang | node->suffix = g_strdup(suffix); |
1125 | 1ca4d09a | Gleb Natapov | node->dev = dev; |
1126 | 1ca4d09a | Gleb Natapov | |
1127 | 1ca4d09a | Gleb Natapov | QTAILQ_FOREACH(i, &fw_boot_order, link) { |
1128 | 1ca4d09a | Gleb Natapov | if (i->bootindex == bootindex) {
|
1129 | 1ca4d09a | Gleb Natapov | fprintf(stderr, "Two devices with same boot index %d\n", bootindex);
|
1130 | 1ca4d09a | Gleb Natapov | exit(1);
|
1131 | 1ca4d09a | Gleb Natapov | } else if (i->bootindex < bootindex) { |
1132 | 1ca4d09a | Gleb Natapov | continue;
|
1133 | 1ca4d09a | Gleb Natapov | } |
1134 | 1ca4d09a | Gleb Natapov | QTAILQ_INSERT_BEFORE(i, node, link); |
1135 | 1ca4d09a | Gleb Natapov | return;
|
1136 | 1ca4d09a | Gleb Natapov | } |
1137 | 1ca4d09a | Gleb Natapov | QTAILQ_INSERT_TAIL(&fw_boot_order, node, link); |
1138 | 1ca4d09a | Gleb Natapov | } |
1139 | 1ca4d09a | Gleb Natapov | |
1140 | 7dc5af55 | Dominik Dingel | DeviceState *get_boot_device(uint32_t position) |
1141 | 7dc5af55 | Dominik Dingel | { |
1142 | 7dc5af55 | Dominik Dingel | uint32_t counter = 0;
|
1143 | 7dc5af55 | Dominik Dingel | FWBootEntry *i = NULL;
|
1144 | 7dc5af55 | Dominik Dingel | DeviceState *res = NULL;
|
1145 | 7dc5af55 | Dominik Dingel | |
1146 | 7dc5af55 | Dominik Dingel | if (!QTAILQ_EMPTY(&fw_boot_order)) {
|
1147 | 7dc5af55 | Dominik Dingel | QTAILQ_FOREACH(i, &fw_boot_order, link) { |
1148 | 7dc5af55 | Dominik Dingel | if (counter == position) {
|
1149 | 7dc5af55 | Dominik Dingel | res = i->dev; |
1150 | 7dc5af55 | Dominik Dingel | break;
|
1151 | 7dc5af55 | Dominik Dingel | } |
1152 | 7dc5af55 | Dominik Dingel | counter++; |
1153 | 7dc5af55 | Dominik Dingel | } |
1154 | 7dc5af55 | Dominik Dingel | } |
1155 | 7dc5af55 | Dominik Dingel | return res;
|
1156 | 7dc5af55 | Dominik Dingel | } |
1157 | 7dc5af55 | Dominik Dingel | |
1158 | 962630f2 | Gleb Natapov | /*
|
1159 | 962630f2 | Gleb Natapov | * This function returns null terminated string that consist of new line
|
1160 | 71785aba | Brad Hards | * separated device paths.
|
1161 | 962630f2 | Gleb Natapov | *
|
1162 | 962630f2 | Gleb Natapov | * memory pointed by "size" is assigned total length of the array in bytes
|
1163 | 962630f2 | Gleb Natapov | *
|
1164 | 962630f2 | Gleb Natapov | */
|
1165 | 0e7a7592 | Markus Armbruster | char *get_boot_devices_list(size_t *size)
|
1166 | 962630f2 | Gleb Natapov | { |
1167 | 962630f2 | Gleb Natapov | FWBootEntry *i; |
1168 | 0e7a7592 | Markus Armbruster | size_t total = 0;
|
1169 | 962630f2 | Gleb Natapov | char *list = NULL; |
1170 | 962630f2 | Gleb Natapov | |
1171 | 962630f2 | Gleb Natapov | QTAILQ_FOREACH(i, &fw_boot_order, link) { |
1172 | 962630f2 | Gleb Natapov | char *devpath = NULL, *bootpath; |
1173 | 0e7a7592 | Markus Armbruster | size_t len; |
1174 | 962630f2 | Gleb Natapov | |
1175 | 962630f2 | Gleb Natapov | if (i->dev) {
|
1176 | 962630f2 | Gleb Natapov | devpath = qdev_get_fw_dev_path(i->dev); |
1177 | 962630f2 | Gleb Natapov | assert(devpath); |
1178 | 962630f2 | Gleb Natapov | } |
1179 | 962630f2 | Gleb Natapov | |
1180 | 962630f2 | Gleb Natapov | if (i->suffix && devpath) {
|
1181 | 4fd37a98 | Blue Swirl | size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1;
|
1182 | 4fd37a98 | Blue Swirl | |
1183 | 7267c094 | Anthony Liguori | bootpath = g_malloc(bootpathlen); |
1184 | 4fd37a98 | Blue Swirl | snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix);
|
1185 | 7267c094 | Anthony Liguori | g_free(devpath); |
1186 | 962630f2 | Gleb Natapov | } else if (devpath) { |
1187 | 962630f2 | Gleb Natapov | bootpath = devpath; |
1188 | 962630f2 | Gleb Natapov | } else {
|
1189 | 1bf6ccd3 | Markus Armbruster | assert(i->suffix); |
1190 | 7267c094 | Anthony Liguori | bootpath = g_strdup(i->suffix); |
1191 | 962630f2 | Gleb Natapov | } |
1192 | 962630f2 | Gleb Natapov | |
1193 | 962630f2 | Gleb Natapov | if (total) {
|
1194 | 962630f2 | Gleb Natapov | list[total-1] = '\n'; |
1195 | 962630f2 | Gleb Natapov | } |
1196 | 962630f2 | Gleb Natapov | len = strlen(bootpath) + 1;
|
1197 | 7267c094 | Anthony Liguori | list = g_realloc(list, total + len); |
1198 | 962630f2 | Gleb Natapov | memcpy(&list[total], bootpath, len); |
1199 | 962630f2 | Gleb Natapov | total += len; |
1200 | 7267c094 | Anthony Liguori | g_free(bootpath); |
1201 | 962630f2 | Gleb Natapov | } |
1202 | 962630f2 | Gleb Natapov | |
1203 | 962630f2 | Gleb Natapov | *size = total; |
1204 | 962630f2 | Gleb Natapov | |
1205 | c8a6ae8b | Amos Kong | if (boot_strict && *size > 0) { |
1206 | c8a6ae8b | Amos Kong | list[total-1] = '\n'; |
1207 | 4690579e | Amos Kong | list = g_realloc(list, total + 5);
|
1208 | 4690579e | Amos Kong | memcpy(&list[total], "HALT", 5); |
1209 | 4690579e | Amos Kong | *size = total + 5;
|
1210 | c8a6ae8b | Amos Kong | } |
1211 | 962630f2 | Gleb Natapov | return list;
|
1212 | 962630f2 | Gleb Natapov | } |
1213 | 962630f2 | Gleb Natapov | |
1214 | 845e5bf9 | Eduardo Habkost | static void numa_node_parse_cpus(int nodenr, const char *cpus) |
1215 | 845e5bf9 | Eduardo Habkost | { |
1216 | 845e5bf9 | Eduardo Habkost | char *endptr;
|
1217 | 845e5bf9 | Eduardo Habkost | unsigned long long value, endvalue; |
1218 | 845e5bf9 | Eduardo Habkost | |
1219 | c881e20e | Eduardo Habkost | /* Empty CPU range strings will be considered valid, they will simply
|
1220 | c881e20e | Eduardo Habkost | * not set any bit in the CPU bitmap.
|
1221 | c881e20e | Eduardo Habkost | */
|
1222 | c881e20e | Eduardo Habkost | if (!*cpus) {
|
1223 | c881e20e | Eduardo Habkost | return;
|
1224 | c881e20e | Eduardo Habkost | } |
1225 | c881e20e | Eduardo Habkost | |
1226 | c881e20e | Eduardo Habkost | if (parse_uint(cpus, &value, &endptr, 10) < 0) { |
1227 | c881e20e | Eduardo Habkost | goto error;
|
1228 | c881e20e | Eduardo Habkost | } |
1229 | 845e5bf9 | Eduardo Habkost | if (*endptr == '-') { |
1230 | c881e20e | Eduardo Habkost | if (parse_uint_full(endptr + 1, &endvalue, 10) < 0) { |
1231 | c881e20e | Eduardo Habkost | goto error;
|
1232 | c881e20e | Eduardo Habkost | } |
1233 | c881e20e | Eduardo Habkost | } else if (*endptr == '\0') { |
1234 | 845e5bf9 | Eduardo Habkost | endvalue = value; |
1235 | c881e20e | Eduardo Habkost | } else {
|
1236 | c881e20e | Eduardo Habkost | goto error;
|
1237 | 845e5bf9 | Eduardo Habkost | } |
1238 | 845e5bf9 | Eduardo Habkost | |
1239 | c881e20e | Eduardo Habkost | if (endvalue >= MAX_CPUMASK_BITS) {
|
1240 | 845e5bf9 | Eduardo Habkost | endvalue = MAX_CPUMASK_BITS - 1;
|
1241 | 845e5bf9 | Eduardo Habkost | fprintf(stderr, |
1242 | c881e20e | Eduardo Habkost | "qemu: NUMA: A max of %d VCPUs are supported\n",
|
1243 | 845e5bf9 | Eduardo Habkost | MAX_CPUMASK_BITS); |
1244 | 845e5bf9 | Eduardo Habkost | } |
1245 | 845e5bf9 | Eduardo Habkost | |
1246 | c881e20e | Eduardo Habkost | if (endvalue < value) {
|
1247 | c881e20e | Eduardo Habkost | goto error;
|
1248 | c881e20e | Eduardo Habkost | } |
1249 | c881e20e | Eduardo Habkost | |
1250 | 845e5bf9 | Eduardo Habkost | bitmap_set(node_cpumask[nodenr], value, endvalue-value+1);
|
1251 | c881e20e | Eduardo Habkost | return;
|
1252 | c881e20e | Eduardo Habkost | |
1253 | c881e20e | Eduardo Habkost | error:
|
1254 | c881e20e | Eduardo Habkost | fprintf(stderr, "qemu: Invalid NUMA CPU range: %s\n", cpus);
|
1255 | c881e20e | Eduardo Habkost | exit(1);
|
1256 | 845e5bf9 | Eduardo Habkost | } |
1257 | 845e5bf9 | Eduardo Habkost | |
1258 | 268a362c | aliguori | static void numa_add(const char *optarg) |
1259 | 268a362c | aliguori | { |
1260 | 268a362c | aliguori | char option[128]; |
1261 | 268a362c | aliguori | char *endptr;
|
1262 | e4ce85b2 | Eduardo Habkost | unsigned long long nodenr; |
1263 | 268a362c | aliguori | |
1264 | 8f302cb0 | Eduardo Habkost | optarg = get_opt_name(option, 128, optarg, ','); |
1265 | 8f302cb0 | Eduardo Habkost | if (*optarg == ',') { |
1266 | 8f302cb0 | Eduardo Habkost | optarg++; |
1267 | 8f302cb0 | Eduardo Habkost | } |
1268 | 268a362c | aliguori | if (!strcmp(option, "node")) { |
1269 | ca4c6d36 | Eduardo Habkost | |
1270 | ca4c6d36 | Eduardo Habkost | if (nb_numa_nodes >= MAX_NODES) {
|
1271 | ca4c6d36 | Eduardo Habkost | fprintf(stderr, "qemu: too many NUMA nodes\n");
|
1272 | ca4c6d36 | Eduardo Habkost | exit(1);
|
1273 | ca4c6d36 | Eduardo Habkost | } |
1274 | ca4c6d36 | Eduardo Habkost | |
1275 | 268a362c | aliguori | if (get_param_value(option, 128, "nodeid", optarg) == 0) { |
1276 | 268a362c | aliguori | nodenr = nb_numa_nodes; |
1277 | 268a362c | aliguori | } else {
|
1278 | 5f139965 | Eduardo Habkost | if (parse_uint_full(option, &nodenr, 10) < 0) { |
1279 | 5f139965 | Eduardo Habkost | fprintf(stderr, "qemu: Invalid NUMA nodeid: %s\n", option);
|
1280 | 5f139965 | Eduardo Habkost | exit(1);
|
1281 | 5f139965 | Eduardo Habkost | } |
1282 | 268a362c | aliguori | } |
1283 | 268a362c | aliguori | |
1284 | e4ce85b2 | Eduardo Habkost | if (nodenr >= MAX_NODES) {
|
1285 | e4ce85b2 | Eduardo Habkost | fprintf(stderr, "qemu: invalid NUMA nodeid: %llu\n", nodenr);
|
1286 | e4ce85b2 | Eduardo Habkost | exit(1);
|
1287 | e4ce85b2 | Eduardo Habkost | } |
1288 | e4ce85b2 | Eduardo Habkost | |
1289 | 268a362c | aliguori | if (get_param_value(option, 128, "mem", optarg) == 0) { |
1290 | 268a362c | aliguori | node_mem[nodenr] = 0;
|
1291 | 268a362c | aliguori | } else {
|
1292 | 70b4f4bb | Jes Sorensen | int64_t sval; |
1293 | c03417b4 | Markus Armbruster | sval = strtosz(option, &endptr); |
1294 | c03417b4 | Markus Armbruster | if (sval < 0 || *endptr) { |
1295 | 9f9b17a4 | Jes Sorensen | fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg);
|
1296 | 9f9b17a4 | Jes Sorensen | exit(1);
|
1297 | 268a362c | aliguori | } |
1298 | 9f9b17a4 | Jes Sorensen | node_mem[nodenr] = sval; |
1299 | 268a362c | aliguori | } |
1300 | ee785fed | Chegu Vinod | if (get_param_value(option, 128, "cpus", optarg) != 0) { |
1301 | 845e5bf9 | Eduardo Habkost | numa_node_parse_cpus(nodenr, option); |
1302 | 268a362c | aliguori | } |
1303 | 268a362c | aliguori | nb_numa_nodes++; |
1304 | 12e53a9d | Eduardo Habkost | } else {
|
1305 | 12e53a9d | Eduardo Habkost | fprintf(stderr, "Invalid -numa option: %s\n", option);
|
1306 | 12e53a9d | Eduardo Habkost | exit(1);
|
1307 | 268a362c | aliguori | } |
1308 | 268a362c | aliguori | } |
1309 | 268a362c | aliguori | |
1310 | 12b7f57e | Michael Tokarev | static QemuOptsList qemu_smp_opts = {
|
1311 | 12b7f57e | Michael Tokarev | .name = "smp-opts",
|
1312 | 12b7f57e | Michael Tokarev | .implied_opt_name = "cpus",
|
1313 | 12b7f57e | Michael Tokarev | .merge_lists = true,
|
1314 | 12b7f57e | Michael Tokarev | .head = QTAILQ_HEAD_INITIALIZER(qemu_smp_opts.head), |
1315 | 12b7f57e | Michael Tokarev | .desc = { |
1316 | 12b7f57e | Michael Tokarev | { |
1317 | 12b7f57e | Michael Tokarev | .name = "cpus",
|
1318 | 12b7f57e | Michael Tokarev | .type = QEMU_OPT_NUMBER, |
1319 | 12b7f57e | Michael Tokarev | }, { |
1320 | 12b7f57e | Michael Tokarev | .name = "sockets",
|
1321 | 12b7f57e | Michael Tokarev | .type = QEMU_OPT_NUMBER, |
1322 | 12b7f57e | Michael Tokarev | }, { |
1323 | 12b7f57e | Michael Tokarev | .name = "cores",
|
1324 | 12b7f57e | Michael Tokarev | .type = QEMU_OPT_NUMBER, |
1325 | 12b7f57e | Michael Tokarev | }, { |
1326 | 12b7f57e | Michael Tokarev | .name = "threads",
|
1327 | 12b7f57e | Michael Tokarev | .type = QEMU_OPT_NUMBER, |
1328 | 12b7f57e | Michael Tokarev | }, { |
1329 | 12b7f57e | Michael Tokarev | .name = "maxcpus",
|
1330 | 12b7f57e | Michael Tokarev | .type = QEMU_OPT_NUMBER, |
1331 | 12b7f57e | Michael Tokarev | }, |
1332 | 12b7f57e | Michael Tokarev | { /*End of list */ }
|
1333 | 12b7f57e | Michael Tokarev | }, |
1334 | 12b7f57e | Michael Tokarev | }; |
1335 | 12b7f57e | Michael Tokarev | |
1336 | 12b7f57e | Michael Tokarev | static void smp_parse(QemuOpts *opts) |
1337 | dc6b1c09 | Andre Przywara | { |
1338 | 12b7f57e | Michael Tokarev | if (opts) {
|
1339 | dc6b1c09 | Andre Przywara | |
1340 | 12b7f57e | Michael Tokarev | unsigned cpus = qemu_opt_get_number(opts, "cpus", 0); |
1341 | 12b7f57e | Michael Tokarev | unsigned sockets = qemu_opt_get_number(opts, "sockets", 0); |
1342 | 12b7f57e | Michael Tokarev | unsigned cores = qemu_opt_get_number(opts, "cores", 0); |
1343 | 12b7f57e | Michael Tokarev | unsigned threads = qemu_opt_get_number(opts, "threads", 0); |
1344 | 12b7f57e | Michael Tokarev | |
1345 | 12b7f57e | Michael Tokarev | /* compute missing values, prefer sockets over cores over threads */
|
1346 | 12b7f57e | Michael Tokarev | if (cpus == 0 || sockets == 0) { |
1347 | 12b7f57e | Michael Tokarev | sockets = sockets > 0 ? sockets : 1; |
1348 | 12b7f57e | Michael Tokarev | cores = cores > 0 ? cores : 1; |
1349 | dc6b1c09 | Andre Przywara | threads = threads > 0 ? threads : 1; |
1350 | 12b7f57e | Michael Tokarev | if (cpus == 0) { |
1351 | 12b7f57e | Michael Tokarev | cpus = cores * threads * sockets; |
1352 | 12b7f57e | Michael Tokarev | } |
1353 | dc6b1c09 | Andre Przywara | } else {
|
1354 | 12b7f57e | Michael Tokarev | if (cores == 0) { |
1355 | 12b7f57e | Michael Tokarev | threads = threads > 0 ? threads : 1; |
1356 | 12b7f57e | Michael Tokarev | cores = cpus / (sockets * threads); |
1357 | 12b7f57e | Michael Tokarev | } else {
|
1358 | 12b7f57e | Michael Tokarev | threads = cpus / (cores * sockets); |
1359 | 12b7f57e | Michael Tokarev | } |
1360 | dc6b1c09 | Andre Przywara | } |
1361 | 12b7f57e | Michael Tokarev | |
1362 | 12b7f57e | Michael Tokarev | max_cpus = qemu_opt_get_number(opts, "maxcpus", 0); |
1363 | 12b7f57e | Michael Tokarev | |
1364 | 12b7f57e | Michael Tokarev | smp_cpus = cpus; |
1365 | 12b7f57e | Michael Tokarev | smp_cores = cores > 0 ? cores : 1; |
1366 | 12b7f57e | Michael Tokarev | smp_threads = threads > 0 ? threads : 1; |
1367 | 12b7f57e | Michael Tokarev | |
1368 | dc6b1c09 | Andre Przywara | } |
1369 | 12b7f57e | Michael Tokarev | |
1370 | 12b7f57e | Michael Tokarev | if (max_cpus == 0) { |
1371 | dc6b1c09 | Andre Przywara | max_cpus = smp_cpus; |
1372 | 12b7f57e | Michael Tokarev | } |
1373 | 12b7f57e | Michael Tokarev | |
1374 | 12b7f57e | Michael Tokarev | if (max_cpus > 255) { |
1375 | 12b7f57e | Michael Tokarev | fprintf(stderr, "Unsupported number of maxcpus\n");
|
1376 | 12b7f57e | Michael Tokarev | exit(1);
|
1377 | 12b7f57e | Michael Tokarev | } |
1378 | 12b7f57e | Michael Tokarev | if (max_cpus < smp_cpus) {
|
1379 | 12b7f57e | Michael Tokarev | fprintf(stderr, "maxcpus must be equal to or greater than smp\n");
|
1380 | 12b7f57e | Michael Tokarev | exit(1);
|
1381 | 12b7f57e | Michael Tokarev | } |
1382 | 12b7f57e | Michael Tokarev | |
1383 | dc6b1c09 | Andre Przywara | } |
1384 | dc6b1c09 | Andre Przywara | |
1385 | 888a6bc6 | Satoru Moriya | static void configure_realtime(QemuOpts *opts) |
1386 | 888a6bc6 | Satoru Moriya | { |
1387 | 888a6bc6 | Satoru Moriya | bool enable_mlock;
|
1388 | 888a6bc6 | Satoru Moriya | |
1389 | 888a6bc6 | Satoru Moriya | enable_mlock = qemu_opt_get_bool(opts, "mlock", true); |
1390 | 888a6bc6 | Satoru Moriya | |
1391 | 888a6bc6 | Satoru Moriya | if (enable_mlock) {
|
1392 | 888a6bc6 | Satoru Moriya | if (os_mlock() < 0) { |
1393 | 888a6bc6 | Satoru Moriya | fprintf(stderr, "qemu: locking memory failed\n");
|
1394 | 888a6bc6 | Satoru Moriya | exit(1);
|
1395 | 888a6bc6 | Satoru Moriya | } |
1396 | 888a6bc6 | Satoru Moriya | } |
1397 | 888a6bc6 | Satoru Moriya | } |
1398 | 888a6bc6 | Satoru Moriya | |
1399 | 5e2ac519 | Seiji Aguchi | |
1400 | 5e2ac519 | Seiji Aguchi | static void configure_msg(QemuOpts *opts) |
1401 | 5e2ac519 | Seiji Aguchi | { |
1402 | 5e2ac519 | Seiji Aguchi | enable_timestamp_msg = qemu_opt_get_bool(opts, "timestamp", true); |
1403 | 5e2ac519 | Seiji Aguchi | } |
1404 | 5e2ac519 | Seiji Aguchi | |
1405 | 330d0414 | bellard | /***********************************************************/
|
1406 | a594cfbf | bellard | /* USB devices */
|
1407 | a594cfbf | bellard | |
1408 | fb08000c | Markus Armbruster | static int usb_device_add(const char *devname) |
1409 | a594cfbf | bellard | { |
1410 | a5d2f727 | Gerd Hoffmann | USBDevice *dev = NULL;
|
1411 | 615fe4de | Miroslav Rezanina | #ifndef CONFIG_LINUX
|
1412 | 615fe4de | Miroslav Rezanina | const char *p; |
1413 | 615fe4de | Miroslav Rezanina | #endif
|
1414 | a594cfbf | bellard | |
1415 | 094b287f | zhlcindy@gmail.com | if (!usb_enabled(false)) { |
1416 | a594cfbf | bellard | return -1; |
1417 | 094b287f | zhlcindy@gmail.com | } |
1418 | a594cfbf | bellard | |
1419 | 0958b4cc | Gerd Hoffmann | /* drivers with .usbdevice_name entry in USBDeviceInfo */
|
1420 | 0958b4cc | Gerd Hoffmann | dev = usbdevice_create(devname); |
1421 | 0958b4cc | Gerd Hoffmann | if (dev)
|
1422 | 0958b4cc | Gerd Hoffmann | goto done;
|
1423 | 0958b4cc | Gerd Hoffmann | |
1424 | a5d2f727 | Gerd Hoffmann | /* the other ones */
|
1425 | e447fc63 | Gerd Hoffmann | #ifndef CONFIG_LINUX
|
1426 | e447fc63 | Gerd Hoffmann | /* only the linux version is qdev-ified, usb-bsd still needs this */
|
1427 | a594cfbf | bellard | if (strstart(devname, "host:", &p)) { |
1428 | 3741715c | Jan Kiszka | dev = usb_host_device_open(usb_bus_find(-1), p);
|
1429 | a594cfbf | bellard | } |
1430 | 615fe4de | Miroslav Rezanina | #endif
|
1431 | 0d92ed30 | pbrook | if (!dev)
|
1432 | 0d92ed30 | pbrook | return -1; |
1433 | 0d92ed30 | pbrook | |
1434 | a5d2f727 | Gerd Hoffmann | done:
|
1435 | a594cfbf | bellard | return 0; |
1436 | a594cfbf | bellard | } |
1437 | a594cfbf | bellard | |
1438 | 1f3870ab | aliguori | static int usb_device_del(const char *devname) |
1439 | 1f3870ab | aliguori | { |
1440 | 1f3870ab | aliguori | int bus_num, addr;
|
1441 | 1f3870ab | aliguori | const char *p; |
1442 | 1f3870ab | aliguori | |
1443 | 1a3973b3 | Gerd Hoffmann | if (strstart(devname, "host:", &p)) { |
1444 | 1a3973b3 | Gerd Hoffmann | return -1; |
1445 | 1a3973b3 | Gerd Hoffmann | } |
1446 | 5d0c5750 | aliguori | |
1447 | 094b287f | zhlcindy@gmail.com | if (!usb_enabled(false)) { |
1448 | 1f3870ab | aliguori | return -1; |
1449 | 094b287f | zhlcindy@gmail.com | } |
1450 | 1f3870ab | aliguori | |
1451 | 1f3870ab | aliguori | p = strchr(devname, '.');
|
1452 | 1f3870ab | aliguori | if (!p)
|
1453 | 1f3870ab | aliguori | return -1; |
1454 | 1f3870ab | aliguori | bus_num = strtoul(devname, NULL, 0); |
1455 | 1f3870ab | aliguori | addr = strtoul(p + 1, NULL, 0); |
1456 | 1f3870ab | aliguori | |
1457 | a5d2f727 | Gerd Hoffmann | return usb_device_delete_addr(bus_num, addr);
|
1458 | 1f3870ab | aliguori | } |
1459 | 1f3870ab | aliguori | |
1460 | bd3c948d | Gerd Hoffmann | static int usb_parse(const char *cmdline) |
1461 | bd3c948d | Gerd Hoffmann | { |
1462 | 59d1c1c2 | Scott Tsai | int r;
|
1463 | fb08000c | Markus Armbruster | r = usb_device_add(cmdline); |
1464 | 59d1c1c2 | Scott Tsai | if (r < 0) { |
1465 | 59d1c1c2 | Scott Tsai | fprintf(stderr, "qemu: could not add USB device '%s'\n", cmdline);
|
1466 | 59d1c1c2 | Scott Tsai | } |
1467 | 59d1c1c2 | Scott Tsai | return r;
|
1468 | bd3c948d | Gerd Hoffmann | } |
1469 | bd3c948d | Gerd Hoffmann | |
1470 | d54908a5 | Luiz Capitulino | void do_usb_add(Monitor *mon, const QDict *qdict) |
1471 | a594cfbf | bellard | { |
1472 | 59d1c1c2 | Scott Tsai | const char *devname = qdict_get_str(qdict, "devname"); |
1473 | fb08000c | Markus Armbruster | if (usb_device_add(devname) < 0) { |
1474 | 1ecda02b | Markus Armbruster | error_report("could not add USB device '%s'", devname);
|
1475 | 59d1c1c2 | Scott Tsai | } |
1476 | a594cfbf | bellard | } |
1477 | a594cfbf | bellard | |
1478 | d54908a5 | Luiz Capitulino | void do_usb_del(Monitor *mon, const QDict *qdict) |
1479 | a594cfbf | bellard | { |
1480 | 59d1c1c2 | Scott Tsai | const char *devname = qdict_get_str(qdict, "devname"); |
1481 | 59d1c1c2 | Scott Tsai | if (usb_device_del(devname) < 0) { |
1482 | 1ecda02b | Markus Armbruster | error_report("could not delete USB device '%s'", devname);
|
1483 | 59d1c1c2 | Scott Tsai | } |
1484 | a594cfbf | bellard | } |
1485 | a594cfbf | bellard | |
1486 | f7cce898 | bellard | /***********************************************************/
|
1487 | 201a51fc | balrog | /* PCMCIA/Cardbus */
|
1488 | 201a51fc | balrog | |
1489 | 201a51fc | balrog | static struct pcmcia_socket_entry_s { |
1490 | bc24a225 | Paul Brook | PCMCIASocket *socket; |
1491 | 201a51fc | balrog | struct pcmcia_socket_entry_s *next;
|
1492 | 201a51fc | balrog | } *pcmcia_sockets = 0;
|
1493 | 201a51fc | balrog | |
1494 | bc24a225 | Paul Brook | void pcmcia_socket_register(PCMCIASocket *socket)
|
1495 | 201a51fc | balrog | { |
1496 | 201a51fc | balrog | struct pcmcia_socket_entry_s *entry;
|
1497 | 201a51fc | balrog | |
1498 | 7267c094 | Anthony Liguori | entry = g_malloc(sizeof(struct pcmcia_socket_entry_s)); |
1499 | 201a51fc | balrog | entry->socket = socket; |
1500 | 201a51fc | balrog | entry->next = pcmcia_sockets; |
1501 | 201a51fc | balrog | pcmcia_sockets = entry; |
1502 | 201a51fc | balrog | } |
1503 | 201a51fc | balrog | |
1504 | bc24a225 | Paul Brook | void pcmcia_socket_unregister(PCMCIASocket *socket)
|
1505 | 201a51fc | balrog | { |
1506 | 201a51fc | balrog | struct pcmcia_socket_entry_s *entry, **ptr;
|
1507 | 201a51fc | balrog | |
1508 | 201a51fc | balrog | ptr = &pcmcia_sockets; |
1509 | 201a51fc | balrog | for (entry = *ptr; entry; ptr = &entry->next, entry = *ptr)
|
1510 | 201a51fc | balrog | if (entry->socket == socket) {
|
1511 | 201a51fc | balrog | *ptr = entry->next; |
1512 | 7267c094 | Anthony Liguori | g_free(entry); |
1513 | 201a51fc | balrog | } |
1514 | 201a51fc | balrog | } |
1515 | 201a51fc | balrog | |
1516 | 84f2d0ea | Wenchao Xia | void pcmcia_info(Monitor *mon, const QDict *qdict) |
1517 | 201a51fc | balrog | { |
1518 | 201a51fc | balrog | struct pcmcia_socket_entry_s *iter;
|
1519 | 376253ec | aliguori | |
1520 | 201a51fc | balrog | if (!pcmcia_sockets)
|
1521 | 376253ec | aliguori | monitor_printf(mon, "No PCMCIA sockets\n");
|
1522 | 201a51fc | balrog | |
1523 | 201a51fc | balrog | for (iter = pcmcia_sockets; iter; iter = iter->next)
|
1524 | 376253ec | aliguori | monitor_printf(mon, "%s: %s\n", iter->socket->slot_string,
|
1525 | 376253ec | aliguori | iter->socket->attached ? iter->socket->card_string : |
1526 | 376253ec | aliguori | "Empty");
|
1527 | 201a51fc | balrog | } |
1528 | 201a51fc | balrog | |
1529 | 201a51fc | balrog | /***********************************************************/
|
1530 | cc1daa40 | bellard | /* machine registration */
|
1531 | cc1daa40 | bellard | |
1532 | bdaf78e0 | blueswir1 | static QEMUMachine *first_machine = NULL; |
1533 | 6f338c34 | aliguori | QEMUMachine *current_machine = NULL;
|
1534 | cc1daa40 | bellard | |
1535 | cc1daa40 | bellard | int qemu_register_machine(QEMUMachine *m)
|
1536 | cc1daa40 | bellard | { |
1537 | cc1daa40 | bellard | QEMUMachine **pm; |
1538 | cc1daa40 | bellard | pm = &first_machine; |
1539 | cc1daa40 | bellard | while (*pm != NULL) |
1540 | cc1daa40 | bellard | pm = &(*pm)->next; |
1541 | cc1daa40 | bellard | m->next = NULL;
|
1542 | cc1daa40 | bellard | *pm = m; |
1543 | cc1daa40 | bellard | return 0; |
1544 | cc1daa40 | bellard | } |
1545 | cc1daa40 | bellard | |
1546 | 9596ebb7 | pbrook | static QEMUMachine *find_machine(const char *name) |
1547 | cc1daa40 | bellard | { |
1548 | cc1daa40 | bellard | QEMUMachine *m; |
1549 | cc1daa40 | bellard | |
1550 | cc1daa40 | bellard | for(m = first_machine; m != NULL; m = m->next) { |
1551 | cc1daa40 | bellard | if (!strcmp(m->name, name))
|
1552 | cc1daa40 | bellard | return m;
|
1553 | 3f6599e6 | Mark McLoughlin | if (m->alias && !strcmp(m->alias, name))
|
1554 | 3f6599e6 | Mark McLoughlin | return m;
|
1555 | cc1daa40 | bellard | } |
1556 | cc1daa40 | bellard | return NULL; |
1557 | cc1daa40 | bellard | } |
1558 | cc1daa40 | bellard | |
1559 | 2c8cffa5 | Jordan Justen | QEMUMachine *find_default_machine(void)
|
1560 | 0c257437 | Anthony Liguori | { |
1561 | 0c257437 | Anthony Liguori | QEMUMachine *m; |
1562 | 0c257437 | Anthony Liguori | |
1563 | 0c257437 | Anthony Liguori | for(m = first_machine; m != NULL; m = m->next) { |
1564 | 0c257437 | Anthony Liguori | if (m->is_default) {
|
1565 | 0c257437 | Anthony Liguori | return m;
|
1566 | 0c257437 | Anthony Liguori | } |
1567 | 0c257437 | Anthony Liguori | } |
1568 | 0c257437 | Anthony Liguori | return NULL; |
1569 | 0c257437 | Anthony Liguori | } |
1570 | 0c257437 | Anthony Liguori | |
1571 | 01d3c80d | Anthony Liguori | MachineInfoList *qmp_query_machines(Error **errp) |
1572 | 01d3c80d | Anthony Liguori | { |
1573 | 01d3c80d | Anthony Liguori | MachineInfoList *mach_list = NULL;
|
1574 | 01d3c80d | Anthony Liguori | QEMUMachine *m; |
1575 | 01d3c80d | Anthony Liguori | |
1576 | 01d3c80d | Anthony Liguori | for (m = first_machine; m; m = m->next) {
|
1577 | 01d3c80d | Anthony Liguori | MachineInfoList *entry; |
1578 | 01d3c80d | Anthony Liguori | MachineInfo *info; |
1579 | 01d3c80d | Anthony Liguori | |
1580 | 01d3c80d | Anthony Liguori | info = g_malloc0(sizeof(*info));
|
1581 | 01d3c80d | Anthony Liguori | if (m->is_default) {
|
1582 | 01d3c80d | Anthony Liguori | info->has_is_default = true;
|
1583 | 01d3c80d | Anthony Liguori | info->is_default = true;
|
1584 | 01d3c80d | Anthony Liguori | } |
1585 | 01d3c80d | Anthony Liguori | |
1586 | 01d3c80d | Anthony Liguori | if (m->alias) {
|
1587 | 01d3c80d | Anthony Liguori | info->has_alias = true;
|
1588 | 01d3c80d | Anthony Liguori | info->alias = g_strdup(m->alias); |
1589 | 01d3c80d | Anthony Liguori | } |
1590 | 01d3c80d | Anthony Liguori | |
1591 | 01d3c80d | Anthony Liguori | info->name = g_strdup(m->name); |
1592 | c72e7688 | Michal Novotny | info->cpu_max = !m->max_cpus ? 1 : m->max_cpus;
|
1593 | 01d3c80d | Anthony Liguori | |
1594 | 01d3c80d | Anthony Liguori | entry = g_malloc0(sizeof(*entry));
|
1595 | 01d3c80d | Anthony Liguori | entry->value = info; |
1596 | 01d3c80d | Anthony Liguori | entry->next = mach_list; |
1597 | 01d3c80d | Anthony Liguori | mach_list = entry; |
1598 | 01d3c80d | Anthony Liguori | } |
1599 | 01d3c80d | Anthony Liguori | |
1600 | 01d3c80d | Anthony Liguori | return mach_list;
|
1601 | 01d3c80d | Anthony Liguori | } |
1602 | 01d3c80d | Anthony Liguori | |
1603 | cc1daa40 | bellard | /***********************************************************/
|
1604 | 8a7ddc38 | bellard | /* main execution loop */
|
1605 | 8a7ddc38 | bellard | |
1606 | 0bd48850 | bellard | struct vm_change_state_entry {
|
1607 | 0bd48850 | bellard | VMChangeStateHandler *cb; |
1608 | 0bd48850 | bellard | void *opaque;
|
1609 | 72cf2d4f | Blue Swirl | QLIST_ENTRY (vm_change_state_entry) entries; |
1610 | 0bd48850 | bellard | }; |
1611 | 0bd48850 | bellard | |
1612 | 72cf2d4f | Blue Swirl | static QLIST_HEAD(vm_change_state_head, vm_change_state_entry) vm_change_state_head;
|
1613 | 0bd48850 | bellard | |
1614 | 0bd48850 | bellard | VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, |
1615 | 0bd48850 | bellard | void *opaque)
|
1616 | 0bd48850 | bellard | { |
1617 | 0bd48850 | bellard | VMChangeStateEntry *e; |
1618 | 0bd48850 | bellard | |
1619 | 7267c094 | Anthony Liguori | e = g_malloc0(sizeof (*e));
|
1620 | 0bd48850 | bellard | |
1621 | 0bd48850 | bellard | e->cb = cb; |
1622 | 0bd48850 | bellard | e->opaque = opaque; |
1623 | 72cf2d4f | Blue Swirl | QLIST_INSERT_HEAD(&vm_change_state_head, e, entries); |
1624 | 0bd48850 | bellard | return e;
|
1625 | 0bd48850 | bellard | } |
1626 | 0bd48850 | bellard | |
1627 | 0bd48850 | bellard | void qemu_del_vm_change_state_handler(VMChangeStateEntry *e)
|
1628 | 0bd48850 | bellard | { |
1629 | 72cf2d4f | Blue Swirl | QLIST_REMOVE (e, entries); |
1630 | 7267c094 | Anthony Liguori | g_free (e); |
1631 | 0bd48850 | bellard | } |
1632 | 0bd48850 | bellard | |
1633 | 1dfb4dd9 | Luiz Capitulino | void vm_state_notify(int running, RunState state) |
1634 | 0bd48850 | bellard | { |
1635 | 0bd48850 | bellard | VMChangeStateEntry *e; |
1636 | 0bd48850 | bellard | |
1637 | 1dfb4dd9 | Luiz Capitulino | trace_vm_state_notify(running, state); |
1638 | 94b0b5ff | Stefan Hajnoczi | |
1639 | 0bd48850 | bellard | for (e = vm_change_state_head.lh_first; e; e = e->entries.le_next) {
|
1640 | 1dfb4dd9 | Luiz Capitulino | e->cb(e->opaque, running, state); |
1641 | 0bd48850 | bellard | } |
1642 | 0bd48850 | bellard | } |
1643 | 0bd48850 | bellard | |
1644 | 8a7ddc38 | bellard | void vm_start(void) |
1645 | 8a7ddc38 | bellard | { |
1646 | 1354869c | Luiz Capitulino | if (!runstate_is_running()) {
|
1647 | 8a7ddc38 | bellard | cpu_enable_ticks(); |
1648 | 0461d5a6 | Luiz Capitulino | runstate_set(RUN_STATE_RUNNING); |
1649 | 0461d5a6 | Luiz Capitulino | vm_state_notify(1, RUN_STATE_RUNNING);
|
1650 | d6dc3d42 | aliguori | resume_all_vcpus(); |
1651 | 6ed2c484 | Luiz Capitulino | monitor_protocol_event(QEVENT_RESUME, NULL);
|
1652 | 8a7ddc38 | bellard | } |
1653 | 8a7ddc38 | bellard | } |
1654 | 8a7ddc38 | bellard | |
1655 | bb0c6722 | bellard | /* reset/shutdown handler */
|
1656 | bb0c6722 | bellard | |
1657 | bb0c6722 | bellard | typedef struct QEMUResetEntry { |
1658 | 72cf2d4f | Blue Swirl | QTAILQ_ENTRY(QEMUResetEntry) entry; |
1659 | bb0c6722 | bellard | QEMUResetHandler *func; |
1660 | bb0c6722 | bellard | void *opaque;
|
1661 | bb0c6722 | bellard | } QEMUResetEntry; |
1662 | bb0c6722 | bellard | |
1663 | 72cf2d4f | Blue Swirl | static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
|
1664 | 72cf2d4f | Blue Swirl | QTAILQ_HEAD_INITIALIZER(reset_handlers); |
1665 | bb0c6722 | bellard | static int reset_requested; |
1666 | f64622c4 | Gleb Natapov | static int shutdown_requested, shutdown_signal = -1; |
1667 | f64622c4 | Gleb Natapov | static pid_t shutdown_pid;
|
1668 | 3475187d | bellard | static int powerdown_requested; |
1669 | 8cf71710 | Jan Kiszka | static int debug_requested; |
1670 | 95b363b5 | Gerd Hoffmann | static int suspend_requested; |
1671 | 4bc78a87 | Liu, Jinsong | static WakeupReason wakeup_reason;
|
1672 | a9552c8e | Igor Mammedov | static NotifierList powerdown_notifiers =
|
1673 | a9552c8e | Igor Mammedov | NOTIFIER_LIST_INITIALIZER(powerdown_notifiers); |
1674 | 95b363b5 | Gerd Hoffmann | static NotifierList suspend_notifiers =
|
1675 | 95b363b5 | Gerd Hoffmann | NOTIFIER_LIST_INITIALIZER(suspend_notifiers); |
1676 | 95b363b5 | Gerd Hoffmann | static NotifierList wakeup_notifiers =
|
1677 | 95b363b5 | Gerd Hoffmann | NOTIFIER_LIST_INITIALIZER(wakeup_notifiers); |
1678 | 4bc78a87 | Liu, Jinsong | static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE); |
1679 | 0461d5a6 | Luiz Capitulino | static RunState vmstop_requested = RUN_STATE_MAX;
|
1680 | bb0c6722 | bellard | |
1681 | 1291eb35 | Anthony PERARD | int qemu_shutdown_requested_get(void) |
1682 | 1291eb35 | Anthony PERARD | { |
1683 | 1291eb35 | Anthony PERARD | return shutdown_requested;
|
1684 | 1291eb35 | Anthony PERARD | } |
1685 | 1291eb35 | Anthony PERARD | |
1686 | 1291eb35 | Anthony PERARD | int qemu_reset_requested_get(void) |
1687 | 1291eb35 | Anthony PERARD | { |
1688 | 1291eb35 | Anthony PERARD | return reset_requested;
|
1689 | 1291eb35 | Anthony PERARD | } |
1690 | 1291eb35 | Anthony PERARD | |
1691 | 4fdcac0e | Blue Swirl | static int qemu_shutdown_requested(void) |
1692 | cf7a2fe2 | aurel32 | { |
1693 | cf7a2fe2 | aurel32 | int r = shutdown_requested;
|
1694 | cf7a2fe2 | aurel32 | shutdown_requested = 0;
|
1695 | cf7a2fe2 | aurel32 | return r;
|
1696 | cf7a2fe2 | aurel32 | } |
1697 | cf7a2fe2 | aurel32 | |
1698 | 4fdcac0e | Blue Swirl | static void qemu_kill_report(void) |
1699 | f64622c4 | Gleb Natapov | { |
1700 | 35b30712 | Michael S. Tsirkin | if (!qtest_driver() && shutdown_signal != -1) { |
1701 | f1d3fb04 | Peter Maydell | fprintf(stderr, "qemu: terminating on signal %d", shutdown_signal);
|
1702 | f1d3fb04 | Peter Maydell | if (shutdown_pid == 0) { |
1703 | f1d3fb04 | Peter Maydell | /* This happens for eg ^C at the terminal, so it's worth
|
1704 | f1d3fb04 | Peter Maydell | * avoiding printing an odd message in that case.
|
1705 | f1d3fb04 | Peter Maydell | */
|
1706 | f1d3fb04 | Peter Maydell | fputc('\n', stderr);
|
1707 | f1d3fb04 | Peter Maydell | } else {
|
1708 | 953ffe0f | Andreas Färber | fprintf(stderr, " from pid " FMT_pid "\n", shutdown_pid); |
1709 | f1d3fb04 | Peter Maydell | } |
1710 | f64622c4 | Gleb Natapov | shutdown_signal = -1;
|
1711 | f64622c4 | Gleb Natapov | } |
1712 | f64622c4 | Gleb Natapov | } |
1713 | f64622c4 | Gleb Natapov | |
1714 | 4fdcac0e | Blue Swirl | static int qemu_reset_requested(void) |
1715 | cf7a2fe2 | aurel32 | { |
1716 | cf7a2fe2 | aurel32 | int r = reset_requested;
|
1717 | cf7a2fe2 | aurel32 | reset_requested = 0;
|
1718 | cf7a2fe2 | aurel32 | return r;
|
1719 | cf7a2fe2 | aurel32 | } |
1720 | cf7a2fe2 | aurel32 | |
1721 | 95b363b5 | Gerd Hoffmann | static int qemu_suspend_requested(void) |
1722 | 95b363b5 | Gerd Hoffmann | { |
1723 | 95b363b5 | Gerd Hoffmann | int r = suspend_requested;
|
1724 | 95b363b5 | Gerd Hoffmann | suspend_requested = 0;
|
1725 | 95b363b5 | Gerd Hoffmann | return r;
|
1726 | 95b363b5 | Gerd Hoffmann | } |
1727 | 95b363b5 | Gerd Hoffmann | |
1728 | 4bc78a87 | Liu, Jinsong | static WakeupReason qemu_wakeup_requested(void) |
1729 | 14058196 | Luiz Capitulino | { |
1730 | 4bc78a87 | Liu, Jinsong | return wakeup_reason;
|
1731 | 14058196 | Luiz Capitulino | } |
1732 | 14058196 | Luiz Capitulino | |
1733 | 4fdcac0e | Blue Swirl | static int qemu_powerdown_requested(void) |
1734 | cf7a2fe2 | aurel32 | { |
1735 | cf7a2fe2 | aurel32 | int r = powerdown_requested;
|
1736 | cf7a2fe2 | aurel32 | powerdown_requested = 0;
|
1737 | cf7a2fe2 | aurel32 | return r;
|
1738 | cf7a2fe2 | aurel32 | } |
1739 | cf7a2fe2 | aurel32 | |
1740 | e568902a | aliguori | static int qemu_debug_requested(void) |
1741 | e568902a | aliguori | { |
1742 | e568902a | aliguori | int r = debug_requested;
|
1743 | e568902a | aliguori | debug_requested = 0;
|
1744 | e568902a | aliguori | return r;
|
1745 | e568902a | aliguori | } |
1746 | e568902a | aliguori | |
1747 | 0461d5a6 | Luiz Capitulino | /* We use RUN_STATE_MAX but any invalid value will do */
|
1748 | 0d45b702 | Luiz Capitulino | static bool qemu_vmstop_requested(RunState *r) |
1749 | 6e29f5da | aliguori | { |
1750 | 0461d5a6 | Luiz Capitulino | if (vmstop_requested < RUN_STATE_MAX) {
|
1751 | 0d45b702 | Luiz Capitulino | *r = vmstop_requested; |
1752 | 0461d5a6 | Luiz Capitulino | vmstop_requested = RUN_STATE_MAX; |
1753 | 0d45b702 | Luiz Capitulino | return true; |
1754 | 0d45b702 | Luiz Capitulino | } |
1755 | 0d45b702 | Luiz Capitulino | |
1756 | 0d45b702 | Luiz Capitulino | return false; |
1757 | 6e29f5da | aliguori | } |
1758 | 6e29f5da | aliguori | |
1759 | a08d4367 | Jan Kiszka | void qemu_register_reset(QEMUResetHandler *func, void *opaque) |
1760 | bb0c6722 | bellard | { |
1761 | 7267c094 | Anthony Liguori | QEMUResetEntry *re = g_malloc0(sizeof(QEMUResetEntry));
|
1762 | bb0c6722 | bellard | |
1763 | bb0c6722 | bellard | re->func = func; |
1764 | bb0c6722 | bellard | re->opaque = opaque; |
1765 | 72cf2d4f | Blue Swirl | QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); |
1766 | bb0c6722 | bellard | } |
1767 | bb0c6722 | bellard | |
1768 | dda9b29f | Jan Kiszka | void qemu_unregister_reset(QEMUResetHandler *func, void *opaque) |
1769 | bb0c6722 | bellard | { |
1770 | bb0c6722 | bellard | QEMUResetEntry *re; |
1771 | bb0c6722 | bellard | |
1772 | 72cf2d4f | Blue Swirl | QTAILQ_FOREACH(re, &reset_handlers, entry) { |
1773 | dda9b29f | Jan Kiszka | if (re->func == func && re->opaque == opaque) {
|
1774 | 72cf2d4f | Blue Swirl | QTAILQ_REMOVE(&reset_handlers, re, entry); |
1775 | 7267c094 | Anthony Liguori | g_free(re); |
1776 | dda9b29f | Jan Kiszka | return;
|
1777 | dda9b29f | Jan Kiszka | } |
1778 | dda9b29f | Jan Kiszka | } |
1779 | dda9b29f | Jan Kiszka | } |
1780 | dda9b29f | Jan Kiszka | |
1781 | be522029 | David Gibson | void qemu_devices_reset(void) |
1782 | dda9b29f | Jan Kiszka | { |
1783 | dda9b29f | Jan Kiszka | QEMUResetEntry *re, *nre; |
1784 | dda9b29f | Jan Kiszka | |
1785 | dda9b29f | Jan Kiszka | /* reset all devices */
|
1786 | 72cf2d4f | Blue Swirl | QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) { |
1787 | bb0c6722 | bellard | re->func(re->opaque); |
1788 | bb0c6722 | bellard | } |
1789 | be522029 | David Gibson | } |
1790 | be522029 | David Gibson | |
1791 | be522029 | David Gibson | void qemu_system_reset(bool report) |
1792 | be522029 | David Gibson | { |
1793 | be522029 | David Gibson | if (current_machine && current_machine->reset) {
|
1794 | be522029 | David Gibson | current_machine->reset(); |
1795 | be522029 | David Gibson | } else {
|
1796 | be522029 | David Gibson | qemu_devices_reset(); |
1797 | be522029 | David Gibson | } |
1798 | e063eb1f | Jan Kiszka | if (report) {
|
1799 | e063eb1f | Jan Kiszka | monitor_protocol_event(QEVENT_RESET, NULL);
|
1800 | e063eb1f | Jan Kiszka | } |
1801 | ea375f9a | Jan Kiszka | cpu_synchronize_all_post_reset(); |
1802 | bb0c6722 | bellard | } |
1803 | bb0c6722 | bellard | |
1804 | bb0c6722 | bellard | void qemu_system_reset_request(void) |
1805 | bb0c6722 | bellard | { |
1806 | d1beab82 | bellard | if (no_reboot) {
|
1807 | d1beab82 | bellard | shutdown_requested = 1;
|
1808 | d1beab82 | bellard | } else {
|
1809 | d1beab82 | bellard | reset_requested = 1;
|
1810 | d1beab82 | bellard | } |
1811 | b4a3d965 | Jan Kiszka | cpu_stop_current(); |
1812 | d9f75a4e | aliguori | qemu_notify_event(); |
1813 | bb0c6722 | bellard | } |
1814 | bb0c6722 | bellard | |
1815 | 95b363b5 | Gerd Hoffmann | static void qemu_system_suspend(void) |
1816 | 95b363b5 | Gerd Hoffmann | { |
1817 | 95b363b5 | Gerd Hoffmann | pause_all_vcpus(); |
1818 | 95b363b5 | Gerd Hoffmann | notifier_list_notify(&suspend_notifiers, NULL);
|
1819 | ad02b96a | Luiz Capitulino | runstate_set(RUN_STATE_SUSPENDED); |
1820 | 53370b78 | Gerd Hoffmann | monitor_protocol_event(QEVENT_SUSPEND, NULL);
|
1821 | 95b363b5 | Gerd Hoffmann | } |
1822 | 95b363b5 | Gerd Hoffmann | |
1823 | 95b363b5 | Gerd Hoffmann | void qemu_system_suspend_request(void) |
1824 | 95b363b5 | Gerd Hoffmann | { |
1825 | 9abc62f6 | Luiz Capitulino | if (runstate_check(RUN_STATE_SUSPENDED)) {
|
1826 | 95b363b5 | Gerd Hoffmann | return;
|
1827 | 95b363b5 | Gerd Hoffmann | } |
1828 | 95b363b5 | Gerd Hoffmann | suspend_requested = 1;
|
1829 | 95b363b5 | Gerd Hoffmann | cpu_stop_current(); |
1830 | 95b363b5 | Gerd Hoffmann | qemu_notify_event(); |
1831 | 95b363b5 | Gerd Hoffmann | } |
1832 | 95b363b5 | Gerd Hoffmann | |
1833 | 95b363b5 | Gerd Hoffmann | void qemu_register_suspend_notifier(Notifier *notifier)
|
1834 | 95b363b5 | Gerd Hoffmann | { |
1835 | 95b363b5 | Gerd Hoffmann | notifier_list_add(&suspend_notifiers, notifier); |
1836 | 95b363b5 | Gerd Hoffmann | } |
1837 | 95b363b5 | Gerd Hoffmann | |
1838 | 95b363b5 | Gerd Hoffmann | void qemu_system_wakeup_request(WakeupReason reason)
|
1839 | 95b363b5 | Gerd Hoffmann | { |
1840 | 9abc62f6 | Luiz Capitulino | if (!runstate_check(RUN_STATE_SUSPENDED)) {
|
1841 | 95b363b5 | Gerd Hoffmann | return;
|
1842 | 95b363b5 | Gerd Hoffmann | } |
1843 | 95b363b5 | Gerd Hoffmann | if (!(wakeup_reason_mask & (1 << reason))) { |
1844 | 95b363b5 | Gerd Hoffmann | return;
|
1845 | 95b363b5 | Gerd Hoffmann | } |
1846 | ad02b96a | Luiz Capitulino | runstate_set(RUN_STATE_RUNNING); |
1847 | 4bc78a87 | Liu, Jinsong | wakeup_reason = reason; |
1848 | 95b363b5 | Gerd Hoffmann | qemu_notify_event(); |
1849 | 95b363b5 | Gerd Hoffmann | } |
1850 | 95b363b5 | Gerd Hoffmann | |
1851 | 95b363b5 | Gerd Hoffmann | void qemu_system_wakeup_enable(WakeupReason reason, bool enabled) |
1852 | 95b363b5 | Gerd Hoffmann | { |
1853 | 95b363b5 | Gerd Hoffmann | if (enabled) {
|
1854 | 95b363b5 | Gerd Hoffmann | wakeup_reason_mask |= (1 << reason);
|
1855 | 95b363b5 | Gerd Hoffmann | } else {
|
1856 | 95b363b5 | Gerd Hoffmann | wakeup_reason_mask &= ~(1 << reason);
|
1857 | 95b363b5 | Gerd Hoffmann | } |
1858 | 95b363b5 | Gerd Hoffmann | } |
1859 | 95b363b5 | Gerd Hoffmann | |
1860 | 95b363b5 | Gerd Hoffmann | void qemu_register_wakeup_notifier(Notifier *notifier)
|
1861 | 95b363b5 | Gerd Hoffmann | { |
1862 | 95b363b5 | Gerd Hoffmann | notifier_list_add(&wakeup_notifiers, notifier); |
1863 | 95b363b5 | Gerd Hoffmann | } |
1864 | 95b363b5 | Gerd Hoffmann | |
1865 | f64622c4 | Gleb Natapov | void qemu_system_killed(int signal, pid_t pid) |
1866 | f64622c4 | Gleb Natapov | { |
1867 | f64622c4 | Gleb Natapov | shutdown_signal = signal; |
1868 | f64622c4 | Gleb Natapov | shutdown_pid = pid; |
1869 | d9389b96 | Kevin Wolf | no_shutdown = 0;
|
1870 | f64622c4 | Gleb Natapov | qemu_system_shutdown_request(); |
1871 | f64622c4 | Gleb Natapov | } |
1872 | f64622c4 | Gleb Natapov | |
1873 | bb0c6722 | bellard | void qemu_system_shutdown_request(void) |
1874 | bb0c6722 | bellard | { |
1875 | bb0c6722 | bellard | shutdown_requested = 1;
|
1876 | d9f75a4e | aliguori | qemu_notify_event(); |
1877 | bb0c6722 | bellard | } |
1878 | bb0c6722 | bellard | |
1879 | 013c2f15 | Igor Mammedov | static void qemu_system_powerdown(void) |
1880 | 013c2f15 | Igor Mammedov | { |
1881 | 013c2f15 | Igor Mammedov | monitor_protocol_event(QEVENT_POWERDOWN, NULL);
|
1882 | 013c2f15 | Igor Mammedov | notifier_list_notify(&powerdown_notifiers, NULL);
|
1883 | 013c2f15 | Igor Mammedov | } |
1884 | 013c2f15 | Igor Mammedov | |
1885 | 3475187d | bellard | void qemu_system_powerdown_request(void) |
1886 | 3475187d | bellard | { |
1887 | 3475187d | bellard | powerdown_requested = 1;
|
1888 | d9f75a4e | aliguori | qemu_notify_event(); |
1889 | d9f75a4e | aliguori | } |
1890 | d9f75a4e | aliguori | |
1891 | a9552c8e | Igor Mammedov | void qemu_register_powerdown_notifier(Notifier *notifier)
|
1892 | a9552c8e | Igor Mammedov | { |
1893 | a9552c8e | Igor Mammedov | notifier_list_add(&powerdown_notifiers, notifier); |
1894 | a9552c8e | Igor Mammedov | } |
1895 | a9552c8e | Igor Mammedov | |
1896 | 8cf71710 | Jan Kiszka | void qemu_system_debug_request(void) |
1897 | 8cf71710 | Jan Kiszka | { |
1898 | 8cf71710 | Jan Kiszka | debug_requested = 1;
|
1899 | 83f338f7 | Jan Kiszka | qemu_notify_event(); |
1900 | 8cf71710 | Jan Kiszka | } |
1901 | 8cf71710 | Jan Kiszka | |
1902 | 1dfb4dd9 | Luiz Capitulino | void qemu_system_vmstop_request(RunState state)
|
1903 | 8cf71710 | Jan Kiszka | { |
1904 | 1dfb4dd9 | Luiz Capitulino | vmstop_requested = state; |
1905 | 8cf71710 | Jan Kiszka | qemu_notify_event(); |
1906 | 8cf71710 | Jan Kiszka | } |
1907 | 8cf71710 | Jan Kiszka | |
1908 | 99435906 | Paolo Bonzini | static bool main_loop_should_exit(void) |
1909 | 99435906 | Paolo Bonzini | { |
1910 | 99435906 | Paolo Bonzini | RunState r; |
1911 | 99435906 | Paolo Bonzini | if (qemu_debug_requested()) {
|
1912 | 99435906 | Paolo Bonzini | vm_stop(RUN_STATE_DEBUG); |
1913 | 99435906 | Paolo Bonzini | } |
1914 | 95b363b5 | Gerd Hoffmann | if (qemu_suspend_requested()) {
|
1915 | 95b363b5 | Gerd Hoffmann | qemu_system_suspend(); |
1916 | 95b363b5 | Gerd Hoffmann | } |
1917 | 99435906 | Paolo Bonzini | if (qemu_shutdown_requested()) {
|
1918 | 99435906 | Paolo Bonzini | qemu_kill_report(); |
1919 | 99435906 | Paolo Bonzini | monitor_protocol_event(QEVENT_SHUTDOWN, NULL);
|
1920 | 99435906 | Paolo Bonzini | if (no_shutdown) {
|
1921 | 99435906 | Paolo Bonzini | vm_stop(RUN_STATE_SHUTDOWN); |
1922 | 99435906 | Paolo Bonzini | } else {
|
1923 | 99435906 | Paolo Bonzini | return true; |
1924 | 99435906 | Paolo Bonzini | } |
1925 | 99435906 | Paolo Bonzini | } |
1926 | 99435906 | Paolo Bonzini | if (qemu_reset_requested()) {
|
1927 | 99435906 | Paolo Bonzini | pause_all_vcpus(); |
1928 | 99435906 | Paolo Bonzini | cpu_synchronize_all_states(); |
1929 | 99435906 | Paolo Bonzini | qemu_system_reset(VMRESET_REPORT); |
1930 | 99435906 | Paolo Bonzini | resume_all_vcpus(); |
1931 | ede085b3 | Hu Tao | if (runstate_needs_reset()) {
|
1932 | 99435906 | Paolo Bonzini | runstate_set(RUN_STATE_PAUSED); |
1933 | 99435906 | Paolo Bonzini | } |
1934 | 99435906 | Paolo Bonzini | } |
1935 | 14058196 | Luiz Capitulino | if (qemu_wakeup_requested()) {
|
1936 | 14058196 | Luiz Capitulino | pause_all_vcpus(); |
1937 | 14058196 | Luiz Capitulino | cpu_synchronize_all_states(); |
1938 | 14058196 | Luiz Capitulino | qemu_system_reset(VMRESET_SILENT); |
1939 | 4bc78a87 | Liu, Jinsong | notifier_list_notify(&wakeup_notifiers, &wakeup_reason); |
1940 | 4bc78a87 | Liu, Jinsong | wakeup_reason = QEMU_WAKEUP_REASON_NONE; |
1941 | 14058196 | Luiz Capitulino | resume_all_vcpus(); |
1942 | 17c8660b | Luiz Capitulino | monitor_protocol_event(QEVENT_WAKEUP, NULL);
|
1943 | 14058196 | Luiz Capitulino | } |
1944 | 99435906 | Paolo Bonzini | if (qemu_powerdown_requested()) {
|
1945 | 013c2f15 | Igor Mammedov | qemu_system_powerdown(); |
1946 | 99435906 | Paolo Bonzini | } |
1947 | 99435906 | Paolo Bonzini | if (qemu_vmstop_requested(&r)) {
|
1948 | 99435906 | Paolo Bonzini | vm_stop(r); |
1949 | 99435906 | Paolo Bonzini | } |
1950 | 99435906 | Paolo Bonzini | return false; |
1951 | 99435906 | Paolo Bonzini | } |
1952 | 99435906 | Paolo Bonzini | |
1953 | 43b96858 | aliguori | static void main_loop(void) |
1954 | 43b96858 | aliguori | { |
1955 | c9f711a5 | Jan Kiszka | bool nonblocking;
|
1956 | 99435906 | Paolo Bonzini | int last_io = 0; |
1957 | 8e1b90ec | Jan Kiszka | #ifdef CONFIG_PROFILER
|
1958 | 8e1b90ec | Jan Kiszka | int64_t ti; |
1959 | 8e1b90ec | Jan Kiszka | #endif
|
1960 | 99435906 | Paolo Bonzini | do {
|
1961 | a7d4207d | Stefano Stabellini | nonblocking = !kvm_enabled() && !xen_enabled() && last_io > 0;
|
1962 | 89bfc105 | bellard | #ifdef CONFIG_PROFILER
|
1963 | 46481d39 | Jan Kiszka | ti = profile_getclock(); |
1964 | 89bfc105 | bellard | #endif
|
1965 | c9f711a5 | Jan Kiszka | last_io = main_loop_wait(nonblocking); |
1966 | 89bfc105 | bellard | #ifdef CONFIG_PROFILER
|
1967 | 46481d39 | Jan Kiszka | dev_time += profile_getclock() - ti; |
1968 | 89bfc105 | bellard | #endif
|
1969 | 99435906 | Paolo Bonzini | } while (!main_loop_should_exit());
|
1970 | b4608c04 | bellard | } |
1971 | b4608c04 | bellard | |
1972 | 9bd7e6d9 | pbrook | static void version(void) |
1973 | 9bd7e6d9 | pbrook | { |
1974 | f75ca1ae | Thomas Monjalon | printf("QEMU emulator version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"); |
1975 | 9bd7e6d9 | pbrook | } |
1976 | 9bd7e6d9 | pbrook | |
1977 | 15f82208 | ths | static void help(int exitcode) |
1978 | 0824d6fc | bellard | { |
1979 | a3adb7ad | Michael Ellerman | version(); |
1980 | a3adb7ad | Michael Ellerman | printf("usage: %s [options] [disk_image]\n\n"
|
1981 | a3adb7ad | Michael Ellerman | "'disk_image' is a raw hard disk image for IDE hard disk 0\n\n",
|
1982 | a3adb7ad | Michael Ellerman | error_get_progname()); |
1983 | a3adb7ad | Michael Ellerman | |
1984 | 77bd1119 | Michael Ellerman | #define QEMU_OPTIONS_GENERATE_HELP
|
1985 | 77bd1119 | Michael Ellerman | #include "qemu-options-wrapper.h" |
1986 | a3adb7ad | Michael Ellerman | |
1987 | a3adb7ad | Michael Ellerman | printf("\nDuring emulation, the following keys are useful:\n"
|
1988 | 3f020d70 | malc | "ctrl-alt-f toggle full screen\n"
|
1989 | 3f020d70 | malc | "ctrl-alt-n switch to virtual console 'n'\n"
|
1990 | 3f020d70 | malc | "ctrl-alt toggle mouse and keyboard grab\n"
|
1991 | 3f020d70 | malc | "\n"
|
1992 | a3adb7ad | Michael Ellerman | "When using -nographic, press 'ctrl-a h' to get some help.\n");
|
1993 | a3adb7ad | Michael Ellerman | |
1994 | 15f82208 | ths | exit(exitcode); |
1995 | 0824d6fc | bellard | } |
1996 | 0824d6fc | bellard | |
1997 | cd6f1169 | bellard | #define HAS_ARG 0x0001 |
1998 | cd6f1169 | bellard | |
1999 | cd6f1169 | bellard | typedef struct QEMUOption { |
2000 | cd6f1169 | bellard | const char *name; |
2001 | cd6f1169 | bellard | int flags;
|
2002 | cd6f1169 | bellard | int index;
|
2003 | ad96090a | Blue Swirl | uint32_t arch_mask; |
2004 | cd6f1169 | bellard | } QEMUOption; |
2005 | cd6f1169 | bellard | |
2006 | dbed7e40 | blueswir1 | static const QEMUOption qemu_options[] = { |
2007 | ad96090a | Blue Swirl | { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, |
2008 | 77bd1119 | Michael Ellerman | #define QEMU_OPTIONS_GENERATE_OPTIONS
|
2009 | 77bd1119 | Michael Ellerman | #include "qemu-options-wrapper.h" |
2010 | cd6f1169 | bellard | { NULL },
|
2011 | fc01f7e7 | bellard | }; |
2012 | a369da5f | Blue Swirl | |
2013 | a369da5f | Blue Swirl | static bool vga_available(void) |
2014 | a369da5f | Blue Swirl | { |
2015 | 36b7f27d | Aurelien Jarno | return object_class_by_name("VGA") || object_class_by_name("isa-vga"); |
2016 | a369da5f | Blue Swirl | } |
2017 | a369da5f | Blue Swirl | |
2018 | a369da5f | Blue Swirl | static bool cirrus_vga_available(void) |
2019 | a369da5f | Blue Swirl | { |
2020 | 36b7f27d | Aurelien Jarno | return object_class_by_name("cirrus-vga") |
2021 | 36b7f27d | Aurelien Jarno | || object_class_by_name("isa-cirrus-vga");
|
2022 | a369da5f | Blue Swirl | } |
2023 | a369da5f | Blue Swirl | |
2024 | a369da5f | Blue Swirl | static bool vmware_vga_available(void) |
2025 | a369da5f | Blue Swirl | { |
2026 | 36b7f27d | Aurelien Jarno | return object_class_by_name("vmware-svga"); |
2027 | a369da5f | Blue Swirl | } |
2028 | a369da5f | Blue Swirl | |
2029 | 879049a3 | Aurelien Jarno | static bool qxl_vga_available(void) |
2030 | 879049a3 | Aurelien Jarno | { |
2031 | 879049a3 | Aurelien Jarno | return object_class_by_name("qxl-vga"); |
2032 | 879049a3 | Aurelien Jarno | } |
2033 | 879049a3 | Aurelien Jarno | |
2034 | af87bf29 | Mark Cave-Ayland | static bool tcx_vga_available(void) |
2035 | af87bf29 | Mark Cave-Ayland | { |
2036 | af87bf29 | Mark Cave-Ayland | return object_class_by_name("SUNW,tcx"); |
2037 | af87bf29 | Mark Cave-Ayland | } |
2038 | af87bf29 | Mark Cave-Ayland | |
2039 | af87bf29 | Mark Cave-Ayland | static bool cg3_vga_available(void) |
2040 | af87bf29 | Mark Cave-Ayland | { |
2041 | af87bf29 | Mark Cave-Ayland | return object_class_by_name("cgthree"); |
2042 | af87bf29 | Mark Cave-Ayland | } |
2043 | af87bf29 | Mark Cave-Ayland | |
2044 | 3893c124 | malc | static void select_vgahw (const char *p) |
2045 | 3893c124 | malc | { |
2046 | 3893c124 | malc | const char *opts; |
2047 | 3893c124 | malc | |
2048 | 86176759 | Zachary Amsden | vga_interface_type = VGA_NONE; |
2049 | 3893c124 | malc | if (strstart(p, "std", &opts)) { |
2050 | a369da5f | Blue Swirl | if (vga_available()) {
|
2051 | a369da5f | Blue Swirl | vga_interface_type = VGA_STD; |
2052 | a369da5f | Blue Swirl | } else {
|
2053 | a369da5f | Blue Swirl | fprintf(stderr, "Error: standard VGA not available\n");
|
2054 | a369da5f | Blue Swirl | exit(0);
|
2055 | a369da5f | Blue Swirl | } |
2056 | 3893c124 | malc | } else if (strstart(p, "cirrus", &opts)) { |
2057 | a369da5f | Blue Swirl | if (cirrus_vga_available()) {
|
2058 | a369da5f | Blue Swirl | vga_interface_type = VGA_CIRRUS; |
2059 | a369da5f | Blue Swirl | } else {
|
2060 | a369da5f | Blue Swirl | fprintf(stderr, "Error: Cirrus VGA not available\n");
|
2061 | a369da5f | Blue Swirl | exit(0);
|
2062 | a369da5f | Blue Swirl | } |
2063 | 3893c124 | malc | } else if (strstart(p, "vmware", &opts)) { |
2064 | a369da5f | Blue Swirl | if (vmware_vga_available()) {
|
2065 | a369da5f | Blue Swirl | vga_interface_type = VGA_VMWARE; |
2066 | a369da5f | Blue Swirl | } else {
|
2067 | a369da5f | Blue Swirl | fprintf(stderr, "Error: VMWare SVGA not available\n");
|
2068 | a369da5f | Blue Swirl | exit(0);
|
2069 | a369da5f | Blue Swirl | } |
2070 | 94909d9f | aliguori | } else if (strstart(p, "xenfb", &opts)) { |
2071 | 86176759 | Zachary Amsden | vga_interface_type = VGA_XENFB; |
2072 | a19cbfb3 | Gerd Hoffmann | } else if (strstart(p, "qxl", &opts)) { |
2073 | 879049a3 | Aurelien Jarno | if (qxl_vga_available()) {
|
2074 | 879049a3 | Aurelien Jarno | vga_interface_type = VGA_QXL; |
2075 | 879049a3 | Aurelien Jarno | } else {
|
2076 | 879049a3 | Aurelien Jarno | fprintf(stderr, "Error: QXL VGA not available\n");
|
2077 | 879049a3 | Aurelien Jarno | exit(0);
|
2078 | 879049a3 | Aurelien Jarno | } |
2079 | af87bf29 | Mark Cave-Ayland | } else if (strstart(p, "tcx", &opts)) { |
2080 | af87bf29 | Mark Cave-Ayland | if (tcx_vga_available()) {
|
2081 | af87bf29 | Mark Cave-Ayland | vga_interface_type = VGA_TCX; |
2082 | af87bf29 | Mark Cave-Ayland | } else {
|
2083 | af87bf29 | Mark Cave-Ayland | fprintf(stderr, "Error: TCX framebuffer not available\n");
|
2084 | af87bf29 | Mark Cave-Ayland | exit(0);
|
2085 | af87bf29 | Mark Cave-Ayland | } |
2086 | af87bf29 | Mark Cave-Ayland | } else if (strstart(p, "cg3", &opts)) { |
2087 | af87bf29 | Mark Cave-Ayland | if (cg3_vga_available()) {
|
2088 | af87bf29 | Mark Cave-Ayland | vga_interface_type = VGA_CG3; |
2089 | af87bf29 | Mark Cave-Ayland | } else {
|
2090 | af87bf29 | Mark Cave-Ayland | fprintf(stderr, "Error: CG3 framebuffer not available\n");
|
2091 | af87bf29 | Mark Cave-Ayland | exit(0);
|
2092 | af87bf29 | Mark Cave-Ayland | } |
2093 | 28b85ed8 | aliguori | } else if (!strstart(p, "none", &opts)) { |
2094 | 3893c124 | malc | invalid_vga:
|
2095 | 3893c124 | malc | fprintf(stderr, "Unknown vga type: %s\n", p);
|
2096 | 3893c124 | malc | exit(1);
|
2097 | 3893c124 | malc | } |
2098 | cb5a7aa8 | malc | while (*opts) {
|
2099 | cb5a7aa8 | malc | const char *nextopt; |
2100 | cb5a7aa8 | malc | |
2101 | cb5a7aa8 | malc | if (strstart(opts, ",retrace=", &nextopt)) { |
2102 | cb5a7aa8 | malc | opts = nextopt; |
2103 | cb5a7aa8 | malc | if (strstart(opts, "dumb", &nextopt)) |
2104 | cb5a7aa8 | malc | vga_retrace_method = VGA_RETRACE_DUMB; |
2105 | cb5a7aa8 | malc | else if (strstart(opts, "precise", &nextopt)) |
2106 | cb5a7aa8 | malc | vga_retrace_method = VGA_RETRACE_PRECISE; |
2107 | cb5a7aa8 | malc | else goto invalid_vga; |
2108 | cb5a7aa8 | malc | } else goto invalid_vga; |
2109 | cb5a7aa8 | malc | opts = nextopt; |
2110 | cb5a7aa8 | malc | } |
2111 | 3893c124 | malc | } |
2112 | 3893c124 | malc | |
2113 | 1472a95b | Jes Sorensen | static DisplayType select_display(const char *p) |
2114 | 1472a95b | Jes Sorensen | { |
2115 | 1472a95b | Jes Sorensen | const char *opts; |
2116 | 1472a95b | Jes Sorensen | DisplayType display = DT_DEFAULT; |
2117 | 1472a95b | Jes Sorensen | |
2118 | 1472a95b | Jes Sorensen | if (strstart(p, "sdl", &opts)) { |
2119 | 1472a95b | Jes Sorensen | #ifdef CONFIG_SDL
|
2120 | 1472a95b | Jes Sorensen | display = DT_SDL; |
2121 | 1472a95b | Jes Sorensen | while (*opts) {
|
2122 | 1472a95b | Jes Sorensen | const char *nextopt; |
2123 | 1472a95b | Jes Sorensen | |
2124 | 1472a95b | Jes Sorensen | if (strstart(opts, ",frame=", &nextopt)) { |
2125 | 1472a95b | Jes Sorensen | opts = nextopt; |
2126 | 1472a95b | Jes Sorensen | if (strstart(opts, "on", &nextopt)) { |
2127 | 1472a95b | Jes Sorensen | no_frame = 0;
|
2128 | 1472a95b | Jes Sorensen | } else if (strstart(opts, "off", &nextopt)) { |
2129 | 1472a95b | Jes Sorensen | no_frame = 1;
|
2130 | 1472a95b | Jes Sorensen | } else {
|
2131 | 05175535 | Peter Maydell | goto invalid_sdl_args;
|
2132 | 1472a95b | Jes Sorensen | } |
2133 | 1472a95b | Jes Sorensen | } else if (strstart(opts, ",alt_grab=", &nextopt)) { |
2134 | 1472a95b | Jes Sorensen | opts = nextopt; |
2135 | 1472a95b | Jes Sorensen | if (strstart(opts, "on", &nextopt)) { |
2136 | 1472a95b | Jes Sorensen | alt_grab = 1;
|
2137 | 1472a95b | Jes Sorensen | } else if (strstart(opts, "off", &nextopt)) { |
2138 | 1472a95b | Jes Sorensen | alt_grab = 0;
|
2139 | 1472a95b | Jes Sorensen | } else {
|
2140 | 05175535 | Peter Maydell | goto invalid_sdl_args;
|
2141 | 1472a95b | Jes Sorensen | } |
2142 | 1472a95b | Jes Sorensen | } else if (strstart(opts, ",ctrl_grab=", &nextopt)) { |
2143 | 1472a95b | Jes Sorensen | opts = nextopt; |
2144 | 1472a95b | Jes Sorensen | if (strstart(opts, "on", &nextopt)) { |
2145 | 1472a95b | Jes Sorensen | ctrl_grab = 1;
|
2146 | 1472a95b | Jes Sorensen | } else if (strstart(opts, "off", &nextopt)) { |
2147 | 1472a95b | Jes Sorensen | ctrl_grab = 0;
|
2148 | 1472a95b | Jes Sorensen | } else {
|
2149 | 05175535 | Peter Maydell | goto invalid_sdl_args;
|
2150 | 1472a95b | Jes Sorensen | } |
2151 | 1472a95b | Jes Sorensen | } else if (strstart(opts, ",window_close=", &nextopt)) { |
2152 | 1472a95b | Jes Sorensen | opts = nextopt; |
2153 | 1472a95b | Jes Sorensen | if (strstart(opts, "on", &nextopt)) { |
2154 | 1472a95b | Jes Sorensen | no_quit = 0;
|
2155 | 1472a95b | Jes Sorensen | } else if (strstart(opts, "off", &nextopt)) { |
2156 | 1472a95b | Jes Sorensen | no_quit = 1;
|
2157 | 1472a95b | Jes Sorensen | } else {
|
2158 | 05175535 | Peter Maydell | goto invalid_sdl_args;
|
2159 | 1472a95b | Jes Sorensen | } |
2160 | 1472a95b | Jes Sorensen | } else {
|
2161 | 05175535 | Peter Maydell | invalid_sdl_args:
|
2162 | 05175535 | Peter Maydell | fprintf(stderr, "Invalid SDL option string: %s\n", p);
|
2163 | 05175535 | Peter Maydell | exit(1);
|
2164 | 1472a95b | Jes Sorensen | } |
2165 | 1472a95b | Jes Sorensen | opts = nextopt; |
2166 | 1472a95b | Jes Sorensen | } |
2167 | 1472a95b | Jes Sorensen | #else
|
2168 | 1472a95b | Jes Sorensen | fprintf(stderr, "SDL support is disabled\n");
|
2169 | 1472a95b | Jes Sorensen | exit(1);
|
2170 | 1472a95b | Jes Sorensen | #endif
|
2171 | 3264ff12 | Jes Sorensen | } else if (strstart(p, "vnc", &opts)) { |
2172 | 821601ea | Jes Sorensen | #ifdef CONFIG_VNC
|
2173 | 3264ff12 | Jes Sorensen | display_remote++; |
2174 | 3264ff12 | Jes Sorensen | |
2175 | 3264ff12 | Jes Sorensen | if (*opts) {
|
2176 | 3264ff12 | Jes Sorensen | const char *nextopt; |
2177 | 3264ff12 | Jes Sorensen | |
2178 | 3264ff12 | Jes Sorensen | if (strstart(opts, "=", &nextopt)) { |
2179 | 3264ff12 | Jes Sorensen | vnc_display = nextopt; |
2180 | 3264ff12 | Jes Sorensen | } |
2181 | 3264ff12 | Jes Sorensen | } |
2182 | 3264ff12 | Jes Sorensen | if (!vnc_display) {
|
2183 | 3264ff12 | Jes Sorensen | fprintf(stderr, "VNC requires a display argument vnc=<display>\n");
|
2184 | 3264ff12 | Jes Sorensen | exit(1);
|
2185 | 3264ff12 | Jes Sorensen | } |
2186 | 821601ea | Jes Sorensen | #else
|
2187 | 821601ea | Jes Sorensen | fprintf(stderr, "VNC support is disabled\n");
|
2188 | 821601ea | Jes Sorensen | exit(1);
|
2189 | 821601ea | Jes Sorensen | #endif
|
2190 | 1472a95b | Jes Sorensen | } else if (strstart(p, "curses", &opts)) { |
2191 | 1472a95b | Jes Sorensen | #ifdef CONFIG_CURSES
|
2192 | 1472a95b | Jes Sorensen | display = DT_CURSES; |
2193 | 1472a95b | Jes Sorensen | #else
|
2194 | 1472a95b | Jes Sorensen | fprintf(stderr, "Curses support is disabled\n");
|
2195 | 1472a95b | Jes Sorensen | exit(1);
|
2196 | 1472a95b | Jes Sorensen | #endif
|
2197 | 15546425 | Anthony Liguori | } else if (strstart(p, "gtk", &opts)) { |
2198 | 15546425 | Anthony Liguori | #ifdef CONFIG_GTK
|
2199 | 15546425 | Anthony Liguori | display = DT_GTK; |
2200 | 15546425 | Anthony Liguori | #else
|
2201 | 15546425 | Anthony Liguori | fprintf(stderr, "GTK support is disabled\n");
|
2202 | 15546425 | Anthony Liguori | exit(1);
|
2203 | 15546425 | Anthony Liguori | #endif
|
2204 | 4171d32e | Jes Sorensen | } else if (strstart(p, "none", &opts)) { |
2205 | 4171d32e | Jes Sorensen | display = DT_NONE; |
2206 | 1472a95b | Jes Sorensen | } else {
|
2207 | 1472a95b | Jes Sorensen | fprintf(stderr, "Unknown display type: %s\n", p);
|
2208 | 1472a95b | Jes Sorensen | exit(1);
|
2209 | 1472a95b | Jes Sorensen | } |
2210 | 1472a95b | Jes Sorensen | |
2211 | 1472a95b | Jes Sorensen | return display;
|
2212 | 1472a95b | Jes Sorensen | } |
2213 | 1472a95b | Jes Sorensen | |
2214 | 7d4c3d53 | Markus Armbruster | static int balloon_parse(const char *arg) |
2215 | 7d4c3d53 | Markus Armbruster | { |
2216 | 382f0743 | Gerd Hoffmann | QemuOpts *opts; |
2217 | 7d4c3d53 | Markus Armbruster | |
2218 | 382f0743 | Gerd Hoffmann | if (strcmp(arg, "none") == 0) { |
2219 | 382f0743 | Gerd Hoffmann | return 0; |
2220 | 382f0743 | Gerd Hoffmann | } |
2221 | 382f0743 | Gerd Hoffmann | |
2222 | 382f0743 | Gerd Hoffmann | if (!strncmp(arg, "virtio", 6)) { |
2223 | 382f0743 | Gerd Hoffmann | if (arg[6] == ',') { |
2224 | 382f0743 | Gerd Hoffmann | /* have params -> parse them */
|
2225 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_parse(qemu_find_opts("device"), arg+7, 0); |
2226 | 382f0743 | Gerd Hoffmann | if (!opts)
|
2227 | 382f0743 | Gerd Hoffmann | return -1; |
2228 | 382f0743 | Gerd Hoffmann | } else {
|
2229 | 382f0743 | Gerd Hoffmann | /* create empty opts */
|
2230 | 87ea75d5 | Peter Crosthwaite | opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, |
2231 | 87ea75d5 | Peter Crosthwaite | &error_abort); |
2232 | 7d4c3d53 | Markus Armbruster | } |
2233 | 29f82b37 | Alexander Graf | qemu_opt_set(opts, "driver", "virtio-balloon"); |
2234 | 382f0743 | Gerd Hoffmann | return 0; |
2235 | 7d4c3d53 | Markus Armbruster | } |
2236 | 382f0743 | Gerd Hoffmann | |
2237 | 382f0743 | Gerd Hoffmann | return -1; |
2238 | 7d4c3d53 | Markus Armbruster | } |
2239 | 7d4c3d53 | Markus Armbruster | |
2240 | 5cea8590 | Paul Brook | char *qemu_find_file(int type, const char *name) |
2241 | 5cea8590 | Paul Brook | { |
2242 | 4524051c | Gerd Hoffmann | int i;
|
2243 | 5cea8590 | Paul Brook | const char *subdir; |
2244 | 5cea8590 | Paul Brook | char *buf;
|
2245 | 5cea8590 | Paul Brook | |
2246 | 31783203 | Peter Maydell | /* Try the name as a straight path first */
|
2247 | 31783203 | Peter Maydell | if (access(name, R_OK) == 0) { |
2248 | 4524051c | Gerd Hoffmann | trace_load_file(name, name); |
2249 | 7267c094 | Anthony Liguori | return g_strdup(name);
|
2250 | 5cea8590 | Paul Brook | } |
2251 | 4524051c | Gerd Hoffmann | |
2252 | 5cea8590 | Paul Brook | switch (type) {
|
2253 | 5cea8590 | Paul Brook | case QEMU_FILE_TYPE_BIOS:
|
2254 | 5cea8590 | Paul Brook | subdir = "";
|
2255 | 5cea8590 | Paul Brook | break;
|
2256 | 5cea8590 | Paul Brook | case QEMU_FILE_TYPE_KEYMAP:
|
2257 | 5cea8590 | Paul Brook | subdir = "keymaps/";
|
2258 | 5cea8590 | Paul Brook | break;
|
2259 | 5cea8590 | Paul Brook | default:
|
2260 | 5cea8590 | Paul Brook | abort(); |
2261 | 5cea8590 | Paul Brook | } |
2262 | 4524051c | Gerd Hoffmann | |
2263 | 4524051c | Gerd Hoffmann | for (i = 0; i < data_dir_idx; i++) { |
2264 | 4524051c | Gerd Hoffmann | buf = g_strdup_printf("%s/%s%s", data_dir[i], subdir, name);
|
2265 | 4524051c | Gerd Hoffmann | if (access(buf, R_OK) == 0) { |
2266 | 4524051c | Gerd Hoffmann | trace_load_file(name, buf); |
2267 | 4524051c | Gerd Hoffmann | return buf;
|
2268 | 4524051c | Gerd Hoffmann | } |
2269 | 7267c094 | Anthony Liguori | g_free(buf); |
2270 | 5cea8590 | Paul Brook | } |
2271 | 4524051c | Gerd Hoffmann | return NULL; |
2272 | 5cea8590 | Paul Brook | } |
2273 | 5cea8590 | Paul Brook | |
2274 | ff952ba2 | Markus Armbruster | static int device_help_func(QemuOpts *opts, void *opaque) |
2275 | ff952ba2 | Markus Armbruster | { |
2276 | ff952ba2 | Markus Armbruster | return qdev_device_help(opts);
|
2277 | ff952ba2 | Markus Armbruster | } |
2278 | ff952ba2 | Markus Armbruster | |
2279 | f31d07d1 | Gerd Hoffmann | static int device_init_func(QemuOpts *opts, void *opaque) |
2280 | f31d07d1 | Gerd Hoffmann | { |
2281 | f31d07d1 | Gerd Hoffmann | DeviceState *dev; |
2282 | f31d07d1 | Gerd Hoffmann | |
2283 | f31d07d1 | Gerd Hoffmann | dev = qdev_device_add(opts); |
2284 | f31d07d1 | Gerd Hoffmann | if (!dev)
|
2285 | f31d07d1 | Gerd Hoffmann | return -1; |
2286 | b09995ae | Paolo Bonzini | object_unref(OBJECT(dev)); |
2287 | f31d07d1 | Gerd Hoffmann | return 0; |
2288 | f31d07d1 | Gerd Hoffmann | } |
2289 | f31d07d1 | Gerd Hoffmann | |
2290 | 1a688d3b | Gerd Hoffmann | static int chardev_init_func(QemuOpts *opts, void *opaque) |
2291 | 1a688d3b | Gerd Hoffmann | { |
2292 | bd2d80b2 | Gerd Hoffmann | Error *local_err = NULL;
|
2293 | 1a688d3b | Gerd Hoffmann | |
2294 | bd2d80b2 | Gerd Hoffmann | qemu_chr_new_from_opts(opts, NULL, &local_err);
|
2295 | 84d18f06 | Markus Armbruster | if (local_err) {
|
2296 | 4a44d85e | Seiji Aguchi | error_report("%s", error_get_pretty(local_err));
|
2297 | bd2d80b2 | Gerd Hoffmann | error_free(local_err); |
2298 | 1a688d3b | Gerd Hoffmann | return -1; |
2299 | bd2d80b2 | Gerd Hoffmann | } |
2300 | 1a688d3b | Gerd Hoffmann | return 0; |
2301 | 1a688d3b | Gerd Hoffmann | } |
2302 | 1a688d3b | Gerd Hoffmann | |
2303 | 758e8e38 | Venkateswararao Jujjuri (JV) | #ifdef CONFIG_VIRTFS
|
2304 | 74db920c | Gautham R Shenoy | static int fsdev_init_func(QemuOpts *opts, void *opaque) |
2305 | 74db920c | Gautham R Shenoy | { |
2306 | 74db920c | Gautham R Shenoy | int ret;
|
2307 | 74db920c | Gautham R Shenoy | ret = qemu_fsdev_add(opts); |
2308 | 74db920c | Gautham R Shenoy | |
2309 | 74db920c | Gautham R Shenoy | return ret;
|
2310 | 74db920c | Gautham R Shenoy | } |
2311 | 74db920c | Gautham R Shenoy | #endif
|
2312 | 74db920c | Gautham R Shenoy | |
2313 | 88589343 | Gerd Hoffmann | static int mon_init_func(QemuOpts *opts, void *opaque) |
2314 | 88589343 | Gerd Hoffmann | { |
2315 | 88589343 | Gerd Hoffmann | CharDriverState *chr; |
2316 | 88589343 | Gerd Hoffmann | const char *chardev; |
2317 | 88589343 | Gerd Hoffmann | const char *mode; |
2318 | 88589343 | Gerd Hoffmann | int flags;
|
2319 | 88589343 | Gerd Hoffmann | |
2320 | 88589343 | Gerd Hoffmann | mode = qemu_opt_get(opts, "mode");
|
2321 | 88589343 | Gerd Hoffmann | if (mode == NULL) { |
2322 | 88589343 | Gerd Hoffmann | mode = "readline";
|
2323 | 88589343 | Gerd Hoffmann | } |
2324 | 88589343 | Gerd Hoffmann | if (strcmp(mode, "readline") == 0) { |
2325 | 88589343 | Gerd Hoffmann | flags = MONITOR_USE_READLINE; |
2326 | 88589343 | Gerd Hoffmann | } else if (strcmp(mode, "control") == 0) { |
2327 | 88589343 | Gerd Hoffmann | flags = MONITOR_USE_CONTROL; |
2328 | 88589343 | Gerd Hoffmann | } else {
|
2329 | 88589343 | Gerd Hoffmann | fprintf(stderr, "unknown monitor mode \"%s\"\n", mode);
|
2330 | 88589343 | Gerd Hoffmann | exit(1);
|
2331 | 88589343 | Gerd Hoffmann | } |
2332 | 88589343 | Gerd Hoffmann | |
2333 | 39eaab9a | Daniel P. Berrange | if (qemu_opt_get_bool(opts, "pretty", 0)) |
2334 | 39eaab9a | Daniel P. Berrange | flags |= MONITOR_USE_PRETTY; |
2335 | 39eaab9a | Daniel P. Berrange | |
2336 | 88589343 | Gerd Hoffmann | if (qemu_opt_get_bool(opts, "default", 0)) |
2337 | 88589343 | Gerd Hoffmann | flags |= MONITOR_IS_DEFAULT; |
2338 | 88589343 | Gerd Hoffmann | |
2339 | 88589343 | Gerd Hoffmann | chardev = qemu_opt_get(opts, "chardev");
|
2340 | 88589343 | Gerd Hoffmann | chr = qemu_chr_find(chardev); |
2341 | 88589343 | Gerd Hoffmann | if (chr == NULL) { |
2342 | 88589343 | Gerd Hoffmann | fprintf(stderr, "chardev \"%s\" not found\n", chardev);
|
2343 | 88589343 | Gerd Hoffmann | exit(1);
|
2344 | 88589343 | Gerd Hoffmann | } |
2345 | 88589343 | Gerd Hoffmann | |
2346 | 456d6069 | Hans de Goede | qemu_chr_fe_claim_no_fail(chr); |
2347 | 88589343 | Gerd Hoffmann | monitor_init(chr, flags); |
2348 | 88589343 | Gerd Hoffmann | return 0; |
2349 | 88589343 | Gerd Hoffmann | } |
2350 | 88589343 | Gerd Hoffmann | |
2351 | 6ca5582d | Gerd Hoffmann | static void monitor_parse(const char *optarg, const char *mode) |
2352 | 88589343 | Gerd Hoffmann | { |
2353 | 88589343 | Gerd Hoffmann | static int monitor_device_index = 0; |
2354 | 88589343 | Gerd Hoffmann | QemuOpts *opts; |
2355 | 88589343 | Gerd Hoffmann | const char *p; |
2356 | 88589343 | Gerd Hoffmann | char label[32]; |
2357 | 88589343 | Gerd Hoffmann | int def = 0; |
2358 | 88589343 | Gerd Hoffmann | |
2359 | 88589343 | Gerd Hoffmann | if (strstart(optarg, "chardev:", &p)) { |
2360 | 88589343 | Gerd Hoffmann | snprintf(label, sizeof(label), "%s", p); |
2361 | 88589343 | Gerd Hoffmann | } else {
|
2362 | 140e065d | Jan Kiszka | snprintf(label, sizeof(label), "compat_monitor%d", |
2363 | 140e065d | Jan Kiszka | monitor_device_index); |
2364 | 140e065d | Jan Kiszka | if (monitor_device_index == 0) { |
2365 | 88589343 | Gerd Hoffmann | def = 1;
|
2366 | 88589343 | Gerd Hoffmann | } |
2367 | 88589343 | Gerd Hoffmann | opts = qemu_chr_parse_compat(label, optarg); |
2368 | 88589343 | Gerd Hoffmann | if (!opts) {
|
2369 | 88589343 | Gerd Hoffmann | fprintf(stderr, "parse error: %s\n", optarg);
|
2370 | 88589343 | Gerd Hoffmann | exit(1);
|
2371 | 88589343 | Gerd Hoffmann | } |
2372 | 88589343 | Gerd Hoffmann | } |
2373 | 88589343 | Gerd Hoffmann | |
2374 | 8be7e7e4 | Luiz Capitulino | opts = qemu_opts_create(qemu_find_opts("mon"), label, 1, NULL); |
2375 | 88589343 | Gerd Hoffmann | if (!opts) {
|
2376 | 88589343 | Gerd Hoffmann | fprintf(stderr, "duplicate chardev: %s\n", label);
|
2377 | 88589343 | Gerd Hoffmann | exit(1);
|
2378 | 88589343 | Gerd Hoffmann | } |
2379 | 6ca5582d | Gerd Hoffmann | qemu_opt_set(opts, "mode", mode);
|
2380 | 88589343 | Gerd Hoffmann | qemu_opt_set(opts, "chardev", label);
|
2381 | 88589343 | Gerd Hoffmann | if (def)
|
2382 | 88589343 | Gerd Hoffmann | qemu_opt_set(opts, "default", "on"); |
2383 | 88589343 | Gerd Hoffmann | monitor_device_index++; |
2384 | 88589343 | Gerd Hoffmann | } |
2385 | 88589343 | Gerd Hoffmann | |
2386 | bd3c948d | Gerd Hoffmann | struct device_config {
|
2387 | bd3c948d | Gerd Hoffmann | enum {
|
2388 | aee1b935 | Gerd Hoffmann | DEV_USB, /* -usbdevice */
|
2389 | aee1b935 | Gerd Hoffmann | DEV_BT, /* -bt */
|
2390 | aee1b935 | Gerd Hoffmann | DEV_SERIAL, /* -serial */
|
2391 | aee1b935 | Gerd Hoffmann | DEV_PARALLEL, /* -parallel */
|
2392 | aee1b935 | Gerd Hoffmann | DEV_VIRTCON, /* -virtioconsole */
|
2393 | c9f398e5 | H. Peter Anvin | DEV_DEBUGCON, /* -debugcon */
|
2394 | ef0c4a0d | Markus Armbruster | DEV_GDB, /* -gdb, -s */
|
2395 | 3ef669e1 | Alexander Graf | DEV_SCLP, /* s390 sclp */
|
2396 | bd3c948d | Gerd Hoffmann | } type; |
2397 | bd3c948d | Gerd Hoffmann | const char *cmdline; |
2398 | d9a5954d | Markus Armbruster | Location loc; |
2399 | 72cf2d4f | Blue Swirl | QTAILQ_ENTRY(device_config) next; |
2400 | bd3c948d | Gerd Hoffmann | }; |
2401 | 4fdcac0e | Blue Swirl | |
2402 | 4fdcac0e | Blue Swirl | static QTAILQ_HEAD(, device_config) device_configs =
|
2403 | 4fdcac0e | Blue Swirl | QTAILQ_HEAD_INITIALIZER(device_configs); |
2404 | bd3c948d | Gerd Hoffmann | |
2405 | bd3c948d | Gerd Hoffmann | static void add_device_config(int type, const char *cmdline) |
2406 | bd3c948d | Gerd Hoffmann | { |
2407 | bd3c948d | Gerd Hoffmann | struct device_config *conf;
|
2408 | bd3c948d | Gerd Hoffmann | |
2409 | 7267c094 | Anthony Liguori | conf = g_malloc0(sizeof(*conf));
|
2410 | bd3c948d | Gerd Hoffmann | conf->type = type; |
2411 | bd3c948d | Gerd Hoffmann | conf->cmdline = cmdline; |
2412 | d9a5954d | Markus Armbruster | loc_save(&conf->loc); |
2413 | 72cf2d4f | Blue Swirl | QTAILQ_INSERT_TAIL(&device_configs, conf, next); |
2414 | bd3c948d | Gerd Hoffmann | } |
2415 | bd3c948d | Gerd Hoffmann | |
2416 | bd3c948d | Gerd Hoffmann | static int foreach_device_config(int type, int (*func)(const char *cmdline)) |
2417 | bd3c948d | Gerd Hoffmann | { |
2418 | bd3c948d | Gerd Hoffmann | struct device_config *conf;
|
2419 | bd3c948d | Gerd Hoffmann | int rc;
|
2420 | bd3c948d | Gerd Hoffmann | |
2421 | 72cf2d4f | Blue Swirl | QTAILQ_FOREACH(conf, &device_configs, next) { |
2422 | bd3c948d | Gerd Hoffmann | if (conf->type != type)
|
2423 | bd3c948d | Gerd Hoffmann | continue;
|
2424 | d9a5954d | Markus Armbruster | loc_push_restore(&conf->loc); |
2425 | bd3c948d | Gerd Hoffmann | rc = func(conf->cmdline); |
2426 | d9a5954d | Markus Armbruster | loc_pop(&conf->loc); |
2427 | bd3c948d | Gerd Hoffmann | if (0 != rc) |
2428 | bd3c948d | Gerd Hoffmann | return rc;
|
2429 | bd3c948d | Gerd Hoffmann | } |
2430 | bd3c948d | Gerd Hoffmann | return 0; |
2431 | bd3c948d | Gerd Hoffmann | } |
2432 | bd3c948d | Gerd Hoffmann | |
2433 | 998bbd74 | Gerd Hoffmann | static int serial_parse(const char *devname) |
2434 | 998bbd74 | Gerd Hoffmann | { |
2435 | 998bbd74 | Gerd Hoffmann | static int index = 0; |
2436 | 998bbd74 | Gerd Hoffmann | char label[32]; |
2437 | 998bbd74 | Gerd Hoffmann | |
2438 | 998bbd74 | Gerd Hoffmann | if (strcmp(devname, "none") == 0) |
2439 | 998bbd74 | Gerd Hoffmann | return 0; |
2440 | 998bbd74 | Gerd Hoffmann | if (index == MAX_SERIAL_PORTS) {
|
2441 | 998bbd74 | Gerd Hoffmann | fprintf(stderr, "qemu: too many serial ports\n");
|
2442 | 998bbd74 | Gerd Hoffmann | exit(1);
|
2443 | 998bbd74 | Gerd Hoffmann | } |
2444 | 998bbd74 | Gerd Hoffmann | snprintf(label, sizeof(label), "serial%d", index); |
2445 | 27143a44 | Anthony Liguori | serial_hds[index] = qemu_chr_new(label, devname, NULL);
|
2446 | 998bbd74 | Gerd Hoffmann | if (!serial_hds[index]) {
|
2447 | 52d06136 | Peter Maydell | fprintf(stderr, "qemu: could not connect serial device"
|
2448 | 52d06136 | Peter Maydell | " to character backend '%s'\n", devname);
|
2449 | 998bbd74 | Gerd Hoffmann | return -1; |
2450 | 998bbd74 | Gerd Hoffmann | } |
2451 | 998bbd74 | Gerd Hoffmann | index++; |
2452 | 998bbd74 | Gerd Hoffmann | return 0; |
2453 | 998bbd74 | Gerd Hoffmann | } |
2454 | 998bbd74 | Gerd Hoffmann | |
2455 | 6a5e8b0e | Gerd Hoffmann | static int parallel_parse(const char *devname) |
2456 | 6a5e8b0e | Gerd Hoffmann | { |
2457 | 6a5e8b0e | Gerd Hoffmann | static int index = 0; |
2458 | 6a5e8b0e | Gerd Hoffmann | char label[32]; |
2459 | 6a5e8b0e | Gerd Hoffmann | |
2460 | 6a5e8b0e | Gerd Hoffmann | if (strcmp(devname, "none") == 0) |
2461 | 6a5e8b0e | Gerd Hoffmann | return 0; |
2462 | 6a5e8b0e | Gerd Hoffmann | if (index == MAX_PARALLEL_PORTS) {
|
2463 | 6a5e8b0e | Gerd Hoffmann | fprintf(stderr, "qemu: too many parallel ports\n");
|
2464 | 6a5e8b0e | Gerd Hoffmann | exit(1);
|
2465 | 6a5e8b0e | Gerd Hoffmann | } |
2466 | 6a5e8b0e | Gerd Hoffmann | snprintf(label, sizeof(label), "parallel%d", index); |
2467 | 27143a44 | Anthony Liguori | parallel_hds[index] = qemu_chr_new(label, devname, NULL);
|
2468 | 6a5e8b0e | Gerd Hoffmann | if (!parallel_hds[index]) {
|
2469 | 52d06136 | Peter Maydell | fprintf(stderr, "qemu: could not connect parallel device"
|
2470 | 52d06136 | Peter Maydell | " to character backend '%s'\n", devname);
|
2471 | 6a5e8b0e | Gerd Hoffmann | return -1; |
2472 | 6a5e8b0e | Gerd Hoffmann | } |
2473 | 6a5e8b0e | Gerd Hoffmann | index++; |
2474 | 6a5e8b0e | Gerd Hoffmann | return 0; |
2475 | 6a5e8b0e | Gerd Hoffmann | } |
2476 | 6a5e8b0e | Gerd Hoffmann | |
2477 | aee1b935 | Gerd Hoffmann | static int virtcon_parse(const char *devname) |
2478 | aee1b935 | Gerd Hoffmann | { |
2479 | 3329f07b | Gerd Hoffmann | QemuOptsList *device = qemu_find_opts("device");
|
2480 | aee1b935 | Gerd Hoffmann | static int index = 0; |
2481 | aee1b935 | Gerd Hoffmann | char label[32]; |
2482 | 392ecf54 | Amit Shah | QemuOpts *bus_opts, *dev_opts; |
2483 | aee1b935 | Gerd Hoffmann | |
2484 | aee1b935 | Gerd Hoffmann | if (strcmp(devname, "none") == 0) |
2485 | aee1b935 | Gerd Hoffmann | return 0; |
2486 | aee1b935 | Gerd Hoffmann | if (index == MAX_VIRTIO_CONSOLES) {
|
2487 | aee1b935 | Gerd Hoffmann | fprintf(stderr, "qemu: too many virtio consoles\n");
|
2488 | aee1b935 | Gerd Hoffmann | exit(1);
|
2489 | aee1b935 | Gerd Hoffmann | } |
2490 | 392ecf54 | Amit Shah | |
2491 | 87ea75d5 | Peter Crosthwaite | bus_opts = qemu_opts_create(device, NULL, 0, &error_abort); |
2492 | e87f7fc6 | Anthony Liguori | if (arch_type == QEMU_ARCH_S390X) {
|
2493 | e87f7fc6 | Anthony Liguori | qemu_opt_set(bus_opts, "driver", "virtio-serial-s390"); |
2494 | e87f7fc6 | Anthony Liguori | } else {
|
2495 | e87f7fc6 | Anthony Liguori | qemu_opt_set(bus_opts, "driver", "virtio-serial-pci"); |
2496 | 4d8b3c63 | Laszlo Ersek | } |
2497 | 392ecf54 | Amit Shah | |
2498 | 87ea75d5 | Peter Crosthwaite | dev_opts = qemu_opts_create(device, NULL, 0, &error_abort); |
2499 | 392ecf54 | Amit Shah | qemu_opt_set(dev_opts, "driver", "virtconsole"); |
2500 | 392ecf54 | Amit Shah | |
2501 | aee1b935 | Gerd Hoffmann | snprintf(label, sizeof(label), "virtcon%d", index); |
2502 | 27143a44 | Anthony Liguori | virtcon_hds[index] = qemu_chr_new(label, devname, NULL);
|
2503 | aee1b935 | Gerd Hoffmann | if (!virtcon_hds[index]) {
|
2504 | 52d06136 | Peter Maydell | fprintf(stderr, "qemu: could not connect virtio console"
|
2505 | 52d06136 | Peter Maydell | " to character backend '%s'\n", devname);
|
2506 | aee1b935 | Gerd Hoffmann | return -1; |
2507 | aee1b935 | Gerd Hoffmann | } |
2508 | 392ecf54 | Amit Shah | qemu_opt_set(dev_opts, "chardev", label);
|
2509 | 392ecf54 | Amit Shah | |
2510 | aee1b935 | Gerd Hoffmann | index++; |
2511 | aee1b935 | Gerd Hoffmann | return 0; |
2512 | aee1b935 | Gerd Hoffmann | } |
2513 | aee1b935 | Gerd Hoffmann | |
2514 | 3ef669e1 | Alexander Graf | static int sclp_parse(const char *devname) |
2515 | 3ef669e1 | Alexander Graf | { |
2516 | 3ef669e1 | Alexander Graf | QemuOptsList *device = qemu_find_opts("device");
|
2517 | 3ef669e1 | Alexander Graf | static int index = 0; |
2518 | 3ef669e1 | Alexander Graf | char label[32]; |
2519 | 3ef669e1 | Alexander Graf | QemuOpts *dev_opts; |
2520 | 3ef669e1 | Alexander Graf | |
2521 | 3ef669e1 | Alexander Graf | if (strcmp(devname, "none") == 0) { |
2522 | 3ef669e1 | Alexander Graf | return 0; |
2523 | 3ef669e1 | Alexander Graf | } |
2524 | 3ef669e1 | Alexander Graf | if (index == MAX_SCLP_CONSOLES) {
|
2525 | 3ef669e1 | Alexander Graf | fprintf(stderr, "qemu: too many sclp consoles\n");
|
2526 | 3ef669e1 | Alexander Graf | exit(1);
|
2527 | 3ef669e1 | Alexander Graf | } |
2528 | 3ef669e1 | Alexander Graf | |
2529 | 3ef669e1 | Alexander Graf | assert(arch_type == QEMU_ARCH_S390X); |
2530 | 3ef669e1 | Alexander Graf | |
2531 | 3ef669e1 | Alexander Graf | dev_opts = qemu_opts_create(device, NULL, 0, NULL); |
2532 | 3ef669e1 | Alexander Graf | qemu_opt_set(dev_opts, "driver", "sclpconsole"); |
2533 | 3ef669e1 | Alexander Graf | |
2534 | 3ef669e1 | Alexander Graf | snprintf(label, sizeof(label), "sclpcon%d", index); |
2535 | 3ef669e1 | Alexander Graf | sclp_hds[index] = qemu_chr_new(label, devname, NULL);
|
2536 | 3ef669e1 | Alexander Graf | if (!sclp_hds[index]) {
|
2537 | 3ef669e1 | Alexander Graf | fprintf(stderr, "qemu: could not connect sclp console"
|
2538 | 3ef669e1 | Alexander Graf | " to character backend '%s'\n", devname);
|
2539 | 3ef669e1 | Alexander Graf | return -1; |
2540 | 3ef669e1 | Alexander Graf | } |
2541 | 3ef669e1 | Alexander Graf | qemu_opt_set(dev_opts, "chardev", label);
|
2542 | 3ef669e1 | Alexander Graf | |
2543 | 3ef669e1 | Alexander Graf | index++; |
2544 | 3ef669e1 | Alexander Graf | return 0; |
2545 | 3ef669e1 | Alexander Graf | } |
2546 | 3ef669e1 | Alexander Graf | |
2547 | c9f398e5 | H. Peter Anvin | static int debugcon_parse(const char *devname) |
2548 | 4d8b3c63 | Laszlo Ersek | { |
2549 | c9f398e5 | H. Peter Anvin | QemuOpts *opts; |
2550 | c9f398e5 | H. Peter Anvin | |
2551 | 27143a44 | Anthony Liguori | if (!qemu_chr_new("debugcon", devname, NULL)) { |
2552 | c9f398e5 | H. Peter Anvin | exit(1);
|
2553 | c9f398e5 | H. Peter Anvin | } |
2554 | 8be7e7e4 | Luiz Capitulino | opts = qemu_opts_create(qemu_find_opts("device"), "debugcon", 1, NULL); |
2555 | c9f398e5 | H. Peter Anvin | if (!opts) {
|
2556 | c9f398e5 | H. Peter Anvin | fprintf(stderr, "qemu: already have a debugcon device\n");
|
2557 | c9f398e5 | H. Peter Anvin | exit(1);
|
2558 | c9f398e5 | H. Peter Anvin | } |
2559 | c9f398e5 | H. Peter Anvin | qemu_opt_set(opts, "driver", "isa-debugcon"); |
2560 | c9f398e5 | H. Peter Anvin | qemu_opt_set(opts, "chardev", "debugcon"); |
2561 | c9f398e5 | H. Peter Anvin | return 0; |
2562 | c9f398e5 | H. Peter Anvin | } |
2563 | c9f398e5 | H. Peter Anvin | |
2564 | 9052ea6b | Jan Kiszka | static QEMUMachine *machine_parse(const char *name) |
2565 | 9052ea6b | Jan Kiszka | { |
2566 | 9052ea6b | Jan Kiszka | QEMUMachine *m, *machine = NULL;
|
2567 | 9052ea6b | Jan Kiszka | |
2568 | 9052ea6b | Jan Kiszka | if (name) {
|
2569 | 9052ea6b | Jan Kiszka | machine = find_machine(name); |
2570 | 9052ea6b | Jan Kiszka | } |
2571 | 9052ea6b | Jan Kiszka | if (machine) {
|
2572 | 9052ea6b | Jan Kiszka | return machine;
|
2573 | 9052ea6b | Jan Kiszka | } |
2574 | 9052ea6b | Jan Kiszka | printf("Supported machines are:\n");
|
2575 | 9052ea6b | Jan Kiszka | for (m = first_machine; m != NULL; m = m->next) { |
2576 | 9052ea6b | Jan Kiszka | if (m->alias) {
|
2577 | 3b26486a | Peter Maydell | printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
|
2578 | 9052ea6b | Jan Kiszka | } |
2579 | 3b26486a | Peter Maydell | printf("%-20s %s%s\n", m->name, m->desc,
|
2580 | 9052ea6b | Jan Kiszka | m->is_default ? " (default)" : ""); |
2581 | 9052ea6b | Jan Kiszka | } |
2582 | c8057f95 | Peter Maydell | exit(!name || !is_help_option(name)); |
2583 | 9052ea6b | Jan Kiszka | } |
2584 | 9052ea6b | Jan Kiszka | |
2585 | 135a129a | Aneesh Kumar K.V | static int tcg_init(QEMUMachine *machine) |
2586 | 303d4e86 | Anthony PERARD | { |
2587 | d5ab9713 | Jan Kiszka | tcg_exec_init(tcg_tb_size * 1024 * 1024); |
2588 | 303d4e86 | Anthony PERARD | return 0; |
2589 | 303d4e86 | Anthony PERARD | } |
2590 | 303d4e86 | Anthony PERARD | |
2591 | 303d4e86 | Anthony PERARD | static struct { |
2592 | 303d4e86 | Anthony PERARD | const char *opt_name; |
2593 | 303d4e86 | Anthony PERARD | const char *name; |
2594 | 303d4e86 | Anthony PERARD | int (*available)(void); |
2595 | 135a129a | Aneesh Kumar K.V | int (*init)(QEMUMachine *);
|
2596 | d5286af5 | liguang | bool *allowed;
|
2597 | 303d4e86 | Anthony PERARD | } accel_list[] = { |
2598 | 303d4e86 | Anthony PERARD | { "tcg", "tcg", tcg_available, tcg_init, &tcg_allowed }, |
2599 | 3285cf4f | Anthony PERARD | { "xen", "Xen", xen_available, xen_init, &xen_allowed }, |
2600 | 303d4e86 | Anthony PERARD | { "kvm", "KVM", kvm_available, kvm_init, &kvm_allowed }, |
2601 | d4fce24f | Paolo Bonzini | { "qtest", "QTest", qtest_available, qtest_init_accel, &qtest_allowed }, |
2602 | 303d4e86 | Anthony PERARD | }; |
2603 | 303d4e86 | Anthony PERARD | |
2604 | 135a129a | Aneesh Kumar K.V | static int configure_accelerator(QEMUMachine *machine) |
2605 | 303d4e86 | Anthony PERARD | { |
2606 | 36ad0e94 | Markus Armbruster | const char *p; |
2607 | 303d4e86 | Anthony PERARD | char buf[10]; |
2608 | 303d4e86 | Anthony PERARD | int i, ret;
|
2609 | 217e21be | liguang | bool accel_initialised = false; |
2610 | 217e21be | liguang | bool init_failed = false; |
2611 | 303d4e86 | Anthony PERARD | |
2612 | 36ad0e94 | Markus Armbruster | p = qemu_opt_get(qemu_get_machine_opts(), "accel");
|
2613 | 303d4e86 | Anthony PERARD | if (p == NULL) { |
2614 | 303d4e86 | Anthony PERARD | /* Use the default "accelerator", tcg */
|
2615 | 303d4e86 | Anthony PERARD | p = "tcg";
|
2616 | 303d4e86 | Anthony PERARD | } |
2617 | 303d4e86 | Anthony PERARD | |
2618 | 1b785a97 | Peter Maydell | while (!accel_initialised && *p != '\0') { |
2619 | 303d4e86 | Anthony PERARD | if (*p == ':') { |
2620 | 303d4e86 | Anthony PERARD | p++; |
2621 | 303d4e86 | Anthony PERARD | } |
2622 | 303d4e86 | Anthony PERARD | p = get_opt_name(buf, sizeof (buf), p, ':'); |
2623 | 303d4e86 | Anthony PERARD | for (i = 0; i < ARRAY_SIZE(accel_list); i++) { |
2624 | 303d4e86 | Anthony PERARD | if (strcmp(accel_list[i].opt_name, buf) == 0) { |
2625 | e3c66d93 | liguang | if (!accel_list[i].available()) {
|
2626 | e3c66d93 | liguang | printf("%s not supported for this target\n",
|
2627 | e3c66d93 | liguang | accel_list[i].name); |
2628 | e3c66d93 | liguang | continue;
|
2629 | e3c66d93 | liguang | } |
2630 | d5286af5 | liguang | *(accel_list[i].allowed) = true;
|
2631 | 135a129a | Aneesh Kumar K.V | ret = accel_list[i].init(machine); |
2632 | 303d4e86 | Anthony PERARD | if (ret < 0) { |
2633 | 217e21be | liguang | init_failed = true;
|
2634 | e3c66d93 | liguang | fprintf(stderr, "failed to initialize %s: %s\n",
|
2635 | e3c66d93 | liguang | accel_list[i].name, |
2636 | e3c66d93 | liguang | strerror(-ret)); |
2637 | d5286af5 | liguang | *(accel_list[i].allowed) = false;
|
2638 | 303d4e86 | Anthony PERARD | } else {
|
2639 | 217e21be | liguang | accel_initialised = true;
|
2640 | 303d4e86 | Anthony PERARD | } |
2641 | 303d4e86 | Anthony PERARD | break;
|
2642 | 303d4e86 | Anthony PERARD | } |
2643 | 303d4e86 | Anthony PERARD | } |
2644 | 303d4e86 | Anthony PERARD | if (i == ARRAY_SIZE(accel_list)) {
|
2645 | 303d4e86 | Anthony PERARD | fprintf(stderr, "\"%s\" accelerator does not exist.\n", buf);
|
2646 | 303d4e86 | Anthony PERARD | } |
2647 | 303d4e86 | Anthony PERARD | } |
2648 | 303d4e86 | Anthony PERARD | |
2649 | 1b785a97 | Peter Maydell | if (!accel_initialised) {
|
2650 | 217e21be | liguang | if (!init_failed) {
|
2651 | 217e21be | liguang | fprintf(stderr, "No accelerator found!\n");
|
2652 | 217e21be | liguang | } |
2653 | 303d4e86 | Anthony PERARD | exit(1);
|
2654 | 303d4e86 | Anthony PERARD | } |
2655 | 303d4e86 | Anthony PERARD | |
2656 | 303d4e86 | Anthony PERARD | if (init_failed) {
|
2657 | 303d4e86 | Anthony PERARD | fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name);
|
2658 | 303d4e86 | Anthony PERARD | } |
2659 | 303d4e86 | Anthony PERARD | |
2660 | 1b785a97 | Peter Maydell | return !accel_initialised;
|
2661 | 303d4e86 | Anthony PERARD | } |
2662 | 303d4e86 | Anthony PERARD | |
2663 | fd42deeb | Gerd Hoffmann | void qemu_add_exit_notifier(Notifier *notify)
|
2664 | fd42deeb | Gerd Hoffmann | { |
2665 | fd42deeb | Gerd Hoffmann | notifier_list_add(&exit_notifiers, notify); |
2666 | fd42deeb | Gerd Hoffmann | } |
2667 | fd42deeb | Gerd Hoffmann | |
2668 | fd42deeb | Gerd Hoffmann | void qemu_remove_exit_notifier(Notifier *notify)
|
2669 | fd42deeb | Gerd Hoffmann | { |
2670 | 31552529 | Paolo Bonzini | notifier_remove(notify); |
2671 | fd42deeb | Gerd Hoffmann | } |
2672 | fd42deeb | Gerd Hoffmann | |
2673 | fd42deeb | Gerd Hoffmann | static void qemu_run_exit_notifiers(void) |
2674 | fd42deeb | Gerd Hoffmann | { |
2675 | 9e8dd451 | Jan Kiszka | notifier_list_notify(&exit_notifiers, NULL);
|
2676 | fd42deeb | Gerd Hoffmann | } |
2677 | fd42deeb | Gerd Hoffmann | |
2678 | 4cab946a | Gleb Natapov | void qemu_add_machine_init_done_notifier(Notifier *notify)
|
2679 | 4cab946a | Gleb Natapov | { |
2680 | 4cab946a | Gleb Natapov | notifier_list_add(&machine_init_done_notifiers, notify); |
2681 | 4cab946a | Gleb Natapov | } |
2682 | 4cab946a | Gleb Natapov | |
2683 | 4cab946a | Gleb Natapov | static void qemu_run_machine_init_done_notifiers(void) |
2684 | 4cab946a | Gleb Natapov | { |
2685 | 9e8dd451 | Jan Kiszka | notifier_list_notify(&machine_init_done_notifiers, NULL);
|
2686 | 4cab946a | Gleb Natapov | } |
2687 | 4cab946a | Gleb Natapov | |
2688 | 6530a97b | Anthony Liguori | static const QEMUOption *lookup_opt(int argc, char **argv, |
2689 | 6530a97b | Anthony Liguori | const char **poptarg, int *poptind) |
2690 | 6530a97b | Anthony Liguori | { |
2691 | 6530a97b | Anthony Liguori | const QEMUOption *popt;
|
2692 | 6530a97b | Anthony Liguori | int optind = *poptind;
|
2693 | 6530a97b | Anthony Liguori | char *r = argv[optind];
|
2694 | 6530a97b | Anthony Liguori | const char *optarg; |
2695 | 6530a97b | Anthony Liguori | |
2696 | 0f0bc3f1 | Markus Armbruster | loc_set_cmdline(argv, optind, 1);
|
2697 | 6530a97b | Anthony Liguori | optind++; |
2698 | 6530a97b | Anthony Liguori | /* Treat --foo the same as -foo. */
|
2699 | 6530a97b | Anthony Liguori | if (r[1] == '-') |
2700 | 6530a97b | Anthony Liguori | r++; |
2701 | 6530a97b | Anthony Liguori | popt = qemu_options; |
2702 | 6530a97b | Anthony Liguori | for(;;) {
|
2703 | 6530a97b | Anthony Liguori | if (!popt->name) {
|
2704 | 0f0bc3f1 | Markus Armbruster | error_report("invalid option");
|
2705 | 6530a97b | Anthony Liguori | exit(1);
|
2706 | 6530a97b | Anthony Liguori | } |
2707 | 6530a97b | Anthony Liguori | if (!strcmp(popt->name, r + 1)) |
2708 | 6530a97b | Anthony Liguori | break;
|
2709 | 6530a97b | Anthony Liguori | popt++; |
2710 | 6530a97b | Anthony Liguori | } |
2711 | 6530a97b | Anthony Liguori | if (popt->flags & HAS_ARG) {
|
2712 | 6530a97b | Anthony Liguori | if (optind >= argc) {
|
2713 | 0f0bc3f1 | Markus Armbruster | error_report("requires an argument");
|
2714 | 6530a97b | Anthony Liguori | exit(1);
|
2715 | 6530a97b | Anthony Liguori | } |
2716 | 6530a97b | Anthony Liguori | optarg = argv[optind++]; |
2717 | 0f0bc3f1 | Markus Armbruster | loc_set_cmdline(argv, optind - 2, 2); |
2718 | 6530a97b | Anthony Liguori | } else {
|
2719 | 6530a97b | Anthony Liguori | optarg = NULL;
|
2720 | 6530a97b | Anthony Liguori | } |
2721 | 6530a97b | Anthony Liguori | |
2722 | 6530a97b | Anthony Liguori | *poptarg = optarg; |
2723 | 6530a97b | Anthony Liguori | *poptind = optind; |
2724 | 6530a97b | Anthony Liguori | |
2725 | 6530a97b | Anthony Liguori | return popt;
|
2726 | 6530a97b | Anthony Liguori | } |
2727 | 6530a97b | Anthony Liguori | |
2728 | 0750112a | Anthony Liguori | static gpointer malloc_and_trace(gsize n_bytes)
|
2729 | 0750112a | Anthony Liguori | { |
2730 | 0750112a | Anthony Liguori | void *ptr = malloc(n_bytes);
|
2731 | a74cd8cc | Frediano Ziglio | trace_g_malloc(n_bytes, ptr); |
2732 | 0750112a | Anthony Liguori | return ptr;
|
2733 | 0750112a | Anthony Liguori | } |
2734 | 0750112a | Anthony Liguori | |
2735 | 0750112a | Anthony Liguori | static gpointer realloc_and_trace(gpointer mem, gsize n_bytes)
|
2736 | 0750112a | Anthony Liguori | { |
2737 | 0750112a | Anthony Liguori | void *ptr = realloc(mem, n_bytes);
|
2738 | a74cd8cc | Frediano Ziglio | trace_g_realloc(mem, n_bytes, ptr); |
2739 | 0750112a | Anthony Liguori | return ptr;
|
2740 | 0750112a | Anthony Liguori | } |
2741 | 0750112a | Anthony Liguori | |
2742 | 0750112a | Anthony Liguori | static void free_and_trace(gpointer mem) |
2743 | 0750112a | Anthony Liguori | { |
2744 | a74cd8cc | Frediano Ziglio | trace_g_free(mem); |
2745 | 0750112a | Anthony Liguori | free(mem); |
2746 | 0750112a | Anthony Liguori | } |
2747 | 0750112a | Anthony Liguori | |
2748 | 68d98d3e | Anthony Liguori | static int object_set_property(const char *name, const char *value, void *opaque) |
2749 | 68d98d3e | Anthony Liguori | { |
2750 | 68d98d3e | Anthony Liguori | Object *obj = OBJECT(opaque); |
2751 | 68d98d3e | Anthony Liguori | StringInputVisitor *siv; |
2752 | 68d98d3e | Anthony Liguori | Error *local_err = NULL;
|
2753 | 68d98d3e | Anthony Liguori | |
2754 | 68d98d3e | Anthony Liguori | if (strcmp(name, "qom-type") == 0 || strcmp(name, "id") == 0) { |
2755 | 68d98d3e | Anthony Liguori | return 0; |
2756 | 68d98d3e | Anthony Liguori | } |
2757 | 68d98d3e | Anthony Liguori | |
2758 | 68d98d3e | Anthony Liguori | siv = string_input_visitor_new(value); |
2759 | 68d98d3e | Anthony Liguori | object_property_set(obj, string_input_get_visitor(siv), name, &local_err); |
2760 | 68d98d3e | Anthony Liguori | string_input_visitor_cleanup(siv); |
2761 | 68d98d3e | Anthony Liguori | |
2762 | 68d98d3e | Anthony Liguori | if (local_err) {
|
2763 | 68d98d3e | Anthony Liguori | qerror_report_err(local_err); |
2764 | 68d98d3e | Anthony Liguori | error_free(local_err); |
2765 | 68d98d3e | Anthony Liguori | return -1; |
2766 | 68d98d3e | Anthony Liguori | } |
2767 | 68d98d3e | Anthony Liguori | |
2768 | 68d98d3e | Anthony Liguori | return 0; |
2769 | 68d98d3e | Anthony Liguori | } |
2770 | 68d98d3e | Anthony Liguori | |
2771 | 68d98d3e | Anthony Liguori | static int object_create(QemuOpts *opts, void *opaque) |
2772 | 68d98d3e | Anthony Liguori | { |
2773 | 68d98d3e | Anthony Liguori | const char *type = qemu_opt_get(opts, "qom-type"); |
2774 | 68d98d3e | Anthony Liguori | const char *id = qemu_opts_id(opts); |
2775 | 90e9cf28 | Igor Mammedov | Error *local_err = NULL;
|
2776 | 68d98d3e | Anthony Liguori | Object *obj; |
2777 | 68d98d3e | Anthony Liguori | |
2778 | 68d98d3e | Anthony Liguori | g_assert(type != NULL);
|
2779 | 68d98d3e | Anthony Liguori | |
2780 | 68d98d3e | Anthony Liguori | if (id == NULL) { |
2781 | 68d98d3e | Anthony Liguori | qerror_report(QERR_MISSING_PARAMETER, "id");
|
2782 | 68d98d3e | Anthony Liguori | return -1; |
2783 | 68d98d3e | Anthony Liguori | } |
2784 | 68d98d3e | Anthony Liguori | |
2785 | 68d98d3e | Anthony Liguori | obj = object_new(type); |
2786 | 68d98d3e | Anthony Liguori | if (qemu_opt_foreach(opts, object_set_property, obj, 1) < 0) { |
2787 | 28ec2598 | Paolo Bonzini | object_unref(obj); |
2788 | 68d98d3e | Anthony Liguori | return -1; |
2789 | 68d98d3e | Anthony Liguori | } |
2790 | 68d98d3e | Anthony Liguori | |
2791 | 269e09f3 | Igor Mammedov | if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
|
2792 | 269e09f3 | Igor Mammedov | error_setg(&local_err, "object '%s' isn't supported by -object",
|
2793 | 269e09f3 | Igor Mammedov | id); |
2794 | 269e09f3 | Igor Mammedov | goto out;
|
2795 | 269e09f3 | Igor Mammedov | } |
2796 | 269e09f3 | Igor Mammedov | |
2797 | 269e09f3 | Igor Mammedov | user_creatable_complete(obj, &local_err); |
2798 | 269e09f3 | Igor Mammedov | if (local_err) {
|
2799 | 269e09f3 | Igor Mammedov | goto out;
|
2800 | 269e09f3 | Igor Mammedov | } |
2801 | 269e09f3 | Igor Mammedov | |
2802 | 68d98d3e | Anthony Liguori | object_property_add_child(container_get(object_get_root(), "/objects"),
|
2803 | 90e9cf28 | Igor Mammedov | id, obj, &local_err); |
2804 | 90e9cf28 | Igor Mammedov | |
2805 | 269e09f3 | Igor Mammedov | out:
|
2806 | 28ec2598 | Paolo Bonzini | object_unref(obj); |
2807 | 90e9cf28 | Igor Mammedov | if (local_err) {
|
2808 | 90e9cf28 | Igor Mammedov | qerror_report_err(local_err); |
2809 | 90e9cf28 | Igor Mammedov | error_free(local_err); |
2810 | 90e9cf28 | Igor Mammedov | return -1; |
2811 | 90e9cf28 | Igor Mammedov | } |
2812 | 68d98d3e | Anthony Liguori | return 0; |
2813 | 68d98d3e | Anthony Liguori | } |
2814 | 68d98d3e | Anthony Liguori | |
2815 | 902b3d5c | malc | int main(int argc, char **argv, char **envp) |
2816 | 0824d6fc | bellard | { |
2817 | e4bcb14c | ths | int i;
|
2818 | da1fcfda | Eduardo Habkost | int snapshot, linux_boot;
|
2819 | 4e3de9e9 | Paolo Bonzini | const char *icount_option = NULL; |
2820 | 7f7f9873 | bellard | const char *initrd_filename; |
2821 | a20dd508 | bellard | const char *kernel_filename, *kernel_cmdline; |
2822 | e3fdc535 | Markus Armbruster | const char *boot_order; |
2823 | 3023f332 | aliguori | DisplayState *ds; |
2824 | 9f227bc3 | malc | int cyls, heads, secs, translation;
|
2825 | 9f227bc3 | malc | QemuOpts *hda_opts = NULL, *opts, *machine_opts;
|
2826 | 03b0ba70 | Gerd Hoffmann | QemuOptsList *olist; |
2827 | cd6f1169 | bellard | int optind;
|
2828 | 6530a97b | Anthony Liguori | const char *optarg; |
2829 | d63d307f | bellard | const char *loadvm = NULL; |
2830 | cc1daa40 | bellard | QEMUMachine *machine; |
2831 | 94fc95cd | j_mayer | const char *cpu_model; |
2832 | 7f1b17f2 | Paolo Bonzini | const char *vga_model = "none"; |
2833 | d4fce24f | Paolo Bonzini | const char *qtest_chrdev = NULL; |
2834 | d4fce24f | Paolo Bonzini | const char *qtest_log = NULL; |
2835 | 93815bc2 | ths | const char *pid_file = NULL; |
2836 | 5bb7910a | aliguori | const char *incoming = NULL; |
2837 | 821601ea | Jes Sorensen | #ifdef CONFIG_VNC
|
2838 | 993fbfdb | Anthony Liguori | int show_vnc_port = 0; |
2839 | 821601ea | Jes Sorensen | #endif
|
2840 | 3ed2d9ee | Eduardo Habkost | bool defconfig = true; |
2841 | f29a5614 | Eduardo Habkost | bool userconfig = true; |
2842 | c235d738 | Matthew Fernandez | const char *log_mask = NULL; |
2843 | c235d738 | Matthew Fernandez | const char *log_file = NULL; |
2844 | 0750112a | Anthony Liguori | GMemVTable mem_trace = { |
2845 | 0750112a | Anthony Liguori | .malloc = malloc_and_trace, |
2846 | 0750112a | Anthony Liguori | .realloc = realloc_and_trace, |
2847 | 0750112a | Anthony Liguori | .free = free_and_trace, |
2848 | 0750112a | Anthony Liguori | }; |
2849 | 23d15e86 | Lluís | const char *trace_events = NULL; |
2850 | e4858974 | Lluís | const char *trace_file = NULL; |
2851 | 0b5538c3 | Stefan Hajnoczi | |
2852 | fd42deeb | Gerd Hoffmann | atexit(qemu_run_exit_notifiers); |
2853 | 65abca0a | Markus Armbruster | error_set_progname(argv[0]);
|
2854 | 10f5bff6 | Fam Zheng | qemu_init_exec_dir(argv[0]);
|
2855 | 65abca0a | Markus Armbruster | |
2856 | 0750112a | Anthony Liguori | g_mem_set_vtable(&mem_trace); |
2857 | db529aab | Andreas Färber | if (!g_thread_supported()) {
|
2858 | 42ed3727 | Alon Levy | #if !GLIB_CHECK_VERSION(2, 31, 0) |
2859 | db529aab | Andreas Färber | g_thread_init(NULL);
|
2860 | 42ed3727 | Alon Levy | #else
|
2861 | 42ed3727 | Alon Levy | fprintf(stderr, "glib threading failed to initialize.\n");
|
2862 | 42ed3727 | Alon Levy | exit(1);
|
2863 | 42ed3727 | Alon Levy | #endif
|
2864 | db529aab | Andreas Färber | } |
2865 | 0750112a | Anthony Liguori | |
2866 | 1b71f7c1 | Andreas Färber | module_call_init(MODULE_INIT_QOM); |
2867 | 1b71f7c1 | Andreas Färber | |
2868 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_drive_opts); |
2869 | 968854c8 | Amos Kong | qemu_add_drive_opts(&qemu_legacy_drive_opts); |
2870 | 968854c8 | Amos Kong | qemu_add_drive_opts(&qemu_common_drive_opts); |
2871 | 968854c8 | Amos Kong | qemu_add_drive_opts(&qemu_drive_opts); |
2872 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_chardev_opts); |
2873 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_device_opts); |
2874 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_netdev_opts); |
2875 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_net_opts); |
2876 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_rtc_opts); |
2877 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_global_opts); |
2878 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_mon_opts); |
2879 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_trace_opts); |
2880 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_option_rom_opts); |
2881 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_machine_opts); |
2882 | 12b7f57e | Michael Tokarev | qemu_add_opts(&qemu_smp_opts); |
2883 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_boot_opts); |
2884 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_sandbox_opts); |
2885 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_add_fd_opts); |
2886 | 4d454574 | Paolo Bonzini | qemu_add_opts(&qemu_object_opts); |
2887 | d1a0cf73 | Stefan Berger | qemu_add_opts(&qemu_tpmdev_opts); |
2888 | 888a6bc6 | Satoru Moriya | qemu_add_opts(&qemu_realtime_opts); |
2889 | 5e2ac519 | Seiji Aguchi | qemu_add_opts(&qemu_msg_opts); |
2890 | 4d454574 | Paolo Bonzini | |
2891 | 5db9d4d1 | Luiz Capitulino | runstate_init(); |
2892 | 5db9d4d1 | Luiz Capitulino | |
2893 | 6875204c | Jan Kiszka | init_clocks(); |
2894 | 884f17c2 | Alex Bligh | rtc_clock = QEMU_CLOCK_HOST; |
2895 | 6875204c | Jan Kiszka | |
2896 | b6a3e690 | Richard Henderson | qemu_init_auxval(envp); |
2897 | 664d2c44 | Richard Henderson | qemu_cache_utils_init(); |
2898 | 902b3d5c | malc | |
2899 | 72cf2d4f | Blue Swirl | QLIST_INIT (&vm_change_state_head); |
2900 | fe98ac14 | Jes Sorensen | os_setup_early_signal_handling(); |
2901 | be995c27 | bellard | |
2902 | f80f9ec9 | Anthony Liguori | module_call_init(MODULE_INIT_MACHINE); |
2903 | 0c257437 | Anthony Liguori | machine = find_default_machine(); |
2904 | 94fc95cd | j_mayer | cpu_model = NULL;
|
2905 | 4fc5d071 | aurel32 | ram_size = 0;
|
2906 | 33e3963e | bellard | snapshot = 0;
|
2907 | 9f227bc3 | malc | cyls = heads = secs = 0;
|
2908 | 9f227bc3 | malc | translation = BIOS_ATA_TRANSLATION_AUTO; |
2909 | c4b1fcc0 | bellard | |
2910 | 268a362c | aliguori | for (i = 0; i < MAX_NODES; i++) { |
2911 | 268a362c | aliguori | node_mem[i] = 0;
|
2912 | ee785fed | Chegu Vinod | node_cpumask[i] = bitmap_new(MAX_CPUMASK_BITS); |
2913 | 268a362c | aliguori | } |
2914 | 268a362c | aliguori | |
2915 | 268a362c | aliguori | nb_numa_nodes = 0;
|
2916 | 7c9d8e07 | bellard | nb_nics = 0;
|
2917 | 3b46e624 | ths | |
2918 | 142c6b1a | Peter Lieven | bdrv_init_with_whitelist(); |
2919 | 142c6b1a | Peter Lieven | |
2920 | 2c02d1ad | Kewei Yu | autostart = 1;
|
2921 | 41bd639b | blueswir1 | |
2922 | 292444cb | Anthony Liguori | /* first pass of option parsing */
|
2923 | 292444cb | Anthony Liguori | optind = 1;
|
2924 | 292444cb | Anthony Liguori | while (optind < argc) {
|
2925 | 292444cb | Anthony Liguori | if (argv[optind][0] != '-') { |
2926 | 292444cb | Anthony Liguori | /* disk image */
|
2927 | 28e68d68 | Anthony Liguori | optind++; |
2928 | 292444cb | Anthony Liguori | continue;
|
2929 | 292444cb | Anthony Liguori | } else {
|
2930 | 292444cb | Anthony Liguori | const QEMUOption *popt;
|
2931 | 292444cb | Anthony Liguori | |
2932 | 292444cb | Anthony Liguori | popt = lookup_opt(argc, argv, &optarg, &optind); |
2933 | 292444cb | Anthony Liguori | switch (popt->index) {
|
2934 | 292444cb | Anthony Liguori | case QEMU_OPTION_nodefconfig:
|
2935 | 3ed2d9ee | Eduardo Habkost | defconfig = false;
|
2936 | 292444cb | Anthony Liguori | break;
|
2937 | f29a5614 | Eduardo Habkost | case QEMU_OPTION_nouserconfig:
|
2938 | f29a5614 | Eduardo Habkost | userconfig = false;
|
2939 | f29a5614 | Eduardo Habkost | break;
|
2940 | 292444cb | Anthony Liguori | } |
2941 | 292444cb | Anthony Liguori | } |
2942 | 292444cb | Anthony Liguori | } |
2943 | 292444cb | Anthony Liguori | |
2944 | 292444cb | Anthony Liguori | if (defconfig) {
|
2945 | dcfb0939 | Kevin Wolf | int ret;
|
2946 | f29a5614 | Eduardo Habkost | ret = qemu_read_default_config_files(userconfig); |
2947 | b5a8fe5e | Eduardo Habkost | if (ret < 0) { |
2948 | dcfb0939 | Kevin Wolf | exit(1);
|
2949 | 292444cb | Anthony Liguori | } |
2950 | 292444cb | Anthony Liguori | } |
2951 | 292444cb | Anthony Liguori | |
2952 | 292444cb | Anthony Liguori | /* second pass of option parsing */
|
2953 | cd6f1169 | bellard | optind = 1;
|
2954 | 0824d6fc | bellard | for(;;) {
|
2955 | cd6f1169 | bellard | if (optind >= argc)
|
2956 | 0824d6fc | bellard | break;
|
2957 | 6530a97b | Anthony Liguori | if (argv[optind][0] != '-') { |
2958 | 9f227bc3 | malc | hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
|
2959 | cd6f1169 | bellard | } else {
|
2960 | cd6f1169 | bellard | const QEMUOption *popt;
|
2961 | cd6f1169 | bellard | |
2962 | 6530a97b | Anthony Liguori | popt = lookup_opt(argc, argv, &optarg, &optind); |
2963 | ad96090a | Blue Swirl | if (!(popt->arch_mask & arch_type)) {
|
2964 | ad96090a | Blue Swirl | printf("Option %s not supported for this target\n", popt->name);
|
2965 | ad96090a | Blue Swirl | exit(1);
|
2966 | ad96090a | Blue Swirl | } |
2967 | cd6f1169 | bellard | switch(popt->index) {
|
2968 | cc1daa40 | bellard | case QEMU_OPTION_M:
|
2969 | 9052ea6b | Jan Kiszka | machine = machine_parse(optarg); |
2970 | cc1daa40 | bellard | break;
|
2971 | e43d594e | Jan Kiszka | case QEMU_OPTION_no_kvm_irqchip: {
|
2972 | e43d594e | Jan Kiszka | olist = qemu_find_opts("machine");
|
2973 | e43d594e | Jan Kiszka | qemu_opts_parse(olist, "kernel_irqchip=off", 0); |
2974 | e43d594e | Jan Kiszka | break;
|
2975 | e43d594e | Jan Kiszka | } |
2976 | 94fc95cd | j_mayer | case QEMU_OPTION_cpu:
|
2977 | 94fc95cd | j_mayer | /* hw initialization will check this */
|
2978 | ecf40bea | Eduardo Habkost | cpu_model = optarg; |
2979 | 94fc95cd | j_mayer | break;
|
2980 | cd6f1169 | bellard | case QEMU_OPTION_hda:
|
2981 | 9f227bc3 | malc | { |
2982 | 9f227bc3 | malc | char buf[256]; |
2983 | 9f227bc3 | malc | if (cyls == 0) |
2984 | 9f227bc3 | malc | snprintf(buf, sizeof(buf), "%s", HD_OPTS); |
2985 | 9f227bc3 | malc | else
|
2986 | 9f227bc3 | malc | snprintf(buf, sizeof(buf),
|
2987 | 9f227bc3 | malc | "%s,cyls=%d,heads=%d,secs=%d%s",
|
2988 | 9f227bc3 | malc | HD_OPTS , cyls, heads, secs, |
2989 | 9f227bc3 | malc | translation == BIOS_ATA_TRANSLATION_LBA ? |
2990 | 9f227bc3 | malc | ",trans=lba" :
|
2991 | 9f227bc3 | malc | translation == BIOS_ATA_TRANSLATION_NONE ? |
2992 | 9f227bc3 | malc | ",trans=none" : ""); |
2993 | 9f227bc3 | malc | drive_add(IF_DEFAULT, 0, optarg, buf);
|
2994 | 9f227bc3 | malc | break;
|
2995 | 9f227bc3 | malc | } |
2996 | cd6f1169 | bellard | case QEMU_OPTION_hdb:
|
2997 | cc1daa40 | bellard | case QEMU_OPTION_hdc:
|
2998 | cc1daa40 | bellard | case QEMU_OPTION_hdd:
|
2999 | 2292ddae | Markus Armbruster | drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg, |
3000 | 2292ddae | Markus Armbruster | HD_OPTS); |
3001 | fc01f7e7 | bellard | break;
|
3002 | e4bcb14c | ths | case QEMU_OPTION_drive:
|
3003 | e2982c3a | Michael Tokarev | if (drive_def(optarg) == NULL) { |
3004 | e2982c3a | Michael Tokarev | exit(1);
|
3005 | e2982c3a | Michael Tokarev | } |
3006 | e4bcb14c | ths | break;
|
3007 | d058fe03 | Gerd Hoffmann | case QEMU_OPTION_set:
|
3008 | d058fe03 | Gerd Hoffmann | if (qemu_set_option(optarg) != 0) |
3009 | d058fe03 | Gerd Hoffmann | exit(1);
|
3010 | d058fe03 | Gerd Hoffmann | break;
|
3011 | d0fef6fb | Gerd Hoffmann | case QEMU_OPTION_global:
|
3012 | d0fef6fb | Gerd Hoffmann | if (qemu_global_option(optarg) != 0) |
3013 | d0fef6fb | Gerd Hoffmann | exit(1);
|
3014 | d0fef6fb | Gerd Hoffmann | break;
|
3015 | 3e3d5815 | balrog | case QEMU_OPTION_mtdblock:
|
3016 | 2292ddae | Markus Armbruster | drive_add(IF_MTD, -1, optarg, MTD_OPTS);
|
3017 | 3e3d5815 | balrog | break;
|
3018 | a1bb27b1 | pbrook | case QEMU_OPTION_sd:
|
3019 | 80f4d9fc | Peter Crosthwaite | drive_add(IF_SD, -1, optarg, SD_OPTS);
|
3020 | a1bb27b1 | pbrook | break;
|
3021 | 86f55663 | j_mayer | case QEMU_OPTION_pflash:
|
3022 | 2292ddae | Markus Armbruster | drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);
|
3023 | 86f55663 | j_mayer | break;
|
3024 | cd6f1169 | bellard | case QEMU_OPTION_snapshot:
|
3025 | 33e3963e | bellard | snapshot = 1;
|
3026 | 33e3963e | bellard | break;
|
3027 | cd6f1169 | bellard | case QEMU_OPTION_hdachs:
|
3028 | 330d0414 | bellard | { |
3029 | 330d0414 | bellard | const char *p; |
3030 | 330d0414 | bellard | p = optarg; |
3031 | 330d0414 | bellard | cyls = strtol(p, (char **)&p, 0); |
3032 | 46d4767d | bellard | if (cyls < 1 || cyls > 16383) |
3033 | 46d4767d | bellard | goto chs_fail;
|
3034 | 330d0414 | bellard | if (*p != ',') |
3035 | 330d0414 | bellard | goto chs_fail;
|
3036 | 330d0414 | bellard | p++; |
3037 | 330d0414 | bellard | heads = strtol(p, (char **)&p, 0); |
3038 | 46d4767d | bellard | if (heads < 1 || heads > 16) |
3039 | 46d4767d | bellard | goto chs_fail;
|
3040 | 330d0414 | bellard | if (*p != ',') |
3041 | 330d0414 | bellard | goto chs_fail;
|
3042 | 330d0414 | bellard | p++; |
3043 | 330d0414 | bellard | secs = strtol(p, (char **)&p, 0); |
3044 | 46d4767d | bellard | if (secs < 1 || secs > 63) |
3045 | 46d4767d | bellard | goto chs_fail;
|
3046 | 46d4767d | bellard | if (*p == ',') { |
3047 | 46d4767d | bellard | p++; |
3048 | f31c41ff | Paolo Bonzini | if (!strcmp(p, "large")) { |
3049 | f31c41ff | Paolo Bonzini | translation = BIOS_ATA_TRANSLATION_LARGE; |
3050 | f31c41ff | Paolo Bonzini | } else if (!strcmp(p, "rechs")) { |
3051 | f31c41ff | Paolo Bonzini | translation = BIOS_ATA_TRANSLATION_RECHS; |
3052 | f31c41ff | Paolo Bonzini | } else if (!strcmp(p, "none")) { |
3053 | 46d4767d | bellard | translation = BIOS_ATA_TRANSLATION_NONE; |
3054 | f31c41ff | Paolo Bonzini | } else if (!strcmp(p, "lba")) { |
3055 | 46d4767d | bellard | translation = BIOS_ATA_TRANSLATION_LBA; |
3056 | f31c41ff | Paolo Bonzini | } else if (!strcmp(p, "auto")) { |
3057 | 46d4767d | bellard | translation = BIOS_ATA_TRANSLATION_AUTO; |
3058 | f31c41ff | Paolo Bonzini | } else {
|
3059 | 46d4767d | bellard | goto chs_fail;
|
3060 | f31c41ff | Paolo Bonzini | } |
3061 | 46d4767d | bellard | } else if (*p != '\0') { |
3062 | c4b1fcc0 | bellard | chs_fail:
|
3063 | 46d4767d | bellard | fprintf(stderr, "qemu: invalid physical CHS format\n");
|
3064 | 46d4767d | bellard | exit(1);
|
3065 | c4b1fcc0 | bellard | } |
3066 | 9f227bc3 | malc | if (hda_opts != NULL) { |
3067 | 9dfd7c7a | Gerd Hoffmann | char num[16]; |
3068 | 9dfd7c7a | Gerd Hoffmann | snprintf(num, sizeof(num), "%d", cyls); |
3069 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(hda_opts, "cyls", num);
|
3070 | 9dfd7c7a | Gerd Hoffmann | snprintf(num, sizeof(num), "%d", heads); |
3071 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(hda_opts, "heads", num);
|
3072 | 9dfd7c7a | Gerd Hoffmann | snprintf(num, sizeof(num), "%d", secs); |
3073 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(hda_opts, "secs", num);
|
3074 | f31c41ff | Paolo Bonzini | if (translation == BIOS_ATA_TRANSLATION_LARGE) {
|
3075 | f31c41ff | Paolo Bonzini | qemu_opt_set(hda_opts, "trans", "large"); |
3076 | f31c41ff | Paolo Bonzini | } else if (translation == BIOS_ATA_TRANSLATION_RECHS) { |
3077 | f31c41ff | Paolo Bonzini | qemu_opt_set(hda_opts, "trans", "rechs"); |
3078 | f31c41ff | Paolo Bonzini | } else if (translation == BIOS_ATA_TRANSLATION_LBA) { |
3079 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(hda_opts, "trans", "lba"); |
3080 | f31c41ff | Paolo Bonzini | } else if (translation == BIOS_ATA_TRANSLATION_NONE) { |
3081 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(hda_opts, "trans", "none"); |
3082 | f31c41ff | Paolo Bonzini | } |
3083 | 9dfd7c7a | Gerd Hoffmann | } |
3084 | 330d0414 | bellard | } |
3085 | 330d0414 | bellard | break;
|
3086 | 268a362c | aliguori | case QEMU_OPTION_numa:
|
3087 | 268a362c | aliguori | numa_add(optarg); |
3088 | 268a362c | aliguori | break;
|
3089 | 1472a95b | Jes Sorensen | case QEMU_OPTION_display:
|
3090 | 1472a95b | Jes Sorensen | display_type = select_display(optarg); |
3091 | 1472a95b | Jes Sorensen | break;
|
3092 | cd6f1169 | bellard | case QEMU_OPTION_nographic:
|
3093 | 993fbfdb | Anthony Liguori | display_type = DT_NOGRAPHIC; |
3094 | a20dd508 | bellard | break;
|
3095 | 4d3b6f6e | balrog | case QEMU_OPTION_curses:
|
3096 | 47b05369 | Jes Sorensen | #ifdef CONFIG_CURSES
|
3097 | 993fbfdb | Anthony Liguori | display_type = DT_CURSES; |
3098 | 47b05369 | Jes Sorensen | #else
|
3099 | 47b05369 | Jes Sorensen | fprintf(stderr, "Curses support is disabled\n");
|
3100 | 47b05369 | Jes Sorensen | exit(1);
|
3101 | 4d3b6f6e | balrog | #endif
|
3102 | 47b05369 | Jes Sorensen | break;
|
3103 | a171fe39 | balrog | case QEMU_OPTION_portrait:
|
3104 | 9312805d | Vasily Khoruzhick | graphic_rotate = 90;
|
3105 | 9312805d | Vasily Khoruzhick | break;
|
3106 | 9312805d | Vasily Khoruzhick | case QEMU_OPTION_rotate:
|
3107 | 9312805d | Vasily Khoruzhick | graphic_rotate = strtol(optarg, (char **) &optarg, 10); |
3108 | 9312805d | Vasily Khoruzhick | if (graphic_rotate != 0 && graphic_rotate != 90 && |
3109 | 9312805d | Vasily Khoruzhick | graphic_rotate != 180 && graphic_rotate != 270) { |
3110 | 9312805d | Vasily Khoruzhick | fprintf(stderr, |
3111 | 9312805d | Vasily Khoruzhick | "qemu: only 90, 180, 270 deg rotation is available\n");
|
3112 | 9312805d | Vasily Khoruzhick | exit(1);
|
3113 | 9312805d | Vasily Khoruzhick | } |
3114 | a171fe39 | balrog | break;
|
3115 | cd6f1169 | bellard | case QEMU_OPTION_kernel:
|
3116 | a0abe474 | Peter Maydell | qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", optarg); |
3117 | a0abe474 | Peter Maydell | break;
|
3118 | a0abe474 | Peter Maydell | case QEMU_OPTION_initrd:
|
3119 | a0abe474 | Peter Maydell | qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg); |
3120 | a20dd508 | bellard | break;
|
3121 | cd6f1169 | bellard | case QEMU_OPTION_append:
|
3122 | a0abe474 | Peter Maydell | qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg); |
3123 | 313aa567 | bellard | break;
|
3124 | 412beee6 | Grant Likely | case QEMU_OPTION_dtb:
|
3125 | 412beee6 | Grant Likely | qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg); |
3126 | 412beee6 | Grant Likely | break;
|
3127 | cd6f1169 | bellard | case QEMU_OPTION_cdrom:
|
3128 | 2292ddae | Markus Armbruster | drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
|
3129 | 36b486bb | bellard | break;
|
3130 | cd6f1169 | bellard | case QEMU_OPTION_boot:
|
3131 | 8281abd5 | Markus Armbruster | opts = qemu_opts_parse(qemu_find_opts("boot-opts"), optarg, 1); |
3132 | 8281abd5 | Markus Armbruster | if (!opts) {
|
3133 | 8281abd5 | Markus Armbruster | exit(1);
|
3134 | 36b486bb | bellard | } |
3135 | 36b486bb | bellard | break;
|
3136 | cd6f1169 | bellard | case QEMU_OPTION_fda:
|
3137 | cd6f1169 | bellard | case QEMU_OPTION_fdb:
|
3138 | 2292ddae | Markus Armbruster | drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda, |
3139 | 2292ddae | Markus Armbruster | optarg, FD_OPTS); |
3140 | c45886db | bellard | break;
|
3141 | 52ca8d6a | bellard | case QEMU_OPTION_no_fd_bootchk:
|
3142 | 52ca8d6a | bellard | fd_bootchk = 0;
|
3143 | 52ca8d6a | bellard | break;
|
3144 | a1ea458f | Mark McLoughlin | case QEMU_OPTION_netdev:
|
3145 | 3329f07b | Gerd Hoffmann | if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) { |
3146 | a1ea458f | Mark McLoughlin | exit(1);
|
3147 | a1ea458f | Mark McLoughlin | } |
3148 | a1ea458f | Mark McLoughlin | break;
|
3149 | 7c9d8e07 | bellard | case QEMU_OPTION_net:
|
3150 | 3329f07b | Gerd Hoffmann | if (net_client_parse(qemu_find_opts("net"), optarg) == -1) { |
3151 | c4b1fcc0 | bellard | exit(1);
|
3152 | c4b1fcc0 | bellard | } |
3153 | 702c651c | bellard | break;
|
3154 | f9dadc98 | Ronnie Sahlberg | #ifdef CONFIG_LIBISCSI
|
3155 | f9dadc98 | Ronnie Sahlberg | case QEMU_OPTION_iscsi:
|
3156 | f9dadc98 | Ronnie Sahlberg | opts = qemu_opts_parse(qemu_find_opts("iscsi"), optarg, 0); |
3157 | f9dadc98 | Ronnie Sahlberg | if (!opts) {
|
3158 | f9dadc98 | Ronnie Sahlberg | exit(1);
|
3159 | f9dadc98 | Ronnie Sahlberg | } |
3160 | f9dadc98 | Ronnie Sahlberg | break;
|
3161 | f9dadc98 | Ronnie Sahlberg | #endif
|
3162 | c7f74643 | bellard | #ifdef CONFIG_SLIRP
|
3163 | c7f74643 | bellard | case QEMU_OPTION_tftp:
|
3164 | ad196a9d | Jan Kiszka | legacy_tftp_prefix = optarg; |
3165 | 9bf05444 | bellard | break;
|
3166 | 47d5d01a | ths | case QEMU_OPTION_bootp:
|
3167 | ad196a9d | Jan Kiszka | legacy_bootp_filename = optarg; |
3168 | 47d5d01a | ths | break;
|
3169 | 9bf05444 | bellard | case QEMU_OPTION_redir:
|
3170 | 0752706d | Markus Armbruster | if (net_slirp_redir(optarg) < 0) |
3171 | 0752706d | Markus Armbruster | exit(1);
|
3172 | 9bf05444 | bellard | break;
|
3173 | c7f74643 | bellard | #endif
|
3174 | dc72ac14 | balrog | case QEMU_OPTION_bt:
|
3175 | bd3c948d | Gerd Hoffmann | add_device_config(DEV_BT, optarg); |
3176 | dc72ac14 | balrog | break;
|
3177 | 1d14ffa9 | bellard | case QEMU_OPTION_audio_help:
|
3178 | 1d14ffa9 | bellard | AUD_help (); |
3179 | 1d14ffa9 | bellard | exit (0);
|
3180 | 1d14ffa9 | bellard | break;
|
3181 | 1d14ffa9 | bellard | case QEMU_OPTION_soundhw:
|
3182 | 1d14ffa9 | bellard | select_soundhw (optarg); |
3183 | 1d14ffa9 | bellard | break;
|
3184 | cd6f1169 | bellard | case QEMU_OPTION_h:
|
3185 | 15f82208 | ths | help(0);
|
3186 | cd6f1169 | bellard | break;
|
3187 | 9bd7e6d9 | pbrook | case QEMU_OPTION_version:
|
3188 | 9bd7e6d9 | pbrook | version(); |
3189 | 9bd7e6d9 | pbrook | exit(0);
|
3190 | 9bd7e6d9 | pbrook | break;
|
3191 | 00f82b8a | aurel32 | case QEMU_OPTION_m: {
|
3192 | 70b4f4bb | Jes Sorensen | int64_t value; |
3193 | ff961015 | Markus Armbruster | uint64_t sz; |
3194 | 961b42b9 | Markus Armbruster | char *end;
|
3195 | 9f9b17a4 | Jes Sorensen | |
3196 | 961b42b9 | Markus Armbruster | value = strtosz(optarg, &end); |
3197 | 961b42b9 | Markus Armbruster | if (value < 0 || *end) { |
3198 | 00f82b8a | aurel32 | fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
|
3199 | cd6f1169 | bellard | exit(1);
|
3200 | cd6f1169 | bellard | } |
3201 | ff961015 | Markus Armbruster | sz = QEMU_ALIGN_UP((uint64_t)value, 8192);
|
3202 | ff961015 | Markus Armbruster | ram_size = sz; |
3203 | ff961015 | Markus Armbruster | if (ram_size != sz) {
|
3204 | 00f82b8a | aurel32 | fprintf(stderr, "qemu: ram size too large\n");
|
3205 | 00f82b8a | aurel32 | exit(1);
|
3206 | 00f82b8a | aurel32 | } |
3207 | cd6f1169 | bellard | break;
|
3208 | 00f82b8a | aurel32 | } |
3209 | d1a0cf73 | Stefan Berger | #ifdef CONFIG_TPM
|
3210 | d1a0cf73 | Stefan Berger | case QEMU_OPTION_tpmdev:
|
3211 | d1a0cf73 | Stefan Berger | if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) { |
3212 | d1a0cf73 | Stefan Berger | exit(1);
|
3213 | d1a0cf73 | Stefan Berger | } |
3214 | d1a0cf73 | Stefan Berger | break;
|
3215 | d1a0cf73 | Stefan Berger | #endif
|
3216 | c902760f | Marcelo Tosatti | case QEMU_OPTION_mempath:
|
3217 | c902760f | Marcelo Tosatti | mem_path = optarg; |
3218 | c902760f | Marcelo Tosatti | break;
|
3219 | c902760f | Marcelo Tosatti | case QEMU_OPTION_mem_prealloc:
|
3220 | c902760f | Marcelo Tosatti | mem_prealloc = 1;
|
3221 | c902760f | Marcelo Tosatti | break;
|
3222 | cd6f1169 | bellard | case QEMU_OPTION_d:
|
3223 | c235d738 | Matthew Fernandez | log_mask = optarg; |
3224 | c235d738 | Matthew Fernandez | break;
|
3225 | c235d738 | Matthew Fernandez | case QEMU_OPTION_D:
|
3226 | c235d738 | Matthew Fernandez | log_file = optarg; |
3227 | cd6f1169 | bellard | break;
|
3228 | cd6f1169 | bellard | case QEMU_OPTION_s:
|
3229 | ef0c4a0d | Markus Armbruster | add_device_config(DEV_GDB, "tcp::" DEFAULT_GDBSTUB_PORT);
|
3230 | cd6f1169 | bellard | break;
|
3231 | 59030a8c | aliguori | case QEMU_OPTION_gdb:
|
3232 | ef0c4a0d | Markus Armbruster | add_device_config(DEV_GDB, optarg); |
3233 | cd6f1169 | bellard | break;
|
3234 | cd6f1169 | bellard | case QEMU_OPTION_L:
|
3235 | 4524051c | Gerd Hoffmann | if (data_dir_idx < ARRAY_SIZE(data_dir)) {
|
3236 | 4524051c | Gerd Hoffmann | data_dir[data_dir_idx++] = optarg; |
3237 | 4524051c | Gerd Hoffmann | } |
3238 | cd6f1169 | bellard | break;
|
3239 | 1192dad8 | j_mayer | case QEMU_OPTION_bios:
|
3240 | 1442d3e6 | Gerd Hoffmann | qemu_opts_set(qemu_find_opts("machine"), 0, "firmware", optarg); |
3241 | 1192dad8 | j_mayer | break;
|
3242 | 1b530a6d | aurel32 | case QEMU_OPTION_singlestep:
|
3243 | 1b530a6d | aurel32 | singlestep = 1;
|
3244 | 1b530a6d | aurel32 | break;
|
3245 | cd6f1169 | bellard | case QEMU_OPTION_S:
|
3246 | 3c07f8e8 | pbrook | autostart = 0;
|
3247 | cd6f1169 | bellard | break;
|
3248 | 3d11d0eb | bellard | case QEMU_OPTION_k:
|
3249 | 3d11d0eb | bellard | keyboard_layout = optarg; |
3250 | 3d11d0eb | bellard | break;
|
3251 | ee22c2f7 | bellard | case QEMU_OPTION_localtime:
|
3252 | ee22c2f7 | bellard | rtc_utc = 0;
|
3253 | ee22c2f7 | bellard | break;
|
3254 | 3893c124 | malc | case QEMU_OPTION_vga:
|
3255 | a369da5f | Blue Swirl | vga_model = optarg; |
3256 | 7f1b17f2 | Paolo Bonzini | default_vga = 0;
|
3257 | 1bfe856e | bellard | break;
|
3258 | e9b137c2 | bellard | case QEMU_OPTION_g:
|
3259 | e9b137c2 | bellard | { |
3260 | e9b137c2 | bellard | const char *p; |
3261 | e9b137c2 | bellard | int w, h, depth;
|
3262 | e9b137c2 | bellard | p = optarg; |
3263 | e9b137c2 | bellard | w = strtol(p, (char **)&p, 10); |
3264 | e9b137c2 | bellard | if (w <= 0) { |
3265 | e9b137c2 | bellard | graphic_error:
|
3266 | e9b137c2 | bellard | fprintf(stderr, "qemu: invalid resolution or depth\n");
|
3267 | e9b137c2 | bellard | exit(1);
|
3268 | e9b137c2 | bellard | } |
3269 | e9b137c2 | bellard | if (*p != 'x') |
3270 | e9b137c2 | bellard | goto graphic_error;
|
3271 | e9b137c2 | bellard | p++; |
3272 | e9b137c2 | bellard | h = strtol(p, (char **)&p, 10); |
3273 | e9b137c2 | bellard | if (h <= 0) |
3274 | e9b137c2 | bellard | goto graphic_error;
|
3275 | e9b137c2 | bellard | if (*p == 'x') { |
3276 | e9b137c2 | bellard | p++; |
3277 | e9b137c2 | bellard | depth = strtol(p, (char **)&p, 10); |
3278 | 5fafdf24 | ths | if (depth != 8 && depth != 15 && depth != 16 && |
3279 | e9b137c2 | bellard | depth != 24 && depth != 32) |
3280 | e9b137c2 | bellard | goto graphic_error;
|
3281 | e9b137c2 | bellard | } else if (*p == '\0') { |
3282 | e9b137c2 | bellard | depth = graphic_depth; |
3283 | e9b137c2 | bellard | } else {
|
3284 | e9b137c2 | bellard | goto graphic_error;
|
3285 | e9b137c2 | bellard | } |
3286 | 3b46e624 | ths | |
3287 | e9b137c2 | bellard | graphic_width = w; |
3288 | e9b137c2 | bellard | graphic_height = h; |
3289 | e9b137c2 | bellard | graphic_depth = depth; |
3290 | e9b137c2 | bellard | } |
3291 | e9b137c2 | bellard | break;
|
3292 | 20d8a3ed | ths | case QEMU_OPTION_echr:
|
3293 | 20d8a3ed | ths | { |
3294 | 20d8a3ed | ths | char *r;
|
3295 | 20d8a3ed | ths | term_escape_char = strtol(optarg, &r, 0);
|
3296 | 20d8a3ed | ths | if (r == optarg)
|
3297 | 20d8a3ed | ths | printf("Bad argument to echr\n");
|
3298 | 20d8a3ed | ths | break;
|
3299 | 20d8a3ed | ths | } |
3300 | 82c643ff | bellard | case QEMU_OPTION_monitor:
|
3301 | 6ca5582d | Gerd Hoffmann | default_monitor = 0;
|
3302 | 70e098af | Luiz Capitulino | if (strncmp(optarg, "none", 4)) { |
3303 | 70e098af | Luiz Capitulino | monitor_parse(optarg, "readline");
|
3304 | 70e098af | Luiz Capitulino | } |
3305 | 6ca5582d | Gerd Hoffmann | break;
|
3306 | 6ca5582d | Gerd Hoffmann | case QEMU_OPTION_qmp:
|
3307 | 6ca5582d | Gerd Hoffmann | monitor_parse(optarg, "control");
|
3308 | 2d114dc1 | Anthony Liguori | default_monitor = 0;
|
3309 | 82c643ff | bellard | break;
|
3310 | 22a0e04b | Gerd Hoffmann | case QEMU_OPTION_mon:
|
3311 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1); |
3312 | 22a0e04b | Gerd Hoffmann | if (!opts) {
|
3313 | 22a0e04b | Gerd Hoffmann | exit(1);
|
3314 | 22a0e04b | Gerd Hoffmann | } |
3315 | 2d114dc1 | Anthony Liguori | default_monitor = 0;
|
3316 | 22a0e04b | Gerd Hoffmann | break;
|
3317 | 191bc01b | Gerd Hoffmann | case QEMU_OPTION_chardev:
|
3318 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_parse(qemu_find_opts("chardev"), optarg, 1); |
3319 | 191bc01b | Gerd Hoffmann | if (!opts) {
|
3320 | 191bc01b | Gerd Hoffmann | exit(1);
|
3321 | 191bc01b | Gerd Hoffmann | } |
3322 | 191bc01b | Gerd Hoffmann | break;
|
3323 | 74db920c | Gautham R Shenoy | case QEMU_OPTION_fsdev:
|
3324 | 03b0ba70 | Gerd Hoffmann | olist = qemu_find_opts("fsdev");
|
3325 | 03b0ba70 | Gerd Hoffmann | if (!olist) {
|
3326 | 03b0ba70 | Gerd Hoffmann | fprintf(stderr, "fsdev is not supported by this qemu build.\n");
|
3327 | 03b0ba70 | Gerd Hoffmann | exit(1);
|
3328 | 03b0ba70 | Gerd Hoffmann | } |
3329 | 03b0ba70 | Gerd Hoffmann | opts = qemu_opts_parse(olist, optarg, 1);
|
3330 | 74db920c | Gautham R Shenoy | if (!opts) {
|
3331 | 74db920c | Gautham R Shenoy | exit(1);
|
3332 | 74db920c | Gautham R Shenoy | } |
3333 | 74db920c | Gautham R Shenoy | break;
|
3334 | 3d54abc7 | Gautham R Shenoy | case QEMU_OPTION_virtfs: {
|
3335 | e14ea479 | Stefan Hajnoczi | QemuOpts *fsdev; |
3336 | e14ea479 | Stefan Hajnoczi | QemuOpts *device; |
3337 | 84a87cc4 | M. Mohan Kumar | const char *writeout, *sock_fd, *socket; |
3338 | 3d54abc7 | Gautham R Shenoy | |
3339 | 03b0ba70 | Gerd Hoffmann | olist = qemu_find_opts("virtfs");
|
3340 | 03b0ba70 | Gerd Hoffmann | if (!olist) {
|
3341 | 03b0ba70 | Gerd Hoffmann | fprintf(stderr, "virtfs is not supported by this qemu build.\n");
|
3342 | 03b0ba70 | Gerd Hoffmann | exit(1);
|
3343 | 03b0ba70 | Gerd Hoffmann | } |
3344 | 03b0ba70 | Gerd Hoffmann | opts = qemu_opts_parse(olist, optarg, 1);
|
3345 | 3d54abc7 | Gautham R Shenoy | if (!opts) {
|
3346 | 3d54abc7 | Gautham R Shenoy | exit(1);
|
3347 | 3d54abc7 | Gautham R Shenoy | } |
3348 | 3d54abc7 | Gautham R Shenoy | |
3349 | fbcbf101 | Aneesh Kumar K.V | if (qemu_opt_get(opts, "fsdriver") == NULL || |
3350 | 99519f0a | Aneesh Kumar K.V | qemu_opt_get(opts, "mount_tag") == NULL) { |
3351 | 99519f0a | Aneesh Kumar K.V | fprintf(stderr, "Usage: -virtfs fsdriver,mount_tag=tag.\n");
|
3352 | 9ce56db6 | Venkateswararao Jujjuri (JV) | exit(1);
|
3353 | 9ce56db6 | Venkateswararao Jujjuri (JV) | } |
3354 | e14ea479 | Stefan Hajnoczi | fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
|
3355 | 8be7e7e4 | Luiz Capitulino | qemu_opt_get(opts, "mount_tag"),
|
3356 | 8be7e7e4 | Luiz Capitulino | 1, NULL); |
3357 | e14ea479 | Stefan Hajnoczi | if (!fsdev) {
|
3358 | e14ea479 | Stefan Hajnoczi | fprintf(stderr, "duplicate fsdev id: %s\n",
|
3359 | e14ea479 | Stefan Hajnoczi | qemu_opt_get(opts, "mount_tag"));
|
3360 | 3d54abc7 | Gautham R Shenoy | exit(1);
|
3361 | 3d54abc7 | Gautham R Shenoy | } |
3362 | d3ab98e6 | Aneesh Kumar K.V | |
3363 | d3ab98e6 | Aneesh Kumar K.V | writeout = qemu_opt_get(opts, "writeout");
|
3364 | d3ab98e6 | Aneesh Kumar K.V | if (writeout) {
|
3365 | d3ab98e6 | Aneesh Kumar K.V | #ifdef CONFIG_SYNC_FILE_RANGE
|
3366 | d3ab98e6 | Aneesh Kumar K.V | qemu_opt_set(fsdev, "writeout", writeout);
|
3367 | d3ab98e6 | Aneesh Kumar K.V | #else
|
3368 | d3ab98e6 | Aneesh Kumar K.V | fprintf(stderr, "writeout=immediate not supported on "
|
3369 | d3ab98e6 | Aneesh Kumar K.V | "this platform\n");
|
3370 | d3ab98e6 | Aneesh Kumar K.V | exit(1);
|
3371 | d3ab98e6 | Aneesh Kumar K.V | #endif
|
3372 | d3ab98e6 | Aneesh Kumar K.V | } |
3373 | fbcbf101 | Aneesh Kumar K.V | qemu_opt_set(fsdev, "fsdriver", qemu_opt_get(opts, "fsdriver")); |
3374 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path")); |
3375 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(fsdev, "security_model",
|
3376 | e14ea479 | Stefan Hajnoczi | qemu_opt_get(opts, "security_model"));
|
3377 | 84a87cc4 | M. Mohan Kumar | socket = qemu_opt_get(opts, "socket");
|
3378 | 84a87cc4 | M. Mohan Kumar | if (socket) {
|
3379 | 84a87cc4 | M. Mohan Kumar | qemu_opt_set(fsdev, "socket", socket);
|
3380 | 84a87cc4 | M. Mohan Kumar | } |
3381 | 4c793dda | M. Mohan Kumar | sock_fd = qemu_opt_get(opts, "sock_fd");
|
3382 | 4c793dda | M. Mohan Kumar | if (sock_fd) {
|
3383 | 4c793dda | M. Mohan Kumar | qemu_opt_set(fsdev, "sock_fd", sock_fd);
|
3384 | 4c793dda | M. Mohan Kumar | } |
3385 | e14ea479 | Stefan Hajnoczi | |
3386 | 2c74c2cb | M. Mohan Kumar | qemu_opt_set_bool(fsdev, "readonly",
|
3387 | 2c74c2cb | M. Mohan Kumar | qemu_opt_get_bool(opts, "readonly", 0)); |
3388 | 87ea75d5 | Peter Crosthwaite | device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, |
3389 | 87ea75d5 | Peter Crosthwaite | &error_abort); |
3390 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(device, "driver", "virtio-9p-pci"); |
3391 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(device, "fsdev",
|
3392 | e14ea479 | Stefan Hajnoczi | qemu_opt_get(opts, "mount_tag"));
|
3393 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(device, "mount_tag",
|
3394 | e14ea479 | Stefan Hajnoczi | qemu_opt_get(opts, "mount_tag"));
|
3395 | 3d54abc7 | Gautham R Shenoy | break;
|
3396 | 3d54abc7 | Gautham R Shenoy | } |
3397 | 9db221ae | Aneesh Kumar K.V | case QEMU_OPTION_virtfs_synth: {
|
3398 | 9db221ae | Aneesh Kumar K.V | QemuOpts *fsdev; |
3399 | 9db221ae | Aneesh Kumar K.V | QemuOpts *device; |
3400 | 9db221ae | Aneesh Kumar K.V | |
3401 | 8be7e7e4 | Luiz Capitulino | fsdev = qemu_opts_create(qemu_find_opts("fsdev"), "v_synth", |
3402 | 8be7e7e4 | Luiz Capitulino | 1, NULL); |
3403 | 9db221ae | Aneesh Kumar K.V | if (!fsdev) {
|
3404 | 9db221ae | Aneesh Kumar K.V | fprintf(stderr, "duplicate option: %s\n", "virtfs_synth"); |
3405 | 9db221ae | Aneesh Kumar K.V | exit(1);
|
3406 | 9db221ae | Aneesh Kumar K.V | } |
3407 | 9db221ae | Aneesh Kumar K.V | qemu_opt_set(fsdev, "fsdriver", "synth"); |
3408 | 9db221ae | Aneesh Kumar K.V | |
3409 | 87ea75d5 | Peter Crosthwaite | device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, |
3410 | 87ea75d5 | Peter Crosthwaite | &error_abort); |
3411 | 9db221ae | Aneesh Kumar K.V | qemu_opt_set(device, "driver", "virtio-9p-pci"); |
3412 | 9db221ae | Aneesh Kumar K.V | qemu_opt_set(device, "fsdev", "v_synth"); |
3413 | 9db221ae | Aneesh Kumar K.V | qemu_opt_set(device, "mount_tag", "v_synth"); |
3414 | 9db221ae | Aneesh Kumar K.V | break;
|
3415 | 9db221ae | Aneesh Kumar K.V | } |
3416 | 82c643ff | bellard | case QEMU_OPTION_serial:
|
3417 | 998bbd74 | Gerd Hoffmann | add_device_config(DEV_SERIAL, optarg); |
3418 | 998bbd74 | Gerd Hoffmann | default_serial = 0;
|
3419 | 18141ed6 | Jan Kiszka | if (strncmp(optarg, "mon:", 4) == 0) { |
3420 | 18141ed6 | Jan Kiszka | default_monitor = 0;
|
3421 | 18141ed6 | Jan Kiszka | } |
3422 | 82c643ff | bellard | break;
|
3423 | 9dd986cc | Richard W.M. Jones | case QEMU_OPTION_watchdog:
|
3424 | 09aaa160 | Markus Armbruster | if (watchdog) {
|
3425 | 09aaa160 | Markus Armbruster | fprintf(stderr, |
3426 | 09aaa160 | Markus Armbruster | "qemu: only one watchdog option may be given\n");
|
3427 | 09aaa160 | Markus Armbruster | return 1; |
3428 | 09aaa160 | Markus Armbruster | } |
3429 | 09aaa160 | Markus Armbruster | watchdog = optarg; |
3430 | 9dd986cc | Richard W.M. Jones | break;
|
3431 | 9dd986cc | Richard W.M. Jones | case QEMU_OPTION_watchdog_action:
|
3432 | 9dd986cc | Richard W.M. Jones | if (select_watchdog_action(optarg) == -1) { |
3433 | 9dd986cc | Richard W.M. Jones | fprintf(stderr, "Unknown -watchdog-action parameter\n");
|
3434 | 9dd986cc | Richard W.M. Jones | exit(1);
|
3435 | 9dd986cc | Richard W.M. Jones | } |
3436 | 9dd986cc | Richard W.M. Jones | break;
|
3437 | 51ecf136 | aliguori | case QEMU_OPTION_virtiocon:
|
3438 | aee1b935 | Gerd Hoffmann | add_device_config(DEV_VIRTCON, optarg); |
3439 | aee1b935 | Gerd Hoffmann | default_virtcon = 0;
|
3440 | 18141ed6 | Jan Kiszka | if (strncmp(optarg, "mon:", 4) == 0) { |
3441 | 18141ed6 | Jan Kiszka | default_monitor = 0;
|
3442 | 18141ed6 | Jan Kiszka | } |
3443 | 51ecf136 | aliguori | break;
|
3444 | 6508fe59 | bellard | case QEMU_OPTION_parallel:
|
3445 | 6a5e8b0e | Gerd Hoffmann | add_device_config(DEV_PARALLEL, optarg); |
3446 | 6a5e8b0e | Gerd Hoffmann | default_parallel = 0;
|
3447 | 18141ed6 | Jan Kiszka | if (strncmp(optarg, "mon:", 4) == 0) { |
3448 | 18141ed6 | Jan Kiszka | default_monitor = 0;
|
3449 | 18141ed6 | Jan Kiszka | } |
3450 | 6508fe59 | bellard | break;
|
3451 | c9f398e5 | H. Peter Anvin | case QEMU_OPTION_debugcon:
|
3452 | c9f398e5 | H. Peter Anvin | add_device_config(DEV_DEBUGCON, optarg); |
3453 | c9f398e5 | H. Peter Anvin | break;
|
3454 | d63d307f | bellard | case QEMU_OPTION_loadvm:
|
3455 | d63d307f | bellard | loadvm = optarg; |
3456 | d63d307f | bellard | break;
|
3457 | d63d307f | bellard | case QEMU_OPTION_full_screen:
|
3458 | d63d307f | bellard | full_screen = 1;
|
3459 | d63d307f | bellard | break;
|
3460 | 43523e93 | ths | case QEMU_OPTION_no_frame:
|
3461 | 43523e93 | ths | no_frame = 1;
|
3462 | 43523e93 | ths | break;
|
3463 | 3780e197 | ths | case QEMU_OPTION_alt_grab:
|
3464 | 3780e197 | ths | alt_grab = 1;
|
3465 | 3780e197 | ths | break;
|
3466 | 0ca9f8a4 | Dustin Kirkland | case QEMU_OPTION_ctrl_grab:
|
3467 | 0ca9f8a4 | Dustin Kirkland | ctrl_grab = 1;
|
3468 | 0ca9f8a4 | Dustin Kirkland | break;
|
3469 | 667accab | ths | case QEMU_OPTION_no_quit:
|
3470 | 667accab | ths | no_quit = 1;
|
3471 | 667accab | ths | break;
|
3472 | 7d957bd8 | aliguori | case QEMU_OPTION_sdl:
|
3473 | 24f6ff86 | Michael Tokarev | #ifdef CONFIG_SDL
|
3474 | 993fbfdb | Anthony Liguori | display_type = DT_SDL; |
3475 | 7d957bd8 | aliguori | break;
|
3476 | 58fc096c | Jes Sorensen | #else
|
3477 | 58fc096c | Jes Sorensen | fprintf(stderr, "SDL support is disabled\n");
|
3478 | 58fc096c | Jes Sorensen | exit(1);
|
3479 | 667accab | ths | #endif
|
3480 | f7cce898 | bellard | case QEMU_OPTION_pidfile:
|
3481 | 93815bc2 | ths | pid_file = optarg; |
3482 | f7cce898 | bellard | break;
|
3483 | a09db21f | bellard | case QEMU_OPTION_win2k_hack:
|
3484 | a09db21f | bellard | win2k_install_hack = 1;
|
3485 | a09db21f | bellard | break;
|
3486 | 433acf0d | Jan Kiszka | case QEMU_OPTION_rtc_td_hack: {
|
3487 | 433acf0d | Jan Kiszka | static GlobalProperty slew_lost_ticks[] = {
|
3488 | 433acf0d | Jan Kiszka | { |
3489 | 433acf0d | Jan Kiszka | .driver = "mc146818rtc",
|
3490 | 433acf0d | Jan Kiszka | .property = "lost_tick_policy",
|
3491 | 433acf0d | Jan Kiszka | .value = "slew",
|
3492 | 433acf0d | Jan Kiszka | }, |
3493 | 433acf0d | Jan Kiszka | { /* end of list */ }
|
3494 | 433acf0d | Jan Kiszka | }; |
3495 | 433acf0d | Jan Kiszka | |
3496 | 433acf0d | Jan Kiszka | qdev_prop_register_global_list(slew_lost_ticks); |
3497 | 73822ec8 | aliguori | break;
|
3498 | 433acf0d | Jan Kiszka | } |
3499 | 8a92ea2f | aliguori | case QEMU_OPTION_acpitable:
|
3500 | 0c764a9d | Laszlo Ersek | opts = qemu_opts_parse(qemu_find_opts("acpi"), optarg, 1); |
3501 | f46e720a | Laszlo Ersek | if (!opts) {
|
3502 | f46e720a | Laszlo Ersek | exit(1);
|
3503 | f46e720a | Laszlo Ersek | } |
3504 | 0c764a9d | Laszlo Ersek | do_acpitable_option(opts); |
3505 | 8a92ea2f | aliguori | break;
|
3506 | b6f6e3d3 | aliguori | case QEMU_OPTION_smbios:
|
3507 | 4f953d2f | Markus Armbruster | opts = qemu_opts_parse(qemu_find_opts("smbios"), optarg, 0); |
3508 | f46e720a | Laszlo Ersek | if (!opts) {
|
3509 | f46e720a | Laszlo Ersek | exit(1);
|
3510 | f46e720a | Laszlo Ersek | } |
3511 | 4f953d2f | Markus Armbruster | do_smbios_option(opts); |
3512 | b6f6e3d3 | aliguori | break;
|
3513 | 7ba1e619 | aliguori | case QEMU_OPTION_enable_kvm:
|
3514 | 303d4e86 | Anthony PERARD | olist = qemu_find_opts("machine");
|
3515 | 303d4e86 | Anthony PERARD | qemu_opts_parse(olist, "accel=kvm", 0); |
3516 | 303d4e86 | Anthony PERARD | break;
|
3517 | 303d4e86 | Anthony PERARD | case QEMU_OPTION_machine:
|
3518 | 303d4e86 | Anthony PERARD | olist = qemu_find_opts("machine");
|
3519 | 9052ea6b | Jan Kiszka | opts = qemu_opts_parse(olist, optarg, 1);
|
3520 | 303d4e86 | Anthony PERARD | if (!opts) {
|
3521 | 303d4e86 | Anthony PERARD | exit(1);
|
3522 | 303d4e86 | Anthony PERARD | } |
3523 | 2645c6dc | Jan Kiszka | optarg = qemu_opt_get(opts, "type");
|
3524 | 2645c6dc | Jan Kiszka | if (optarg) {
|
3525 | 2645c6dc | Jan Kiszka | machine = machine_parse(optarg); |
3526 | 2645c6dc | Jan Kiszka | } |
3527 | 7ba1e619 | aliguori | break;
|
3528 | a0dac021 | Jan Kiszka | case QEMU_OPTION_no_kvm:
|
3529 | a0dac021 | Jan Kiszka | olist = qemu_find_opts("machine");
|
3530 | a0dac021 | Jan Kiszka | qemu_opts_parse(olist, "accel=tcg", 0); |
3531 | a0dac021 | Jan Kiszka | break;
|
3532 | 4086bde8 | Jan Kiszka | case QEMU_OPTION_no_kvm_pit: {
|
3533 | 4086bde8 | Jan Kiszka | fprintf(stderr, "Warning: KVM PIT can no longer be disabled "
|
3534 | 4086bde8 | Jan Kiszka | "separately.\n");
|
3535 | 4086bde8 | Jan Kiszka | break;
|
3536 | 4086bde8 | Jan Kiszka | } |
3537 | c21fb4f8 | Jan Kiszka | case QEMU_OPTION_no_kvm_pit_reinjection: {
|
3538 | c21fb4f8 | Jan Kiszka | static GlobalProperty kvm_pit_lost_tick_policy[] = {
|
3539 | c21fb4f8 | Jan Kiszka | { |
3540 | c21fb4f8 | Jan Kiszka | .driver = "kvm-pit",
|
3541 | c21fb4f8 | Jan Kiszka | .property = "lost_tick_policy",
|
3542 | c21fb4f8 | Jan Kiszka | .value = "discard",
|
3543 | c21fb4f8 | Jan Kiszka | }, |
3544 | c21fb4f8 | Jan Kiszka | { /* end of list */ }
|
3545 | c21fb4f8 | Jan Kiszka | }; |
3546 | c21fb4f8 | Jan Kiszka | |
3547 | c21fb4f8 | Jan Kiszka | fprintf(stderr, "Warning: option deprecated, use "
|
3548 | c21fb4f8 | Jan Kiszka | "lost_tick_policy property of kvm-pit instead.\n");
|
3549 | c21fb4f8 | Jan Kiszka | qdev_prop_register_global_list(kvm_pit_lost_tick_policy); |
3550 | c21fb4f8 | Jan Kiszka | break;
|
3551 | c21fb4f8 | Jan Kiszka | } |
3552 | bb36d470 | bellard | case QEMU_OPTION_usb:
|
3553 | fa5358c6 | Peter Maydell | olist = qemu_find_opts("machine");
|
3554 | fa5358c6 | Peter Maydell | qemu_opts_parse(olist, "usb=on", 0); |
3555 | bb36d470 | bellard | break;
|
3556 | a594cfbf | bellard | case QEMU_OPTION_usbdevice:
|
3557 | fa5358c6 | Peter Maydell | olist = qemu_find_opts("machine");
|
3558 | fa5358c6 | Peter Maydell | qemu_opts_parse(olist, "usb=on", 0); |
3559 | bd3c948d | Gerd Hoffmann | add_device_config(DEV_USB, optarg); |
3560 | bd3c948d | Gerd Hoffmann | break;
|
3561 | bd3c948d | Gerd Hoffmann | case QEMU_OPTION_device:
|
3562 | 3329f07b | Gerd Hoffmann | if (!qemu_opts_parse(qemu_find_opts("device"), optarg, 1)) { |
3563 | f31d07d1 | Gerd Hoffmann | exit(1);
|
3564 | f31d07d1 | Gerd Hoffmann | } |
3565 | a594cfbf | bellard | break;
|
3566 | 6a00d601 | bellard | case QEMU_OPTION_smp:
|
3567 | 12b7f57e | Michael Tokarev | if (!qemu_opts_parse(qemu_find_opts("smp-opts"), optarg, 1)) { |
3568 | 6be68d7e | Jes Sorensen | exit(1);
|
3569 | 6be68d7e | Jes Sorensen | } |
3570 | 6a00d601 | bellard | break;
|
3571 | 24236869 | bellard | case QEMU_OPTION_vnc:
|
3572 | 821601ea | Jes Sorensen | #ifdef CONFIG_VNC
|
3573 | 6b62dc2d | Gerd Hoffmann | display_remote++; |
3574 | 821601ea | Jes Sorensen | vnc_display = optarg; |
3575 | 821601ea | Jes Sorensen | #else
|
3576 | 821601ea | Jes Sorensen | fprintf(stderr, "VNC support is disabled\n");
|
3577 | 821601ea | Jes Sorensen | exit(1);
|
3578 | 821601ea | Jes Sorensen | #endif
|
3579 | 821601ea | Jes Sorensen | break;
|
3580 | 6515b203 | bellard | case QEMU_OPTION_no_acpi:
|
3581 | 6515b203 | bellard | acpi_enabled = 0;
|
3582 | 6515b203 | bellard | break;
|
3583 | 16b29ae1 | aliguori | case QEMU_OPTION_no_hpet:
|
3584 | 16b29ae1 | aliguori | no_hpet = 1;
|
3585 | 16b29ae1 | aliguori | break;
|
3586 | 7d4c3d53 | Markus Armbruster | case QEMU_OPTION_balloon:
|
3587 | 7d4c3d53 | Markus Armbruster | if (balloon_parse(optarg) < 0) { |
3588 | 7d4c3d53 | Markus Armbruster | fprintf(stderr, "Unknown -balloon argument %s\n", optarg);
|
3589 | 7d4c3d53 | Markus Armbruster | exit(1);
|
3590 | 7d4c3d53 | Markus Armbruster | } |
3591 | df97b920 | Eduardo Habkost | break;
|
3592 | d1beab82 | bellard | case QEMU_OPTION_no_reboot:
|
3593 | d1beab82 | bellard | no_reboot = 1;
|
3594 | d1beab82 | bellard | break;
|
3595 | b2f76161 | aurel32 | case QEMU_OPTION_no_shutdown:
|
3596 | b2f76161 | aurel32 | no_shutdown = 1;
|
3597 | b2f76161 | aurel32 | break;
|
3598 | 9467cd46 | balrog | case QEMU_OPTION_show_cursor:
|
3599 | 9467cd46 | balrog | cursor_hide = 0;
|
3600 | 9467cd46 | balrog | break;
|
3601 | 8fcb1b90 | blueswir1 | case QEMU_OPTION_uuid:
|
3602 | 8fcb1b90 | blueswir1 | if(qemu_uuid_parse(optarg, qemu_uuid) < 0) { |
3603 | 8fcb1b90 | blueswir1 | fprintf(stderr, "Fail to parse UUID string."
|
3604 | 8fcb1b90 | blueswir1 | " Wrong format.\n");
|
3605 | 8fcb1b90 | blueswir1 | exit(1);
|
3606 | 8fcb1b90 | blueswir1 | } |
3607 | fc3b3295 | Markus Armbruster | qemu_uuid_set = true;
|
3608 | 8fcb1b90 | blueswir1 | break;
|
3609 | 9ae02555 | ths | case QEMU_OPTION_option_rom:
|
3610 | 9ae02555 | ths | if (nb_option_roms >= MAX_OPTION_ROMS) {
|
3611 | 9ae02555 | ths | fprintf(stderr, "Too many option ROMs\n");
|
3612 | 9ae02555 | ths | exit(1);
|
3613 | 9ae02555 | ths | } |
3614 | 2e55e842 | Gleb Natapov | opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1); |
3615 | 49295ebc | Markus Armbruster | if (!opts) {
|
3616 | 49295ebc | Markus Armbruster | exit(1);
|
3617 | 49295ebc | Markus Armbruster | } |
3618 | 2e55e842 | Gleb Natapov | option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile");
|
3619 | 2e55e842 | Gleb Natapov | option_rom[nb_option_roms].bootindex = |
3620 | 2e55e842 | Gleb Natapov | qemu_opt_get_number(opts, "bootindex", -1); |
3621 | 2e55e842 | Gleb Natapov | if (!option_rom[nb_option_roms].name) {
|
3622 | 2e55e842 | Gleb Natapov | fprintf(stderr, "Option ROM file is not specified\n");
|
3623 | 2e55e842 | Gleb Natapov | exit(1);
|
3624 | 2e55e842 | Gleb Natapov | } |
3625 | 9ae02555 | ths | nb_option_roms++; |
3626 | 9ae02555 | ths | break;
|
3627 | 8e71621f | pbrook | case QEMU_OPTION_semihosting:
|
3628 | 8e71621f | pbrook | semihosting_enabled = 1;
|
3629 | 8e71621f | pbrook | break;
|
3630 | 88eed34a | Jan Kiszka | case QEMU_OPTION_tdf:
|
3631 | 88eed34a | Jan Kiszka | fprintf(stderr, "Warning: user space PIT time drift fix "
|
3632 | 88eed34a | Jan Kiszka | "is no longer supported.\n");
|
3633 | 88eed34a | Jan Kiszka | break;
|
3634 | c35734b2 | ths | case QEMU_OPTION_name:
|
3635 | 7267c094 | Anthony Liguori | qemu_name = g_strdup(optarg); |
3636 | 1889465a | Andi Kleen | { |
3637 | 1889465a | Andi Kleen | char *p = strchr(qemu_name, ','); |
3638 | 1889465a | Andi Kleen | if (p != NULL) { |
3639 | 1889465a | Andi Kleen | *p++ = 0;
|
3640 | 1889465a | Andi Kleen | if (strncmp(p, "process=", 8)) { |
3641 | 5697f6ae | Aurelien Jarno | fprintf(stderr, "Unknown subargument %s to -name\n", p);
|
3642 | 1889465a | Andi Kleen | exit(1);
|
3643 | 1889465a | Andi Kleen | } |
3644 | 1889465a | Andi Kleen | p += 8;
|
3645 | ce798cf2 | Jes Sorensen | os_set_proc_name(p); |
3646 | 4d8b3c63 | Laszlo Ersek | } |
3647 | 4d8b3c63 | Laszlo Ersek | } |
3648 | c35734b2 | ths | break;
|
3649 | 66508601 | blueswir1 | case QEMU_OPTION_prom_env:
|
3650 | 66508601 | blueswir1 | if (nb_prom_envs >= MAX_PROM_ENVS) {
|
3651 | 66508601 | blueswir1 | fprintf(stderr, "Too many prom variables\n");
|
3652 | 66508601 | blueswir1 | exit(1);
|
3653 | 66508601 | blueswir1 | } |
3654 | 66508601 | blueswir1 | prom_envs[nb_prom_envs] = optarg; |
3655 | 66508601 | blueswir1 | nb_prom_envs++; |
3656 | 66508601 | blueswir1 | break;
|
3657 | 2b8f2d41 | balrog | case QEMU_OPTION_old_param:
|
3658 | 2b8f2d41 | balrog | old_param = 1;
|
3659 | 05ebd537 | ths | break;
|
3660 | f3dcfada | ths | case QEMU_OPTION_clock:
|
3661 | 6d327171 | Alex Bligh | /* Clock options no longer exist. Keep this option for
|
3662 | 6d327171 | Alex Bligh | * backward compatibility.
|
3663 | 6d327171 | Alex Bligh | */
|
3664 | f3dcfada | ths | break;
|
3665 | 7e0af5d0 | bellard | case QEMU_OPTION_startdate:
|
3666 | 1ed2fc1f | Jan Kiszka | configure_rtc_date_offset(optarg, 1);
|
3667 | 1ed2fc1f | Jan Kiszka | break;
|
3668 | 1ed2fc1f | Jan Kiszka | case QEMU_OPTION_rtc:
|
3669 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_parse(qemu_find_opts("rtc"), optarg, 0); |
3670 | 1ed2fc1f | Jan Kiszka | if (!opts) {
|
3671 | 1ed2fc1f | Jan Kiszka | exit(1);
|
3672 | 7e0af5d0 | bellard | } |
3673 | 1ed2fc1f | Jan Kiszka | configure_rtc(opts); |
3674 | 7e0af5d0 | bellard | break;
|
3675 | 26a5f13b | bellard | case QEMU_OPTION_tb_size:
|
3676 | d5ab9713 | Jan Kiszka | tcg_tb_size = strtol(optarg, NULL, 0); |
3677 | d5ab9713 | Jan Kiszka | if (tcg_tb_size < 0) { |
3678 | d5ab9713 | Jan Kiszka | tcg_tb_size = 0;
|
3679 | d5ab9713 | Jan Kiszka | } |
3680 | 26a5f13b | bellard | break;
|
3681 | 2e70f6ef | pbrook | case QEMU_OPTION_icount:
|
3682 | 4e3de9e9 | Paolo Bonzini | icount_option = optarg; |
3683 | 2e70f6ef | pbrook | break;
|
3684 | 5bb7910a | aliguori | case QEMU_OPTION_incoming:
|
3685 | 5bb7910a | aliguori | incoming = optarg; |
3686 | 81323a6c | Stefano Stabellini | runstate_set(RUN_STATE_INMIGRATE); |
3687 | 5bb7910a | aliguori | break;
|
3688 | d8c208dd | Gerd Hoffmann | case QEMU_OPTION_nodefaults:
|
3689 | d8c208dd | Gerd Hoffmann | default_serial = 0;
|
3690 | d8c208dd | Gerd Hoffmann | default_parallel = 0;
|
3691 | aee1b935 | Gerd Hoffmann | default_virtcon = 0;
|
3692 | 2e788490 | Christian Borntraeger | default_sclp = 0;
|
3693 | d8c208dd | Gerd Hoffmann | default_monitor = 0;
|
3694 | cb4522cc | Gerd Hoffmann | default_net = 0;
|
3695 | ac33f8fa | Gerd Hoffmann | default_floppy = 0;
|
3696 | ac33f8fa | Gerd Hoffmann | default_cdrom = 0;
|
3697 | ac33f8fa | Gerd Hoffmann | default_sdcard = 0;
|
3698 | 7f1b17f2 | Paolo Bonzini | default_vga = 0;
|
3699 | d8c208dd | Gerd Hoffmann | break;
|
3700 | e37630ca | aliguori | case QEMU_OPTION_xen_domid:
|
3701 | ad96090a | Blue Swirl | if (!(xen_available())) {
|
3702 | ad96090a | Blue Swirl | printf("Option %s not supported for this target\n", popt->name);
|
3703 | ad96090a | Blue Swirl | exit(1);
|
3704 | ad96090a | Blue Swirl | } |
3705 | e37630ca | aliguori | xen_domid = atoi(optarg); |
3706 | e37630ca | aliguori | break;
|
3707 | e37630ca | aliguori | case QEMU_OPTION_xen_create:
|
3708 | ad96090a | Blue Swirl | if (!(xen_available())) {
|
3709 | ad96090a | Blue Swirl | printf("Option %s not supported for this target\n", popt->name);
|
3710 | ad96090a | Blue Swirl | exit(1);
|
3711 | ad96090a | Blue Swirl | } |
3712 | e37630ca | aliguori | xen_mode = XEN_CREATE; |
3713 | e37630ca | aliguori | break;
|
3714 | e37630ca | aliguori | case QEMU_OPTION_xen_attach:
|
3715 | ad96090a | Blue Swirl | if (!(xen_available())) {
|
3716 | ad96090a | Blue Swirl | printf("Option %s not supported for this target\n", popt->name);
|
3717 | ad96090a | Blue Swirl | exit(1);
|
3718 | ad96090a | Blue Swirl | } |
3719 | e37630ca | aliguori | xen_mode = XEN_ATTACH; |
3720 | e37630ca | aliguori | break;
|
3721 | ab6540d5 | Prerna Saxena | case QEMU_OPTION_trace:
|
3722 | e4858974 | Lluís | { |
3723 | ab6540d5 | Prerna Saxena | opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 0); |
3724 | e4858974 | Lluís | if (!opts) {
|
3725 | e4858974 | Lluís | exit(1);
|
3726 | ab6540d5 | Prerna Saxena | } |
3727 | 23d15e86 | Lluís | trace_events = qemu_opt_get(opts, "events");
|
3728 | e4858974 | Lluís | trace_file = qemu_opt_get(opts, "file");
|
3729 | ab6540d5 | Prerna Saxena | break;
|
3730 | e4858974 | Lluís | } |
3731 | 715a664a | Gerd Hoffmann | case QEMU_OPTION_readconfig:
|
3732 | 715a664a | Gerd Hoffmann | { |
3733 | dcfb0939 | Kevin Wolf | int ret = qemu_read_config_file(optarg);
|
3734 | dcfb0939 | Kevin Wolf | if (ret < 0) { |
3735 | dcfb0939 | Kevin Wolf | fprintf(stderr, "read config %s: %s\n", optarg,
|
3736 | dcfb0939 | Kevin Wolf | strerror(-ret)); |
3737 | 715a664a | Gerd Hoffmann | exit(1);
|
3738 | 715a664a | Gerd Hoffmann | } |
3739 | 715a664a | Gerd Hoffmann | break;
|
3740 | 715a664a | Gerd Hoffmann | } |
3741 | 29b0040b | Gerd Hoffmann | case QEMU_OPTION_spice:
|
3742 | 29b0040b | Gerd Hoffmann | olist = qemu_find_opts("spice");
|
3743 | 29b0040b | Gerd Hoffmann | if (!olist) {
|
3744 | 29b0040b | Gerd Hoffmann | fprintf(stderr, "spice is not supported by this qemu build.\n");
|
3745 | 29b0040b | Gerd Hoffmann | exit(1);
|
3746 | 29b0040b | Gerd Hoffmann | } |
3747 | 29b0040b | Gerd Hoffmann | opts = qemu_opts_parse(olist, optarg, 0);
|
3748 | 29b0040b | Gerd Hoffmann | if (!opts) {
|
3749 | 29b0040b | Gerd Hoffmann | exit(1);
|
3750 | 29b0040b | Gerd Hoffmann | } |
3751 | f963e4d0 | Gerd Hoffmann | display_remote++; |
3752 | 29b0040b | Gerd Hoffmann | break;
|
3753 | 715a664a | Gerd Hoffmann | case QEMU_OPTION_writeconfig:
|
3754 | 715a664a | Gerd Hoffmann | { |
3755 | 715a664a | Gerd Hoffmann | FILE *fp; |
3756 | 715a664a | Gerd Hoffmann | if (strcmp(optarg, "-") == 0) { |
3757 | 715a664a | Gerd Hoffmann | fp = stdout; |
3758 | 715a664a | Gerd Hoffmann | } else {
|
3759 | 715a664a | Gerd Hoffmann | fp = fopen(optarg, "w");
|
3760 | 715a664a | Gerd Hoffmann | if (fp == NULL) { |
3761 | 715a664a | Gerd Hoffmann | fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
|
3762 | 715a664a | Gerd Hoffmann | exit(1);
|
3763 | 715a664a | Gerd Hoffmann | } |
3764 | 715a664a | Gerd Hoffmann | } |
3765 | 715a664a | Gerd Hoffmann | qemu_config_write(fp); |
3766 | 715a664a | Gerd Hoffmann | fclose(fp); |
3767 | 715a664a | Gerd Hoffmann | break;
|
3768 | 715a664a | Gerd Hoffmann | } |
3769 | c7f0f3b1 | Anthony Liguori | case QEMU_OPTION_qtest:
|
3770 | c7f0f3b1 | Anthony Liguori | qtest_chrdev = optarg; |
3771 | c7f0f3b1 | Anthony Liguori | break;
|
3772 | c7f0f3b1 | Anthony Liguori | case QEMU_OPTION_qtest_log:
|
3773 | c7f0f3b1 | Anthony Liguori | qtest_log = optarg; |
3774 | c7f0f3b1 | Anthony Liguori | break;
|
3775 | 7d76ad4f | Eduardo Otubo | case QEMU_OPTION_sandbox:
|
3776 | 7d76ad4f | Eduardo Otubo | opts = qemu_opts_parse(qemu_find_opts("sandbox"), optarg, 1); |
3777 | 7d76ad4f | Eduardo Otubo | if (!opts) {
|
3778 | 49295ebc | Markus Armbruster | exit(1);
|
3779 | 7d76ad4f | Eduardo Otubo | } |
3780 | 7d76ad4f | Eduardo Otubo | break;
|
3781 | 587ed6be | Corey Bryant | case QEMU_OPTION_add_fd:
|
3782 | 587ed6be | Corey Bryant | #ifndef _WIN32
|
3783 | 587ed6be | Corey Bryant | opts = qemu_opts_parse(qemu_find_opts("add-fd"), optarg, 0); |
3784 | 587ed6be | Corey Bryant | if (!opts) {
|
3785 | 49295ebc | Markus Armbruster | exit(1);
|
3786 | 587ed6be | Corey Bryant | } |
3787 | 587ed6be | Corey Bryant | #else
|
3788 | 587ed6be | Corey Bryant | error_report("File descriptor passing is disabled on this "
|
3789 | 587ed6be | Corey Bryant | "platform");
|
3790 | 587ed6be | Corey Bryant | exit(1);
|
3791 | 587ed6be | Corey Bryant | #endif
|
3792 | 587ed6be | Corey Bryant | break;
|
3793 | 68d98d3e | Anthony Liguori | case QEMU_OPTION_object:
|
3794 | 68d98d3e | Anthony Liguori | opts = qemu_opts_parse(qemu_find_opts("object"), optarg, 1); |
3795 | 49295ebc | Markus Armbruster | if (!opts) {
|
3796 | 49295ebc | Markus Armbruster | exit(1);
|
3797 | 49295ebc | Markus Armbruster | } |
3798 | 68d98d3e | Anthony Liguori | break;
|
3799 | 888a6bc6 | Satoru Moriya | case QEMU_OPTION_realtime:
|
3800 | 888a6bc6 | Satoru Moriya | opts = qemu_opts_parse(qemu_find_opts("realtime"), optarg, 0); |
3801 | 888a6bc6 | Satoru Moriya | if (!opts) {
|
3802 | 888a6bc6 | Satoru Moriya | exit(1);
|
3803 | 888a6bc6 | Satoru Moriya | } |
3804 | 888a6bc6 | Satoru Moriya | configure_realtime(opts); |
3805 | 888a6bc6 | Satoru Moriya | break;
|
3806 | 5e2ac519 | Seiji Aguchi | case QEMU_OPTION_msg:
|
3807 | 5e2ac519 | Seiji Aguchi | opts = qemu_opts_parse(qemu_find_opts("msg"), optarg, 0); |
3808 | 5e2ac519 | Seiji Aguchi | if (!opts) {
|
3809 | 5e2ac519 | Seiji Aguchi | exit(1);
|
3810 | 5e2ac519 | Seiji Aguchi | } |
3811 | 5e2ac519 | Seiji Aguchi | configure_msg(opts); |
3812 | 5e2ac519 | Seiji Aguchi | break;
|
3813 | 59a5264b | Jes Sorensen | default:
|
3814 | 59a5264b | Jes Sorensen | os_parse_cmd_args(popt->index, optarg); |
3815 | cd6f1169 | bellard | } |
3816 | 0824d6fc | bellard | } |
3817 | 0824d6fc | bellard | } |
3818 | 0f0bc3f1 | Markus Armbruster | loc_set_none(); |
3819 | c235d738 | Matthew Fernandez | |
3820 | 1c53786f | Paolo Bonzini | if (qemu_init_main_loop()) {
|
3821 | 1c53786f | Paolo Bonzini | fprintf(stderr, "qemu_init_main_loop failed\n");
|
3822 | 1c53786f | Paolo Bonzini | exit(1);
|
3823 | 1c53786f | Paolo Bonzini | } |
3824 | 1c53786f | Paolo Bonzini | |
3825 | 7d76ad4f | Eduardo Otubo | if (qemu_opts_foreach(qemu_find_opts("sandbox"), parse_sandbox, NULL, 0)) { |
3826 | 7d76ad4f | Eduardo Otubo | exit(1);
|
3827 | 7d76ad4f | Eduardo Otubo | } |
3828 | 7d76ad4f | Eduardo Otubo | |
3829 | 587ed6be | Corey Bryant | #ifndef _WIN32
|
3830 | 587ed6be | Corey Bryant | if (qemu_opts_foreach(qemu_find_opts("add-fd"), parse_add_fd, NULL, 1)) { |
3831 | 587ed6be | Corey Bryant | exit(1);
|
3832 | 587ed6be | Corey Bryant | } |
3833 | 587ed6be | Corey Bryant | |
3834 | 587ed6be | Corey Bryant | if (qemu_opts_foreach(qemu_find_opts("add-fd"), cleanup_add_fd, NULL, 1)) { |
3835 | 587ed6be | Corey Bryant | exit(1);
|
3836 | 587ed6be | Corey Bryant | } |
3837 | 587ed6be | Corey Bryant | #endif
|
3838 | 587ed6be | Corey Bryant | |
3839 | fb7c269e | Dunrong Huang | if (machine == NULL) { |
3840 | fb7c269e | Dunrong Huang | fprintf(stderr, "No machine found.\n");
|
3841 | fb7c269e | Dunrong Huang | exit(1);
|
3842 | fb7c269e | Dunrong Huang | } |
3843 | fb7c269e | Dunrong Huang | |
3844 | 93bfef4c | Crístian Viana | if (machine->hw_version) {
|
3845 | 93bfef4c | Crístian Viana | qemu_set_version(machine->hw_version); |
3846 | 93bfef4c | Crístian Viana | } |
3847 | 93bfef4c | Crístian Viana | |
3848 | 68d98d3e | Anthony Liguori | if (qemu_opts_foreach(qemu_find_opts("object"), |
3849 | 68d98d3e | Anthony Liguori | object_create, NULL, 0) != 0) { |
3850 | 68d98d3e | Anthony Liguori | exit(1);
|
3851 | 68d98d3e | Anthony Liguori | } |
3852 | 68d98d3e | Anthony Liguori | |
3853 | ecf40bea | Eduardo Habkost | /* Init CPU def lists, based on config
|
3854 | ecf40bea | Eduardo Habkost | * - Must be called after all the qemu_read_config_file() calls
|
3855 | ecf40bea | Eduardo Habkost | * - Must be called before list_cpus()
|
3856 | ecf40bea | Eduardo Habkost | * - Must be called before machine->init()
|
3857 | ecf40bea | Eduardo Habkost | */
|
3858 | ecf40bea | Eduardo Habkost | cpudef_init(); |
3859 | ecf40bea | Eduardo Habkost | |
3860 | c8057f95 | Peter Maydell | if (cpu_model && is_help_option(cpu_model)) {
|
3861 | 1d6528af | Eduardo Habkost | list_cpus(stdout, &fprintf, cpu_model); |
3862 | ecf40bea | Eduardo Habkost | exit(0);
|
3863 | ecf40bea | Eduardo Habkost | } |
3864 | ecf40bea | Eduardo Habkost | |
3865 | c235d738 | Matthew Fernandez | /* Open the logfile at this point, if necessary. We can't open the logfile
|
3866 | c235d738 | Matthew Fernandez | * when encountering either of the logging options (-d or -D) because the
|
3867 | c235d738 | Matthew Fernandez | * other one may be encountered later on the command line, changing the
|
3868 | c235d738 | Matthew Fernandez | * location or level of logging.
|
3869 | c235d738 | Matthew Fernandez | */
|
3870 | c235d738 | Matthew Fernandez | if (log_mask) {
|
3871 | b946bffa | Peter Maydell | int mask;
|
3872 | c235d738 | Matthew Fernandez | if (log_file) {
|
3873 | 9a7e5424 | Peter Maydell | qemu_set_log_filename(log_file); |
3874 | c235d738 | Matthew Fernandez | } |
3875 | b946bffa | Peter Maydell | |
3876 | b946bffa | Peter Maydell | mask = qemu_str_to_log_mask(log_mask); |
3877 | b946bffa | Peter Maydell | if (!mask) {
|
3878 | b946bffa | Peter Maydell | qemu_print_log_usage(stdout); |
3879 | b946bffa | Peter Maydell | exit(1);
|
3880 | b946bffa | Peter Maydell | } |
3881 | b946bffa | Peter Maydell | qemu_set_log(mask); |
3882 | c235d738 | Matthew Fernandez | } |
3883 | 330d0414 | bellard | |
3884 | 8a745f2a | Michael Mueller | if (!is_daemonized()) {
|
3885 | 8a745f2a | Michael Mueller | if (!trace_backend_init(trace_events, trace_file)) {
|
3886 | 8a745f2a | Michael Mueller | exit(1);
|
3887 | 8a745f2a | Michael Mueller | } |
3888 | 31d3c9b8 | Stefan Hajnoczi | } |
3889 | 0b5538c3 | Stefan Hajnoczi | |
3890 | 5cea8590 | Paul Brook | /* If no data_dir is specified then try to find it relative to the
|
3891 | 5cea8590 | Paul Brook | executable path. */
|
3892 | 4524051c | Gerd Hoffmann | if (data_dir_idx < ARRAY_SIZE(data_dir)) {
|
3893 | 10f5bff6 | Fam Zheng | data_dir[data_dir_idx] = os_find_datadir(); |
3894 | 4524051c | Gerd Hoffmann | if (data_dir[data_dir_idx] != NULL) { |
3895 | 4524051c | Gerd Hoffmann | data_dir_idx++; |
3896 | 4524051c | Gerd Hoffmann | } |
3897 | 5cea8590 | Paul Brook | } |
3898 | 60474fb5 | Stefan Weil | /* If all else fails use the install path specified when building. */
|
3899 | 4524051c | Gerd Hoffmann | if (data_dir_idx < ARRAY_SIZE(data_dir)) {
|
3900 | 4524051c | Gerd Hoffmann | data_dir[data_dir_idx++] = CONFIG_QEMU_DATADIR; |
3901 | 5cea8590 | Paul Brook | } |
3902 | 5cea8590 | Paul Brook | |
3903 | 12b7f57e | Michael Tokarev | smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); |
3904 | 6be68d7e | Jes Sorensen | |
3905 | 3d878caa | balrog | machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */ |
3906 | b2097003 | aliguori | if (smp_cpus > machine->max_cpus) {
|
3907 | b2097003 | aliguori | fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
|
3908 | b2097003 | aliguori | "supported by machine `%s' (%d)\n", smp_cpus, machine->name,
|
3909 | b2097003 | aliguori | machine->max_cpus); |
3910 | b2097003 | aliguori | exit(1);
|
3911 | b2097003 | aliguori | } |
3912 | b2097003 | aliguori | |
3913 | 67b724e6 | Anthony PERARD | /*
|
3914 | 67b724e6 | Anthony PERARD | * Get the default machine options from the machine if it is not already
|
3915 | 67b724e6 | Anthony PERARD | * specified either by the configuration file or by the command line.
|
3916 | 67b724e6 | Anthony PERARD | */
|
3917 | 67b724e6 | Anthony PERARD | if (machine->default_machine_opts) {
|
3918 | 25de5935 | Jan Kiszka | qemu_opts_set_defaults(qemu_find_opts("machine"),
|
3919 | 25de5935 | Jan Kiszka | machine->default_machine_opts, 0);
|
3920 | 67b724e6 | Anthony PERARD | } |
3921 | 67b724e6 | Anthony PERARD | |
3922 | 3329f07b | Gerd Hoffmann | qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0); |
3923 | 3329f07b | Gerd Hoffmann | qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0); |
3924 | 998bbd74 | Gerd Hoffmann | |
3925 | 986c5f78 | Gerd Hoffmann | if (machine->no_serial) {
|
3926 | 986c5f78 | Gerd Hoffmann | default_serial = 0;
|
3927 | 986c5f78 | Gerd Hoffmann | } |
3928 | 986c5f78 | Gerd Hoffmann | if (machine->no_parallel) {
|
3929 | 986c5f78 | Gerd Hoffmann | default_parallel = 0;
|
3930 | 986c5f78 | Gerd Hoffmann | } |
3931 | 986c5f78 | Gerd Hoffmann | if (!machine->use_virtcon) {
|
3932 | 986c5f78 | Gerd Hoffmann | default_virtcon = 0;
|
3933 | 986c5f78 | Gerd Hoffmann | } |
3934 | 3ef669e1 | Alexander Graf | if (!machine->use_sclp) {
|
3935 | 3ef669e1 | Alexander Graf | default_sclp = 0;
|
3936 | 3ef669e1 | Alexander Graf | } |
3937 | ac33f8fa | Gerd Hoffmann | if (machine->no_floppy) {
|
3938 | ac33f8fa | Gerd Hoffmann | default_floppy = 0;
|
3939 | ac33f8fa | Gerd Hoffmann | } |
3940 | ac33f8fa | Gerd Hoffmann | if (machine->no_cdrom) {
|
3941 | ac33f8fa | Gerd Hoffmann | default_cdrom = 0;
|
3942 | ac33f8fa | Gerd Hoffmann | } |
3943 | ac33f8fa | Gerd Hoffmann | if (machine->no_sdcard) {
|
3944 | ac33f8fa | Gerd Hoffmann | default_sdcard = 0;
|
3945 | ac33f8fa | Gerd Hoffmann | } |
3946 | 986c5f78 | Gerd Hoffmann | |
3947 | ab51b1d5 | Michael Tokarev | if (is_daemonized()) {
|
3948 | ab51b1d5 | Michael Tokarev | /* According to documentation and historically, -nographic redirects
|
3949 | ab51b1d5 | Michael Tokarev | * serial port, parallel port and monitor to stdio, which does not work
|
3950 | ab51b1d5 | Michael Tokarev | * with -daemonize. We can redirect these to null instead, but since
|
3951 | ab51b1d5 | Michael Tokarev | * -nographic is legacy, let's just error out.
|
3952 | ab51b1d5 | Michael Tokarev | * We disallow -nographic only if all other ports are not redirected
|
3953 | ab51b1d5 | Michael Tokarev | * explicitly, to not break existing legacy setups which uses
|
3954 | ab51b1d5 | Michael Tokarev | * -nographic _and_ redirects all ports explicitly - this is valid
|
3955 | ab51b1d5 | Michael Tokarev | * usage, -nographic is just a no-op in this case.
|
3956 | ab51b1d5 | Michael Tokarev | */
|
3957 | ab51b1d5 | Michael Tokarev | if (display_type == DT_NOGRAPHIC
|
3958 | ab51b1d5 | Michael Tokarev | && (default_parallel || default_serial |
3959 | ab51b1d5 | Michael Tokarev | || default_monitor || default_virtcon)) { |
3960 | ab51b1d5 | Michael Tokarev | fprintf(stderr, "-nographic can not be used with -daemonize\n");
|
3961 | ab51b1d5 | Michael Tokarev | exit(1);
|
3962 | ab51b1d5 | Michael Tokarev | } |
3963 | ab51b1d5 | Michael Tokarev | #ifdef CONFIG_CURSES
|
3964 | ab51b1d5 | Michael Tokarev | if (display_type == DT_CURSES) {
|
3965 | ab51b1d5 | Michael Tokarev | fprintf(stderr, "curses display can not be used with -daemonize\n");
|
3966 | ab51b1d5 | Michael Tokarev | exit(1);
|
3967 | ab51b1d5 | Michael Tokarev | } |
3968 | ab51b1d5 | Michael Tokarev | #endif
|
3969 | ab51b1d5 | Michael Tokarev | } |
3970 | ab51b1d5 | Michael Tokarev | |
3971 | 993fbfdb | Anthony Liguori | if (display_type == DT_NOGRAPHIC) {
|
3972 | 6a5e8b0e | Gerd Hoffmann | if (default_parallel)
|
3973 | 6a5e8b0e | Gerd Hoffmann | add_device_config(DEV_PARALLEL, "null");
|
3974 | e1c09175 | Gerd Hoffmann | if (default_serial && default_monitor) {
|
3975 | e1c09175 | Gerd Hoffmann | add_device_config(DEV_SERIAL, "mon:stdio");
|
3976 | 986c5f78 | Gerd Hoffmann | } else if (default_virtcon && default_monitor) { |
3977 | 986c5f78 | Gerd Hoffmann | add_device_config(DEV_VIRTCON, "mon:stdio");
|
3978 | 3ef669e1 | Alexander Graf | } else if (default_sclp && default_monitor) { |
3979 | 3ef669e1 | Alexander Graf | add_device_config(DEV_SCLP, "mon:stdio");
|
3980 | e1c09175 | Gerd Hoffmann | } else {
|
3981 | e1c09175 | Gerd Hoffmann | if (default_serial)
|
3982 | e1c09175 | Gerd Hoffmann | add_device_config(DEV_SERIAL, "stdio");
|
3983 | 986c5f78 | Gerd Hoffmann | if (default_virtcon)
|
3984 | 986c5f78 | Gerd Hoffmann | add_device_config(DEV_VIRTCON, "stdio");
|
3985 | 3ef669e1 | Alexander Graf | if (default_sclp) {
|
3986 | 3ef669e1 | Alexander Graf | add_device_config(DEV_SCLP, "stdio");
|
3987 | 3ef669e1 | Alexander Graf | } |
3988 | e1c09175 | Gerd Hoffmann | if (default_monitor)
|
3989 | 6ca5582d | Gerd Hoffmann | monitor_parse("stdio", "readline"); |
3990 | e1c09175 | Gerd Hoffmann | } |
3991 | 998bbd74 | Gerd Hoffmann | } else {
|
3992 | 998bbd74 | Gerd Hoffmann | if (default_serial)
|
3993 | 998bbd74 | Gerd Hoffmann | add_device_config(DEV_SERIAL, "vc:80Cx24C");
|
3994 | 6a5e8b0e | Gerd Hoffmann | if (default_parallel)
|
3995 | 6a5e8b0e | Gerd Hoffmann | add_device_config(DEV_PARALLEL, "vc:80Cx24C");
|
3996 | abdeed06 | Gerd Hoffmann | if (default_monitor)
|
3997 | 6ca5582d | Gerd Hoffmann | monitor_parse("vc:80Cx24C", "readline"); |
3998 | 38536da1 | Alexander Graf | if (default_virtcon)
|
3999 | 38536da1 | Alexander Graf | add_device_config(DEV_VIRTCON, "vc:80Cx24C");
|
4000 | 3ef669e1 | Alexander Graf | if (default_sclp) {
|
4001 | 3ef669e1 | Alexander Graf | add_device_config(DEV_SCLP, "vc:80Cx24C");
|
4002 | 3ef669e1 | Alexander Graf | } |
4003 | bc0129d9 | aliguori | } |
4004 | bc0129d9 | aliguori | |
4005 | 15546425 | Anthony Liguori | if (display_type == DT_DEFAULT && !display_remote) {
|
4006 | 15546425 | Anthony Liguori | #if defined(CONFIG_GTK)
|
4007 | 15546425 | Anthony Liguori | display_type = DT_GTK; |
4008 | 15546425 | Anthony Liguori | #elif defined(CONFIG_SDL) || defined(CONFIG_COCOA)
|
4009 | 15546425 | Anthony Liguori | display_type = DT_SDL; |
4010 | 15546425 | Anthony Liguori | #elif defined(CONFIG_VNC)
|
4011 | 15546425 | Anthony Liguori | vnc_display = "localhost:0,to=99";
|
4012 | 15546425 | Anthony Liguori | show_vnc_port = 1;
|
4013 | 15546425 | Anthony Liguori | #else
|
4014 | 15546425 | Anthony Liguori | display_type = DT_NONE; |
4015 | 15546425 | Anthony Liguori | #endif
|
4016 | 15546425 | Anthony Liguori | } |
4017 | 15546425 | Anthony Liguori | |
4018 | 047d4e15 | Peter Wu | if ((no_frame || alt_grab || ctrl_grab) && display_type != DT_SDL) {
|
4019 | 047d4e15 | Peter Wu | fprintf(stderr, "-no-frame, -alt-grab and -ctrl-grab are only valid "
|
4020 | 047d4e15 | Peter Wu | "for SDL, ignoring option\n");
|
4021 | 047d4e15 | Peter Wu | } |
4022 | 047d4e15 | Peter Wu | if (no_quit && (display_type != DT_GTK && display_type != DT_SDL)) {
|
4023 | 047d4e15 | Peter Wu | fprintf(stderr, "-no-quit is only valid for GTK and SDL, "
|
4024 | 047d4e15 | Peter Wu | "ignoring option\n");
|
4025 | 047d4e15 | Peter Wu | } |
4026 | 047d4e15 | Peter Wu | |
4027 | 15546425 | Anthony Liguori | #if defined(CONFIG_GTK)
|
4028 | 15546425 | Anthony Liguori | if (display_type == DT_GTK) {
|
4029 | 15546425 | Anthony Liguori | early_gtk_display_init(); |
4030 | 15546425 | Anthony Liguori | } |
4031 | 15546425 | Anthony Liguori | #endif
|
4032 | 15546425 | Anthony Liguori | |
4033 | a5829fd9 | TeLeMan | socket_init(); |
4034 | a5829fd9 | TeLeMan | |
4035 | 3329f07b | Gerd Hoffmann | if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0) |
4036 | 1a688d3b | Gerd Hoffmann | exit(1);
|
4037 | 758e8e38 | Venkateswararao Jujjuri (JV) | #ifdef CONFIG_VIRTFS
|
4038 | 3329f07b | Gerd Hoffmann | if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) { |
4039 | 74db920c | Gautham R Shenoy | exit(1);
|
4040 | 74db920c | Gautham R Shenoy | } |
4041 | 74db920c | Gautham R Shenoy | #endif
|
4042 | 1a688d3b | Gerd Hoffmann | |
4043 | eb505be1 | Jes Sorensen | os_daemonize(); |
4044 | 71e3ceb8 | ths | |
4045 | aa26bb2d | ths | if (pid_file && qemu_create_pidfile(pid_file) != 0) { |
4046 | eb505be1 | Jes Sorensen | os_pidfile_error(); |
4047 | 93815bc2 | ths | exit(1);
|
4048 | 93815bc2 | ths | } |
4049 | 93815bc2 | ths | |
4050 | 0ac543de | Jan Kiszka | /* init the memory */
|
4051 | 0ac543de | Jan Kiszka | if (ram_size == 0) { |
4052 | 0ac543de | Jan Kiszka | ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; |
4053 | 0ac543de | Jan Kiszka | } |
4054 | 0ac543de | Jan Kiszka | |
4055 | 3d1d9652 | Bruce Rogers | if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) |
4056 | 3d1d9652 | Bruce Rogers | != 0) {
|
4057 | 3d1d9652 | Bruce Rogers | exit(0);
|
4058 | 3d1d9652 | Bruce Rogers | } |
4059 | 3d1d9652 | Bruce Rogers | |
4060 | 135a129a | Aneesh Kumar K.V | configure_accelerator(machine); |
4061 | 214910a7 | Marcelo Tosatti | |
4062 | d4fce24f | Paolo Bonzini | if (qtest_chrdev) {
|
4063 | 23802b4f | Fam Zheng | Error *local_err = NULL;
|
4064 | 23802b4f | Fam Zheng | qtest_init(qtest_chrdev, qtest_log, &local_err); |
4065 | 23802b4f | Fam Zheng | if (local_err) {
|
4066 | 23802b4f | Fam Zheng | error_report("%s", error_get_pretty(local_err));
|
4067 | 23802b4f | Fam Zheng | error_free(local_err); |
4068 | 23802b4f | Fam Zheng | exit(1);
|
4069 | 23802b4f | Fam Zheng | } |
4070 | a907cf59 | Edgar E. Iglesias | } |
4071 | a907cf59 | Edgar E. Iglesias | |
4072 | 2ff3de68 | Markus Armbruster | machine_opts = qemu_get_machine_opts(); |
4073 | 2ff3de68 | Markus Armbruster | kernel_filename = qemu_opt_get(machine_opts, "kernel");
|
4074 | 2ff3de68 | Markus Armbruster | initrd_filename = qemu_opt_get(machine_opts, "initrd");
|
4075 | 2ff3de68 | Markus Armbruster | kernel_cmdline = qemu_opt_get(machine_opts, "append");
|
4076 | 1442d3e6 | Gerd Hoffmann | bios_name = qemu_opt_get(machine_opts, "firmware");
|
4077 | 967c0da7 | Peter Maydell | |
4078 | e3fdc535 | Markus Armbruster | boot_order = machine->default_boot_order; |
4079 | 8281abd5 | Markus Armbruster | opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL); |
4080 | 8281abd5 | Markus Armbruster | if (opts) {
|
4081 | 8281abd5 | Markus Armbruster | char *normal_boot_order;
|
4082 | 8281abd5 | Markus Armbruster | const char *order, *once; |
4083 | 8281abd5 | Markus Armbruster | |
4084 | 8281abd5 | Markus Armbruster | order = qemu_opt_get(opts, "order");
|
4085 | 8281abd5 | Markus Armbruster | if (order) {
|
4086 | 8281abd5 | Markus Armbruster | validate_bootdevices(order); |
4087 | 8281abd5 | Markus Armbruster | boot_order = order; |
4088 | 8281abd5 | Markus Armbruster | } |
4089 | 8281abd5 | Markus Armbruster | |
4090 | 8281abd5 | Markus Armbruster | once = qemu_opt_get(opts, "once");
|
4091 | 8281abd5 | Markus Armbruster | if (once) {
|
4092 | 8281abd5 | Markus Armbruster | validate_bootdevices(once); |
4093 | 8281abd5 | Markus Armbruster | normal_boot_order = g_strdup(boot_order); |
4094 | 8281abd5 | Markus Armbruster | boot_order = once; |
4095 | 083b79c9 | Markus Armbruster | qemu_register_reset(restore_boot_order, normal_boot_order); |
4096 | 8281abd5 | Markus Armbruster | } |
4097 | 8281abd5 | Markus Armbruster | |
4098 | 8281abd5 | Markus Armbruster | boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
|
4099 | e5187b56 | Amos Kong | boot_strict = qemu_opt_get_bool(opts, "strict", false); |
4100 | 8281abd5 | Markus Armbruster | } |
4101 | 8281abd5 | Markus Armbruster | |
4102 | a0abe474 | Peter Maydell | if (!kernel_cmdline) {
|
4103 | a0abe474 | Peter Maydell | kernel_cmdline = "";
|
4104 | a0abe474 | Peter Maydell | } |
4105 | a0abe474 | Peter Maydell | |
4106 | a20dd508 | bellard | linux_boot = (kernel_filename != NULL);
|
4107 | 6c41b272 | balrog | |
4108 | f8d39c01 | ths | if (!linux_boot && *kernel_cmdline != '\0') { |
4109 | f8d39c01 | ths | fprintf(stderr, "-append only allowed with -kernel option\n");
|
4110 | f8d39c01 | ths | exit(1);
|
4111 | f8d39c01 | ths | } |
4112 | f8d39c01 | ths | |
4113 | f8d39c01 | ths | if (!linux_boot && initrd_filename != NULL) { |
4114 | f8d39c01 | ths | fprintf(stderr, "-initrd only allowed with -kernel option\n");
|
4115 | f8d39c01 | ths | exit(1);
|
4116 | f8d39c01 | ths | } |
4117 | f8d39c01 | ths | |
4118 | 2ff3de68 | Markus Armbruster | if (!linux_boot && qemu_opt_get(machine_opts, "dtb")) { |
4119 | 412beee6 | Grant Likely | fprintf(stderr, "-dtb only allowed with -kernel option\n");
|
4120 | 412beee6 | Grant Likely | exit(1);
|
4121 | 412beee6 | Grant Likely | } |
4122 | 412beee6 | Grant Likely | |
4123 | 9156d763 | Jes Sorensen | os_set_line_buffering(); |
4124 | 3b46e624 | ths | |
4125 | 49cf5728 | Paolo Bonzini | qemu_init_cpu_loop(); |
4126 | 49cf5728 | Paolo Bonzini | qemu_mutex_lock_iothread(); |
4127 | 49cf5728 | Paolo Bonzini | |
4128 | ad1be899 | Alon Levy | #ifdef CONFIG_SPICE
|
4129 | ad1be899 | Alon Levy | /* spice needs the timers to be initialized by this point */
|
4130 | ad1be899 | Alon Levy | qemu_spice_init(); |
4131 | ad1be899 | Alon Levy | #endif
|
4132 | ad1be899 | Alon Levy | |
4133 | 0abe905d | Max Filippov | if (icount_option && (kvm_enabled() || xen_enabled())) {
|
4134 | 0abe905d | Max Filippov | fprintf(stderr, "-icount is not allowed with kvm or xen\n");
|
4135 | 0abe905d | Max Filippov | exit(1);
|
4136 | 0abe905d | Max Filippov | } |
4137 | 4e3de9e9 | Paolo Bonzini | configure_icount(icount_option); |
4138 | 634fce96 | pbrook | |
4139 | f30dbae6 | Amos Kong | /* clean up network at qemu process termination */
|
4140 | f30dbae6 | Amos Kong | atexit(&net_cleanup); |
4141 | f30dbae6 | Amos Kong | |
4142 | dc1c9fe8 | Mark McLoughlin | if (net_init_clients() < 0) { |
4143 | dc1c9fe8 | Mark McLoughlin | exit(1);
|
4144 | 702c651c | bellard | } |
4145 | f1510b2c | bellard | |
4146 | d1a0cf73 | Stefan Berger | #ifdef CONFIG_TPM
|
4147 | d1a0cf73 | Stefan Berger | if (tpm_init() < 0) { |
4148 | d1a0cf73 | Stefan Berger | exit(1);
|
4149 | d1a0cf73 | Stefan Berger | } |
4150 | d1a0cf73 | Stefan Berger | #endif
|
4151 | d1a0cf73 | Stefan Berger | |
4152 | dc72ac14 | balrog | /* init the bluetooth world */
|
4153 | bd3c948d | Gerd Hoffmann | if (foreach_device_config(DEV_BT, bt_parse))
|
4154 | bd3c948d | Gerd Hoffmann | exit(1);
|
4155 | dc72ac14 | balrog | |
4156 | 834e76ea | Anthony PERARD | if (!xen_enabled()) {
|
4157 | 834e76ea | Anthony PERARD | /* On 32-bit hosts, QEMU is limited by virtual address space */
|
4158 | 834e76ea | Anthony PERARD | if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) { |
4159 | 834e76ea | Anthony PERARD | fprintf(stderr, "qemu: at most 2047 MB RAM can be simulated\n");
|
4160 | 834e76ea | Anthony PERARD | exit(1);
|
4161 | 834e76ea | Anthony PERARD | } |
4162 | 834e76ea | Anthony PERARD | } |
4163 | 9ae02555 | ths | |
4164 | d5ab9713 | Jan Kiszka | cpu_exec_init_all(); |
4165 | 26a5f13b | bellard | |
4166 | c163b5ca | lirans@il.ibm.com | blk_mig_init(); |
4167 | c163b5ca | lirans@il.ibm.com | |
4168 | e4bcb14c | ths | /* open the virtual block devices */
|
4169 | 9dfd7c7a | Gerd Hoffmann | if (snapshot)
|
4170 | 3329f07b | Gerd Hoffmann | qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0); |
4171 | 2d0d2837 | Christian Borntraeger | if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, |
4172 | 2d0d2837 | Christian Borntraeger | &machine->block_default_type, 1) != 0) { |
4173 | 9dfd7c7a | Gerd Hoffmann | exit(1);
|
4174 | 2d0d2837 | Christian Borntraeger | } |
4175 | 3e3d5815 | balrog | |
4176 | 3c42ea66 | Christian Borntraeger | default_drive(default_cdrom, snapshot, machine->block_default_type, 2,
|
4177 | 3c42ea66 | Christian Borntraeger | CDROM_OPTS); |
4178 | 3c42ea66 | Christian Borntraeger | default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
|
4179 | 3c42ea66 | Christian Borntraeger | default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
|
4180 | 4e5d9b57 | Markus Armbruster | |
4181 | 7908c78d | Juan Quintela | register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, NULL); |
4182 | 8a7ddc38 | bellard | |
4183 | 268a362c | aliguori | if (nb_numa_nodes > 0) { |
4184 | 268a362c | aliguori | int i;
|
4185 | 268a362c | aliguori | |
4186 | ea0e5418 | Sasha Levin | if (nb_numa_nodes > MAX_NODES) {
|
4187 | ea0e5418 | Sasha Levin | nb_numa_nodes = MAX_NODES; |
4188 | 268a362c | aliguori | } |
4189 | 268a362c | aliguori | |
4190 | 268a362c | aliguori | /* If no memory size if given for any node, assume the default case
|
4191 | 268a362c | aliguori | * and distribute the available memory equally across all nodes
|
4192 | 268a362c | aliguori | */
|
4193 | 268a362c | aliguori | for (i = 0; i < nb_numa_nodes; i++) { |
4194 | 268a362c | aliguori | if (node_mem[i] != 0) |
4195 | 268a362c | aliguori | break;
|
4196 | 268a362c | aliguori | } |
4197 | 268a362c | aliguori | if (i == nb_numa_nodes) {
|
4198 | 268a362c | aliguori | uint64_t usedmem = 0;
|
4199 | 268a362c | aliguori | |
4200 | 268a362c | aliguori | /* On Linux, the each node's border has to be 8MB aligned,
|
4201 | 268a362c | aliguori | * the final node gets the rest.
|
4202 | 268a362c | aliguori | */
|
4203 | 268a362c | aliguori | for (i = 0; i < nb_numa_nodes - 1; i++) { |
4204 | 268a362c | aliguori | node_mem[i] = (ram_size / nb_numa_nodes) & ~((1 << 23UL) - 1); |
4205 | 268a362c | aliguori | usedmem += node_mem[i]; |
4206 | 268a362c | aliguori | } |
4207 | 268a362c | aliguori | node_mem[i] = ram_size - usedmem; |
4208 | 268a362c | aliguori | } |
4209 | 268a362c | aliguori | |
4210 | 268a362c | aliguori | for (i = 0; i < nb_numa_nodes; i++) { |
4211 | ee785fed | Chegu Vinod | if (!bitmap_empty(node_cpumask[i], MAX_CPUMASK_BITS)) {
|
4212 | 268a362c | aliguori | break;
|
4213 | ee785fed | Chegu Vinod | } |
4214 | 268a362c | aliguori | } |
4215 | 268a362c | aliguori | /* assigning the VCPUs round-robin is easier to implement, guest OSes
|
4216 | 268a362c | aliguori | * must cope with this anyway, because there are BIOSes out there in
|
4217 | 268a362c | aliguori | * real machines which also use this scheme.
|
4218 | 268a362c | aliguori | */
|
4219 | 268a362c | aliguori | if (i == nb_numa_nodes) {
|
4220 | 991dfefd | Vasilis Liaskovitis | for (i = 0; i < max_cpus; i++) { |
4221 | ee785fed | Chegu Vinod | set_bit(i, node_cpumask[i % nb_numa_nodes]); |
4222 | 268a362c | aliguori | } |
4223 | 268a362c | aliguori | } |
4224 | 268a362c | aliguori | } |
4225 | 268a362c | aliguori | |
4226 | 3329f07b | Gerd Hoffmann | if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) { |
4227 | 157b9319 | Jan Kiszka | exit(1);
|
4228 | 157b9319 | Jan Kiszka | } |
4229 | 157b9319 | Jan Kiszka | |
4230 | 998bbd74 | Gerd Hoffmann | if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) |
4231 | 998bbd74 | Gerd Hoffmann | exit(1);
|
4232 | 6a5e8b0e | Gerd Hoffmann | if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0) |
4233 | 6a5e8b0e | Gerd Hoffmann | exit(1);
|
4234 | aee1b935 | Gerd Hoffmann | if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0) |
4235 | aee1b935 | Gerd Hoffmann | exit(1);
|
4236 | 3ef669e1 | Alexander Graf | if (foreach_device_config(DEV_SCLP, sclp_parse) < 0) { |
4237 | 3ef669e1 | Alexander Graf | exit(1);
|
4238 | 3ef669e1 | Alexander Graf | } |
4239 | c9f398e5 | H. Peter Anvin | if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) |
4240 | c9f398e5 | H. Peter Anvin | exit(1);
|
4241 | 2796dae0 | aliguori | |
4242 | 7f1b17f2 | Paolo Bonzini | /* If no default VGA is requested, the default is "none". */
|
4243 | 3605ded5 | Aurelien Jarno | if (default_vga) {
|
4244 | 3605ded5 | Aurelien Jarno | if (cirrus_vga_available()) {
|
4245 | 3605ded5 | Aurelien Jarno | vga_model = "cirrus";
|
4246 | 3605ded5 | Aurelien Jarno | } else if (vga_available()) { |
4247 | 3605ded5 | Aurelien Jarno | vga_model = "std";
|
4248 | 3605ded5 | Aurelien Jarno | } |
4249 | a369da5f | Blue Swirl | } |
4250 | 7f1b17f2 | Paolo Bonzini | select_vgahw(vga_model); |
4251 | a369da5f | Blue Swirl | |
4252 | 09aaa160 | Markus Armbruster | if (watchdog) {
|
4253 | 09aaa160 | Markus Armbruster | i = select_watchdog(watchdog); |
4254 | 09aaa160 | Markus Armbruster | if (i > 0) |
4255 | 09aaa160 | Markus Armbruster | exit (i == 1 ? 1 : 0); |
4256 | 09aaa160 | Markus Armbruster | } |
4257 | 09aaa160 | Markus Armbruster | |
4258 | b6b61144 | Gerd Hoffmann | if (machine->compat_props) {
|
4259 | 458fb679 | Gerd Hoffmann | qdev_prop_register_global_list(machine->compat_props); |
4260 | b6b61144 | Gerd Hoffmann | } |
4261 | d0fef6fb | Gerd Hoffmann | qemu_add_globals(); |
4262 | d0fef6fb | Gerd Hoffmann | |
4263 | 1de81d28 | Anthony Liguori | qdev_machine_init(); |
4264 | 1de81d28 | Anthony Liguori | |
4265 | e689f7c6 | Markus Armbruster | QEMUMachineInitArgs args = { .machine = machine, |
4266 | e689f7c6 | Markus Armbruster | .ram_size = ram_size, |
4267 | c1654732 | Markus Armbruster | .boot_order = boot_order, |
4268 | 5f072e1f | Eduardo Habkost | .kernel_filename = kernel_filename, |
4269 | 5f072e1f | Eduardo Habkost | .kernel_cmdline = kernel_cmdline, |
4270 | 5f072e1f | Eduardo Habkost | .initrd_filename = initrd_filename, |
4271 | 5f072e1f | Eduardo Habkost | .cpu_model = cpu_model }; |
4272 | 5f072e1f | Eduardo Habkost | machine->init(&args); |
4273 | 3023f332 | aliguori | |
4274 | b3e6d591 | Paolo Bonzini | audio_init(); |
4275 | b3e6d591 | Paolo Bonzini | |
4276 | ea375f9a | Jan Kiszka | cpu_synchronize_all_post_init(); |
4277 | 268a362c | aliguori | |
4278 | 87d0a28e | Blue Swirl | set_numa_modes(); |
4279 | 268a362c | aliguori | |
4280 | 6f338c34 | aliguori | current_machine = machine; |
4281 | 6f338c34 | aliguori | |
4282 | 3023f332 | aliguori | /* init USB devices */
|
4283 | 094b287f | zhlcindy@gmail.com | if (usb_enabled(false)) { |
4284 | 0752706d | Markus Armbruster | if (foreach_device_config(DEV_USB, usb_parse) < 0) |
4285 | 0752706d | Markus Armbruster | exit(1);
|
4286 | 3023f332 | aliguori | } |
4287 | 3023f332 | aliguori | |
4288 | bd3c948d | Gerd Hoffmann | /* init generic devices */
|
4289 | 3329f07b | Gerd Hoffmann | if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0) |
4290 | bd3c948d | Gerd Hoffmann | exit(1);
|
4291 | bd3c948d | Gerd Hoffmann | |
4292 | 668680f7 | Markus Armbruster | net_check_clients(); |
4293 | 668680f7 | Markus Armbruster | |
4294 | 64840c66 | Gerd Hoffmann | ds = init_displaystate(); |
4295 | 993fbfdb | Anthony Liguori | |
4296 | 6b62dc2d | Gerd Hoffmann | /* init local displays */
|
4297 | 993fbfdb | Anthony Liguori | switch (display_type) {
|
4298 | 993fbfdb | Anthony Liguori | case DT_NOGRAPHIC:
|
4299 | 8111d028 | Antony Pavlov | (void)ds; /* avoid warning if no display is configured */ |
4300 | 993fbfdb | Anthony Liguori | break;
|
4301 | 4d3b6f6e | balrog | #if defined(CONFIG_CURSES)
|
4302 | 993fbfdb | Anthony Liguori | case DT_CURSES:
|
4303 | ab51b1d5 | Michael Tokarev | curses_display_init(ds, full_screen); |
4304 | 993fbfdb | Anthony Liguori | break;
|
4305 | 4d3b6f6e | balrog | #endif
|
4306 | 5b0753e0 | bellard | #if defined(CONFIG_SDL)
|
4307 | 993fbfdb | Anthony Liguori | case DT_SDL:
|
4308 | 993fbfdb | Anthony Liguori | sdl_display_init(ds, full_screen, no_frame); |
4309 | 993fbfdb | Anthony Liguori | break;
|
4310 | 5b0753e0 | bellard | #elif defined(CONFIG_COCOA)
|
4311 | 993fbfdb | Anthony Liguori | case DT_SDL:
|
4312 | 993fbfdb | Anthony Liguori | cocoa_display_init(ds, full_screen); |
4313 | 993fbfdb | Anthony Liguori | break;
|
4314 | 313aa567 | bellard | #endif
|
4315 | 15546425 | Anthony Liguori | #if defined(CONFIG_GTK)
|
4316 | 15546425 | Anthony Liguori | case DT_GTK:
|
4317 | 787ba4f0 | Peter Wu | gtk_display_init(ds, full_screen); |
4318 | 15546425 | Anthony Liguori | break;
|
4319 | 15546425 | Anthony Liguori | #endif
|
4320 | 6b62dc2d | Gerd Hoffmann | default:
|
4321 | 6b62dc2d | Gerd Hoffmann | break;
|
4322 | 6b62dc2d | Gerd Hoffmann | } |
4323 | 6b62dc2d | Gerd Hoffmann | |
4324 | 0ce235a7 | Gleb Natapov | /* must be after terminal init, SDL library changes signal handlers */
|
4325 | 0ce235a7 | Gleb Natapov | os_setup_signal_handling(); |
4326 | 0ce235a7 | Gleb Natapov | |
4327 | 821601ea | Jes Sorensen | #ifdef CONFIG_VNC
|
4328 | 6b62dc2d | Gerd Hoffmann | /* init remote displays */
|
4329 | 6b62dc2d | Gerd Hoffmann | if (vnc_display) {
|
4330 | 2d55f0e8 | Paolo Bonzini | Error *local_err = NULL;
|
4331 | 993fbfdb | Anthony Liguori | vnc_display_init(ds); |
4332 | 2d55f0e8 | Paolo Bonzini | vnc_display_open(ds, vnc_display, &local_err); |
4333 | 2d55f0e8 | Paolo Bonzini | if (local_err != NULL) { |
4334 | 4a44d85e | Seiji Aguchi | error_report("Failed to start VNC server on `%s': %s",
|
4335 | 4a44d85e | Seiji Aguchi | vnc_display, error_get_pretty(local_err)); |
4336 | 2d55f0e8 | Paolo Bonzini | error_free(local_err); |
4337 | 993fbfdb | Anthony Liguori | exit(1);
|
4338 | 94b204ca | Amos Kong | } |
4339 | f92f8afe | Anthony Liguori | |
4340 | 993fbfdb | Anthony Liguori | if (show_vnc_port) {
|
4341 | 993fbfdb | Anthony Liguori | printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
|
4342 | f92f8afe | Anthony Liguori | } |
4343 | 313aa567 | bellard | } |
4344 | 821601ea | Jes Sorensen | #endif
|
4345 | a3e22260 | Gerd Hoffmann | #ifdef CONFIG_SPICE
|
4346 | 9fa03286 | Gerd Hoffmann | if (using_spice) {
|
4347 | 9fa03286 | Gerd Hoffmann | qemu_spice_display_init(); |
4348 | a3e22260 | Gerd Hoffmann | } |
4349 | a3e22260 | Gerd Hoffmann | #endif
|
4350 | 5b08fc10 | aliguori | |
4351 | ef0c4a0d | Markus Armbruster | if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { |
4352 | 59030a8c | aliguori | exit(1);
|
4353 | 45669e00 | balrog | } |
4354 | 45669e00 | balrog | |
4355 | 3418bd25 | Gerd Hoffmann | qdev_machine_creation_done(); |
4356 | 3418bd25 | Gerd Hoffmann | |
4357 | 15ff7705 | Gerd Hoffmann | if (rom_load_all() != 0) { |
4358 | 15ff7705 | Gerd Hoffmann | fprintf(stderr, "rom loading failed\n");
|
4359 | 15ff7705 | Gerd Hoffmann | exit(1);
|
4360 | 15ff7705 | Gerd Hoffmann | } |
4361 | 45a50b16 | Gerd Hoffmann | |
4362 | 80376c3f | Isaku Yamahata | /* TODO: once all bus devices are qdevified, this should be done
|
4363 | 80376c3f | Isaku Yamahata | * when bus is created by qdev.c */
|
4364 | 80376c3f | Isaku Yamahata | qemu_register_reset(qbus_reset_all_fn, sysbus_get_default()); |
4365 | 4cab946a | Gleb Natapov | qemu_run_machine_init_done_notifiers(); |
4366 | 4cab946a | Gleb Natapov | |
4367 | d916b464 | Michael S. Tsirkin | /* Done notifiers can load ROMs */
|
4368 | d916b464 | Michael S. Tsirkin | rom_load_done(); |
4369 | d916b464 | Michael S. Tsirkin | |
4370 | e063eb1f | Jan Kiszka | qemu_system_reset(VMRESET_SILENT); |
4371 | 05f2401e | Juan Quintela | if (loadvm) {
|
4372 | 03cd4655 | Markus Armbruster | if (load_vmstate(loadvm) < 0) { |
4373 | 05f2401e | Juan Quintela | autostart = 0;
|
4374 | 05f2401e | Juan Quintela | } |
4375 | 05f2401e | Juan Quintela | } |
4376 | d63d307f | bellard | |
4377 | 2bb8c10c | Glauber Costa | if (incoming) {
|
4378 | 43eaae28 | Paolo Bonzini | Error *local_err = NULL;
|
4379 | 43eaae28 | Paolo Bonzini | qemu_start_incoming_migration(incoming, &local_err); |
4380 | 43eaae28 | Paolo Bonzini | if (local_err) {
|
4381 | 4a44d85e | Seiji Aguchi | error_report("-incoming %s: %s", incoming,
|
4382 | 4a44d85e | Seiji Aguchi | error_get_pretty(local_err)); |
4383 | 43eaae28 | Paolo Bonzini | error_free(local_err); |
4384 | 43eaae28 | Paolo Bonzini | exit(1);
|
4385 | 8ca5e801 | Juan Quintela | } |
4386 | 6b99dadc | Avi Kivity | } else if (autostart) { |
4387 | c0f4ce77 | aliguori | vm_start(); |
4388 | 6b99dadc | Avi Kivity | } |
4389 | ffd843bc | ths | |
4390 | eb505be1 | Jes Sorensen | os_setup_post(); |
4391 | 71e3ceb8 | ths | |
4392 | 8a745f2a | Michael Mueller | if (is_daemonized()) {
|
4393 | 8a745f2a | Michael Mueller | if (!trace_backend_init(trace_events, trace_file)) {
|
4394 | 8a745f2a | Michael Mueller | exit(1);
|
4395 | 8a745f2a | Michael Mueller | } |
4396 | 8a745f2a | Michael Mueller | } |
4397 | 8a745f2a | Michael Mueller | |
4398 | 8a7ddc38 | bellard | main_loop(); |
4399 | 99435906 | Paolo Bonzini | bdrv_close_all(); |
4400 | 99435906 | Paolo Bonzini | pause_all_vcpus(); |
4401 | 3d3b8303 | wayne | res_free(); |
4402 | d1a0cf73 | Stefan Berger | #ifdef CONFIG_TPM
|
4403 | d1a0cf73 | Stefan Berger | tpm_cleanup(); |
4404 | d1a0cf73 | Stefan Berger | #endif
|
4405 | b46a8906 | ths | |
4406 | 0824d6fc | bellard | return 0; |
4407 | 0824d6fc | bellard | } |