root / vl.c @ 9312805d
History | View | Annotate | Download (93.5 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 | c88676f8 | bellard | #include <zlib.h> |
31 | 67b915a5 | bellard | |
32 | 71e72a19 | Juan Quintela | /* Needed early for CONFIG_BSD etc. */
|
33 | d40cdb10 | blueswir1 | #include "config-host.h" |
34 | d40cdb10 | blueswir1 | |
35 | 67b915a5 | bellard | #ifndef _WIN32
|
36 | 5cea8590 | Paul Brook | #include <libgen.h> |
37 | 67b915a5 | bellard | #include <sys/times.h> |
38 | f1510b2c | bellard | #include <sys/wait.h> |
39 | 67b915a5 | bellard | #include <termios.h> |
40 | 67b915a5 | bellard | #include <sys/mman.h> |
41 | f1510b2c | bellard | #include <sys/ioctl.h> |
42 | 24646c7e | blueswir1 | #include <sys/resource.h> |
43 | f1510b2c | bellard | #include <sys/socket.h> |
44 | c94c8d64 | bellard | #include <netinet/in.h> |
45 | 24646c7e | blueswir1 | #include <net/if.h> |
46 | 24646c7e | blueswir1 | #include <arpa/inet.h> |
47 | 9d728e8c | bellard | #include <dirent.h> |
48 | 7c9d8e07 | bellard | #include <netdb.h> |
49 | cb4b976b | ths | #include <sys/select.h> |
50 | ab6540d5 | Prerna Saxena | |
51 | 71e72a19 | Juan Quintela | #ifdef CONFIG_BSD
|
52 | 7d3505c5 | bellard | #include <sys/stat.h> |
53 | a167ba50 | Aurelien Jarno | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
|
54 | 7d3505c5 | bellard | #include <libutil.h> |
55 | 92c0e657 | Juergen Lock | #include <sys/sysctl.h> |
56 | 24646c7e | blueswir1 | #else
|
57 | 24646c7e | blueswir1 | #include <util.h> |
58 | 128ab2ff | blueswir1 | #endif
|
59 | bbe813a2 | Aurelien Jarno | #else
|
60 | 223f0d72 | blueswir1 | #ifdef __linux__
|
61 | 7d3505c5 | bellard | #include <pty.h> |
62 | 7d3505c5 | bellard | #include <malloc.h> |
63 | bd494f4c | ths | |
64 | e57a8c0e | bellard | #include <linux/ppdev.h> |
65 | 5867c88a | ths | #include <linux/parport.h> |
66 | 223f0d72 | blueswir1 | #endif
|
67 | 223f0d72 | blueswir1 | #ifdef __sun__
|
68 | d5d10bc3 | ths | #include <sys/stat.h> |
69 | d5d10bc3 | ths | #include <sys/ethernet.h> |
70 | d5d10bc3 | ths | #include <sys/sockio.h> |
71 | d5d10bc3 | ths | #include <netinet/arp.h> |
72 | d5d10bc3 | ths | #include <netinet/in_systm.h> |
73 | d5d10bc3 | ths | #include <netinet/ip.h> |
74 | d5d10bc3 | ths | #include <netinet/ip_icmp.h> // must come after ip.h |
75 | d5d10bc3 | ths | #include <netinet/udp.h> |
76 | d5d10bc3 | ths | #include <netinet/tcp.h> |
77 | d5d10bc3 | ths | #include <net/if.h> |
78 | d5d10bc3 | ths | #include <syslog.h> |
79 | d5d10bc3 | ths | #include <stropts.h> |
80 | 67b915a5 | bellard | #endif
|
81 | 7d3505c5 | bellard | #endif
|
82 | ec530c81 | bellard | #endif
|
83 | 67b915a5 | bellard | |
84 | 9892fbfb | blueswir1 | #if defined(__OpenBSD__)
|
85 | 9892fbfb | blueswir1 | #include <util.h> |
86 | 9892fbfb | blueswir1 | #endif
|
87 | 9892fbfb | blueswir1 | |
88 | 8a16d273 | ths | #if defined(CONFIG_VDE)
|
89 | 8a16d273 | ths | #include <libvdeplug.h> |
90 | 8a16d273 | ths | #endif
|
91 | 8a16d273 | ths | |
92 | 67b915a5 | bellard | #ifdef _WIN32
|
93 | 49dc768d | aliguori | #include <windows.h> |
94 | 67b915a5 | bellard | #endif
|
95 | 67b915a5 | bellard | |
96 | 73332e5c | bellard | #ifdef CONFIG_SDL
|
97 | 59a36a2f | Stefan Weil | #if defined(__APPLE__) || defined(main)
|
98 | 6693665a | Stefan Weil | #include <SDL.h> |
99 | 880fec5d | malc | int qemu_main(int argc, char **argv, char **envp); |
100 | 880fec5d | malc | int main(int argc, char **argv) |
101 | 880fec5d | malc | { |
102 | 59a36a2f | Stefan Weil | return qemu_main(argc, argv, NULL); |
103 | 880fec5d | malc | } |
104 | 880fec5d | malc | #undef main
|
105 | 880fec5d | malc | #define main qemu_main
|
106 | 96bcd4f8 | bellard | #endif
|
107 | 73332e5c | bellard | #endif /* CONFIG_SDL */ |
108 | 0824d6fc | bellard | |
109 | 5b0753e0 | bellard | #ifdef CONFIG_COCOA
|
110 | 5b0753e0 | bellard | #undef main
|
111 | 5b0753e0 | bellard | #define main qemu_main
|
112 | 5b0753e0 | bellard | #endif /* CONFIG_COCOA */ |
113 | 5b0753e0 | bellard | |
114 | 511d2b14 | blueswir1 | #include "hw/hw.h" |
115 | 511d2b14 | blueswir1 | #include "hw/boards.h" |
116 | 511d2b14 | blueswir1 | #include "hw/usb.h" |
117 | 511d2b14 | blueswir1 | #include "hw/pcmcia.h" |
118 | 511d2b14 | blueswir1 | #include "hw/pc.h" |
119 | 511d2b14 | blueswir1 | #include "hw/isa.h" |
120 | 511d2b14 | blueswir1 | #include "hw/baum.h" |
121 | 511d2b14 | blueswir1 | #include "hw/bt.h" |
122 | 9dd986cc | Richard W.M. Jones | #include "hw/watchdog.h" |
123 | b6f6e3d3 | aliguori | #include "hw/smbios.h" |
124 | e37630ca | aliguori | #include "hw/xen.h" |
125 | bd3c948d | Gerd Hoffmann | #include "hw/qdev.h" |
126 | 45a50b16 | Gerd Hoffmann | #include "hw/loader.h" |
127 | 5ef4efa4 | aurel32 | #include "bt-host.h" |
128 | 511d2b14 | blueswir1 | #include "net.h" |
129 | 68ac40d2 | Mark McLoughlin | #include "net/slirp.h" |
130 | 511d2b14 | blueswir1 | #include "monitor.h" |
131 | 511d2b14 | blueswir1 | #include "console.h" |
132 | 511d2b14 | blueswir1 | #include "sysemu.h" |
133 | 511d2b14 | blueswir1 | #include "gdbstub.h" |
134 | 511d2b14 | blueswir1 | #include "qemu-timer.h" |
135 | 511d2b14 | blueswir1 | #include "qemu-char.h" |
136 | 511d2b14 | blueswir1 | #include "cache-utils.h" |
137 | 511d2b14 | blueswir1 | #include "block.h" |
138 | 666daa68 | Markus Armbruster | #include "blockdev.h" |
139 | c163b5ca | lirans@il.ibm.com | #include "block-migration.h" |
140 | a718acec | blueswir1 | #include "dma.h" |
141 | 511d2b14 | blueswir1 | #include "audio/audio.h" |
142 | 511d2b14 | blueswir1 | #include "migration.h" |
143 | 511d2b14 | blueswir1 | #include "kvm.h" |
144 | d3f24367 | Kevin Wolf | #include "qemu-option.h" |
145 | 7282a033 | Gerd Hoffmann | #include "qemu-config.h" |
146 | e78c48ec | Luiz Capitulino | #include "qemu-objects.h" |
147 | 59a5264b | Jes Sorensen | #include "qemu-options.h" |
148 | 758e8e38 | Venkateswararao Jujjuri (JV) | #ifdef CONFIG_VIRTFS
|
149 | 74db920c | Gautham R Shenoy | #include "fsdev/qemu-fsdev.h" |
150 | 74db920c | Gautham R Shenoy | #endif
|
151 | 511d2b14 | blueswir1 | |
152 | 0824d6fc | bellard | #include "disas.h" |
153 | fc01f7e7 | bellard | |
154 | 511d2b14 | blueswir1 | #include "qemu_socket.h" |
155 | 511d2b14 | blueswir1 | |
156 | d918f23e | Jan Kiszka | #include "slirp/libslirp.h" |
157 | 511d2b14 | blueswir1 | |
158 | 94b0b5ff | Stefan Hajnoczi | #include "trace.h" |
159 | 0b5538c3 | Stefan Hajnoczi | #include "simpletrace.h" |
160 | 72cf2d4f | Blue Swirl | #include "qemu-queue.h" |
161 | 296af7c9 | Blue Swirl | #include "cpus.h" |
162 | ad96090a | Blue Swirl | #include "arch_init.h" |
163 | 72cf2d4f | Blue Swirl | |
164 | 29b0040b | Gerd Hoffmann | #include "ui/qemu-spice.h" |
165 | 29b0040b | Gerd Hoffmann | |
166 | 9dc63a1e | blueswir1 | //#define DEBUG_NET
|
167 | 9dc63a1e | blueswir1 | //#define DEBUG_SLIRP
|
168 | 330d0414 | bellard | |
169 | 1bfe856e | bellard | #define DEFAULT_RAM_SIZE 128 |
170 | 313aa567 | bellard | |
171 | 98b19252 | Amit Shah | #define MAX_VIRTIO_CONSOLES 1 |
172 | 98b19252 | Amit Shah | |
173 | 5cea8590 | Paul Brook | static const char *data_dir; |
174 | 1192dad8 | j_mayer | const char *bios_name = NULL; |
175 | cb5a7aa8 | malc | enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
|
176 | 993fbfdb | Anthony Liguori | DisplayType display_type = DT_DEFAULT; |
177 | 6b62dc2d | Gerd Hoffmann | int display_remote = 0; |
178 | 3d11d0eb | bellard | const char* keyboard_layout = NULL; |
179 | c227f099 | Anthony Liguori | ram_addr_t ram_size; |
180 | c902760f | Marcelo Tosatti | const char *mem_path = NULL; |
181 | c902760f | Marcelo Tosatti | #ifdef MAP_POPULATE
|
182 | c902760f | Marcelo Tosatti | int mem_prealloc = 0; /* force preallocation of physical target memory */ |
183 | c902760f | Marcelo Tosatti | #endif
|
184 | c4b1fcc0 | bellard | int nb_nics;
|
185 | 7c9d8e07 | bellard | NICInfo nd_table[MAX_NICS]; |
186 | 8a7ddc38 | bellard | int vm_running;
|
187 | d399f677 | Paolo Bonzini | int autostart;
|
188 | 8e84865e | Amit Shah | int incoming_expected; /* Started with -incoming and waiting for incoming */ |
189 | f6503059 | balrog | static int rtc_utc = 1; |
190 | f6503059 | balrog | static int rtc_date_offset = -1; /* -1 means no change */ |
191 | 6875204c | Jan Kiszka | QEMUClock *rtc_clock; |
192 | 64465297 | Gerd Hoffmann | int vga_interface_type = VGA_NONE;
|
193 | dbed7e40 | blueswir1 | static int full_screen = 0; |
194 | 634a21f6 | blueswir1 | #ifdef CONFIG_SDL
|
195 | dbed7e40 | blueswir1 | static int no_frame = 0; |
196 | 634a21f6 | blueswir1 | #endif
|
197 | 667accab | ths | int no_quit = 0; |
198 | 8d11df9e | bellard | CharDriverState *serial_hds[MAX_SERIAL_PORTS]; |
199 | 6508fe59 | bellard | CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; |
200 | 9ede2fde | aliguori | CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; |
201 | a09db21f | bellard | int win2k_install_hack = 0; |
202 | 73822ec8 | aliguori | int rtc_td_hack = 0; |
203 | bb36d470 | bellard | int usb_enabled = 0; |
204 | 1b530a6d | aurel32 | int singlestep = 0; |
205 | 6a00d601 | bellard | int smp_cpus = 1; |
206 | 6be68d7e | Jes Sorensen | int max_cpus = 0; |
207 | dc6b1c09 | Andre Przywara | int smp_cores = 1; |
208 | dc6b1c09 | Andre Przywara | int smp_threads = 1; |
209 | 821601ea | Jes Sorensen | #ifdef CONFIG_VNC
|
210 | 73fc9742 | ths | const char *vnc_display; |
211 | 821601ea | Jes Sorensen | #endif
|
212 | 6515b203 | bellard | int acpi_enabled = 1; |
213 | 16b29ae1 | aliguori | int no_hpet = 0; |
214 | 52ca8d6a | bellard | int fd_bootchk = 1; |
215 | d1beab82 | bellard | int no_reboot = 0; |
216 | b2f76161 | aurel32 | int no_shutdown = 0; |
217 | 9467cd46 | balrog | int cursor_hide = 1; |
218 | a171fe39 | balrog | int graphic_rotate = 0; |
219 | 6b35e7bf | Jes Sorensen | uint8_t irq0override = 1;
|
220 | 09aaa160 | Markus Armbruster | const char *watchdog; |
221 | 2e55e842 | Gleb Natapov | QEMUOptionRom option_rom[MAX_OPTION_ROMS]; |
222 | 9ae02555 | ths | int nb_option_roms;
|
223 | 8e71621f | pbrook | int semihosting_enabled = 0; |
224 | 2b8f2d41 | balrog | int old_param = 0; |
225 | c35734b2 | ths | const char *qemu_name; |
226 | 3780e197 | ths | int alt_grab = 0; |
227 | 0ca9f8a4 | Dustin Kirkland | int ctrl_grab = 0; |
228 | 66508601 | blueswir1 | unsigned int nb_prom_envs = 0; |
229 | 66508601 | blueswir1 | const char *prom_envs[MAX_PROM_ENVS]; |
230 | 95387491 | Jan Kiszka | int boot_menu;
|
231 | 0824d6fc | bellard | |
232 | 1ca4d09a | Gleb Natapov | typedef struct FWBootEntry FWBootEntry; |
233 | 1ca4d09a | Gleb Natapov | |
234 | 1ca4d09a | Gleb Natapov | struct FWBootEntry {
|
235 | 1ca4d09a | Gleb Natapov | QTAILQ_ENTRY(FWBootEntry) link; |
236 | 1ca4d09a | Gleb Natapov | int32_t bootindex; |
237 | 1ca4d09a | Gleb Natapov | DeviceState *dev; |
238 | 1ca4d09a | Gleb Natapov | char *suffix;
|
239 | 1ca4d09a | Gleb Natapov | }; |
240 | 1ca4d09a | Gleb Natapov | |
241 | 1ca4d09a | Gleb Natapov | QTAILQ_HEAD(, FWBootEntry) fw_boot_order = QTAILQ_HEAD_INITIALIZER(fw_boot_order); |
242 | 1ca4d09a | Gleb Natapov | |
243 | 268a362c | aliguori | int nb_numa_nodes;
|
244 | 268a362c | aliguori | uint64_t node_mem[MAX_NODES]; |
245 | 268a362c | aliguori | uint64_t node_cpumask[MAX_NODES]; |
246 | 268a362c | aliguori | |
247 | 9043b62d | blueswir1 | static QEMUTimer *nographic_timer;
|
248 | ee5605e5 | balrog | |
249 | 8fcb1b90 | blueswir1 | uint8_t qemu_uuid[16];
|
250 | 8fcb1b90 | blueswir1 | |
251 | 76e30d0f | Jan Kiszka | static QEMUBootSetHandler *boot_set_handler;
|
252 | 76e30d0f | Jan Kiszka | static void *boot_set_opaque; |
253 | 76e30d0f | Jan Kiszka | |
254 | fd42deeb | Gerd Hoffmann | static NotifierList exit_notifiers =
|
255 | fd42deeb | Gerd Hoffmann | NOTIFIER_LIST_INITIALIZER(exit_notifiers); |
256 | fd42deeb | Gerd Hoffmann | |
257 | 4cab946a | Gleb Natapov | static NotifierList machine_init_done_notifiers =
|
258 | 4cab946a | Gleb Natapov | NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); |
259 | 4cab946a | Gleb Natapov | |
260 | 303d4e86 | Anthony PERARD | static int tcg_allowed = 1; |
261 | d745bef8 | Blue Swirl | int kvm_allowed = 0; |
262 | 3285cf4f | Anthony PERARD | int xen_allowed = 0; |
263 | d745bef8 | Blue Swirl | uint32_t xen_domid; |
264 | d745bef8 | Blue Swirl | enum xen_mode xen_mode = XEN_EMULATE;
|
265 | d745bef8 | Blue Swirl | |
266 | 998bbd74 | Gerd Hoffmann | static int default_serial = 1; |
267 | 6a5e8b0e | Gerd Hoffmann | static int default_parallel = 1; |
268 | 986c5f78 | Gerd Hoffmann | static int default_virtcon = 1; |
269 | abdeed06 | Gerd Hoffmann | static int default_monitor = 1; |
270 | 64465297 | Gerd Hoffmann | static int default_vga = 1; |
271 | ac33f8fa | Gerd Hoffmann | static int default_floppy = 1; |
272 | ac33f8fa | Gerd Hoffmann | static int default_cdrom = 1; |
273 | ac33f8fa | Gerd Hoffmann | static int default_sdcard = 1; |
274 | 998bbd74 | Gerd Hoffmann | |
275 | 998bbd74 | Gerd Hoffmann | static struct { |
276 | 998bbd74 | Gerd Hoffmann | const char *driver; |
277 | 998bbd74 | Gerd Hoffmann | int *flag;
|
278 | 998bbd74 | Gerd Hoffmann | } default_list[] = { |
279 | 6a5e8b0e | Gerd Hoffmann | { .driver = "isa-serial", .flag = &default_serial },
|
280 | 6a5e8b0e | Gerd Hoffmann | { .driver = "isa-parallel", .flag = &default_parallel },
|
281 | d8bcbabf | Gerd Hoffmann | { .driver = "isa-fdc", .flag = &default_floppy },
|
282 | af6bf132 | Markus Armbruster | { .driver = "ide-cd", .flag = &default_cdrom },
|
283 | af6bf132 | Markus Armbruster | { .driver = "ide-hd", .flag = &default_cdrom },
|
284 | d8bcbabf | Gerd Hoffmann | { .driver = "ide-drive", .flag = &default_cdrom },
|
285 | af6bf132 | Markus Armbruster | { .driver = "scsi-cd", .flag = &default_cdrom },
|
286 | 392ecf54 | Amit Shah | { .driver = "virtio-serial-pci", .flag = &default_virtcon },
|
287 | 392ecf54 | Amit Shah | { .driver = "virtio-serial-s390", .flag = &default_virtcon },
|
288 | 392ecf54 | Amit Shah | { .driver = "virtio-serial", .flag = &default_virtcon },
|
289 | 64465297 | Gerd Hoffmann | { .driver = "VGA", .flag = &default_vga },
|
290 | 69fd02ee | Gerd Hoffmann | { .driver = "cirrus-vga", .flag = &default_vga },
|
291 | 69fd02ee | Gerd Hoffmann | { .driver = "vmware-svga", .flag = &default_vga },
|
292 | 0826c710 | Markus Armbruster | { .driver = "isa-vga", .flag = &default_vga },
|
293 | 42138043 | Gerd Hoffmann | { .driver = "qxl-vga", .flag = &default_vga },
|
294 | 998bbd74 | Gerd Hoffmann | }; |
295 | 998bbd74 | Gerd Hoffmann | |
296 | 998bbd74 | Gerd Hoffmann | static int default_driver_check(QemuOpts *opts, void *opaque) |
297 | 998bbd74 | Gerd Hoffmann | { |
298 | 998bbd74 | Gerd Hoffmann | const char *driver = qemu_opt_get(opts, "driver"); |
299 | 998bbd74 | Gerd Hoffmann | int i;
|
300 | 998bbd74 | Gerd Hoffmann | |
301 | 998bbd74 | Gerd Hoffmann | if (!driver)
|
302 | 998bbd74 | Gerd Hoffmann | return 0; |
303 | 998bbd74 | Gerd Hoffmann | for (i = 0; i < ARRAY_SIZE(default_list); i++) { |
304 | 998bbd74 | Gerd Hoffmann | if (strcmp(default_list[i].driver, driver) != 0) |
305 | 998bbd74 | Gerd Hoffmann | continue;
|
306 | 998bbd74 | Gerd Hoffmann | *(default_list[i].flag) = 0;
|
307 | 998bbd74 | Gerd Hoffmann | } |
308 | 998bbd74 | Gerd Hoffmann | return 0; |
309 | 998bbd74 | Gerd Hoffmann | } |
310 | 998bbd74 | Gerd Hoffmann | |
311 | 0824d6fc | bellard | /***********************************************************/
|
312 | 8f0056b7 | Paolo Bonzini | /* real time host monotonic timer */
|
313 | 09b26c5e | bellard | |
314 | c4b1fcc0 | bellard | /***********************************************************/
|
315 | f6503059 | balrog | /* host time/date access */
|
316 | f6503059 | balrog | void qemu_get_timedate(struct tm *tm, int offset) |
317 | f6503059 | balrog | { |
318 | f6503059 | balrog | time_t ti; |
319 | f6503059 | balrog | struct tm *ret;
|
320 | f6503059 | balrog | |
321 | f6503059 | balrog | time(&ti); |
322 | f6503059 | balrog | ti += offset; |
323 | f6503059 | balrog | if (rtc_date_offset == -1) { |
324 | f6503059 | balrog | if (rtc_utc)
|
325 | f6503059 | balrog | ret = gmtime(&ti); |
326 | f6503059 | balrog | else
|
327 | f6503059 | balrog | ret = localtime(&ti); |
328 | f6503059 | balrog | } else {
|
329 | f6503059 | balrog | ti -= rtc_date_offset; |
330 | f6503059 | balrog | ret = gmtime(&ti); |
331 | f6503059 | balrog | } |
332 | f6503059 | balrog | |
333 | f6503059 | balrog | memcpy(tm, ret, sizeof(struct tm)); |
334 | f6503059 | balrog | } |
335 | f6503059 | balrog | |
336 | f6503059 | balrog | int qemu_timedate_diff(struct tm *tm) |
337 | f6503059 | balrog | { |
338 | f6503059 | balrog | time_t seconds; |
339 | f6503059 | balrog | |
340 | f6503059 | balrog | if (rtc_date_offset == -1) |
341 | f6503059 | balrog | if (rtc_utc)
|
342 | f6503059 | balrog | seconds = mktimegm(tm); |
343 | f6503059 | balrog | else
|
344 | f6503059 | balrog | seconds = mktime(tm); |
345 | f6503059 | balrog | else
|
346 | f6503059 | balrog | seconds = mktimegm(tm) + rtc_date_offset; |
347 | f6503059 | balrog | |
348 | f6503059 | balrog | return seconds - time(NULL); |
349 | f6503059 | balrog | } |
350 | f6503059 | balrog | |
351 | 80cd3478 | Luiz Capitulino | void rtc_change_mon_event(struct tm *tm) |
352 | 80cd3478 | Luiz Capitulino | { |
353 | 80cd3478 | Luiz Capitulino | QObject *data; |
354 | 80cd3478 | Luiz Capitulino | |
355 | 80cd3478 | Luiz Capitulino | data = qobject_from_jsonf("{ 'offset': %d }", qemu_timedate_diff(tm));
|
356 | 80cd3478 | Luiz Capitulino | monitor_protocol_event(QEVENT_RTC_CHANGE, data); |
357 | 80cd3478 | Luiz Capitulino | qobject_decref(data); |
358 | 80cd3478 | Luiz Capitulino | } |
359 | 80cd3478 | Luiz Capitulino | |
360 | 1ed2fc1f | Jan Kiszka | static void configure_rtc_date_offset(const char *startdate, int legacy) |
361 | 1ed2fc1f | Jan Kiszka | { |
362 | 1ed2fc1f | Jan Kiszka | time_t rtc_start_date; |
363 | 1ed2fc1f | Jan Kiszka | struct tm tm;
|
364 | 1ed2fc1f | Jan Kiszka | |
365 | 1ed2fc1f | Jan Kiszka | if (!strcmp(startdate, "now") && legacy) { |
366 | 1ed2fc1f | Jan Kiszka | rtc_date_offset = -1;
|
367 | 1ed2fc1f | Jan Kiszka | } else {
|
368 | 1ed2fc1f | Jan Kiszka | if (sscanf(startdate, "%d-%d-%dT%d:%d:%d", |
369 | 1ed2fc1f | Jan Kiszka | &tm.tm_year, |
370 | 1ed2fc1f | Jan Kiszka | &tm.tm_mon, |
371 | 1ed2fc1f | Jan Kiszka | &tm.tm_mday, |
372 | 1ed2fc1f | Jan Kiszka | &tm.tm_hour, |
373 | 1ed2fc1f | Jan Kiszka | &tm.tm_min, |
374 | 1ed2fc1f | Jan Kiszka | &tm.tm_sec) == 6) {
|
375 | 1ed2fc1f | Jan Kiszka | /* OK */
|
376 | 1ed2fc1f | Jan Kiszka | } else if (sscanf(startdate, "%d-%d-%d", |
377 | 1ed2fc1f | Jan Kiszka | &tm.tm_year, |
378 | 1ed2fc1f | Jan Kiszka | &tm.tm_mon, |
379 | 1ed2fc1f | Jan Kiszka | &tm.tm_mday) == 3) {
|
380 | 1ed2fc1f | Jan Kiszka | tm.tm_hour = 0;
|
381 | 1ed2fc1f | Jan Kiszka | tm.tm_min = 0;
|
382 | 1ed2fc1f | Jan Kiszka | tm.tm_sec = 0;
|
383 | 1ed2fc1f | Jan Kiszka | } else {
|
384 | 1ed2fc1f | Jan Kiszka | goto date_fail;
|
385 | 1ed2fc1f | Jan Kiszka | } |
386 | 1ed2fc1f | Jan Kiszka | tm.tm_year -= 1900;
|
387 | 1ed2fc1f | Jan Kiszka | tm.tm_mon--; |
388 | 1ed2fc1f | Jan Kiszka | rtc_start_date = mktimegm(&tm); |
389 | 1ed2fc1f | Jan Kiszka | if (rtc_start_date == -1) { |
390 | 1ed2fc1f | Jan Kiszka | date_fail:
|
391 | 1ed2fc1f | Jan Kiszka | fprintf(stderr, "Invalid date format. Valid formats are:\n"
|
392 | 1ed2fc1f | Jan Kiszka | "'2006-06-17T16:01:21' or '2006-06-17'\n");
|
393 | 1ed2fc1f | Jan Kiszka | exit(1);
|
394 | 1ed2fc1f | Jan Kiszka | } |
395 | 1ed2fc1f | Jan Kiszka | rtc_date_offset = time(NULL) - rtc_start_date;
|
396 | 1ed2fc1f | Jan Kiszka | } |
397 | 1ed2fc1f | Jan Kiszka | } |
398 | 1ed2fc1f | Jan Kiszka | |
399 | 1ed2fc1f | Jan Kiszka | static void configure_rtc(QemuOpts *opts) |
400 | 1ed2fc1f | Jan Kiszka | { |
401 | 1ed2fc1f | Jan Kiszka | const char *value; |
402 | 1ed2fc1f | Jan Kiszka | |
403 | 1ed2fc1f | Jan Kiszka | value = qemu_opt_get(opts, "base");
|
404 | 1ed2fc1f | Jan Kiszka | if (value) {
|
405 | 1ed2fc1f | Jan Kiszka | if (!strcmp(value, "utc")) { |
406 | 1ed2fc1f | Jan Kiszka | rtc_utc = 1;
|
407 | 1ed2fc1f | Jan Kiszka | } else if (!strcmp(value, "localtime")) { |
408 | 1ed2fc1f | Jan Kiszka | rtc_utc = 0;
|
409 | 1ed2fc1f | Jan Kiszka | } else {
|
410 | 1ed2fc1f | Jan Kiszka | configure_rtc_date_offset(value, 0);
|
411 | 1ed2fc1f | Jan Kiszka | } |
412 | 1ed2fc1f | Jan Kiszka | } |
413 | 6875204c | Jan Kiszka | value = qemu_opt_get(opts, "clock");
|
414 | 6875204c | Jan Kiszka | if (value) {
|
415 | 6875204c | Jan Kiszka | if (!strcmp(value, "host")) { |
416 | 6875204c | Jan Kiszka | rtc_clock = host_clock; |
417 | 6875204c | Jan Kiszka | } else if (!strcmp(value, "vm")) { |
418 | 6875204c | Jan Kiszka | rtc_clock = vm_clock; |
419 | 6875204c | Jan Kiszka | } else {
|
420 | 6875204c | Jan Kiszka | fprintf(stderr, "qemu: invalid option value '%s'\n", value);
|
421 | 6875204c | Jan Kiszka | exit(1);
|
422 | 6875204c | Jan Kiszka | } |
423 | 6875204c | Jan Kiszka | } |
424 | 1ed2fc1f | Jan Kiszka | value = qemu_opt_get(opts, "driftfix");
|
425 | 1ed2fc1f | Jan Kiszka | if (value) {
|
426 | 7e4c0336 | Blue Swirl | if (!strcmp(value, "slew")) { |
427 | 1ed2fc1f | Jan Kiszka | rtc_td_hack = 1;
|
428 | 7e4c0336 | Blue Swirl | } else if (!strcmp(value, "none")) { |
429 | 1ed2fc1f | Jan Kiszka | rtc_td_hack = 0;
|
430 | 1ed2fc1f | Jan Kiszka | } else {
|
431 | 1ed2fc1f | Jan Kiszka | fprintf(stderr, "qemu: invalid option value '%s'\n", value);
|
432 | 1ed2fc1f | Jan Kiszka | exit(1);
|
433 | 1ed2fc1f | Jan Kiszka | } |
434 | 1ed2fc1f | Jan Kiszka | } |
435 | 1ed2fc1f | Jan Kiszka | } |
436 | 1ed2fc1f | Jan Kiszka | |
437 | 1ae26a18 | balrog | /***********************************************************/
|
438 | 1ae26a18 | balrog | /* Bluetooth support */
|
439 | 1ae26a18 | balrog | static int nb_hcis; |
440 | 1ae26a18 | balrog | static int cur_hci; |
441 | 1ae26a18 | balrog | static struct HCIInfo *hci_table[MAX_NICS]; |
442 | dc72ac14 | balrog | |
443 | 1ae26a18 | balrog | static struct bt_vlan_s { |
444 | 1ae26a18 | balrog | struct bt_scatternet_s net;
|
445 | 1ae26a18 | balrog | int id;
|
446 | 1ae26a18 | balrog | struct bt_vlan_s *next;
|
447 | 1ae26a18 | balrog | } *first_bt_vlan; |
448 | 1ae26a18 | balrog | |
449 | 1ae26a18 | balrog | /* find or alloc a new bluetooth "VLAN" */
|
450 | 674bb261 | blueswir1 | static struct bt_scatternet_s *qemu_find_bt_vlan(int id) |
451 | 1ae26a18 | balrog | { |
452 | 1ae26a18 | balrog | struct bt_vlan_s **pvlan, *vlan;
|
453 | 1ae26a18 | balrog | for (vlan = first_bt_vlan; vlan != NULL; vlan = vlan->next) { |
454 | 1ae26a18 | balrog | if (vlan->id == id)
|
455 | 1ae26a18 | balrog | return &vlan->net;
|
456 | 1ae26a18 | balrog | } |
457 | 1ae26a18 | balrog | vlan = qemu_mallocz(sizeof(struct bt_vlan_s)); |
458 | 1ae26a18 | balrog | vlan->id = id; |
459 | 1ae26a18 | balrog | pvlan = &first_bt_vlan; |
460 | 1ae26a18 | balrog | while (*pvlan != NULL) |
461 | 1ae26a18 | balrog | pvlan = &(*pvlan)->next; |
462 | 1ae26a18 | balrog | *pvlan = vlan; |
463 | 1ae26a18 | balrog | return &vlan->net;
|
464 | 1ae26a18 | balrog | } |
465 | 1ae26a18 | balrog | |
466 | 1ae26a18 | balrog | static void null_hci_send(struct HCIInfo *hci, const uint8_t *data, int len) |
467 | 1ae26a18 | balrog | { |
468 | 1ae26a18 | balrog | } |
469 | 1ae26a18 | balrog | |
470 | 1ae26a18 | balrog | static int null_hci_addr_set(struct HCIInfo *hci, const uint8_t *bd_addr) |
471 | 1ae26a18 | balrog | { |
472 | 1ae26a18 | balrog | return -ENOTSUP;
|
473 | 1ae26a18 | balrog | } |
474 | 1ae26a18 | balrog | |
475 | 1ae26a18 | balrog | static struct HCIInfo null_hci = { |
476 | 1ae26a18 | balrog | .cmd_send = null_hci_send, |
477 | 1ae26a18 | balrog | .sco_send = null_hci_send, |
478 | 1ae26a18 | balrog | .acl_send = null_hci_send, |
479 | 1ae26a18 | balrog | .bdaddr_set = null_hci_addr_set, |
480 | 1ae26a18 | balrog | }; |
481 | 1ae26a18 | balrog | |
482 | 1ae26a18 | balrog | struct HCIInfo *qemu_next_hci(void) |
483 | 1ae26a18 | balrog | { |
484 | 1ae26a18 | balrog | if (cur_hci == nb_hcis)
|
485 | 1ae26a18 | balrog | return &null_hci;
|
486 | 1ae26a18 | balrog | |
487 | 1ae26a18 | balrog | return hci_table[cur_hci++];
|
488 | 1ae26a18 | balrog | } |
489 | 1ae26a18 | balrog | |
490 | dc72ac14 | balrog | static struct HCIInfo *hci_init(const char *str) |
491 | dc72ac14 | balrog | { |
492 | dc72ac14 | balrog | char *endp;
|
493 | dc72ac14 | balrog | struct bt_scatternet_s *vlan = 0; |
494 | dc72ac14 | balrog | |
495 | dc72ac14 | balrog | if (!strcmp(str, "null")) |
496 | dc72ac14 | balrog | /* null */
|
497 | dc72ac14 | balrog | return &null_hci;
|
498 | dc72ac14 | balrog | else if (!strncmp(str, "host", 4) && (str[4] == '\0' || str[4] == ':')) |
499 | dc72ac14 | balrog | /* host[:hciN] */
|
500 | dc72ac14 | balrog | return bt_host_hci(str[4] ? str + 5 : "hci0"); |
501 | dc72ac14 | balrog | else if (!strncmp(str, "hci", 3)) { |
502 | dc72ac14 | balrog | /* hci[,vlan=n] */
|
503 | dc72ac14 | balrog | if (str[3]) { |
504 | dc72ac14 | balrog | if (!strncmp(str + 3, ",vlan=", 6)) { |
505 | dc72ac14 | balrog | vlan = qemu_find_bt_vlan(strtol(str + 9, &endp, 0)); |
506 | dc72ac14 | balrog | if (*endp)
|
507 | dc72ac14 | balrog | vlan = 0;
|
508 | dc72ac14 | balrog | } |
509 | dc72ac14 | balrog | } else
|
510 | dc72ac14 | balrog | vlan = qemu_find_bt_vlan(0);
|
511 | dc72ac14 | balrog | if (vlan)
|
512 | dc72ac14 | balrog | return bt_new_hci(vlan);
|
513 | dc72ac14 | balrog | } |
514 | dc72ac14 | balrog | |
515 | dc72ac14 | balrog | fprintf(stderr, "qemu: Unknown bluetooth HCI `%s'.\n", str);
|
516 | dc72ac14 | balrog | |
517 | dc72ac14 | balrog | return 0; |
518 | dc72ac14 | balrog | } |
519 | dc72ac14 | balrog | |
520 | dc72ac14 | balrog | static int bt_hci_parse(const char *str) |
521 | dc72ac14 | balrog | { |
522 | dc72ac14 | balrog | struct HCIInfo *hci;
|
523 | c227f099 | Anthony Liguori | bdaddr_t bdaddr; |
524 | dc72ac14 | balrog | |
525 | dc72ac14 | balrog | if (nb_hcis >= MAX_NICS) {
|
526 | dc72ac14 | balrog | fprintf(stderr, "qemu: Too many bluetooth HCIs (max %i).\n", MAX_NICS);
|
527 | dc72ac14 | balrog | return -1; |
528 | dc72ac14 | balrog | } |
529 | dc72ac14 | balrog | |
530 | dc72ac14 | balrog | hci = hci_init(str); |
531 | dc72ac14 | balrog | if (!hci)
|
532 | dc72ac14 | balrog | return -1; |
533 | dc72ac14 | balrog | |
534 | dc72ac14 | balrog | bdaddr.b[0] = 0x52; |
535 | dc72ac14 | balrog | bdaddr.b[1] = 0x54; |
536 | dc72ac14 | balrog | bdaddr.b[2] = 0x00; |
537 | dc72ac14 | balrog | bdaddr.b[3] = 0x12; |
538 | dc72ac14 | balrog | bdaddr.b[4] = 0x34; |
539 | dc72ac14 | balrog | bdaddr.b[5] = 0x56 + nb_hcis; |
540 | dc72ac14 | balrog | hci->bdaddr_set(hci, bdaddr.b); |
541 | dc72ac14 | balrog | |
542 | dc72ac14 | balrog | hci_table[nb_hcis++] = hci; |
543 | dc72ac14 | balrog | |
544 | dc72ac14 | balrog | return 0; |
545 | dc72ac14 | balrog | } |
546 | dc72ac14 | balrog | |
547 | dc72ac14 | balrog | static void bt_vhci_add(int vlan_id) |
548 | dc72ac14 | balrog | { |
549 | dc72ac14 | balrog | struct bt_scatternet_s *vlan = qemu_find_bt_vlan(vlan_id);
|
550 | dc72ac14 | balrog | |
551 | dc72ac14 | balrog | if (!vlan->slave)
|
552 | dc72ac14 | balrog | fprintf(stderr, "qemu: warning: adding a VHCI to "
|
553 | dc72ac14 | balrog | "an empty scatternet %i\n", vlan_id);
|
554 | dc72ac14 | balrog | |
555 | dc72ac14 | balrog | bt_vhci_init(bt_new_hci(vlan)); |
556 | dc72ac14 | balrog | } |
557 | dc72ac14 | balrog | |
558 | dc72ac14 | balrog | static struct bt_device_s *bt_device_add(const char *opt) |
559 | dc72ac14 | balrog | { |
560 | dc72ac14 | balrog | struct bt_scatternet_s *vlan;
|
561 | dc72ac14 | balrog | int vlan_id = 0; |
562 | dc72ac14 | balrog | char *endp = strstr(opt, ",vlan="); |
563 | dc72ac14 | balrog | int len = (endp ? endp - opt : strlen(opt)) + 1; |
564 | dc72ac14 | balrog | char devname[10]; |
565 | dc72ac14 | balrog | |
566 | dc72ac14 | balrog | pstrcpy(devname, MIN(sizeof(devname), len), opt);
|
567 | dc72ac14 | balrog | |
568 | dc72ac14 | balrog | if (endp) {
|
569 | dc72ac14 | balrog | vlan_id = strtol(endp + 6, &endp, 0); |
570 | dc72ac14 | balrog | if (*endp) {
|
571 | dc72ac14 | balrog | fprintf(stderr, "qemu: unrecognised bluetooth vlan Id\n");
|
572 | dc72ac14 | balrog | return 0; |
573 | dc72ac14 | balrog | } |
574 | dc72ac14 | balrog | } |
575 | dc72ac14 | balrog | |
576 | dc72ac14 | balrog | vlan = qemu_find_bt_vlan(vlan_id); |
577 | dc72ac14 | balrog | |
578 | dc72ac14 | balrog | if (!vlan->slave)
|
579 | dc72ac14 | balrog | fprintf(stderr, "qemu: warning: adding a slave device to "
|
580 | dc72ac14 | balrog | "an empty scatternet %i\n", vlan_id);
|
581 | dc72ac14 | balrog | |
582 | dc72ac14 | balrog | if (!strcmp(devname, "keyboard")) |
583 | dc72ac14 | balrog | return bt_keyboard_init(vlan);
|
584 | dc72ac14 | balrog | |
585 | dc72ac14 | balrog | fprintf(stderr, "qemu: unsupported bluetooth device `%s'\n", devname);
|
586 | dc72ac14 | balrog | return 0; |
587 | dc72ac14 | balrog | } |
588 | dc72ac14 | balrog | |
589 | dc72ac14 | balrog | static int bt_parse(const char *opt) |
590 | dc72ac14 | balrog | { |
591 | dc72ac14 | balrog | const char *endp, *p; |
592 | dc72ac14 | balrog | int vlan;
|
593 | dc72ac14 | balrog | |
594 | dc72ac14 | balrog | if (strstart(opt, "hci", &endp)) { |
595 | dc72ac14 | balrog | if (!*endp || *endp == ',') { |
596 | dc72ac14 | balrog | if (*endp)
|
597 | dc72ac14 | balrog | if (!strstart(endp, ",vlan=", 0)) |
598 | dc72ac14 | balrog | opt = endp + 1;
|
599 | dc72ac14 | balrog | |
600 | dc72ac14 | balrog | return bt_hci_parse(opt);
|
601 | dc72ac14 | balrog | } |
602 | dc72ac14 | balrog | } else if (strstart(opt, "vhci", &endp)) { |
603 | dc72ac14 | balrog | if (!*endp || *endp == ',') { |
604 | dc72ac14 | balrog | if (*endp) {
|
605 | dc72ac14 | balrog | if (strstart(endp, ",vlan=", &p)) { |
606 | dc72ac14 | balrog | vlan = strtol(p, (char **) &endp, 0); |
607 | dc72ac14 | balrog | if (*endp) {
|
608 | dc72ac14 | balrog | fprintf(stderr, "qemu: bad scatternet '%s'\n", p);
|
609 | dc72ac14 | balrog | return 1; |
610 | dc72ac14 | balrog | } |
611 | dc72ac14 | balrog | } else {
|
612 | dc72ac14 | balrog | fprintf(stderr, "qemu: bad parameter '%s'\n", endp + 1); |
613 | dc72ac14 | balrog | return 1; |
614 | dc72ac14 | balrog | } |
615 | dc72ac14 | balrog | } else
|
616 | dc72ac14 | balrog | vlan = 0;
|
617 | dc72ac14 | balrog | |
618 | dc72ac14 | balrog | bt_vhci_add(vlan); |
619 | dc72ac14 | balrog | return 0; |
620 | dc72ac14 | balrog | } |
621 | dc72ac14 | balrog | } else if (strstart(opt, "device:", &endp)) |
622 | dc72ac14 | balrog | return !bt_device_add(endp);
|
623 | dc72ac14 | balrog | |
624 | dc72ac14 | balrog | fprintf(stderr, "qemu: bad bluetooth parameter '%s'\n", opt);
|
625 | dc72ac14 | balrog | return 1; |
626 | dc72ac14 | balrog | } |
627 | dc72ac14 | balrog | |
628 | 1ae26a18 | balrog | /***********************************************************/
|
629 | 1ae26a18 | balrog | /* QEMU Block devices */
|
630 | 1ae26a18 | balrog | |
631 | 2292ddae | Markus Armbruster | #define HD_OPTS "media=disk" |
632 | 2292ddae | Markus Armbruster | #define CDROM_OPTS "media=cdrom" |
633 | 2292ddae | Markus Armbruster | #define FD_OPTS "" |
634 | 2292ddae | Markus Armbruster | #define PFLASH_OPTS "" |
635 | 2292ddae | Markus Armbruster | #define MTD_OPTS "" |
636 | 2292ddae | Markus Armbruster | #define SD_OPTS "" |
637 | e4bcb14c | ths | |
638 | 9dfd7c7a | Gerd Hoffmann | static int drive_init_func(QemuOpts *opts, void *opaque) |
639 | 9dfd7c7a | Gerd Hoffmann | { |
640 | a803cb8e | Markus Armbruster | int *use_scsi = opaque;
|
641 | 9dfd7c7a | Gerd Hoffmann | |
642 | 319ae529 | Markus Armbruster | return drive_init(opts, *use_scsi) == NULL; |
643 | 9dfd7c7a | Gerd Hoffmann | } |
644 | 9dfd7c7a | Gerd Hoffmann | |
645 | 9dfd7c7a | Gerd Hoffmann | static int drive_enable_snapshot(QemuOpts *opts, void *opaque) |
646 | 9dfd7c7a | Gerd Hoffmann | { |
647 | 9dfd7c7a | Gerd Hoffmann | if (NULL == qemu_opt_get(opts, "snapshot")) { |
648 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(opts, "snapshot", "on"); |
649 | 9dfd7c7a | Gerd Hoffmann | } |
650 | 9dfd7c7a | Gerd Hoffmann | return 0; |
651 | 9dfd7c7a | Gerd Hoffmann | } |
652 | 9dfd7c7a | Gerd Hoffmann | |
653 | 4e5d9b57 | Markus Armbruster | static void default_drive(int enable, int snapshot, int use_scsi, |
654 | 4e5d9b57 | Markus Armbruster | BlockInterfaceType type, int index,
|
655 | 4e5d9b57 | Markus Armbruster | const char *optstr) |
656 | 4e5d9b57 | Markus Armbruster | { |
657 | 4e5d9b57 | Markus Armbruster | QemuOpts *opts; |
658 | 4e5d9b57 | Markus Armbruster | |
659 | 4e5d9b57 | Markus Armbruster | if (type == IF_DEFAULT) {
|
660 | 4e5d9b57 | Markus Armbruster | type = use_scsi ? IF_SCSI : IF_IDE; |
661 | 4e5d9b57 | Markus Armbruster | } |
662 | 4e5d9b57 | Markus Armbruster | |
663 | 4e5d9b57 | Markus Armbruster | if (!enable || drive_get_by_index(type, index)) {
|
664 | 4e5d9b57 | Markus Armbruster | return;
|
665 | 4e5d9b57 | Markus Armbruster | } |
666 | 4e5d9b57 | Markus Armbruster | |
667 | 4e5d9b57 | Markus Armbruster | opts = drive_add(type, index, NULL, optstr);
|
668 | 4e5d9b57 | Markus Armbruster | if (snapshot) {
|
669 | 4e5d9b57 | Markus Armbruster | drive_enable_snapshot(opts, NULL);
|
670 | 4e5d9b57 | Markus Armbruster | } |
671 | 319ae529 | Markus Armbruster | if (!drive_init(opts, use_scsi)) {
|
672 | 4e5d9b57 | Markus Armbruster | exit(1);
|
673 | 4e5d9b57 | Markus Armbruster | } |
674 | 4e5d9b57 | Markus Armbruster | } |
675 | 4e5d9b57 | Markus Armbruster | |
676 | 76e30d0f | Jan Kiszka | void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque) |
677 | 76e30d0f | Jan Kiszka | { |
678 | 76e30d0f | Jan Kiszka | boot_set_handler = func; |
679 | 76e30d0f | Jan Kiszka | boot_set_opaque = opaque; |
680 | 76e30d0f | Jan Kiszka | } |
681 | 76e30d0f | Jan Kiszka | |
682 | 76e30d0f | Jan Kiszka | int qemu_boot_set(const char *boot_devices) |
683 | 76e30d0f | Jan Kiszka | { |
684 | 76e30d0f | Jan Kiszka | if (!boot_set_handler) {
|
685 | 76e30d0f | Jan Kiszka | return -EINVAL;
|
686 | 76e30d0f | Jan Kiszka | } |
687 | 76e30d0f | Jan Kiszka | return boot_set_handler(boot_set_opaque, boot_devices);
|
688 | 76e30d0f | Jan Kiszka | } |
689 | 76e30d0f | Jan Kiszka | |
690 | 4e9e9d6e | Eduardo Habkost | static void validate_bootdevices(char *devices) |
691 | ef3adf68 | Jan Kiszka | { |
692 | ef3adf68 | Jan Kiszka | /* We just do some generic consistency checks */
|
693 | ef3adf68 | Jan Kiszka | const char *p; |
694 | ef3adf68 | Jan Kiszka | int bitmap = 0; |
695 | ef3adf68 | Jan Kiszka | |
696 | ef3adf68 | Jan Kiszka | for (p = devices; *p != '\0'; p++) { |
697 | ef3adf68 | Jan Kiszka | /* Allowed boot devices are:
|
698 | ef3adf68 | Jan Kiszka | * a-b: floppy disk drives
|
699 | ef3adf68 | Jan Kiszka | * c-f: IDE disk drives
|
700 | ef3adf68 | Jan Kiszka | * g-m: machine implementation dependant drives
|
701 | ef3adf68 | Jan Kiszka | * n-p: network devices
|
702 | ef3adf68 | Jan Kiszka | * It's up to each machine implementation to check if the given boot
|
703 | ef3adf68 | Jan Kiszka | * devices match the actual hardware implementation and firmware
|
704 | ef3adf68 | Jan Kiszka | * features.
|
705 | ef3adf68 | Jan Kiszka | */
|
706 | ef3adf68 | Jan Kiszka | if (*p < 'a' || *p > 'p') { |
707 | ef3adf68 | Jan Kiszka | fprintf(stderr, "Invalid boot device '%c'\n", *p);
|
708 | ef3adf68 | Jan Kiszka | exit(1);
|
709 | ef3adf68 | Jan Kiszka | } |
710 | ef3adf68 | Jan Kiszka | if (bitmap & (1 << (*p - 'a'))) { |
711 | ef3adf68 | Jan Kiszka | fprintf(stderr, "Boot device '%c' was given twice\n", *p);
|
712 | ef3adf68 | Jan Kiszka | exit(1);
|
713 | ef3adf68 | Jan Kiszka | } |
714 | ef3adf68 | Jan Kiszka | bitmap |= 1 << (*p - 'a'); |
715 | ef3adf68 | Jan Kiszka | } |
716 | ef3adf68 | Jan Kiszka | } |
717 | ef3adf68 | Jan Kiszka | |
718 | e0f084bf | Jan Kiszka | static void restore_boot_devices(void *opaque) |
719 | e0f084bf | Jan Kiszka | { |
720 | e0f084bf | Jan Kiszka | char *standard_boot_devices = opaque;
|
721 | 37905d6a | Alex Williamson | static int first = 1; |
722 | 37905d6a | Alex Williamson | |
723 | 37905d6a | Alex Williamson | /* Restore boot order and remove ourselves after the first boot */
|
724 | 37905d6a | Alex Williamson | if (first) {
|
725 | 37905d6a | Alex Williamson | first = 0;
|
726 | 37905d6a | Alex Williamson | return;
|
727 | 37905d6a | Alex Williamson | } |
728 | e0f084bf | Jan Kiszka | |
729 | e0f084bf | Jan Kiszka | qemu_boot_set(standard_boot_devices); |
730 | e0f084bf | Jan Kiszka | |
731 | e0f084bf | Jan Kiszka | qemu_unregister_reset(restore_boot_devices, standard_boot_devices); |
732 | e0f084bf | Jan Kiszka | qemu_free(standard_boot_devices); |
733 | e0f084bf | Jan Kiszka | } |
734 | e0f084bf | Jan Kiszka | |
735 | 1ca4d09a | Gleb Natapov | void add_boot_device_path(int32_t bootindex, DeviceState *dev,
|
736 | 1ca4d09a | Gleb Natapov | const char *suffix) |
737 | 1ca4d09a | Gleb Natapov | { |
738 | 1ca4d09a | Gleb Natapov | FWBootEntry *node, *i; |
739 | 1ca4d09a | Gleb Natapov | |
740 | 1ca4d09a | Gleb Natapov | if (bootindex < 0) { |
741 | 1ca4d09a | Gleb Natapov | return;
|
742 | 1ca4d09a | Gleb Natapov | } |
743 | 1ca4d09a | Gleb Natapov | |
744 | 1ca4d09a | Gleb Natapov | assert(dev != NULL || suffix != NULL); |
745 | 1ca4d09a | Gleb Natapov | |
746 | 1ca4d09a | Gleb Natapov | node = qemu_mallocz(sizeof(FWBootEntry));
|
747 | 1ca4d09a | Gleb Natapov | node->bootindex = bootindex; |
748 | 4fef930a | Gleb Natapov | node->suffix = suffix ? qemu_strdup(suffix) : NULL;
|
749 | 1ca4d09a | Gleb Natapov | node->dev = dev; |
750 | 1ca4d09a | Gleb Natapov | |
751 | 1ca4d09a | Gleb Natapov | QTAILQ_FOREACH(i, &fw_boot_order, link) { |
752 | 1ca4d09a | Gleb Natapov | if (i->bootindex == bootindex) {
|
753 | 1ca4d09a | Gleb Natapov | fprintf(stderr, "Two devices with same boot index %d\n", bootindex);
|
754 | 1ca4d09a | Gleb Natapov | exit(1);
|
755 | 1ca4d09a | Gleb Natapov | } else if (i->bootindex < bootindex) { |
756 | 1ca4d09a | Gleb Natapov | continue;
|
757 | 1ca4d09a | Gleb Natapov | } |
758 | 1ca4d09a | Gleb Natapov | QTAILQ_INSERT_BEFORE(i, node, link); |
759 | 1ca4d09a | Gleb Natapov | return;
|
760 | 1ca4d09a | Gleb Natapov | } |
761 | 1ca4d09a | Gleb Natapov | QTAILQ_INSERT_TAIL(&fw_boot_order, node, link); |
762 | 1ca4d09a | Gleb Natapov | } |
763 | 1ca4d09a | Gleb Natapov | |
764 | 962630f2 | Gleb Natapov | /*
|
765 | 962630f2 | Gleb Natapov | * This function returns null terminated string that consist of new line
|
766 | 71785aba | Brad Hards | * separated device paths.
|
767 | 962630f2 | Gleb Natapov | *
|
768 | 962630f2 | Gleb Natapov | * memory pointed by "size" is assigned total length of the array in bytes
|
769 | 962630f2 | Gleb Natapov | *
|
770 | 962630f2 | Gleb Natapov | */
|
771 | 962630f2 | Gleb Natapov | char *get_boot_devices_list(uint32_t *size)
|
772 | 962630f2 | Gleb Natapov | { |
773 | 962630f2 | Gleb Natapov | FWBootEntry *i; |
774 | 962630f2 | Gleb Natapov | uint32_t total = 0;
|
775 | 962630f2 | Gleb Natapov | char *list = NULL; |
776 | 962630f2 | Gleb Natapov | |
777 | 962630f2 | Gleb Natapov | QTAILQ_FOREACH(i, &fw_boot_order, link) { |
778 | 962630f2 | Gleb Natapov | char *devpath = NULL, *bootpath; |
779 | 962630f2 | Gleb Natapov | int len;
|
780 | 962630f2 | Gleb Natapov | |
781 | 962630f2 | Gleb Natapov | if (i->dev) {
|
782 | 962630f2 | Gleb Natapov | devpath = qdev_get_fw_dev_path(i->dev); |
783 | 962630f2 | Gleb Natapov | assert(devpath); |
784 | 962630f2 | Gleb Natapov | } |
785 | 962630f2 | Gleb Natapov | |
786 | 962630f2 | Gleb Natapov | if (i->suffix && devpath) {
|
787 | 4fd37a98 | Blue Swirl | size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1;
|
788 | 4fd37a98 | Blue Swirl | |
789 | 4fd37a98 | Blue Swirl | bootpath = qemu_malloc(bootpathlen); |
790 | 4fd37a98 | Blue Swirl | snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix);
|
791 | 962630f2 | Gleb Natapov | qemu_free(devpath); |
792 | 962630f2 | Gleb Natapov | } else if (devpath) { |
793 | 962630f2 | Gleb Natapov | bootpath = devpath; |
794 | 962630f2 | Gleb Natapov | } else {
|
795 | 4fef930a | Gleb Natapov | bootpath = qemu_strdup(i->suffix); |
796 | 962630f2 | Gleb Natapov | assert(bootpath); |
797 | 962630f2 | Gleb Natapov | } |
798 | 962630f2 | Gleb Natapov | |
799 | 962630f2 | Gleb Natapov | if (total) {
|
800 | 962630f2 | Gleb Natapov | list[total-1] = '\n'; |
801 | 962630f2 | Gleb Natapov | } |
802 | 962630f2 | Gleb Natapov | len = strlen(bootpath) + 1;
|
803 | 962630f2 | Gleb Natapov | list = qemu_realloc(list, total + len); |
804 | 962630f2 | Gleb Natapov | memcpy(&list[total], bootpath, len); |
805 | 962630f2 | Gleb Natapov | total += len; |
806 | 962630f2 | Gleb Natapov | qemu_free(bootpath); |
807 | 962630f2 | Gleb Natapov | } |
808 | 962630f2 | Gleb Natapov | |
809 | 962630f2 | Gleb Natapov | *size = total; |
810 | 962630f2 | Gleb Natapov | |
811 | 962630f2 | Gleb Natapov | return list;
|
812 | 962630f2 | Gleb Natapov | } |
813 | 962630f2 | Gleb Natapov | |
814 | 268a362c | aliguori | static void numa_add(const char *optarg) |
815 | 268a362c | aliguori | { |
816 | 268a362c | aliguori | char option[128]; |
817 | 268a362c | aliguori | char *endptr;
|
818 | 268a362c | aliguori | unsigned long long value, endvalue; |
819 | 268a362c | aliguori | int nodenr;
|
820 | 268a362c | aliguori | |
821 | 268a362c | aliguori | optarg = get_opt_name(option, 128, optarg, ',') + 1; |
822 | 268a362c | aliguori | if (!strcmp(option, "node")) { |
823 | 268a362c | aliguori | if (get_param_value(option, 128, "nodeid", optarg) == 0) { |
824 | 268a362c | aliguori | nodenr = nb_numa_nodes; |
825 | 268a362c | aliguori | } else {
|
826 | 268a362c | aliguori | nodenr = strtoull(option, NULL, 10); |
827 | 268a362c | aliguori | } |
828 | 268a362c | aliguori | |
829 | 268a362c | aliguori | if (get_param_value(option, 128, "mem", optarg) == 0) { |
830 | 268a362c | aliguori | node_mem[nodenr] = 0;
|
831 | 268a362c | aliguori | } else {
|
832 | 70b4f4bb | Jes Sorensen | int64_t sval; |
833 | 9f9b17a4 | Jes Sorensen | sval = strtosz(option, NULL);
|
834 | 9f9b17a4 | Jes Sorensen | if (sval < 0) { |
835 | 9f9b17a4 | Jes Sorensen | fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg);
|
836 | 9f9b17a4 | Jes Sorensen | exit(1);
|
837 | 268a362c | aliguori | } |
838 | 9f9b17a4 | Jes Sorensen | node_mem[nodenr] = sval; |
839 | 268a362c | aliguori | } |
840 | 268a362c | aliguori | if (get_param_value(option, 128, "cpus", optarg) == 0) { |
841 | 268a362c | aliguori | node_cpumask[nodenr] = 0;
|
842 | 268a362c | aliguori | } else {
|
843 | 268a362c | aliguori | value = strtoull(option, &endptr, 10);
|
844 | 268a362c | aliguori | if (value >= 64) { |
845 | 268a362c | aliguori | value = 63;
|
846 | 268a362c | aliguori | fprintf(stderr, "only 64 CPUs in NUMA mode supported.\n");
|
847 | 268a362c | aliguori | } else {
|
848 | 268a362c | aliguori | if (*endptr == '-') { |
849 | 268a362c | aliguori | endvalue = strtoull(endptr+1, &endptr, 10); |
850 | 268a362c | aliguori | if (endvalue >= 63) { |
851 | 268a362c | aliguori | endvalue = 62;
|
852 | 268a362c | aliguori | fprintf(stderr, |
853 | 268a362c | aliguori | "only 63 CPUs in NUMA mode supported.\n");
|
854 | 268a362c | aliguori | } |
855 | 0dfbd514 | Paolo Bonzini | value = (2ULL << endvalue) - (1ULL << value); |
856 | 268a362c | aliguori | } else {
|
857 | 0dfbd514 | Paolo Bonzini | value = 1ULL << value;
|
858 | 268a362c | aliguori | } |
859 | 268a362c | aliguori | } |
860 | 268a362c | aliguori | node_cpumask[nodenr] = value; |
861 | 268a362c | aliguori | } |
862 | 268a362c | aliguori | nb_numa_nodes++; |
863 | 268a362c | aliguori | } |
864 | 268a362c | aliguori | return;
|
865 | 268a362c | aliguori | } |
866 | 268a362c | aliguori | |
867 | dc6b1c09 | Andre Przywara | static void smp_parse(const char *optarg) |
868 | dc6b1c09 | Andre Przywara | { |
869 | dc6b1c09 | Andre Przywara | int smp, sockets = 0, threads = 0, cores = 0; |
870 | dc6b1c09 | Andre Przywara | char *endptr;
|
871 | dc6b1c09 | Andre Przywara | char option[128]; |
872 | dc6b1c09 | Andre Przywara | |
873 | dc6b1c09 | Andre Przywara | smp = strtoul(optarg, &endptr, 10);
|
874 | dc6b1c09 | Andre Przywara | if (endptr != optarg) {
|
875 | dc6b1c09 | Andre Przywara | if (*endptr == ',') { |
876 | dc6b1c09 | Andre Przywara | endptr++; |
877 | dc6b1c09 | Andre Przywara | } |
878 | dc6b1c09 | Andre Przywara | } |
879 | dc6b1c09 | Andre Przywara | if (get_param_value(option, 128, "sockets", endptr) != 0) |
880 | dc6b1c09 | Andre Przywara | sockets = strtoull(option, NULL, 10); |
881 | dc6b1c09 | Andre Przywara | if (get_param_value(option, 128, "cores", endptr) != 0) |
882 | dc6b1c09 | Andre Przywara | cores = strtoull(option, NULL, 10); |
883 | dc6b1c09 | Andre Przywara | if (get_param_value(option, 128, "threads", endptr) != 0) |
884 | dc6b1c09 | Andre Przywara | threads = strtoull(option, NULL, 10); |
885 | dc6b1c09 | Andre Przywara | if (get_param_value(option, 128, "maxcpus", endptr) != 0) |
886 | dc6b1c09 | Andre Przywara | max_cpus = strtoull(option, NULL, 10); |
887 | dc6b1c09 | Andre Przywara | |
888 | dc6b1c09 | Andre Przywara | /* compute missing values, prefer sockets over cores over threads */
|
889 | dc6b1c09 | Andre Przywara | if (smp == 0 || sockets == 0) { |
890 | dc6b1c09 | Andre Przywara | sockets = sockets > 0 ? sockets : 1; |
891 | dc6b1c09 | Andre Przywara | cores = cores > 0 ? cores : 1; |
892 | dc6b1c09 | Andre Przywara | threads = threads > 0 ? threads : 1; |
893 | dc6b1c09 | Andre Przywara | if (smp == 0) { |
894 | dc6b1c09 | Andre Przywara | smp = cores * threads * sockets; |
895 | dc6b1c09 | Andre Przywara | } |
896 | dc6b1c09 | Andre Przywara | } else {
|
897 | dc6b1c09 | Andre Przywara | if (cores == 0) { |
898 | dc6b1c09 | Andre Przywara | threads = threads > 0 ? threads : 1; |
899 | dc6b1c09 | Andre Przywara | cores = smp / (sockets * threads); |
900 | dc6b1c09 | Andre Przywara | } else {
|
901 | dca98169 | Joel Schopp | threads = smp / (cores * sockets); |
902 | dc6b1c09 | Andre Przywara | } |
903 | dc6b1c09 | Andre Przywara | } |
904 | dc6b1c09 | Andre Przywara | smp_cpus = smp; |
905 | dc6b1c09 | Andre Przywara | smp_cores = cores > 0 ? cores : 1; |
906 | dc6b1c09 | Andre Przywara | smp_threads = threads > 0 ? threads : 1; |
907 | dc6b1c09 | Andre Przywara | if (max_cpus == 0) |
908 | dc6b1c09 | Andre Przywara | max_cpus = smp_cpus; |
909 | dc6b1c09 | Andre Przywara | } |
910 | dc6b1c09 | Andre Przywara | |
911 | 330d0414 | bellard | /***********************************************************/
|
912 | a594cfbf | bellard | /* USB devices */
|
913 | a594cfbf | bellard | |
914 | fb08000c | Markus Armbruster | static int usb_device_add(const char *devname) |
915 | a594cfbf | bellard | { |
916 | a594cfbf | bellard | const char *p; |
917 | a5d2f727 | Gerd Hoffmann | USBDevice *dev = NULL;
|
918 | a594cfbf | bellard | |
919 | a5d2f727 | Gerd Hoffmann | if (!usb_enabled)
|
920 | a594cfbf | bellard | return -1; |
921 | a594cfbf | bellard | |
922 | 0958b4cc | Gerd Hoffmann | /* drivers with .usbdevice_name entry in USBDeviceInfo */
|
923 | 0958b4cc | Gerd Hoffmann | dev = usbdevice_create(devname); |
924 | 0958b4cc | Gerd Hoffmann | if (dev)
|
925 | 0958b4cc | Gerd Hoffmann | goto done;
|
926 | 0958b4cc | Gerd Hoffmann | |
927 | a5d2f727 | Gerd Hoffmann | /* the other ones */
|
928 | e447fc63 | Gerd Hoffmann | #ifndef CONFIG_LINUX
|
929 | e447fc63 | Gerd Hoffmann | /* only the linux version is qdev-ified, usb-bsd still needs this */
|
930 | a594cfbf | bellard | if (strstart(devname, "host:", &p)) { |
931 | a594cfbf | bellard | dev = usb_host_device_open(p); |
932 | e447fc63 | Gerd Hoffmann | } else
|
933 | e447fc63 | Gerd Hoffmann | #endif
|
934 | e447fc63 | Gerd Hoffmann | if (!strcmp(devname, "bt") || strstart(devname, "bt:", &p)) { |
935 | dc72ac14 | balrog | dev = usb_bt_init(devname[2] ? hci_init(p) :
|
936 | dc72ac14 | balrog | bt_new_hci(qemu_find_bt_vlan(0)));
|
937 | a594cfbf | bellard | } else {
|
938 | a594cfbf | bellard | return -1; |
939 | a594cfbf | bellard | } |
940 | 0d92ed30 | pbrook | if (!dev)
|
941 | 0d92ed30 | pbrook | return -1; |
942 | 0d92ed30 | pbrook | |
943 | a5d2f727 | Gerd Hoffmann | done:
|
944 | a594cfbf | bellard | return 0; |
945 | a594cfbf | bellard | } |
946 | a594cfbf | bellard | |
947 | 1f3870ab | aliguori | static int usb_device_del(const char *devname) |
948 | 1f3870ab | aliguori | { |
949 | 1f3870ab | aliguori | int bus_num, addr;
|
950 | 1f3870ab | aliguori | const char *p; |
951 | 1f3870ab | aliguori | |
952 | 5d0c5750 | aliguori | if (strstart(devname, "host:", &p)) |
953 | 5d0c5750 | aliguori | return usb_host_device_close(p);
|
954 | 5d0c5750 | aliguori | |
955 | a5d2f727 | Gerd Hoffmann | if (!usb_enabled)
|
956 | 1f3870ab | aliguori | return -1; |
957 | 1f3870ab | aliguori | |
958 | 1f3870ab | aliguori | p = strchr(devname, '.');
|
959 | 1f3870ab | aliguori | if (!p)
|
960 | 1f3870ab | aliguori | return -1; |
961 | 1f3870ab | aliguori | bus_num = strtoul(devname, NULL, 0); |
962 | 1f3870ab | aliguori | addr = strtoul(p + 1, NULL, 0); |
963 | 1f3870ab | aliguori | |
964 | a5d2f727 | Gerd Hoffmann | return usb_device_delete_addr(bus_num, addr);
|
965 | 1f3870ab | aliguori | } |
966 | 1f3870ab | aliguori | |
967 | bd3c948d | Gerd Hoffmann | static int usb_parse(const char *cmdline) |
968 | bd3c948d | Gerd Hoffmann | { |
969 | 59d1c1c2 | Scott Tsai | int r;
|
970 | fb08000c | Markus Armbruster | r = usb_device_add(cmdline); |
971 | 59d1c1c2 | Scott Tsai | if (r < 0) { |
972 | 59d1c1c2 | Scott Tsai | fprintf(stderr, "qemu: could not add USB device '%s'\n", cmdline);
|
973 | 59d1c1c2 | Scott Tsai | } |
974 | 59d1c1c2 | Scott Tsai | return r;
|
975 | bd3c948d | Gerd Hoffmann | } |
976 | bd3c948d | Gerd Hoffmann | |
977 | d54908a5 | Luiz Capitulino | void do_usb_add(Monitor *mon, const QDict *qdict) |
978 | a594cfbf | bellard | { |
979 | 59d1c1c2 | Scott Tsai | const char *devname = qdict_get_str(qdict, "devname"); |
980 | fb08000c | Markus Armbruster | if (usb_device_add(devname) < 0) { |
981 | 1ecda02b | Markus Armbruster | error_report("could not add USB device '%s'", devname);
|
982 | 59d1c1c2 | Scott Tsai | } |
983 | a594cfbf | bellard | } |
984 | a594cfbf | bellard | |
985 | d54908a5 | Luiz Capitulino | void do_usb_del(Monitor *mon, const QDict *qdict) |
986 | a594cfbf | bellard | { |
987 | 59d1c1c2 | Scott Tsai | const char *devname = qdict_get_str(qdict, "devname"); |
988 | 59d1c1c2 | Scott Tsai | if (usb_device_del(devname) < 0) { |
989 | 1ecda02b | Markus Armbruster | error_report("could not delete USB device '%s'", devname);
|
990 | 59d1c1c2 | Scott Tsai | } |
991 | a594cfbf | bellard | } |
992 | a594cfbf | bellard | |
993 | f7cce898 | bellard | /***********************************************************/
|
994 | 201a51fc | balrog | /* PCMCIA/Cardbus */
|
995 | 201a51fc | balrog | |
996 | 201a51fc | balrog | static struct pcmcia_socket_entry_s { |
997 | bc24a225 | Paul Brook | PCMCIASocket *socket; |
998 | 201a51fc | balrog | struct pcmcia_socket_entry_s *next;
|
999 | 201a51fc | balrog | } *pcmcia_sockets = 0;
|
1000 | 201a51fc | balrog | |
1001 | bc24a225 | Paul Brook | void pcmcia_socket_register(PCMCIASocket *socket)
|
1002 | 201a51fc | balrog | { |
1003 | 201a51fc | balrog | struct pcmcia_socket_entry_s *entry;
|
1004 | 201a51fc | balrog | |
1005 | 201a51fc | balrog | entry = qemu_malloc(sizeof(struct pcmcia_socket_entry_s)); |
1006 | 201a51fc | balrog | entry->socket = socket; |
1007 | 201a51fc | balrog | entry->next = pcmcia_sockets; |
1008 | 201a51fc | balrog | pcmcia_sockets = entry; |
1009 | 201a51fc | balrog | } |
1010 | 201a51fc | balrog | |
1011 | bc24a225 | Paul Brook | void pcmcia_socket_unregister(PCMCIASocket *socket)
|
1012 | 201a51fc | balrog | { |
1013 | 201a51fc | balrog | struct pcmcia_socket_entry_s *entry, **ptr;
|
1014 | 201a51fc | balrog | |
1015 | 201a51fc | balrog | ptr = &pcmcia_sockets; |
1016 | 201a51fc | balrog | for (entry = *ptr; entry; ptr = &entry->next, entry = *ptr)
|
1017 | 201a51fc | balrog | if (entry->socket == socket) {
|
1018 | 201a51fc | balrog | *ptr = entry->next; |
1019 | 201a51fc | balrog | qemu_free(entry); |
1020 | 201a51fc | balrog | } |
1021 | 201a51fc | balrog | } |
1022 | 201a51fc | balrog | |
1023 | 376253ec | aliguori | void pcmcia_info(Monitor *mon)
|
1024 | 201a51fc | balrog | { |
1025 | 201a51fc | balrog | struct pcmcia_socket_entry_s *iter;
|
1026 | 376253ec | aliguori | |
1027 | 201a51fc | balrog | if (!pcmcia_sockets)
|
1028 | 376253ec | aliguori | monitor_printf(mon, "No PCMCIA sockets\n");
|
1029 | 201a51fc | balrog | |
1030 | 201a51fc | balrog | for (iter = pcmcia_sockets; iter; iter = iter->next)
|
1031 | 376253ec | aliguori | monitor_printf(mon, "%s: %s\n", iter->socket->slot_string,
|
1032 | 376253ec | aliguori | iter->socket->attached ? iter->socket->card_string : |
1033 | 376253ec | aliguori | "Empty");
|
1034 | 201a51fc | balrog | } |
1035 | 201a51fc | balrog | |
1036 | 201a51fc | balrog | /***********************************************************/
|
1037 | cc1daa40 | bellard | /* machine registration */
|
1038 | cc1daa40 | bellard | |
1039 | bdaf78e0 | blueswir1 | static QEMUMachine *first_machine = NULL; |
1040 | 6f338c34 | aliguori | QEMUMachine *current_machine = NULL;
|
1041 | cc1daa40 | bellard | |
1042 | cc1daa40 | bellard | int qemu_register_machine(QEMUMachine *m)
|
1043 | cc1daa40 | bellard | { |
1044 | cc1daa40 | bellard | QEMUMachine **pm; |
1045 | cc1daa40 | bellard | pm = &first_machine; |
1046 | cc1daa40 | bellard | while (*pm != NULL) |
1047 | cc1daa40 | bellard | pm = &(*pm)->next; |
1048 | cc1daa40 | bellard | m->next = NULL;
|
1049 | cc1daa40 | bellard | *pm = m; |
1050 | cc1daa40 | bellard | return 0; |
1051 | cc1daa40 | bellard | } |
1052 | cc1daa40 | bellard | |
1053 | 9596ebb7 | pbrook | static QEMUMachine *find_machine(const char *name) |
1054 | cc1daa40 | bellard | { |
1055 | cc1daa40 | bellard | QEMUMachine *m; |
1056 | cc1daa40 | bellard | |
1057 | cc1daa40 | bellard | for(m = first_machine; m != NULL; m = m->next) { |
1058 | cc1daa40 | bellard | if (!strcmp(m->name, name))
|
1059 | cc1daa40 | bellard | return m;
|
1060 | 3f6599e6 | Mark McLoughlin | if (m->alias && !strcmp(m->alias, name))
|
1061 | 3f6599e6 | Mark McLoughlin | return m;
|
1062 | cc1daa40 | bellard | } |
1063 | cc1daa40 | bellard | return NULL; |
1064 | cc1daa40 | bellard | } |
1065 | cc1daa40 | bellard | |
1066 | 0c257437 | Anthony Liguori | static QEMUMachine *find_default_machine(void) |
1067 | 0c257437 | Anthony Liguori | { |
1068 | 0c257437 | Anthony Liguori | QEMUMachine *m; |
1069 | 0c257437 | Anthony Liguori | |
1070 | 0c257437 | Anthony Liguori | for(m = first_machine; m != NULL; m = m->next) { |
1071 | 0c257437 | Anthony Liguori | if (m->is_default) {
|
1072 | 0c257437 | Anthony Liguori | return m;
|
1073 | 0c257437 | Anthony Liguori | } |
1074 | 0c257437 | Anthony Liguori | } |
1075 | 0c257437 | Anthony Liguori | return NULL; |
1076 | 0c257437 | Anthony Liguori | } |
1077 | 0c257437 | Anthony Liguori | |
1078 | cc1daa40 | bellard | /***********************************************************/
|
1079 | 8a7ddc38 | bellard | /* main execution loop */
|
1080 | 8a7ddc38 | bellard | |
1081 | 9596ebb7 | pbrook | static void gui_update(void *opaque) |
1082 | 8a7ddc38 | bellard | { |
1083 | 7d957bd8 | aliguori | uint64_t interval = GUI_REFRESH_INTERVAL; |
1084 | 740733bb | ths | DisplayState *ds = opaque; |
1085 | 7d957bd8 | aliguori | DisplayChangeListener *dcl = ds->listeners; |
1086 | 7d957bd8 | aliguori | |
1087 | 62a2744c | Sheng Yang | qemu_flush_coalesced_mmio_buffer(); |
1088 | 7d957bd8 | aliguori | dpy_refresh(ds); |
1089 | 7d957bd8 | aliguori | |
1090 | 7d957bd8 | aliguori | while (dcl != NULL) { |
1091 | 7d957bd8 | aliguori | if (dcl->gui_timer_interval &&
|
1092 | 7d957bd8 | aliguori | dcl->gui_timer_interval < interval) |
1093 | 7d957bd8 | aliguori | interval = dcl->gui_timer_interval; |
1094 | 7d957bd8 | aliguori | dcl = dcl->next; |
1095 | 7d957bd8 | aliguori | } |
1096 | 7bd427d8 | Paolo Bonzini | qemu_mod_timer(ds->gui_timer, interval + qemu_get_clock_ms(rt_clock)); |
1097 | 8a7ddc38 | bellard | } |
1098 | 8a7ddc38 | bellard | |
1099 | 9043b62d | blueswir1 | static void nographic_update(void *opaque) |
1100 | 9043b62d | blueswir1 | { |
1101 | 9043b62d | blueswir1 | uint64_t interval = GUI_REFRESH_INTERVAL; |
1102 | 9043b62d | blueswir1 | |
1103 | 62a2744c | Sheng Yang | qemu_flush_coalesced_mmio_buffer(); |
1104 | 7bd427d8 | Paolo Bonzini | qemu_mod_timer(nographic_timer, interval + qemu_get_clock_ms(rt_clock)); |
1105 | 9043b62d | blueswir1 | } |
1106 | 9043b62d | blueswir1 | |
1107 | 0bd48850 | bellard | struct vm_change_state_entry {
|
1108 | 0bd48850 | bellard | VMChangeStateHandler *cb; |
1109 | 0bd48850 | bellard | void *opaque;
|
1110 | 72cf2d4f | Blue Swirl | QLIST_ENTRY (vm_change_state_entry) entries; |
1111 | 0bd48850 | bellard | }; |
1112 | 0bd48850 | bellard | |
1113 | 72cf2d4f | Blue Swirl | static QLIST_HEAD(vm_change_state_head, vm_change_state_entry) vm_change_state_head;
|
1114 | 0bd48850 | bellard | |
1115 | 0bd48850 | bellard | VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, |
1116 | 0bd48850 | bellard | void *opaque)
|
1117 | 0bd48850 | bellard | { |
1118 | 0bd48850 | bellard | VMChangeStateEntry *e; |
1119 | 0bd48850 | bellard | |
1120 | 0bd48850 | bellard | e = qemu_mallocz(sizeof (*e));
|
1121 | 0bd48850 | bellard | |
1122 | 0bd48850 | bellard | e->cb = cb; |
1123 | 0bd48850 | bellard | e->opaque = opaque; |
1124 | 72cf2d4f | Blue Swirl | QLIST_INSERT_HEAD(&vm_change_state_head, e, entries); |
1125 | 0bd48850 | bellard | return e;
|
1126 | 0bd48850 | bellard | } |
1127 | 0bd48850 | bellard | |
1128 | 0bd48850 | bellard | void qemu_del_vm_change_state_handler(VMChangeStateEntry *e)
|
1129 | 0bd48850 | bellard | { |
1130 | 72cf2d4f | Blue Swirl | QLIST_REMOVE (e, entries); |
1131 | 0bd48850 | bellard | qemu_free (e); |
1132 | 0bd48850 | bellard | } |
1133 | 0bd48850 | bellard | |
1134 | 296af7c9 | Blue Swirl | void vm_state_notify(int running, int reason) |
1135 | 0bd48850 | bellard | { |
1136 | 0bd48850 | bellard | VMChangeStateEntry *e; |
1137 | 0bd48850 | bellard | |
1138 | 94b0b5ff | Stefan Hajnoczi | trace_vm_state_notify(running, reason); |
1139 | 94b0b5ff | Stefan Hajnoczi | |
1140 | 0bd48850 | bellard | for (e = vm_change_state_head.lh_first; e; e = e->entries.le_next) {
|
1141 | 9781e040 | aliguori | e->cb(e->opaque, running, reason); |
1142 | 0bd48850 | bellard | } |
1143 | 0bd48850 | bellard | } |
1144 | 0bd48850 | bellard | |
1145 | 8a7ddc38 | bellard | void vm_start(void) |
1146 | 8a7ddc38 | bellard | { |
1147 | 8a7ddc38 | bellard | if (!vm_running) {
|
1148 | 8a7ddc38 | bellard | cpu_enable_ticks(); |
1149 | 8a7ddc38 | bellard | vm_running = 1;
|
1150 | 9781e040 | aliguori | vm_state_notify(1, 0); |
1151 | d6dc3d42 | aliguori | resume_all_vcpus(); |
1152 | 6ed2c484 | Luiz Capitulino | monitor_protocol_event(QEVENT_RESUME, NULL);
|
1153 | 8a7ddc38 | bellard | } |
1154 | 8a7ddc38 | bellard | } |
1155 | 8a7ddc38 | bellard | |
1156 | bb0c6722 | bellard | /* reset/shutdown handler */
|
1157 | bb0c6722 | bellard | |
1158 | bb0c6722 | bellard | typedef struct QEMUResetEntry { |
1159 | 72cf2d4f | Blue Swirl | QTAILQ_ENTRY(QEMUResetEntry) entry; |
1160 | bb0c6722 | bellard | QEMUResetHandler *func; |
1161 | bb0c6722 | bellard | void *opaque;
|
1162 | bb0c6722 | bellard | } QEMUResetEntry; |
1163 | bb0c6722 | bellard | |
1164 | 72cf2d4f | Blue Swirl | static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
|
1165 | 72cf2d4f | Blue Swirl | QTAILQ_HEAD_INITIALIZER(reset_handlers); |
1166 | bb0c6722 | bellard | static int reset_requested; |
1167 | f64622c4 | Gleb Natapov | static int shutdown_requested, shutdown_signal = -1; |
1168 | f64622c4 | Gleb Natapov | static pid_t shutdown_pid;
|
1169 | 3475187d | bellard | static int powerdown_requested; |
1170 | 8cf71710 | Jan Kiszka | static int debug_requested; |
1171 | 8cf71710 | Jan Kiszka | static int vmstop_requested; |
1172 | bb0c6722 | bellard | |
1173 | 1291eb35 | Anthony PERARD | int qemu_shutdown_requested_get(void) |
1174 | 1291eb35 | Anthony PERARD | { |
1175 | 1291eb35 | Anthony PERARD | return shutdown_requested;
|
1176 | 1291eb35 | Anthony PERARD | } |
1177 | 1291eb35 | Anthony PERARD | |
1178 | 1291eb35 | Anthony PERARD | int qemu_reset_requested_get(void) |
1179 | 1291eb35 | Anthony PERARD | { |
1180 | 1291eb35 | Anthony PERARD | return reset_requested;
|
1181 | 1291eb35 | Anthony PERARD | } |
1182 | 1291eb35 | Anthony PERARD | |
1183 | cf7a2fe2 | aurel32 | int qemu_shutdown_requested(void) |
1184 | cf7a2fe2 | aurel32 | { |
1185 | cf7a2fe2 | aurel32 | int r = shutdown_requested;
|
1186 | cf7a2fe2 | aurel32 | shutdown_requested = 0;
|
1187 | cf7a2fe2 | aurel32 | return r;
|
1188 | cf7a2fe2 | aurel32 | } |
1189 | cf7a2fe2 | aurel32 | |
1190 | f64622c4 | Gleb Natapov | void qemu_kill_report(void) |
1191 | f64622c4 | Gleb Natapov | { |
1192 | f64622c4 | Gleb Natapov | if (shutdown_signal != -1) { |
1193 | f1d3fb04 | Peter Maydell | fprintf(stderr, "qemu: terminating on signal %d", shutdown_signal);
|
1194 | f1d3fb04 | Peter Maydell | if (shutdown_pid == 0) { |
1195 | f1d3fb04 | Peter Maydell | /* This happens for eg ^C at the terminal, so it's worth
|
1196 | f1d3fb04 | Peter Maydell | * avoiding printing an odd message in that case.
|
1197 | f1d3fb04 | Peter Maydell | */
|
1198 | f1d3fb04 | Peter Maydell | fputc('\n', stderr);
|
1199 | f1d3fb04 | Peter Maydell | } else {
|
1200 | 953ffe0f | Andreas Fรคrber | fprintf(stderr, " from pid " FMT_pid "\n", shutdown_pid); |
1201 | f1d3fb04 | Peter Maydell | } |
1202 | f64622c4 | Gleb Natapov | shutdown_signal = -1;
|
1203 | f64622c4 | Gleb Natapov | } |
1204 | f64622c4 | Gleb Natapov | } |
1205 | f64622c4 | Gleb Natapov | |
1206 | cf7a2fe2 | aurel32 | int qemu_reset_requested(void) |
1207 | cf7a2fe2 | aurel32 | { |
1208 | cf7a2fe2 | aurel32 | int r = reset_requested;
|
1209 | cf7a2fe2 | aurel32 | reset_requested = 0;
|
1210 | cf7a2fe2 | aurel32 | return r;
|
1211 | cf7a2fe2 | aurel32 | } |
1212 | cf7a2fe2 | aurel32 | |
1213 | cf7a2fe2 | aurel32 | int qemu_powerdown_requested(void) |
1214 | cf7a2fe2 | aurel32 | { |
1215 | cf7a2fe2 | aurel32 | int r = powerdown_requested;
|
1216 | cf7a2fe2 | aurel32 | powerdown_requested = 0;
|
1217 | cf7a2fe2 | aurel32 | return r;
|
1218 | cf7a2fe2 | aurel32 | } |
1219 | cf7a2fe2 | aurel32 | |
1220 | e568902a | aliguori | static int qemu_debug_requested(void) |
1221 | e568902a | aliguori | { |
1222 | e568902a | aliguori | int r = debug_requested;
|
1223 | e568902a | aliguori | debug_requested = 0;
|
1224 | e568902a | aliguori | return r;
|
1225 | e568902a | aliguori | } |
1226 | e568902a | aliguori | |
1227 | 6e29f5da | aliguori | static int qemu_vmstop_requested(void) |
1228 | 6e29f5da | aliguori | { |
1229 | 6e29f5da | aliguori | int r = vmstop_requested;
|
1230 | 6e29f5da | aliguori | vmstop_requested = 0;
|
1231 | 6e29f5da | aliguori | return r;
|
1232 | 6e29f5da | aliguori | } |
1233 | 6e29f5da | aliguori | |
1234 | a08d4367 | Jan Kiszka | void qemu_register_reset(QEMUResetHandler *func, void *opaque) |
1235 | bb0c6722 | bellard | { |
1236 | 55ddfe8e | Jan Kiszka | QEMUResetEntry *re = qemu_mallocz(sizeof(QEMUResetEntry));
|
1237 | bb0c6722 | bellard | |
1238 | bb0c6722 | bellard | re->func = func; |
1239 | bb0c6722 | bellard | re->opaque = opaque; |
1240 | 72cf2d4f | Blue Swirl | QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); |
1241 | bb0c6722 | bellard | } |
1242 | bb0c6722 | bellard | |
1243 | dda9b29f | Jan Kiszka | void qemu_unregister_reset(QEMUResetHandler *func, void *opaque) |
1244 | bb0c6722 | bellard | { |
1245 | bb0c6722 | bellard | QEMUResetEntry *re; |
1246 | bb0c6722 | bellard | |
1247 | 72cf2d4f | Blue Swirl | QTAILQ_FOREACH(re, &reset_handlers, entry) { |
1248 | dda9b29f | Jan Kiszka | if (re->func == func && re->opaque == opaque) {
|
1249 | 72cf2d4f | Blue Swirl | QTAILQ_REMOVE(&reset_handlers, re, entry); |
1250 | dda9b29f | Jan Kiszka | qemu_free(re); |
1251 | dda9b29f | Jan Kiszka | return;
|
1252 | dda9b29f | Jan Kiszka | } |
1253 | dda9b29f | Jan Kiszka | } |
1254 | dda9b29f | Jan Kiszka | } |
1255 | dda9b29f | Jan Kiszka | |
1256 | e063eb1f | Jan Kiszka | void qemu_system_reset(bool report) |
1257 | dda9b29f | Jan Kiszka | { |
1258 | dda9b29f | Jan Kiszka | QEMUResetEntry *re, *nre; |
1259 | dda9b29f | Jan Kiszka | |
1260 | dda9b29f | Jan Kiszka | /* reset all devices */
|
1261 | 72cf2d4f | Blue Swirl | QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) { |
1262 | bb0c6722 | bellard | re->func(re->opaque); |
1263 | bb0c6722 | bellard | } |
1264 | e063eb1f | Jan Kiszka | if (report) {
|
1265 | e063eb1f | Jan Kiszka | monitor_protocol_event(QEVENT_RESET, NULL);
|
1266 | e063eb1f | Jan Kiszka | } |
1267 | ea375f9a | Jan Kiszka | cpu_synchronize_all_post_reset(); |
1268 | bb0c6722 | bellard | } |
1269 | bb0c6722 | bellard | |
1270 | bb0c6722 | bellard | void qemu_system_reset_request(void) |
1271 | bb0c6722 | bellard | { |
1272 | d1beab82 | bellard | if (no_reboot) {
|
1273 | d1beab82 | bellard | shutdown_requested = 1;
|
1274 | d1beab82 | bellard | } else {
|
1275 | d1beab82 | bellard | reset_requested = 1;
|
1276 | d1beab82 | bellard | } |
1277 | b4a3d965 | Jan Kiszka | cpu_stop_current(); |
1278 | d9f75a4e | aliguori | qemu_notify_event(); |
1279 | bb0c6722 | bellard | } |
1280 | bb0c6722 | bellard | |
1281 | f64622c4 | Gleb Natapov | void qemu_system_killed(int signal, pid_t pid) |
1282 | f64622c4 | Gleb Natapov | { |
1283 | f64622c4 | Gleb Natapov | shutdown_signal = signal; |
1284 | f64622c4 | Gleb Natapov | shutdown_pid = pid; |
1285 | f64622c4 | Gleb Natapov | qemu_system_shutdown_request(); |
1286 | f64622c4 | Gleb Natapov | } |
1287 | f64622c4 | Gleb Natapov | |
1288 | bb0c6722 | bellard | void qemu_system_shutdown_request(void) |
1289 | bb0c6722 | bellard | { |
1290 | bb0c6722 | bellard | shutdown_requested = 1;
|
1291 | d9f75a4e | aliguori | qemu_notify_event(); |
1292 | bb0c6722 | bellard | } |
1293 | bb0c6722 | bellard | |
1294 | 3475187d | bellard | void qemu_system_powerdown_request(void) |
1295 | 3475187d | bellard | { |
1296 | 3475187d | bellard | powerdown_requested = 1;
|
1297 | d9f75a4e | aliguori | qemu_notify_event(); |
1298 | d9f75a4e | aliguori | } |
1299 | d9f75a4e | aliguori | |
1300 | 8cf71710 | Jan Kiszka | void qemu_system_debug_request(void) |
1301 | 8cf71710 | Jan Kiszka | { |
1302 | 8cf71710 | Jan Kiszka | debug_requested = 1;
|
1303 | 83f338f7 | Jan Kiszka | qemu_notify_event(); |
1304 | 8cf71710 | Jan Kiszka | } |
1305 | 8cf71710 | Jan Kiszka | |
1306 | 8cf71710 | Jan Kiszka | void qemu_system_vmstop_request(int reason) |
1307 | 8cf71710 | Jan Kiszka | { |
1308 | 8cf71710 | Jan Kiszka | vmstop_requested = reason; |
1309 | 8cf71710 | Jan Kiszka | qemu_notify_event(); |
1310 | 8cf71710 | Jan Kiszka | } |
1311 | 8cf71710 | Jan Kiszka | |
1312 | d6f4ade2 | Paolo Bonzini | void main_loop_wait(int nonblocking) |
1313 | 56f3a5d0 | aliguori | { |
1314 | 56f3a5d0 | aliguori | fd_set rfds, wfds, xfds; |
1315 | 56f3a5d0 | aliguori | int ret, nfds;
|
1316 | 56f3a5d0 | aliguori | struct timeval tv;
|
1317 | d6f4ade2 | Paolo Bonzini | int timeout;
|
1318 | 56f3a5d0 | aliguori | |
1319 | d6f4ade2 | Paolo Bonzini | if (nonblocking)
|
1320 | d6f4ade2 | Paolo Bonzini | timeout = 0;
|
1321 | d6f4ade2 | Paolo Bonzini | else {
|
1322 | d6f4ade2 | Paolo Bonzini | timeout = qemu_calculate_timeout(); |
1323 | d6f4ade2 | Paolo Bonzini | qemu_bh_update_timeout(&timeout); |
1324 | d6f4ade2 | Paolo Bonzini | } |
1325 | 56f3a5d0 | aliguori | |
1326 | 0d93ca7c | Jes Sorensen | os_host_main_loop_wait(&timeout); |
1327 | 56f3a5d0 | aliguori | |
1328 | 02981419 | Paolo Bonzini | tv.tv_sec = timeout / 1000;
|
1329 | 02981419 | Paolo Bonzini | tv.tv_usec = (timeout % 1000) * 1000; |
1330 | 02981419 | Paolo Bonzini | |
1331 | fd1dff4b | bellard | /* poll any events */
|
1332 | fd1dff4b | bellard | /* XXX: separate device handlers from system ones */
|
1333 | 6abfbd79 | aliguori | nfds = -1;
|
1334 | fd1dff4b | bellard | FD_ZERO(&rfds); |
1335 | fd1dff4b | bellard | FD_ZERO(&wfds); |
1336 | e035649e | bellard | FD_ZERO(&xfds); |
1337 | 02981419 | Paolo Bonzini | qemu_iohandler_fill(&nfds, &rfds, &wfds, &xfds); |
1338 | d918f23e | Jan Kiszka | slirp_select_fill(&nfds, &rfds, &wfds, &xfds); |
1339 | d918f23e | Jan Kiszka | |
1340 | 4870852c | aliguori | qemu_mutex_unlock_iothread(); |
1341 | e035649e | bellard | ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv);
|
1342 | 4870852c | aliguori | qemu_mutex_lock_iothread(); |
1343 | d918f23e | Jan Kiszka | |
1344 | 02981419 | Paolo Bonzini | qemu_iohandler_poll(&rfds, &wfds, &xfds, ret); |
1345 | d918f23e | Jan Kiszka | slirp_select_poll(&rfds, &wfds, &xfds, (ret < 0));
|
1346 | c20709aa | bellard | |
1347 | b6964827 | Paolo Bonzini | qemu_run_all_timers(); |
1348 | 21d5d12b | Jan Kiszka | |
1349 | 423f0742 | pbrook | /* Check bottom-halves last in case any of the earlier events triggered
|
1350 | 423f0742 | pbrook | them. */
|
1351 | 423f0742 | pbrook | qemu_bh_poll(); |
1352 | 3b46e624 | ths | |
1353 | 5905b2e5 | bellard | } |
1354 | 5905b2e5 | bellard | |
1355 | 46481d39 | Jan Kiszka | #ifndef CONFIG_IOTHREAD
|
1356 | 46481d39 | Jan Kiszka | static int vm_request_pending(void) |
1357 | 43b96858 | aliguori | { |
1358 | 46481d39 | Jan Kiszka | return powerdown_requested ||
|
1359 | 46481d39 | Jan Kiszka | reset_requested || |
1360 | 46481d39 | Jan Kiszka | shutdown_requested || |
1361 | 46481d39 | Jan Kiszka | debug_requested || |
1362 | 46481d39 | Jan Kiszka | vmstop_requested; |
1363 | 43b96858 | aliguori | } |
1364 | 46481d39 | Jan Kiszka | #endif
|
1365 | 43b96858 | aliguori | |
1366 | d9c32310 | Blue Swirl | qemu_irq qemu_system_powerdown; |
1367 | d9c32310 | Blue Swirl | |
1368 | 43b96858 | aliguori | static void main_loop(void) |
1369 | 43b96858 | aliguori | { |
1370 | 8e1b90ec | Jan Kiszka | bool nonblocking = false; |
1371 | 8e1b90ec | Jan Kiszka | #ifdef CONFIG_PROFILER
|
1372 | 8e1b90ec | Jan Kiszka | int64_t ti; |
1373 | 8e1b90ec | Jan Kiszka | #endif
|
1374 | 6e29f5da | aliguori | int r;
|
1375 | e6e35b1e | aliguori | |
1376 | 7277e027 | Blue Swirl | qemu_main_loop_start(); |
1377 | d6dc3d42 | aliguori | |
1378 | 6e29f5da | aliguori | for (;;) {
|
1379 | d6dc3d42 | aliguori | #ifndef CONFIG_IOTHREAD
|
1380 | 46481d39 | Jan Kiszka | nonblocking = cpu_exec_all(); |
1381 | 46481d39 | Jan Kiszka | if (vm_request_pending()) {
|
1382 | 46481d39 | Jan Kiszka | nonblocking = true;
|
1383 | 46481d39 | Jan Kiszka | } |
1384 | d6dc3d42 | aliguori | #endif
|
1385 | 89bfc105 | bellard | #ifdef CONFIG_PROFILER
|
1386 | 46481d39 | Jan Kiszka | ti = profile_getclock(); |
1387 | 89bfc105 | bellard | #endif
|
1388 | 46481d39 | Jan Kiszka | main_loop_wait(nonblocking); |
1389 | 89bfc105 | bellard | #ifdef CONFIG_PROFILER
|
1390 | 46481d39 | Jan Kiszka | dev_time += profile_getclock() - ti; |
1391 | 89bfc105 | bellard | #endif
|
1392 | 43b96858 | aliguori | |
1393 | 8cf71710 | Jan Kiszka | if (qemu_debug_requested()) {
|
1394 | 8cf71710 | Jan Kiszka | vm_stop(VMSTOP_DEBUG); |
1395 | b1a15e7e | Luiz Capitulino | } |
1396 | 43b96858 | aliguori | if (qemu_shutdown_requested()) {
|
1397 | f64622c4 | Gleb Natapov | qemu_kill_report(); |
1398 | 242cd003 | Blue Swirl | monitor_protocol_event(QEVENT_SHUTDOWN, NULL);
|
1399 | 43b96858 | aliguori | if (no_shutdown) {
|
1400 | e07bbac5 | Jan Kiszka | vm_stop(VMSTOP_SHUTDOWN); |
1401 | 43b96858 | aliguori | no_shutdown = 0;
|
1402 | 43b96858 | aliguori | } else
|
1403 | 43b96858 | aliguori | break;
|
1404 | 43b96858 | aliguori | } |
1405 | d6dc3d42 | aliguori | if (qemu_reset_requested()) {
|
1406 | d6dc3d42 | aliguori | pause_all_vcpus(); |
1407 | a7ada151 | Jan Kiszka | cpu_synchronize_all_states(); |
1408 | e063eb1f | Jan Kiszka | qemu_system_reset(VMRESET_REPORT); |
1409 | d6dc3d42 | aliguori | resume_all_vcpus(); |
1410 | d6dc3d42 | aliguori | } |
1411 | d9c32310 | Blue Swirl | if (qemu_powerdown_requested()) {
|
1412 | 242cd003 | Blue Swirl | monitor_protocol_event(QEVENT_POWERDOWN, NULL);
|
1413 | d9c32310 | Blue Swirl | qemu_irq_raise(qemu_system_powerdown); |
1414 | d9c32310 | Blue Swirl | } |
1415 | b1a15e7e | Luiz Capitulino | if ((r = qemu_vmstop_requested())) {
|
1416 | 6e29f5da | aliguori | vm_stop(r); |
1417 | b1a15e7e | Luiz Capitulino | } |
1418 | b4608c04 | bellard | } |
1419 | 2bc93fed | MORITA Kazutaka | bdrv_close_all(); |
1420 | d6dc3d42 | aliguori | pause_all_vcpus(); |
1421 | b4608c04 | bellard | } |
1422 | b4608c04 | bellard | |
1423 | 9bd7e6d9 | pbrook | static void version(void) |
1424 | 9bd7e6d9 | pbrook | { |
1425 | f75ca1ae | Thomas Monjalon | printf("QEMU emulator version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"); |
1426 | 9bd7e6d9 | pbrook | } |
1427 | 9bd7e6d9 | pbrook | |
1428 | 15f82208 | ths | static void help(int exitcode) |
1429 | 0824d6fc | bellard | { |
1430 | e8105ebb | Paolo Bonzini | const char *options_help = |
1431 | ad96090a | Blue Swirl | #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \
|
1432 | ad96090a | Blue Swirl | opt_help |
1433 | 5824d651 | blueswir1 | #define DEFHEADING(text) stringify(text) "\n" |
1434 | 9f16732a | Jes Sorensen | #include "qemu-options.def" |
1435 | 5824d651 | blueswir1 | #undef DEF
|
1436 | 5824d651 | blueswir1 | #undef DEFHEADING
|
1437 | 5824d651 | blueswir1 | #undef GEN_DOCS
|
1438 | e8105ebb | Paolo Bonzini | ; |
1439 | e8105ebb | Paolo Bonzini | version(); |
1440 | e8105ebb | Paolo Bonzini | printf("usage: %s [options] [disk_image]\n"
|
1441 | e8105ebb | Paolo Bonzini | "\n"
|
1442 | f75ca1ae | Thomas Monjalon | "'disk_image' is a raw hard disk image for IDE hard disk 0\n"
|
1443 | 3f020d70 | malc | "\n"
|
1444 | e8105ebb | Paolo Bonzini | "%s\n"
|
1445 | 3f020d70 | malc | "During emulation, the following keys are useful:\n"
|
1446 | 3f020d70 | malc | "ctrl-alt-f toggle full screen\n"
|
1447 | 3f020d70 | malc | "ctrl-alt-n switch to virtual console 'n'\n"
|
1448 | 3f020d70 | malc | "ctrl-alt toggle mouse and keyboard grab\n"
|
1449 | 3f020d70 | malc | "\n"
|
1450 | e8105ebb | Paolo Bonzini | "When using -nographic, press 'ctrl-a h' to get some help.\n",
|
1451 | e8105ebb | Paolo Bonzini | "qemu",
|
1452 | e8105ebb | Paolo Bonzini | options_help); |
1453 | 15f82208 | ths | exit(exitcode); |
1454 | 0824d6fc | bellard | } |
1455 | 0824d6fc | bellard | |
1456 | cd6f1169 | bellard | #define HAS_ARG 0x0001 |
1457 | cd6f1169 | bellard | |
1458 | cd6f1169 | bellard | typedef struct QEMUOption { |
1459 | cd6f1169 | bellard | const char *name; |
1460 | cd6f1169 | bellard | int flags;
|
1461 | cd6f1169 | bellard | int index;
|
1462 | ad96090a | Blue Swirl | uint32_t arch_mask; |
1463 | cd6f1169 | bellard | } QEMUOption; |
1464 | cd6f1169 | bellard | |
1465 | dbed7e40 | blueswir1 | static const QEMUOption qemu_options[] = { |
1466 | ad96090a | Blue Swirl | { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, |
1467 | ad96090a | Blue Swirl | #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \
|
1468 | ad96090a | Blue Swirl | { option, opt_arg, opt_enum, arch_mask }, |
1469 | 5824d651 | blueswir1 | #define DEFHEADING(text)
|
1470 | 9f16732a | Jes Sorensen | #include "qemu-options.def" |
1471 | 5824d651 | blueswir1 | #undef DEF
|
1472 | 5824d651 | blueswir1 | #undef DEFHEADING
|
1473 | 5824d651 | blueswir1 | #undef GEN_DOCS
|
1474 | cd6f1169 | bellard | { NULL },
|
1475 | fc01f7e7 | bellard | }; |
1476 | 3893c124 | malc | static void select_vgahw (const char *p) |
1477 | 3893c124 | malc | { |
1478 | 3893c124 | malc | const char *opts; |
1479 | 3893c124 | malc | |
1480 | 64465297 | Gerd Hoffmann | default_vga = 0;
|
1481 | 86176759 | Zachary Amsden | vga_interface_type = VGA_NONE; |
1482 | 3893c124 | malc | if (strstart(p, "std", &opts)) { |
1483 | 86176759 | Zachary Amsden | vga_interface_type = VGA_STD; |
1484 | 3893c124 | malc | } else if (strstart(p, "cirrus", &opts)) { |
1485 | 86176759 | Zachary Amsden | vga_interface_type = VGA_CIRRUS; |
1486 | 3893c124 | malc | } else if (strstart(p, "vmware", &opts)) { |
1487 | 86176759 | Zachary Amsden | vga_interface_type = VGA_VMWARE; |
1488 | 94909d9f | aliguori | } else if (strstart(p, "xenfb", &opts)) { |
1489 | 86176759 | Zachary Amsden | vga_interface_type = VGA_XENFB; |
1490 | a19cbfb3 | Gerd Hoffmann | } else if (strstart(p, "qxl", &opts)) { |
1491 | a19cbfb3 | Gerd Hoffmann | vga_interface_type = VGA_QXL; |
1492 | 28b85ed8 | aliguori | } else if (!strstart(p, "none", &opts)) { |
1493 | 3893c124 | malc | invalid_vga:
|
1494 | 3893c124 | malc | fprintf(stderr, "Unknown vga type: %s\n", p);
|
1495 | 3893c124 | malc | exit(1);
|
1496 | 3893c124 | malc | } |
1497 | cb5a7aa8 | malc | while (*opts) {
|
1498 | cb5a7aa8 | malc | const char *nextopt; |
1499 | cb5a7aa8 | malc | |
1500 | cb5a7aa8 | malc | if (strstart(opts, ",retrace=", &nextopt)) { |
1501 | cb5a7aa8 | malc | opts = nextopt; |
1502 | cb5a7aa8 | malc | if (strstart(opts, "dumb", &nextopt)) |
1503 | cb5a7aa8 | malc | vga_retrace_method = VGA_RETRACE_DUMB; |
1504 | cb5a7aa8 | malc | else if (strstart(opts, "precise", &nextopt)) |
1505 | cb5a7aa8 | malc | vga_retrace_method = VGA_RETRACE_PRECISE; |
1506 | cb5a7aa8 | malc | else goto invalid_vga; |
1507 | cb5a7aa8 | malc | } else goto invalid_vga; |
1508 | cb5a7aa8 | malc | opts = nextopt; |
1509 | cb5a7aa8 | malc | } |
1510 | 3893c124 | malc | } |
1511 | 3893c124 | malc | |
1512 | 1472a95b | Jes Sorensen | static DisplayType select_display(const char *p) |
1513 | 1472a95b | Jes Sorensen | { |
1514 | 1472a95b | Jes Sorensen | const char *opts; |
1515 | 1472a95b | Jes Sorensen | DisplayType display = DT_DEFAULT; |
1516 | 1472a95b | Jes Sorensen | |
1517 | 1472a95b | Jes Sorensen | if (strstart(p, "sdl", &opts)) { |
1518 | 1472a95b | Jes Sorensen | #ifdef CONFIG_SDL
|
1519 | 1472a95b | Jes Sorensen | display = DT_SDL; |
1520 | 1472a95b | Jes Sorensen | while (*opts) {
|
1521 | 1472a95b | Jes Sorensen | const char *nextopt; |
1522 | 1472a95b | Jes Sorensen | |
1523 | 1472a95b | Jes Sorensen | if (strstart(opts, ",frame=", &nextopt)) { |
1524 | 1472a95b | Jes Sorensen | opts = nextopt; |
1525 | 1472a95b | Jes Sorensen | if (strstart(opts, "on", &nextopt)) { |
1526 | 1472a95b | Jes Sorensen | no_frame = 0;
|
1527 | 1472a95b | Jes Sorensen | } else if (strstart(opts, "off", &nextopt)) { |
1528 | 1472a95b | Jes Sorensen | no_frame = 1;
|
1529 | 1472a95b | Jes Sorensen | } else {
|
1530 | 05175535 | Peter Maydell | goto invalid_sdl_args;
|
1531 | 1472a95b | Jes Sorensen | } |
1532 | 1472a95b | Jes Sorensen | } else if (strstart(opts, ",alt_grab=", &nextopt)) { |
1533 | 1472a95b | Jes Sorensen | opts = nextopt; |
1534 | 1472a95b | Jes Sorensen | if (strstart(opts, "on", &nextopt)) { |
1535 | 1472a95b | Jes Sorensen | alt_grab = 1;
|
1536 | 1472a95b | Jes Sorensen | } else if (strstart(opts, "off", &nextopt)) { |
1537 | 1472a95b | Jes Sorensen | alt_grab = 0;
|
1538 | 1472a95b | Jes Sorensen | } else {
|
1539 | 05175535 | Peter Maydell | goto invalid_sdl_args;
|
1540 | 1472a95b | Jes Sorensen | } |
1541 | 1472a95b | Jes Sorensen | } else if (strstart(opts, ",ctrl_grab=", &nextopt)) { |
1542 | 1472a95b | Jes Sorensen | opts = nextopt; |
1543 | 1472a95b | Jes Sorensen | if (strstart(opts, "on", &nextopt)) { |
1544 | 1472a95b | Jes Sorensen | ctrl_grab = 1;
|
1545 | 1472a95b | Jes Sorensen | } else if (strstart(opts, "off", &nextopt)) { |
1546 | 1472a95b | Jes Sorensen | ctrl_grab = 0;
|
1547 | 1472a95b | Jes Sorensen | } else {
|
1548 | 05175535 | Peter Maydell | goto invalid_sdl_args;
|
1549 | 1472a95b | Jes Sorensen | } |
1550 | 1472a95b | Jes Sorensen | } else if (strstart(opts, ",window_close=", &nextopt)) { |
1551 | 1472a95b | Jes Sorensen | opts = nextopt; |
1552 | 1472a95b | Jes Sorensen | if (strstart(opts, "on", &nextopt)) { |
1553 | 1472a95b | Jes Sorensen | no_quit = 0;
|
1554 | 1472a95b | Jes Sorensen | } else if (strstart(opts, "off", &nextopt)) { |
1555 | 1472a95b | Jes Sorensen | no_quit = 1;
|
1556 | 1472a95b | Jes Sorensen | } else {
|
1557 | 05175535 | Peter Maydell | goto invalid_sdl_args;
|
1558 | 1472a95b | Jes Sorensen | } |
1559 | 1472a95b | Jes Sorensen | } else {
|
1560 | 05175535 | Peter Maydell | invalid_sdl_args:
|
1561 | 05175535 | Peter Maydell | fprintf(stderr, "Invalid SDL option string: %s\n", p);
|
1562 | 05175535 | Peter Maydell | exit(1);
|
1563 | 1472a95b | Jes Sorensen | } |
1564 | 1472a95b | Jes Sorensen | opts = nextopt; |
1565 | 1472a95b | Jes Sorensen | } |
1566 | 1472a95b | Jes Sorensen | #else
|
1567 | 1472a95b | Jes Sorensen | fprintf(stderr, "SDL support is disabled\n");
|
1568 | 1472a95b | Jes Sorensen | exit(1);
|
1569 | 1472a95b | Jes Sorensen | #endif
|
1570 | 3264ff12 | Jes Sorensen | } else if (strstart(p, "vnc", &opts)) { |
1571 | 821601ea | Jes Sorensen | #ifdef CONFIG_VNC
|
1572 | 3264ff12 | Jes Sorensen | display_remote++; |
1573 | 3264ff12 | Jes Sorensen | |
1574 | 3264ff12 | Jes Sorensen | if (*opts) {
|
1575 | 3264ff12 | Jes Sorensen | const char *nextopt; |
1576 | 3264ff12 | Jes Sorensen | |
1577 | 3264ff12 | Jes Sorensen | if (strstart(opts, "=", &nextopt)) { |
1578 | 3264ff12 | Jes Sorensen | vnc_display = nextopt; |
1579 | 3264ff12 | Jes Sorensen | } |
1580 | 3264ff12 | Jes Sorensen | } |
1581 | 3264ff12 | Jes Sorensen | if (!vnc_display) {
|
1582 | 3264ff12 | Jes Sorensen | fprintf(stderr, "VNC requires a display argument vnc=<display>\n");
|
1583 | 3264ff12 | Jes Sorensen | exit(1);
|
1584 | 3264ff12 | Jes Sorensen | } |
1585 | 821601ea | Jes Sorensen | #else
|
1586 | 821601ea | Jes Sorensen | fprintf(stderr, "VNC support is disabled\n");
|
1587 | 821601ea | Jes Sorensen | exit(1);
|
1588 | 821601ea | Jes Sorensen | #endif
|
1589 | 1472a95b | Jes Sorensen | } else if (strstart(p, "curses", &opts)) { |
1590 | 1472a95b | Jes Sorensen | #ifdef CONFIG_CURSES
|
1591 | 1472a95b | Jes Sorensen | display = DT_CURSES; |
1592 | 1472a95b | Jes Sorensen | #else
|
1593 | 1472a95b | Jes Sorensen | fprintf(stderr, "Curses support is disabled\n");
|
1594 | 1472a95b | Jes Sorensen | exit(1);
|
1595 | 1472a95b | Jes Sorensen | #endif
|
1596 | 4171d32e | Jes Sorensen | } else if (strstart(p, "none", &opts)) { |
1597 | 4171d32e | Jes Sorensen | display = DT_NONE; |
1598 | 1472a95b | Jes Sorensen | } else {
|
1599 | 1472a95b | Jes Sorensen | fprintf(stderr, "Unknown display type: %s\n", p);
|
1600 | 1472a95b | Jes Sorensen | exit(1);
|
1601 | 1472a95b | Jes Sorensen | } |
1602 | 1472a95b | Jes Sorensen | |
1603 | 1472a95b | Jes Sorensen | return display;
|
1604 | 1472a95b | Jes Sorensen | } |
1605 | 1472a95b | Jes Sorensen | |
1606 | 7d4c3d53 | Markus Armbruster | static int balloon_parse(const char *arg) |
1607 | 7d4c3d53 | Markus Armbruster | { |
1608 | 382f0743 | Gerd Hoffmann | QemuOpts *opts; |
1609 | 7d4c3d53 | Markus Armbruster | |
1610 | 382f0743 | Gerd Hoffmann | if (strcmp(arg, "none") == 0) { |
1611 | 382f0743 | Gerd Hoffmann | return 0; |
1612 | 382f0743 | Gerd Hoffmann | } |
1613 | 382f0743 | Gerd Hoffmann | |
1614 | 382f0743 | Gerd Hoffmann | if (!strncmp(arg, "virtio", 6)) { |
1615 | 382f0743 | Gerd Hoffmann | if (arg[6] == ',') { |
1616 | 382f0743 | Gerd Hoffmann | /* have params -> parse them */
|
1617 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_parse(qemu_find_opts("device"), arg+7, 0); |
1618 | 382f0743 | Gerd Hoffmann | if (!opts)
|
1619 | 382f0743 | Gerd Hoffmann | return -1; |
1620 | 382f0743 | Gerd Hoffmann | } else {
|
1621 | 382f0743 | Gerd Hoffmann | /* create empty opts */
|
1622 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0); |
1623 | 7d4c3d53 | Markus Armbruster | } |
1624 | 29f82b37 | Alexander Graf | qemu_opt_set(opts, "driver", "virtio-balloon"); |
1625 | 382f0743 | Gerd Hoffmann | return 0; |
1626 | 7d4c3d53 | Markus Armbruster | } |
1627 | 382f0743 | Gerd Hoffmann | |
1628 | 382f0743 | Gerd Hoffmann | return -1; |
1629 | 7d4c3d53 | Markus Armbruster | } |
1630 | 7d4c3d53 | Markus Armbruster | |
1631 | 5cea8590 | Paul Brook | char *qemu_find_file(int type, const char *name) |
1632 | 5cea8590 | Paul Brook | { |
1633 | 5cea8590 | Paul Brook | int len;
|
1634 | 5cea8590 | Paul Brook | const char *subdir; |
1635 | 5cea8590 | Paul Brook | char *buf;
|
1636 | 5cea8590 | Paul Brook | |
1637 | 5cea8590 | Paul Brook | /* If name contains path separators then try it as a straight path. */
|
1638 | 5cea8590 | Paul Brook | if ((strchr(name, '/') || strchr(name, '\\')) |
1639 | 5cea8590 | Paul Brook | && access(name, R_OK) == 0) {
|
1640 | 73ffc805 | Jean-Christophe DUBOIS | return qemu_strdup(name);
|
1641 | 5cea8590 | Paul Brook | } |
1642 | 5cea8590 | Paul Brook | switch (type) {
|
1643 | 5cea8590 | Paul Brook | case QEMU_FILE_TYPE_BIOS:
|
1644 | 5cea8590 | Paul Brook | subdir = "";
|
1645 | 5cea8590 | Paul Brook | break;
|
1646 | 5cea8590 | Paul Brook | case QEMU_FILE_TYPE_KEYMAP:
|
1647 | 5cea8590 | Paul Brook | subdir = "keymaps/";
|
1648 | 5cea8590 | Paul Brook | break;
|
1649 | 5cea8590 | Paul Brook | default:
|
1650 | 5cea8590 | Paul Brook | abort(); |
1651 | 5cea8590 | Paul Brook | } |
1652 | 5cea8590 | Paul Brook | len = strlen(data_dir) + strlen(name) + strlen(subdir) + 2;
|
1653 | 5cea8590 | Paul Brook | buf = qemu_mallocz(len); |
1654 | 3a41759d | Blue Swirl | snprintf(buf, len, "%s/%s%s", data_dir, subdir, name);
|
1655 | 5cea8590 | Paul Brook | if (access(buf, R_OK)) {
|
1656 | 5cea8590 | Paul Brook | qemu_free(buf); |
1657 | 5cea8590 | Paul Brook | return NULL; |
1658 | 5cea8590 | Paul Brook | } |
1659 | 5cea8590 | Paul Brook | return buf;
|
1660 | 5cea8590 | Paul Brook | } |
1661 | 5cea8590 | Paul Brook | |
1662 | ff952ba2 | Markus Armbruster | static int device_help_func(QemuOpts *opts, void *opaque) |
1663 | ff952ba2 | Markus Armbruster | { |
1664 | ff952ba2 | Markus Armbruster | return qdev_device_help(opts);
|
1665 | ff952ba2 | Markus Armbruster | } |
1666 | ff952ba2 | Markus Armbruster | |
1667 | f31d07d1 | Gerd Hoffmann | static int device_init_func(QemuOpts *opts, void *opaque) |
1668 | f31d07d1 | Gerd Hoffmann | { |
1669 | f31d07d1 | Gerd Hoffmann | DeviceState *dev; |
1670 | f31d07d1 | Gerd Hoffmann | |
1671 | f31d07d1 | Gerd Hoffmann | dev = qdev_device_add(opts); |
1672 | f31d07d1 | Gerd Hoffmann | if (!dev)
|
1673 | f31d07d1 | Gerd Hoffmann | return -1; |
1674 | f31d07d1 | Gerd Hoffmann | return 0; |
1675 | f31d07d1 | Gerd Hoffmann | } |
1676 | f31d07d1 | Gerd Hoffmann | |
1677 | 1a688d3b | Gerd Hoffmann | static int chardev_init_func(QemuOpts *opts, void *opaque) |
1678 | 1a688d3b | Gerd Hoffmann | { |
1679 | 1a688d3b | Gerd Hoffmann | CharDriverState *chr; |
1680 | 1a688d3b | Gerd Hoffmann | |
1681 | 1a688d3b | Gerd Hoffmann | chr = qemu_chr_open_opts(opts, NULL);
|
1682 | 1a688d3b | Gerd Hoffmann | if (!chr)
|
1683 | 1a688d3b | Gerd Hoffmann | return -1; |
1684 | 1a688d3b | Gerd Hoffmann | return 0; |
1685 | 1a688d3b | Gerd Hoffmann | } |
1686 | 1a688d3b | Gerd Hoffmann | |
1687 | 758e8e38 | Venkateswararao Jujjuri (JV) | #ifdef CONFIG_VIRTFS
|
1688 | 74db920c | Gautham R Shenoy | static int fsdev_init_func(QemuOpts *opts, void *opaque) |
1689 | 74db920c | Gautham R Shenoy | { |
1690 | 74db920c | Gautham R Shenoy | int ret;
|
1691 | 74db920c | Gautham R Shenoy | ret = qemu_fsdev_add(opts); |
1692 | 74db920c | Gautham R Shenoy | |
1693 | 74db920c | Gautham R Shenoy | return ret;
|
1694 | 74db920c | Gautham R Shenoy | } |
1695 | 74db920c | Gautham R Shenoy | #endif
|
1696 | 74db920c | Gautham R Shenoy | |
1697 | 88589343 | Gerd Hoffmann | static int mon_init_func(QemuOpts *opts, void *opaque) |
1698 | 88589343 | Gerd Hoffmann | { |
1699 | 88589343 | Gerd Hoffmann | CharDriverState *chr; |
1700 | 88589343 | Gerd Hoffmann | const char *chardev; |
1701 | 88589343 | Gerd Hoffmann | const char *mode; |
1702 | 88589343 | Gerd Hoffmann | int flags;
|
1703 | 88589343 | Gerd Hoffmann | |
1704 | 88589343 | Gerd Hoffmann | mode = qemu_opt_get(opts, "mode");
|
1705 | 88589343 | Gerd Hoffmann | if (mode == NULL) { |
1706 | 88589343 | Gerd Hoffmann | mode = "readline";
|
1707 | 88589343 | Gerd Hoffmann | } |
1708 | 88589343 | Gerd Hoffmann | if (strcmp(mode, "readline") == 0) { |
1709 | 88589343 | Gerd Hoffmann | flags = MONITOR_USE_READLINE; |
1710 | 88589343 | Gerd Hoffmann | } else if (strcmp(mode, "control") == 0) { |
1711 | 88589343 | Gerd Hoffmann | flags = MONITOR_USE_CONTROL; |
1712 | 88589343 | Gerd Hoffmann | } else {
|
1713 | 88589343 | Gerd Hoffmann | fprintf(stderr, "unknown monitor mode \"%s\"\n", mode);
|
1714 | 88589343 | Gerd Hoffmann | exit(1);
|
1715 | 88589343 | Gerd Hoffmann | } |
1716 | 88589343 | Gerd Hoffmann | |
1717 | 39eaab9a | Daniel P. Berrange | if (qemu_opt_get_bool(opts, "pretty", 0)) |
1718 | 39eaab9a | Daniel P. Berrange | flags |= MONITOR_USE_PRETTY; |
1719 | 39eaab9a | Daniel P. Berrange | |
1720 | 88589343 | Gerd Hoffmann | if (qemu_opt_get_bool(opts, "default", 0)) |
1721 | 88589343 | Gerd Hoffmann | flags |= MONITOR_IS_DEFAULT; |
1722 | 88589343 | Gerd Hoffmann | |
1723 | 88589343 | Gerd Hoffmann | chardev = qemu_opt_get(opts, "chardev");
|
1724 | 88589343 | Gerd Hoffmann | chr = qemu_chr_find(chardev); |
1725 | 88589343 | Gerd Hoffmann | if (chr == NULL) { |
1726 | 88589343 | Gerd Hoffmann | fprintf(stderr, "chardev \"%s\" not found\n", chardev);
|
1727 | 88589343 | Gerd Hoffmann | exit(1);
|
1728 | 88589343 | Gerd Hoffmann | } |
1729 | 88589343 | Gerd Hoffmann | |
1730 | 88589343 | Gerd Hoffmann | monitor_init(chr, flags); |
1731 | 88589343 | Gerd Hoffmann | return 0; |
1732 | 88589343 | Gerd Hoffmann | } |
1733 | 88589343 | Gerd Hoffmann | |
1734 | 6ca5582d | Gerd Hoffmann | static void monitor_parse(const char *optarg, const char *mode) |
1735 | 88589343 | Gerd Hoffmann | { |
1736 | 88589343 | Gerd Hoffmann | static int monitor_device_index = 0; |
1737 | 88589343 | Gerd Hoffmann | QemuOpts *opts; |
1738 | 88589343 | Gerd Hoffmann | const char *p; |
1739 | 88589343 | Gerd Hoffmann | char label[32]; |
1740 | 88589343 | Gerd Hoffmann | int def = 0; |
1741 | 88589343 | Gerd Hoffmann | |
1742 | 88589343 | Gerd Hoffmann | if (strstart(optarg, "chardev:", &p)) { |
1743 | 88589343 | Gerd Hoffmann | snprintf(label, sizeof(label), "%s", p); |
1744 | 88589343 | Gerd Hoffmann | } else {
|
1745 | 140e065d | Jan Kiszka | snprintf(label, sizeof(label), "compat_monitor%d", |
1746 | 140e065d | Jan Kiszka | monitor_device_index); |
1747 | 140e065d | Jan Kiszka | if (monitor_device_index == 0) { |
1748 | 88589343 | Gerd Hoffmann | def = 1;
|
1749 | 88589343 | Gerd Hoffmann | } |
1750 | 88589343 | Gerd Hoffmann | opts = qemu_chr_parse_compat(label, optarg); |
1751 | 88589343 | Gerd Hoffmann | if (!opts) {
|
1752 | 88589343 | Gerd Hoffmann | fprintf(stderr, "parse error: %s\n", optarg);
|
1753 | 88589343 | Gerd Hoffmann | exit(1);
|
1754 | 88589343 | Gerd Hoffmann | } |
1755 | 88589343 | Gerd Hoffmann | } |
1756 | 88589343 | Gerd Hoffmann | |
1757 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_create(qemu_find_opts("mon"), label, 1); |
1758 | 88589343 | Gerd Hoffmann | if (!opts) {
|
1759 | 88589343 | Gerd Hoffmann | fprintf(stderr, "duplicate chardev: %s\n", label);
|
1760 | 88589343 | Gerd Hoffmann | exit(1);
|
1761 | 88589343 | Gerd Hoffmann | } |
1762 | 6ca5582d | Gerd Hoffmann | qemu_opt_set(opts, "mode", mode);
|
1763 | 88589343 | Gerd Hoffmann | qemu_opt_set(opts, "chardev", label);
|
1764 | 88589343 | Gerd Hoffmann | if (def)
|
1765 | 88589343 | Gerd Hoffmann | qemu_opt_set(opts, "default", "on"); |
1766 | 88589343 | Gerd Hoffmann | monitor_device_index++; |
1767 | 88589343 | Gerd Hoffmann | } |
1768 | 88589343 | Gerd Hoffmann | |
1769 | bd3c948d | Gerd Hoffmann | struct device_config {
|
1770 | bd3c948d | Gerd Hoffmann | enum {
|
1771 | aee1b935 | Gerd Hoffmann | DEV_USB, /* -usbdevice */
|
1772 | aee1b935 | Gerd Hoffmann | DEV_BT, /* -bt */
|
1773 | aee1b935 | Gerd Hoffmann | DEV_SERIAL, /* -serial */
|
1774 | aee1b935 | Gerd Hoffmann | DEV_PARALLEL, /* -parallel */
|
1775 | aee1b935 | Gerd Hoffmann | DEV_VIRTCON, /* -virtioconsole */
|
1776 | c9f398e5 | H. Peter Anvin | DEV_DEBUGCON, /* -debugcon */
|
1777 | bd3c948d | Gerd Hoffmann | } type; |
1778 | bd3c948d | Gerd Hoffmann | const char *cmdline; |
1779 | 72cf2d4f | Blue Swirl | QTAILQ_ENTRY(device_config) next; |
1780 | bd3c948d | Gerd Hoffmann | }; |
1781 | 72cf2d4f | Blue Swirl | QTAILQ_HEAD(, device_config) device_configs = QTAILQ_HEAD_INITIALIZER(device_configs); |
1782 | bd3c948d | Gerd Hoffmann | |
1783 | bd3c948d | Gerd Hoffmann | static void add_device_config(int type, const char *cmdline) |
1784 | bd3c948d | Gerd Hoffmann | { |
1785 | bd3c948d | Gerd Hoffmann | struct device_config *conf;
|
1786 | bd3c948d | Gerd Hoffmann | |
1787 | bd3c948d | Gerd Hoffmann | conf = qemu_mallocz(sizeof(*conf));
|
1788 | bd3c948d | Gerd Hoffmann | conf->type = type; |
1789 | bd3c948d | Gerd Hoffmann | conf->cmdline = cmdline; |
1790 | 72cf2d4f | Blue Swirl | QTAILQ_INSERT_TAIL(&device_configs, conf, next); |
1791 | bd3c948d | Gerd Hoffmann | } |
1792 | bd3c948d | Gerd Hoffmann | |
1793 | bd3c948d | Gerd Hoffmann | static int foreach_device_config(int type, int (*func)(const char *cmdline)) |
1794 | bd3c948d | Gerd Hoffmann | { |
1795 | bd3c948d | Gerd Hoffmann | struct device_config *conf;
|
1796 | bd3c948d | Gerd Hoffmann | int rc;
|
1797 | bd3c948d | Gerd Hoffmann | |
1798 | 72cf2d4f | Blue Swirl | QTAILQ_FOREACH(conf, &device_configs, next) { |
1799 | bd3c948d | Gerd Hoffmann | if (conf->type != type)
|
1800 | bd3c948d | Gerd Hoffmann | continue;
|
1801 | bd3c948d | Gerd Hoffmann | rc = func(conf->cmdline); |
1802 | bd3c948d | Gerd Hoffmann | if (0 != rc) |
1803 | bd3c948d | Gerd Hoffmann | return rc;
|
1804 | bd3c948d | Gerd Hoffmann | } |
1805 | bd3c948d | Gerd Hoffmann | return 0; |
1806 | bd3c948d | Gerd Hoffmann | } |
1807 | bd3c948d | Gerd Hoffmann | |
1808 | 998bbd74 | Gerd Hoffmann | static int serial_parse(const char *devname) |
1809 | 998bbd74 | Gerd Hoffmann | { |
1810 | 998bbd74 | Gerd Hoffmann | static int index = 0; |
1811 | 998bbd74 | Gerd Hoffmann | char label[32]; |
1812 | 998bbd74 | Gerd Hoffmann | |
1813 | 998bbd74 | Gerd Hoffmann | if (strcmp(devname, "none") == 0) |
1814 | 998bbd74 | Gerd Hoffmann | return 0; |
1815 | 998bbd74 | Gerd Hoffmann | if (index == MAX_SERIAL_PORTS) {
|
1816 | 998bbd74 | Gerd Hoffmann | fprintf(stderr, "qemu: too many serial ports\n");
|
1817 | 998bbd74 | Gerd Hoffmann | exit(1);
|
1818 | 998bbd74 | Gerd Hoffmann | } |
1819 | 998bbd74 | Gerd Hoffmann | snprintf(label, sizeof(label), "serial%d", index); |
1820 | 998bbd74 | Gerd Hoffmann | serial_hds[index] = qemu_chr_open(label, devname, NULL);
|
1821 | 998bbd74 | Gerd Hoffmann | if (!serial_hds[index]) {
|
1822 | 998bbd74 | Gerd Hoffmann | fprintf(stderr, "qemu: could not open serial device '%s': %s\n",
|
1823 | 998bbd74 | Gerd Hoffmann | devname, strerror(errno)); |
1824 | 998bbd74 | Gerd Hoffmann | return -1; |
1825 | 998bbd74 | Gerd Hoffmann | } |
1826 | 998bbd74 | Gerd Hoffmann | index++; |
1827 | 998bbd74 | Gerd Hoffmann | return 0; |
1828 | 998bbd74 | Gerd Hoffmann | } |
1829 | 998bbd74 | Gerd Hoffmann | |
1830 | 6a5e8b0e | Gerd Hoffmann | static int parallel_parse(const char *devname) |
1831 | 6a5e8b0e | Gerd Hoffmann | { |
1832 | 6a5e8b0e | Gerd Hoffmann | static int index = 0; |
1833 | 6a5e8b0e | Gerd Hoffmann | char label[32]; |
1834 | 6a5e8b0e | Gerd Hoffmann | |
1835 | 6a5e8b0e | Gerd Hoffmann | if (strcmp(devname, "none") == 0) |
1836 | 6a5e8b0e | Gerd Hoffmann | return 0; |
1837 | 6a5e8b0e | Gerd Hoffmann | if (index == MAX_PARALLEL_PORTS) {
|
1838 | 6a5e8b0e | Gerd Hoffmann | fprintf(stderr, "qemu: too many parallel ports\n");
|
1839 | 6a5e8b0e | Gerd Hoffmann | exit(1);
|
1840 | 6a5e8b0e | Gerd Hoffmann | } |
1841 | 6a5e8b0e | Gerd Hoffmann | snprintf(label, sizeof(label), "parallel%d", index); |
1842 | 6a5e8b0e | Gerd Hoffmann | parallel_hds[index] = qemu_chr_open(label, devname, NULL);
|
1843 | 6a5e8b0e | Gerd Hoffmann | if (!parallel_hds[index]) {
|
1844 | 6a5e8b0e | Gerd Hoffmann | fprintf(stderr, "qemu: could not open parallel device '%s': %s\n",
|
1845 | 6a5e8b0e | Gerd Hoffmann | devname, strerror(errno)); |
1846 | 6a5e8b0e | Gerd Hoffmann | return -1; |
1847 | 6a5e8b0e | Gerd Hoffmann | } |
1848 | 6a5e8b0e | Gerd Hoffmann | index++; |
1849 | 6a5e8b0e | Gerd Hoffmann | return 0; |
1850 | 6a5e8b0e | Gerd Hoffmann | } |
1851 | 6a5e8b0e | Gerd Hoffmann | |
1852 | aee1b935 | Gerd Hoffmann | static int virtcon_parse(const char *devname) |
1853 | aee1b935 | Gerd Hoffmann | { |
1854 | 3329f07b | Gerd Hoffmann | QemuOptsList *device = qemu_find_opts("device");
|
1855 | aee1b935 | Gerd Hoffmann | static int index = 0; |
1856 | aee1b935 | Gerd Hoffmann | char label[32]; |
1857 | 392ecf54 | Amit Shah | QemuOpts *bus_opts, *dev_opts; |
1858 | aee1b935 | Gerd Hoffmann | |
1859 | aee1b935 | Gerd Hoffmann | if (strcmp(devname, "none") == 0) |
1860 | aee1b935 | Gerd Hoffmann | return 0; |
1861 | aee1b935 | Gerd Hoffmann | if (index == MAX_VIRTIO_CONSOLES) {
|
1862 | aee1b935 | Gerd Hoffmann | fprintf(stderr, "qemu: too many virtio consoles\n");
|
1863 | aee1b935 | Gerd Hoffmann | exit(1);
|
1864 | aee1b935 | Gerd Hoffmann | } |
1865 | 392ecf54 | Amit Shah | |
1866 | 3329f07b | Gerd Hoffmann | bus_opts = qemu_opts_create(device, NULL, 0); |
1867 | 392ecf54 | Amit Shah | qemu_opt_set(bus_opts, "driver", "virtio-serial"); |
1868 | 392ecf54 | Amit Shah | |
1869 | 3329f07b | Gerd Hoffmann | dev_opts = qemu_opts_create(device, NULL, 0); |
1870 | 392ecf54 | Amit Shah | qemu_opt_set(dev_opts, "driver", "virtconsole"); |
1871 | 392ecf54 | Amit Shah | |
1872 | aee1b935 | Gerd Hoffmann | snprintf(label, sizeof(label), "virtcon%d", index); |
1873 | aee1b935 | Gerd Hoffmann | virtcon_hds[index] = qemu_chr_open(label, devname, NULL);
|
1874 | aee1b935 | Gerd Hoffmann | if (!virtcon_hds[index]) {
|
1875 | aee1b935 | Gerd Hoffmann | fprintf(stderr, "qemu: could not open virtio console '%s': %s\n",
|
1876 | aee1b935 | Gerd Hoffmann | devname, strerror(errno)); |
1877 | aee1b935 | Gerd Hoffmann | return -1; |
1878 | aee1b935 | Gerd Hoffmann | } |
1879 | 392ecf54 | Amit Shah | qemu_opt_set(dev_opts, "chardev", label);
|
1880 | 392ecf54 | Amit Shah | |
1881 | aee1b935 | Gerd Hoffmann | index++; |
1882 | aee1b935 | Gerd Hoffmann | return 0; |
1883 | aee1b935 | Gerd Hoffmann | } |
1884 | aee1b935 | Gerd Hoffmann | |
1885 | c9f398e5 | H. Peter Anvin | static int debugcon_parse(const char *devname) |
1886 | c9f398e5 | H. Peter Anvin | { |
1887 | c9f398e5 | H. Peter Anvin | QemuOpts *opts; |
1888 | c9f398e5 | H. Peter Anvin | |
1889 | c9f398e5 | H. Peter Anvin | if (!qemu_chr_open("debugcon", devname, NULL)) { |
1890 | c9f398e5 | H. Peter Anvin | exit(1);
|
1891 | c9f398e5 | H. Peter Anvin | } |
1892 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_create(qemu_find_opts("device"), "debugcon", 1); |
1893 | c9f398e5 | H. Peter Anvin | if (!opts) {
|
1894 | c9f398e5 | H. Peter Anvin | fprintf(stderr, "qemu: already have a debugcon device\n");
|
1895 | c9f398e5 | H. Peter Anvin | exit(1);
|
1896 | c9f398e5 | H. Peter Anvin | } |
1897 | c9f398e5 | H. Peter Anvin | qemu_opt_set(opts, "driver", "isa-debugcon"); |
1898 | c9f398e5 | H. Peter Anvin | qemu_opt_set(opts, "chardev", "debugcon"); |
1899 | c9f398e5 | H. Peter Anvin | return 0; |
1900 | c9f398e5 | H. Peter Anvin | } |
1901 | c9f398e5 | H. Peter Anvin | |
1902 | 303d4e86 | Anthony PERARD | static int tcg_init(void) |
1903 | 303d4e86 | Anthony PERARD | { |
1904 | 303d4e86 | Anthony PERARD | return 0; |
1905 | 303d4e86 | Anthony PERARD | } |
1906 | 303d4e86 | Anthony PERARD | |
1907 | 303d4e86 | Anthony PERARD | static struct { |
1908 | 303d4e86 | Anthony PERARD | const char *opt_name; |
1909 | 303d4e86 | Anthony PERARD | const char *name; |
1910 | 303d4e86 | Anthony PERARD | int (*available)(void); |
1911 | 303d4e86 | Anthony PERARD | int (*init)(void); |
1912 | 303d4e86 | Anthony PERARD | int *allowed;
|
1913 | 303d4e86 | Anthony PERARD | } accel_list[] = { |
1914 | 303d4e86 | Anthony PERARD | { "tcg", "tcg", tcg_available, tcg_init, &tcg_allowed }, |
1915 | 3285cf4f | Anthony PERARD | { "xen", "Xen", xen_available, xen_init, &xen_allowed }, |
1916 | 303d4e86 | Anthony PERARD | { "kvm", "KVM", kvm_available, kvm_init, &kvm_allowed }, |
1917 | 303d4e86 | Anthony PERARD | }; |
1918 | 303d4e86 | Anthony PERARD | |
1919 | 303d4e86 | Anthony PERARD | static int configure_accelerator(void) |
1920 | 303d4e86 | Anthony PERARD | { |
1921 | 303d4e86 | Anthony PERARD | const char *p = NULL; |
1922 | 303d4e86 | Anthony PERARD | char buf[10]; |
1923 | 303d4e86 | Anthony PERARD | int i, ret;
|
1924 | 303d4e86 | Anthony PERARD | bool accel_initalised = 0; |
1925 | 303d4e86 | Anthony PERARD | bool init_failed = 0; |
1926 | 303d4e86 | Anthony PERARD | |
1927 | 303d4e86 | Anthony PERARD | QemuOptsList *list = qemu_find_opts("machine");
|
1928 | 303d4e86 | Anthony PERARD | if (!QTAILQ_EMPTY(&list->head)) {
|
1929 | 303d4e86 | Anthony PERARD | p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
|
1930 | 303d4e86 | Anthony PERARD | } |
1931 | 303d4e86 | Anthony PERARD | |
1932 | 303d4e86 | Anthony PERARD | if (p == NULL) { |
1933 | 303d4e86 | Anthony PERARD | /* Use the default "accelerator", tcg */
|
1934 | 303d4e86 | Anthony PERARD | p = "tcg";
|
1935 | 303d4e86 | Anthony PERARD | } |
1936 | 303d4e86 | Anthony PERARD | |
1937 | 303d4e86 | Anthony PERARD | while (!accel_initalised && *p != '\0') { |
1938 | 303d4e86 | Anthony PERARD | if (*p == ':') { |
1939 | 303d4e86 | Anthony PERARD | p++; |
1940 | 303d4e86 | Anthony PERARD | } |
1941 | 303d4e86 | Anthony PERARD | p = get_opt_name(buf, sizeof (buf), p, ':'); |
1942 | 303d4e86 | Anthony PERARD | for (i = 0; i < ARRAY_SIZE(accel_list); i++) { |
1943 | 303d4e86 | Anthony PERARD | if (strcmp(accel_list[i].opt_name, buf) == 0) { |
1944 | a16c53b1 | Anthony Liguori | *(accel_list[i].allowed) = 1;
|
1945 | 303d4e86 | Anthony PERARD | ret = accel_list[i].init(); |
1946 | 303d4e86 | Anthony PERARD | if (ret < 0) { |
1947 | 303d4e86 | Anthony PERARD | init_failed = 1;
|
1948 | 303d4e86 | Anthony PERARD | if (!accel_list[i].available()) {
|
1949 | 303d4e86 | Anthony PERARD | printf("%s not supported for this target\n",
|
1950 | 303d4e86 | Anthony PERARD | accel_list[i].name); |
1951 | 303d4e86 | Anthony PERARD | } else {
|
1952 | 303d4e86 | Anthony PERARD | fprintf(stderr, "failed to initialize %s: %s\n",
|
1953 | 303d4e86 | Anthony PERARD | accel_list[i].name, |
1954 | 303d4e86 | Anthony PERARD | strerror(-ret)); |
1955 | 303d4e86 | Anthony PERARD | } |
1956 | a16c53b1 | Anthony Liguori | *(accel_list[i].allowed) = 0;
|
1957 | 303d4e86 | Anthony PERARD | } else {
|
1958 | 303d4e86 | Anthony PERARD | accel_initalised = 1;
|
1959 | 303d4e86 | Anthony PERARD | } |
1960 | 303d4e86 | Anthony PERARD | break;
|
1961 | 303d4e86 | Anthony PERARD | } |
1962 | 303d4e86 | Anthony PERARD | } |
1963 | 303d4e86 | Anthony PERARD | if (i == ARRAY_SIZE(accel_list)) {
|
1964 | 303d4e86 | Anthony PERARD | fprintf(stderr, "\"%s\" accelerator does not exist.\n", buf);
|
1965 | 303d4e86 | Anthony PERARD | } |
1966 | 303d4e86 | Anthony PERARD | } |
1967 | 303d4e86 | Anthony PERARD | |
1968 | 303d4e86 | Anthony PERARD | if (!accel_initalised) {
|
1969 | 303d4e86 | Anthony PERARD | fprintf(stderr, "No accelerator found!\n");
|
1970 | 303d4e86 | Anthony PERARD | exit(1);
|
1971 | 303d4e86 | Anthony PERARD | } |
1972 | 303d4e86 | Anthony PERARD | |
1973 | 303d4e86 | Anthony PERARD | if (init_failed) {
|
1974 | 303d4e86 | Anthony PERARD | fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name);
|
1975 | 303d4e86 | Anthony PERARD | } |
1976 | 303d4e86 | Anthony PERARD | |
1977 | 303d4e86 | Anthony PERARD | return !accel_initalised;
|
1978 | 303d4e86 | Anthony PERARD | } |
1979 | 303d4e86 | Anthony PERARD | |
1980 | fd42deeb | Gerd Hoffmann | void qemu_add_exit_notifier(Notifier *notify)
|
1981 | fd42deeb | Gerd Hoffmann | { |
1982 | fd42deeb | Gerd Hoffmann | notifier_list_add(&exit_notifiers, notify); |
1983 | fd42deeb | Gerd Hoffmann | } |
1984 | fd42deeb | Gerd Hoffmann | |
1985 | fd42deeb | Gerd Hoffmann | void qemu_remove_exit_notifier(Notifier *notify)
|
1986 | fd42deeb | Gerd Hoffmann | { |
1987 | fd42deeb | Gerd Hoffmann | notifier_list_remove(&exit_notifiers, notify); |
1988 | fd42deeb | Gerd Hoffmann | } |
1989 | fd42deeb | Gerd Hoffmann | |
1990 | fd42deeb | Gerd Hoffmann | static void qemu_run_exit_notifiers(void) |
1991 | fd42deeb | Gerd Hoffmann | { |
1992 | fd42deeb | Gerd Hoffmann | notifier_list_notify(&exit_notifiers); |
1993 | fd42deeb | Gerd Hoffmann | } |
1994 | fd42deeb | Gerd Hoffmann | |
1995 | 4cab946a | Gleb Natapov | void qemu_add_machine_init_done_notifier(Notifier *notify)
|
1996 | 4cab946a | Gleb Natapov | { |
1997 | 4cab946a | Gleb Natapov | notifier_list_add(&machine_init_done_notifiers, notify); |
1998 | 4cab946a | Gleb Natapov | } |
1999 | 4cab946a | Gleb Natapov | |
2000 | 4cab946a | Gleb Natapov | static void qemu_run_machine_init_done_notifiers(void) |
2001 | 4cab946a | Gleb Natapov | { |
2002 | 4cab946a | Gleb Natapov | notifier_list_notify(&machine_init_done_notifiers); |
2003 | 4cab946a | Gleb Natapov | } |
2004 | 4cab946a | Gleb Natapov | |
2005 | 6530a97b | Anthony Liguori | static const QEMUOption *lookup_opt(int argc, char **argv, |
2006 | 6530a97b | Anthony Liguori | const char **poptarg, int *poptind) |
2007 | 6530a97b | Anthony Liguori | { |
2008 | 6530a97b | Anthony Liguori | const QEMUOption *popt;
|
2009 | 6530a97b | Anthony Liguori | int optind = *poptind;
|
2010 | 6530a97b | Anthony Liguori | char *r = argv[optind];
|
2011 | 6530a97b | Anthony Liguori | const char *optarg; |
2012 | 6530a97b | Anthony Liguori | |
2013 | 0f0bc3f1 | Markus Armbruster | loc_set_cmdline(argv, optind, 1);
|
2014 | 6530a97b | Anthony Liguori | optind++; |
2015 | 6530a97b | Anthony Liguori | /* Treat --foo the same as -foo. */
|
2016 | 6530a97b | Anthony Liguori | if (r[1] == '-') |
2017 | 6530a97b | Anthony Liguori | r++; |
2018 | 6530a97b | Anthony Liguori | popt = qemu_options; |
2019 | 6530a97b | Anthony Liguori | for(;;) {
|
2020 | 6530a97b | Anthony Liguori | if (!popt->name) {
|
2021 | 0f0bc3f1 | Markus Armbruster | error_report("invalid option");
|
2022 | 6530a97b | Anthony Liguori | exit(1);
|
2023 | 6530a97b | Anthony Liguori | } |
2024 | 6530a97b | Anthony Liguori | if (!strcmp(popt->name, r + 1)) |
2025 | 6530a97b | Anthony Liguori | break;
|
2026 | 6530a97b | Anthony Liguori | popt++; |
2027 | 6530a97b | Anthony Liguori | } |
2028 | 6530a97b | Anthony Liguori | if (popt->flags & HAS_ARG) {
|
2029 | 6530a97b | Anthony Liguori | if (optind >= argc) {
|
2030 | 0f0bc3f1 | Markus Armbruster | error_report("requires an argument");
|
2031 | 6530a97b | Anthony Liguori | exit(1);
|
2032 | 6530a97b | Anthony Liguori | } |
2033 | 6530a97b | Anthony Liguori | optarg = argv[optind++]; |
2034 | 0f0bc3f1 | Markus Armbruster | loc_set_cmdline(argv, optind - 2, 2); |
2035 | 6530a97b | Anthony Liguori | } else {
|
2036 | 6530a97b | Anthony Liguori | optarg = NULL;
|
2037 | 6530a97b | Anthony Liguori | } |
2038 | 6530a97b | Anthony Liguori | |
2039 | 6530a97b | Anthony Liguori | *poptarg = optarg; |
2040 | 6530a97b | Anthony Liguori | *poptind = optind; |
2041 | 6530a97b | Anthony Liguori | |
2042 | 6530a97b | Anthony Liguori | return popt;
|
2043 | 6530a97b | Anthony Liguori | } |
2044 | 6530a97b | Anthony Liguori | |
2045 | 902b3d5c | malc | int main(int argc, char **argv, char **envp) |
2046 | 0824d6fc | bellard | { |
2047 | 59030a8c | aliguori | const char *gdbstub_dev = NULL; |
2048 | e4bcb14c | ths | int i;
|
2049 | da1fcfda | Eduardo Habkost | int snapshot, linux_boot;
|
2050 | 4e3de9e9 | Paolo Bonzini | const char *icount_option = NULL; |
2051 | 7f7f9873 | bellard | const char *initrd_filename; |
2052 | a20dd508 | bellard | const char *kernel_filename, *kernel_cmdline; |
2053 | 195325a4 | Anthony Liguori | char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */ |
2054 | 3023f332 | aliguori | DisplayState *ds; |
2055 | 7d957bd8 | aliguori | DisplayChangeListener *dcl; |
2056 | 46d4767d | bellard | int cyls, heads, secs, translation;
|
2057 | f31d07d1 | Gerd Hoffmann | QemuOpts *hda_opts = NULL, *opts;
|
2058 | 03b0ba70 | Gerd Hoffmann | QemuOptsList *olist; |
2059 | cd6f1169 | bellard | int optind;
|
2060 | 6530a97b | Anthony Liguori | const char *optarg; |
2061 | d63d307f | bellard | const char *loadvm = NULL; |
2062 | cc1daa40 | bellard | QEMUMachine *machine; |
2063 | 94fc95cd | j_mayer | const char *cpu_model; |
2064 | 26a5f13b | bellard | int tb_size;
|
2065 | 93815bc2 | ths | const char *pid_file = NULL; |
2066 | 5bb7910a | aliguori | const char *incoming = NULL; |
2067 | 821601ea | Jes Sorensen | #ifdef CONFIG_VNC
|
2068 | 993fbfdb | Anthony Liguori | int show_vnc_port = 0; |
2069 | 821601ea | Jes Sorensen | #endif
|
2070 | 292444cb | Anthony Liguori | int defconfig = 1; |
2071 | ab6540d5 | Prerna Saxena | const char *trace_file = NULL; |
2072 | c235d738 | Matthew Fernandez | const char *log_mask = NULL; |
2073 | c235d738 | Matthew Fernandez | const char *log_file = NULL; |
2074 | 0b5538c3 | Stefan Hajnoczi | |
2075 | fd42deeb | Gerd Hoffmann | atexit(qemu_run_exit_notifiers); |
2076 | 65abca0a | Markus Armbruster | error_set_progname(argv[0]);
|
2077 | 65abca0a | Markus Armbruster | |
2078 | 6875204c | Jan Kiszka | init_clocks(); |
2079 | 6875204c | Jan Kiszka | |
2080 | 902b3d5c | malc | qemu_cache_utils_init(envp); |
2081 | 902b3d5c | malc | |
2082 | 72cf2d4f | Blue Swirl | QLIST_INIT (&vm_change_state_head); |
2083 | fe98ac14 | Jes Sorensen | os_setup_early_signal_handling(); |
2084 | be995c27 | bellard | |
2085 | f80f9ec9 | Anthony Liguori | module_call_init(MODULE_INIT_MACHINE); |
2086 | 0c257437 | Anthony Liguori | machine = find_default_machine(); |
2087 | 94fc95cd | j_mayer | cpu_model = NULL;
|
2088 | fc01f7e7 | bellard | initrd_filename = NULL;
|
2089 | 4fc5d071 | aurel32 | ram_size = 0;
|
2090 | 33e3963e | bellard | snapshot = 0;
|
2091 | a20dd508 | bellard | kernel_filename = NULL;
|
2092 | a20dd508 | bellard | kernel_cmdline = "";
|
2093 | c4b1fcc0 | bellard | cyls = heads = secs = 0;
|
2094 | 46d4767d | bellard | translation = BIOS_ATA_TRANSLATION_AUTO; |
2095 | c4b1fcc0 | bellard | |
2096 | 268a362c | aliguori | for (i = 0; i < MAX_NODES; i++) { |
2097 | 268a362c | aliguori | node_mem[i] = 0;
|
2098 | 268a362c | aliguori | node_cpumask[i] = 0;
|
2099 | 268a362c | aliguori | } |
2100 | 268a362c | aliguori | |
2101 | 268a362c | aliguori | nb_numa_nodes = 0;
|
2102 | 7c9d8e07 | bellard | nb_nics = 0;
|
2103 | 3b46e624 | ths | |
2104 | 26a5f13b | bellard | tb_size = 0;
|
2105 | 41bd639b | blueswir1 | autostart= 1;
|
2106 | 41bd639b | blueswir1 | |
2107 | 292444cb | Anthony Liguori | /* first pass of option parsing */
|
2108 | 292444cb | Anthony Liguori | optind = 1;
|
2109 | 292444cb | Anthony Liguori | while (optind < argc) {
|
2110 | 292444cb | Anthony Liguori | if (argv[optind][0] != '-') { |
2111 | 292444cb | Anthony Liguori | /* disk image */
|
2112 | 28e68d68 | Anthony Liguori | optind++; |
2113 | 292444cb | Anthony Liguori | continue;
|
2114 | 292444cb | Anthony Liguori | } else {
|
2115 | 292444cb | Anthony Liguori | const QEMUOption *popt;
|
2116 | 292444cb | Anthony Liguori | |
2117 | 292444cb | Anthony Liguori | popt = lookup_opt(argc, argv, &optarg, &optind); |
2118 | 292444cb | Anthony Liguori | switch (popt->index) {
|
2119 | 292444cb | Anthony Liguori | case QEMU_OPTION_nodefconfig:
|
2120 | 292444cb | Anthony Liguori | defconfig=0;
|
2121 | 292444cb | Anthony Liguori | break;
|
2122 | 292444cb | Anthony Liguori | } |
2123 | 292444cb | Anthony Liguori | } |
2124 | 292444cb | Anthony Liguori | } |
2125 | 292444cb | Anthony Liguori | |
2126 | 292444cb | Anthony Liguori | if (defconfig) {
|
2127 | dcfb0939 | Kevin Wolf | int ret;
|
2128 | cf5a65aa | Markus Armbruster | |
2129 | dcfb0939 | Kevin Wolf | ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
|
2130 | 019e78ba | Kevin Wolf | if (ret < 0 && ret != -ENOENT) { |
2131 | dcfb0939 | Kevin Wolf | exit(1);
|
2132 | 292444cb | Anthony Liguori | } |
2133 | 292444cb | Anthony Liguori | |
2134 | dcfb0939 | Kevin Wolf | ret = qemu_read_config_file(arch_config_name); |
2135 | 019e78ba | Kevin Wolf | if (ret < 0 && ret != -ENOENT) { |
2136 | dcfb0939 | Kevin Wolf | exit(1);
|
2137 | 292444cb | Anthony Liguori | } |
2138 | 292444cb | Anthony Liguori | } |
2139 | de06f8d1 | Blue Swirl | cpudef_init(); |
2140 | 292444cb | Anthony Liguori | |
2141 | 292444cb | Anthony Liguori | /* second pass of option parsing */
|
2142 | cd6f1169 | bellard | optind = 1;
|
2143 | 0824d6fc | bellard | for(;;) {
|
2144 | cd6f1169 | bellard | if (optind >= argc)
|
2145 | 0824d6fc | bellard | break;
|
2146 | 6530a97b | Anthony Liguori | if (argv[optind][0] != '-') { |
2147 | 2292ddae | Markus Armbruster | hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
|
2148 | cd6f1169 | bellard | } else {
|
2149 | cd6f1169 | bellard | const QEMUOption *popt;
|
2150 | cd6f1169 | bellard | |
2151 | 6530a97b | Anthony Liguori | popt = lookup_opt(argc, argv, &optarg, &optind); |
2152 | ad96090a | Blue Swirl | if (!(popt->arch_mask & arch_type)) {
|
2153 | ad96090a | Blue Swirl | printf("Option %s not supported for this target\n", popt->name);
|
2154 | ad96090a | Blue Swirl | exit(1);
|
2155 | ad96090a | Blue Swirl | } |
2156 | cd6f1169 | bellard | switch(popt->index) {
|
2157 | cc1daa40 | bellard | case QEMU_OPTION_M:
|
2158 | cc1daa40 | bellard | machine = find_machine(optarg); |
2159 | cc1daa40 | bellard | if (!machine) {
|
2160 | cc1daa40 | bellard | QEMUMachine *m; |
2161 | cc1daa40 | bellard | printf("Supported machines are:\n");
|
2162 | cc1daa40 | bellard | for(m = first_machine; m != NULL; m = m->next) { |
2163 | 3f6599e6 | Mark McLoughlin | if (m->alias)
|
2164 | 3f6599e6 | Mark McLoughlin | printf("%-10s %s (alias of %s)\n",
|
2165 | 3f6599e6 | Mark McLoughlin | m->alias, m->desc, m->name); |
2166 | cc1daa40 | bellard | printf("%-10s %s%s\n",
|
2167 | 5fafdf24 | ths | m->name, m->desc, |
2168 | 0c257437 | Anthony Liguori | m->is_default ? " (default)" : ""); |
2169 | cc1daa40 | bellard | } |
2170 | 15f82208 | ths | exit(*optarg != '?');
|
2171 | cc1daa40 | bellard | } |
2172 | cc1daa40 | bellard | break;
|
2173 | 94fc95cd | j_mayer | case QEMU_OPTION_cpu:
|
2174 | 94fc95cd | j_mayer | /* hw initialization will check this */
|
2175 | 15f82208 | ths | if (*optarg == '?') { |
2176 | 262353cb | Blue Swirl | list_cpus(stdout, &fprintf, optarg); |
2177 | 15f82208 | ths | exit(0);
|
2178 | 94fc95cd | j_mayer | } else {
|
2179 | 94fc95cd | j_mayer | cpu_model = optarg; |
2180 | 94fc95cd | j_mayer | } |
2181 | 94fc95cd | j_mayer | break;
|
2182 | cd6f1169 | bellard | case QEMU_OPTION_initrd:
|
2183 | fc01f7e7 | bellard | initrd_filename = optarg; |
2184 | fc01f7e7 | bellard | break;
|
2185 | cd6f1169 | bellard | case QEMU_OPTION_hda:
|
2186 | 5645b0f4 | Markus Armbruster | { |
2187 | 5645b0f4 | Markus Armbruster | char buf[256]; |
2188 | 5645b0f4 | Markus Armbruster | if (cyls == 0) |
2189 | 5645b0f4 | Markus Armbruster | snprintf(buf, sizeof(buf), "%s", HD_OPTS); |
2190 | 5645b0f4 | Markus Armbruster | else
|
2191 | 5645b0f4 | Markus Armbruster | snprintf(buf, sizeof(buf),
|
2192 | 5645b0f4 | Markus Armbruster | "%s,cyls=%d,heads=%d,secs=%d%s",
|
2193 | 5645b0f4 | Markus Armbruster | HD_OPTS , cyls, heads, secs, |
2194 | 5645b0f4 | Markus Armbruster | translation == BIOS_ATA_TRANSLATION_LBA ? |
2195 | e4bcb14c | ths | ",trans=lba" :
|
2196 | 5645b0f4 | Markus Armbruster | translation == BIOS_ATA_TRANSLATION_NONE ? |
2197 | e4bcb14c | ths | ",trans=none" : ""); |
2198 | 5645b0f4 | Markus Armbruster | drive_add(IF_DEFAULT, 0, optarg, buf);
|
2199 | 5645b0f4 | Markus Armbruster | break;
|
2200 | 5645b0f4 | Markus Armbruster | } |
2201 | cd6f1169 | bellard | case QEMU_OPTION_hdb:
|
2202 | cc1daa40 | bellard | case QEMU_OPTION_hdc:
|
2203 | cc1daa40 | bellard | case QEMU_OPTION_hdd:
|
2204 | 2292ddae | Markus Armbruster | drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg, |
2205 | 2292ddae | Markus Armbruster | HD_OPTS); |
2206 | fc01f7e7 | bellard | break;
|
2207 | e4bcb14c | ths | case QEMU_OPTION_drive:
|
2208 | e2982c3a | Michael Tokarev | if (drive_def(optarg) == NULL) { |
2209 | e2982c3a | Michael Tokarev | exit(1);
|
2210 | e2982c3a | Michael Tokarev | } |
2211 | e4bcb14c | ths | break;
|
2212 | d058fe03 | Gerd Hoffmann | case QEMU_OPTION_set:
|
2213 | d058fe03 | Gerd Hoffmann | if (qemu_set_option(optarg) != 0) |
2214 | d058fe03 | Gerd Hoffmann | exit(1);
|
2215 | d058fe03 | Gerd Hoffmann | break;
|
2216 | d0fef6fb | Gerd Hoffmann | case QEMU_OPTION_global:
|
2217 | d0fef6fb | Gerd Hoffmann | if (qemu_global_option(optarg) != 0) |
2218 | d0fef6fb | Gerd Hoffmann | exit(1);
|
2219 | d0fef6fb | Gerd Hoffmann | break;
|
2220 | 3e3d5815 | balrog | case QEMU_OPTION_mtdblock:
|
2221 | 2292ddae | Markus Armbruster | drive_add(IF_MTD, -1, optarg, MTD_OPTS);
|
2222 | 3e3d5815 | balrog | break;
|
2223 | a1bb27b1 | pbrook | case QEMU_OPTION_sd:
|
2224 | 2292ddae | Markus Armbruster | drive_add(IF_SD, 0, optarg, SD_OPTS);
|
2225 | a1bb27b1 | pbrook | break;
|
2226 | 86f55663 | j_mayer | case QEMU_OPTION_pflash:
|
2227 | 2292ddae | Markus Armbruster | drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);
|
2228 | 86f55663 | j_mayer | break;
|
2229 | cd6f1169 | bellard | case QEMU_OPTION_snapshot:
|
2230 | 33e3963e | bellard | snapshot = 1;
|
2231 | 33e3963e | bellard | break;
|
2232 | cd6f1169 | bellard | case QEMU_OPTION_hdachs:
|
2233 | 330d0414 | bellard | { |
2234 | 330d0414 | bellard | const char *p; |
2235 | 330d0414 | bellard | p = optarg; |
2236 | 330d0414 | bellard | cyls = strtol(p, (char **)&p, 0); |
2237 | 46d4767d | bellard | if (cyls < 1 || cyls > 16383) |
2238 | 46d4767d | bellard | goto chs_fail;
|
2239 | 330d0414 | bellard | if (*p != ',') |
2240 | 330d0414 | bellard | goto chs_fail;
|
2241 | 330d0414 | bellard | p++; |
2242 | 330d0414 | bellard | heads = strtol(p, (char **)&p, 0); |
2243 | 46d4767d | bellard | if (heads < 1 || heads > 16) |
2244 | 46d4767d | bellard | goto chs_fail;
|
2245 | 330d0414 | bellard | if (*p != ',') |
2246 | 330d0414 | bellard | goto chs_fail;
|
2247 | 330d0414 | bellard | p++; |
2248 | 330d0414 | bellard | secs = strtol(p, (char **)&p, 0); |
2249 | 46d4767d | bellard | if (secs < 1 || secs > 63) |
2250 | 46d4767d | bellard | goto chs_fail;
|
2251 | 46d4767d | bellard | if (*p == ',') { |
2252 | 46d4767d | bellard | p++; |
2253 | 46d4767d | bellard | if (!strcmp(p, "none")) |
2254 | 46d4767d | bellard | translation = BIOS_ATA_TRANSLATION_NONE; |
2255 | 46d4767d | bellard | else if (!strcmp(p, "lba")) |
2256 | 46d4767d | bellard | translation = BIOS_ATA_TRANSLATION_LBA; |
2257 | 46d4767d | bellard | else if (!strcmp(p, "auto")) |
2258 | 46d4767d | bellard | translation = BIOS_ATA_TRANSLATION_AUTO; |
2259 | 46d4767d | bellard | else
|
2260 | 46d4767d | bellard | goto chs_fail;
|
2261 | 46d4767d | bellard | } else if (*p != '\0') { |
2262 | c4b1fcc0 | bellard | chs_fail:
|
2263 | 46d4767d | bellard | fprintf(stderr, "qemu: invalid physical CHS format\n");
|
2264 | 46d4767d | bellard | exit(1);
|
2265 | c4b1fcc0 | bellard | } |
2266 | 9dfd7c7a | Gerd Hoffmann | if (hda_opts != NULL) { |
2267 | 9dfd7c7a | Gerd Hoffmann | char num[16]; |
2268 | 9dfd7c7a | Gerd Hoffmann | snprintf(num, sizeof(num), "%d", cyls); |
2269 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(hda_opts, "cyls", num);
|
2270 | 9dfd7c7a | Gerd Hoffmann | snprintf(num, sizeof(num), "%d", heads); |
2271 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(hda_opts, "heads", num);
|
2272 | 9dfd7c7a | Gerd Hoffmann | snprintf(num, sizeof(num), "%d", secs); |
2273 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(hda_opts, "secs", num);
|
2274 | 9dfd7c7a | Gerd Hoffmann | if (translation == BIOS_ATA_TRANSLATION_LBA)
|
2275 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(hda_opts, "trans", "lba"); |
2276 | 9dfd7c7a | Gerd Hoffmann | if (translation == BIOS_ATA_TRANSLATION_NONE)
|
2277 | 9dfd7c7a | Gerd Hoffmann | qemu_opt_set(hda_opts, "trans", "none"); |
2278 | 9dfd7c7a | Gerd Hoffmann | } |
2279 | 330d0414 | bellard | } |
2280 | 330d0414 | bellard | break;
|
2281 | 268a362c | aliguori | case QEMU_OPTION_numa:
|
2282 | 268a362c | aliguori | if (nb_numa_nodes >= MAX_NODES) {
|
2283 | 268a362c | aliguori | fprintf(stderr, "qemu: too many NUMA nodes\n");
|
2284 | 268a362c | aliguori | exit(1);
|
2285 | 268a362c | aliguori | } |
2286 | 268a362c | aliguori | numa_add(optarg); |
2287 | 268a362c | aliguori | break;
|
2288 | 1472a95b | Jes Sorensen | case QEMU_OPTION_display:
|
2289 | 1472a95b | Jes Sorensen | display_type = select_display(optarg); |
2290 | 1472a95b | Jes Sorensen | break;
|
2291 | cd6f1169 | bellard | case QEMU_OPTION_nographic:
|
2292 | 993fbfdb | Anthony Liguori | display_type = DT_NOGRAPHIC; |
2293 | a20dd508 | bellard | break;
|
2294 | 4d3b6f6e | balrog | case QEMU_OPTION_curses:
|
2295 | 47b05369 | Jes Sorensen | #ifdef CONFIG_CURSES
|
2296 | 993fbfdb | Anthony Liguori | display_type = DT_CURSES; |
2297 | 47b05369 | Jes Sorensen | #else
|
2298 | 47b05369 | Jes Sorensen | fprintf(stderr, "Curses support is disabled\n");
|
2299 | 47b05369 | Jes Sorensen | exit(1);
|
2300 | 4d3b6f6e | balrog | #endif
|
2301 | 47b05369 | Jes Sorensen | break;
|
2302 | a171fe39 | balrog | case QEMU_OPTION_portrait:
|
2303 | 9312805d | Vasily Khoruzhick | graphic_rotate = 90;
|
2304 | 9312805d | Vasily Khoruzhick | break;
|
2305 | 9312805d | Vasily Khoruzhick | case QEMU_OPTION_rotate:
|
2306 | 9312805d | Vasily Khoruzhick | graphic_rotate = strtol(optarg, (char **) &optarg, 10); |
2307 | 9312805d | Vasily Khoruzhick | if (graphic_rotate != 0 && graphic_rotate != 90 && |
2308 | 9312805d | Vasily Khoruzhick | graphic_rotate != 180 && graphic_rotate != 270) { |
2309 | 9312805d | Vasily Khoruzhick | fprintf(stderr, |
2310 | 9312805d | Vasily Khoruzhick | "qemu: only 90, 180, 270 deg rotation is available\n");
|
2311 | 9312805d | Vasily Khoruzhick | exit(1);
|
2312 | 9312805d | Vasily Khoruzhick | } |
2313 | a171fe39 | balrog | break;
|
2314 | cd6f1169 | bellard | case QEMU_OPTION_kernel:
|
2315 | a20dd508 | bellard | kernel_filename = optarg; |
2316 | a20dd508 | bellard | break;
|
2317 | cd6f1169 | bellard | case QEMU_OPTION_append:
|
2318 | a20dd508 | bellard | kernel_cmdline = optarg; |
2319 | 313aa567 | bellard | break;
|
2320 | cd6f1169 | bellard | case QEMU_OPTION_cdrom:
|
2321 | 2292ddae | Markus Armbruster | drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
|
2322 | 36b486bb | bellard | break;
|
2323 | cd6f1169 | bellard | case QEMU_OPTION_boot:
|
2324 | 28c5af54 | j_mayer | { |
2325 | ef3adf68 | Jan Kiszka | static const char * const params[] = { |
2326 | 95387491 | Jan Kiszka | "order", "once", "menu", NULL |
2327 | ef3adf68 | Jan Kiszka | }; |
2328 | ef3adf68 | Jan Kiszka | char buf[sizeof(boot_devices)]; |
2329 | e0f084bf | Jan Kiszka | char *standard_boot_devices;
|
2330 | ef3adf68 | Jan Kiszka | int legacy = 0; |
2331 | ef3adf68 | Jan Kiszka | |
2332 | ef3adf68 | Jan Kiszka | if (!strchr(optarg, '=')) { |
2333 | ef3adf68 | Jan Kiszka | legacy = 1;
|
2334 | ef3adf68 | Jan Kiszka | pstrcpy(buf, sizeof(buf), optarg);
|
2335 | ef3adf68 | Jan Kiszka | } else if (check_params(buf, sizeof(buf), params, optarg) < 0) { |
2336 | ef3adf68 | Jan Kiszka | fprintf(stderr, |
2337 | ef3adf68 | Jan Kiszka | "qemu: unknown boot parameter '%s' in '%s'\n",
|
2338 | ef3adf68 | Jan Kiszka | buf, optarg); |
2339 | ef3adf68 | Jan Kiszka | exit(1);
|
2340 | ef3adf68 | Jan Kiszka | } |
2341 | ef3adf68 | Jan Kiszka | |
2342 | ef3adf68 | Jan Kiszka | if (legacy ||
|
2343 | ef3adf68 | Jan Kiszka | get_param_value(buf, sizeof(buf), "order", optarg)) { |
2344 | 4e9e9d6e | Eduardo Habkost | validate_bootdevices(buf); |
2345 | ef3adf68 | Jan Kiszka | pstrcpy(boot_devices, sizeof(boot_devices), buf);
|
2346 | 28c5af54 | j_mayer | } |
2347 | e0f084bf | Jan Kiszka | if (!legacy) {
|
2348 | e0f084bf | Jan Kiszka | if (get_param_value(buf, sizeof(buf), |
2349 | e0f084bf | Jan Kiszka | "once", optarg)) {
|
2350 | 4e9e9d6e | Eduardo Habkost | validate_bootdevices(buf); |
2351 | e0f084bf | Jan Kiszka | standard_boot_devices = qemu_strdup(boot_devices); |
2352 | e0f084bf | Jan Kiszka | pstrcpy(boot_devices, sizeof(boot_devices), buf);
|
2353 | e0f084bf | Jan Kiszka | qemu_register_reset(restore_boot_devices, |
2354 | e0f084bf | Jan Kiszka | standard_boot_devices); |
2355 | e0f084bf | Jan Kiszka | } |
2356 | 95387491 | Jan Kiszka | if (get_param_value(buf, sizeof(buf), |
2357 | 95387491 | Jan Kiszka | "menu", optarg)) {
|
2358 | 95387491 | Jan Kiszka | if (!strcmp(buf, "on")) { |
2359 | 95387491 | Jan Kiszka | boot_menu = 1;
|
2360 | 95387491 | Jan Kiszka | } else if (!strcmp(buf, "off")) { |
2361 | 95387491 | Jan Kiszka | boot_menu = 0;
|
2362 | 95387491 | Jan Kiszka | } else {
|
2363 | 95387491 | Jan Kiszka | fprintf(stderr, |
2364 | 95387491 | Jan Kiszka | "qemu: invalid option value '%s'\n",
|
2365 | 95387491 | Jan Kiszka | buf); |
2366 | 95387491 | Jan Kiszka | exit(1);
|
2367 | 95387491 | Jan Kiszka | } |
2368 | 95387491 | Jan Kiszka | } |
2369 | e0f084bf | Jan Kiszka | } |
2370 | 36b486bb | bellard | } |
2371 | 36b486bb | bellard | break;
|
2372 | cd6f1169 | bellard | case QEMU_OPTION_fda:
|
2373 | cd6f1169 | bellard | case QEMU_OPTION_fdb:
|
2374 | 2292ddae | Markus Armbruster | drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda, |
2375 | 2292ddae | Markus Armbruster | optarg, FD_OPTS); |
2376 | c45886db | bellard | break;
|
2377 | 52ca8d6a | bellard | case QEMU_OPTION_no_fd_bootchk:
|
2378 | 52ca8d6a | bellard | fd_bootchk = 0;
|
2379 | 52ca8d6a | bellard | break;
|
2380 | a1ea458f | Mark McLoughlin | case QEMU_OPTION_netdev:
|
2381 | 3329f07b | Gerd Hoffmann | if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) { |
2382 | a1ea458f | Mark McLoughlin | exit(1);
|
2383 | a1ea458f | Mark McLoughlin | } |
2384 | a1ea458f | Mark McLoughlin | break;
|
2385 | 7c9d8e07 | bellard | case QEMU_OPTION_net:
|
2386 | 3329f07b | Gerd Hoffmann | if (net_client_parse(qemu_find_opts("net"), optarg) == -1) { |
2387 | c4b1fcc0 | bellard | exit(1);
|
2388 | c4b1fcc0 | bellard | } |
2389 | 702c651c | bellard | break;
|
2390 | c7f74643 | bellard | #ifdef CONFIG_SLIRP
|
2391 | c7f74643 | bellard | case QEMU_OPTION_tftp:
|
2392 | ad196a9d | Jan Kiszka | legacy_tftp_prefix = optarg; |
2393 | 9bf05444 | bellard | break;
|
2394 | 47d5d01a | ths | case QEMU_OPTION_bootp:
|
2395 | ad196a9d | Jan Kiszka | legacy_bootp_filename = optarg; |
2396 | 47d5d01a | ths | break;
|
2397 | 9bf05444 | bellard | case QEMU_OPTION_redir:
|
2398 | 0752706d | Markus Armbruster | if (net_slirp_redir(optarg) < 0) |
2399 | 0752706d | Markus Armbruster | exit(1);
|
2400 | 9bf05444 | bellard | break;
|
2401 | c7f74643 | bellard | #endif
|
2402 | dc72ac14 | balrog | case QEMU_OPTION_bt:
|
2403 | bd3c948d | Gerd Hoffmann | add_device_config(DEV_BT, optarg); |
2404 | dc72ac14 | balrog | break;
|
2405 | 1d14ffa9 | bellard | case QEMU_OPTION_audio_help:
|
2406 | ad96090a | Blue Swirl | if (!(audio_available())) {
|
2407 | ad96090a | Blue Swirl | printf("Option %s not supported for this target\n", popt->name);
|
2408 | ad96090a | Blue Swirl | exit(1);
|
2409 | ad96090a | Blue Swirl | } |
2410 | 1d14ffa9 | bellard | AUD_help (); |
2411 | 1d14ffa9 | bellard | exit (0);
|
2412 | 1d14ffa9 | bellard | break;
|
2413 | 1d14ffa9 | bellard | case QEMU_OPTION_soundhw:
|
2414 | ad96090a | Blue Swirl | if (!(audio_available())) {
|
2415 | ad96090a | Blue Swirl | printf("Option %s not supported for this target\n", popt->name);
|
2416 | ad96090a | Blue Swirl | exit(1);
|
2417 | ad96090a | Blue Swirl | } |
2418 | 1d14ffa9 | bellard | select_soundhw (optarg); |
2419 | 1d14ffa9 | bellard | break;
|
2420 | cd6f1169 | bellard | case QEMU_OPTION_h:
|
2421 | 15f82208 | ths | help(0);
|
2422 | cd6f1169 | bellard | break;
|
2423 | 9bd7e6d9 | pbrook | case QEMU_OPTION_version:
|
2424 | 9bd7e6d9 | pbrook | version(); |
2425 | 9bd7e6d9 | pbrook | exit(0);
|
2426 | 9bd7e6d9 | pbrook | break;
|
2427 | 00f82b8a | aurel32 | case QEMU_OPTION_m: {
|
2428 | 70b4f4bb | Jes Sorensen | int64_t value; |
2429 | 9f9b17a4 | Jes Sorensen | |
2430 | 9f9b17a4 | Jes Sorensen | value = strtosz(optarg, NULL);
|
2431 | 9f9b17a4 | Jes Sorensen | if (value < 0) { |
2432 | 00f82b8a | aurel32 | fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
|
2433 | cd6f1169 | bellard | exit(1);
|
2434 | cd6f1169 | bellard | } |
2435 | 00f82b8a | aurel32 | |
2436 | 00f82b8a | aurel32 | /* On 32-bit hosts, QEMU is limited by virtual address space */
|
2437 | 4a1418e0 | Anthony Liguori | if (value > (2047 << 20) && HOST_LONG_BITS == 32) { |
2438 | 00f82b8a | aurel32 | fprintf(stderr, "qemu: at most 2047 MB RAM can be simulated\n");
|
2439 | 00f82b8a | aurel32 | exit(1);
|
2440 | 00f82b8a | aurel32 | } |
2441 | c227f099 | Anthony Liguori | if (value != (uint64_t)(ram_addr_t)value) {
|
2442 | 00f82b8a | aurel32 | fprintf(stderr, "qemu: ram size too large\n");
|
2443 | 00f82b8a | aurel32 | exit(1);
|
2444 | 00f82b8a | aurel32 | } |
2445 | 00f82b8a | aurel32 | ram_size = value; |
2446 | cd6f1169 | bellard | break;
|
2447 | 00f82b8a | aurel32 | } |
2448 | c902760f | Marcelo Tosatti | case QEMU_OPTION_mempath:
|
2449 | c902760f | Marcelo Tosatti | mem_path = optarg; |
2450 | c902760f | Marcelo Tosatti | break;
|
2451 | c902760f | Marcelo Tosatti | #ifdef MAP_POPULATE
|
2452 | c902760f | Marcelo Tosatti | case QEMU_OPTION_mem_prealloc:
|
2453 | c902760f | Marcelo Tosatti | mem_prealloc = 1;
|
2454 | c902760f | Marcelo Tosatti | break;
|
2455 | c902760f | Marcelo Tosatti | #endif
|
2456 | cd6f1169 | bellard | case QEMU_OPTION_d:
|
2457 | c235d738 | Matthew Fernandez | log_mask = optarg; |
2458 | c235d738 | Matthew Fernandez | break;
|
2459 | c235d738 | Matthew Fernandez | case QEMU_OPTION_D:
|
2460 | c235d738 | Matthew Fernandez | log_file = optarg; |
2461 | cd6f1169 | bellard | break;
|
2462 | cd6f1169 | bellard | case QEMU_OPTION_s:
|
2463 | 59030a8c | aliguori | gdbstub_dev = "tcp::" DEFAULT_GDBSTUB_PORT;
|
2464 | cd6f1169 | bellard | break;
|
2465 | 59030a8c | aliguori | case QEMU_OPTION_gdb:
|
2466 | 59030a8c | aliguori | gdbstub_dev = optarg; |
2467 | cd6f1169 | bellard | break;
|
2468 | cd6f1169 | bellard | case QEMU_OPTION_L:
|
2469 | 5cea8590 | Paul Brook | data_dir = optarg; |
2470 | cd6f1169 | bellard | break;
|
2471 | 1192dad8 | j_mayer | case QEMU_OPTION_bios:
|
2472 | 1192dad8 | j_mayer | bios_name = optarg; |
2473 | 1192dad8 | j_mayer | break;
|
2474 | 1b530a6d | aurel32 | case QEMU_OPTION_singlestep:
|
2475 | 1b530a6d | aurel32 | singlestep = 1;
|
2476 | 1b530a6d | aurel32 | break;
|
2477 | cd6f1169 | bellard | case QEMU_OPTION_S:
|
2478 | 3c07f8e8 | pbrook | autostart = 0;
|
2479 | cd6f1169 | bellard | break;
|
2480 | 3d11d0eb | bellard | case QEMU_OPTION_k:
|
2481 | 3d11d0eb | bellard | keyboard_layout = optarg; |
2482 | 3d11d0eb | bellard | break;
|
2483 | ee22c2f7 | bellard | case QEMU_OPTION_localtime:
|
2484 | ee22c2f7 | bellard | rtc_utc = 0;
|
2485 | ee22c2f7 | bellard | break;
|
2486 | 3893c124 | malc | case QEMU_OPTION_vga:
|
2487 | 3893c124 | malc | select_vgahw (optarg); |
2488 | 1bfe856e | bellard | break;
|
2489 | e9b137c2 | bellard | case QEMU_OPTION_g:
|
2490 | e9b137c2 | bellard | { |
2491 | e9b137c2 | bellard | const char *p; |
2492 | e9b137c2 | bellard | int w, h, depth;
|
2493 | e9b137c2 | bellard | p = optarg; |
2494 | e9b137c2 | bellard | w = strtol(p, (char **)&p, 10); |
2495 | e9b137c2 | bellard | if (w <= 0) { |
2496 | e9b137c2 | bellard | graphic_error:
|
2497 | e9b137c2 | bellard | fprintf(stderr, "qemu: invalid resolution or depth\n");
|
2498 | e9b137c2 | bellard | exit(1);
|
2499 | e9b137c2 | bellard | } |
2500 | e9b137c2 | bellard | if (*p != 'x') |
2501 | e9b137c2 | bellard | goto graphic_error;
|
2502 | e9b137c2 | bellard | p++; |
2503 | e9b137c2 | bellard | h = strtol(p, (char **)&p, 10); |
2504 | e9b137c2 | bellard | if (h <= 0) |
2505 | e9b137c2 | bellard | goto graphic_error;
|
2506 | e9b137c2 | bellard | if (*p == 'x') { |
2507 | e9b137c2 | bellard | p++; |
2508 | e9b137c2 | bellard | depth = strtol(p, (char **)&p, 10); |
2509 | 5fafdf24 | ths | if (depth != 8 && depth != 15 && depth != 16 && |
2510 | e9b137c2 | bellard | depth != 24 && depth != 32) |
2511 | e9b137c2 | bellard | goto graphic_error;
|
2512 | e9b137c2 | bellard | } else if (*p == '\0') { |
2513 | e9b137c2 | bellard | depth = graphic_depth; |
2514 | e9b137c2 | bellard | } else {
|
2515 | e9b137c2 | bellard | goto graphic_error;
|
2516 | e9b137c2 | bellard | } |
2517 | 3b46e624 | ths | |
2518 | e9b137c2 | bellard | graphic_width = w; |
2519 | e9b137c2 | bellard | graphic_height = h; |
2520 | e9b137c2 | bellard | graphic_depth = depth; |
2521 | e9b137c2 | bellard | } |
2522 | e9b137c2 | bellard | break;
|
2523 | 20d8a3ed | ths | case QEMU_OPTION_echr:
|
2524 | 20d8a3ed | ths | { |
2525 | 20d8a3ed | ths | char *r;
|
2526 | 20d8a3ed | ths | term_escape_char = strtol(optarg, &r, 0);
|
2527 | 20d8a3ed | ths | if (r == optarg)
|
2528 | 20d8a3ed | ths | printf("Bad argument to echr\n");
|
2529 | 20d8a3ed | ths | break;
|
2530 | 20d8a3ed | ths | } |
2531 | 82c643ff | bellard | case QEMU_OPTION_monitor:
|
2532 | 6ca5582d | Gerd Hoffmann | monitor_parse(optarg, "readline");
|
2533 | 6ca5582d | Gerd Hoffmann | default_monitor = 0;
|
2534 | 6ca5582d | Gerd Hoffmann | break;
|
2535 | 6ca5582d | Gerd Hoffmann | case QEMU_OPTION_qmp:
|
2536 | 6ca5582d | Gerd Hoffmann | monitor_parse(optarg, "control");
|
2537 | 2d114dc1 | Anthony Liguori | default_monitor = 0;
|
2538 | 82c643ff | bellard | break;
|
2539 | 22a0e04b | Gerd Hoffmann | case QEMU_OPTION_mon:
|
2540 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1); |
2541 | 22a0e04b | Gerd Hoffmann | if (!opts) {
|
2542 | 22a0e04b | Gerd Hoffmann | exit(1);
|
2543 | 22a0e04b | Gerd Hoffmann | } |
2544 | 2d114dc1 | Anthony Liguori | default_monitor = 0;
|
2545 | 22a0e04b | Gerd Hoffmann | break;
|
2546 | 191bc01b | Gerd Hoffmann | case QEMU_OPTION_chardev:
|
2547 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_parse(qemu_find_opts("chardev"), optarg, 1); |
2548 | 191bc01b | Gerd Hoffmann | if (!opts) {
|
2549 | 191bc01b | Gerd Hoffmann | exit(1);
|
2550 | 191bc01b | Gerd Hoffmann | } |
2551 | 191bc01b | Gerd Hoffmann | break;
|
2552 | 74db920c | Gautham R Shenoy | case QEMU_OPTION_fsdev:
|
2553 | 03b0ba70 | Gerd Hoffmann | olist = qemu_find_opts("fsdev");
|
2554 | 03b0ba70 | Gerd Hoffmann | if (!olist) {
|
2555 | 03b0ba70 | Gerd Hoffmann | fprintf(stderr, "fsdev is not supported by this qemu build.\n");
|
2556 | 03b0ba70 | Gerd Hoffmann | exit(1);
|
2557 | 03b0ba70 | Gerd Hoffmann | } |
2558 | 03b0ba70 | Gerd Hoffmann | opts = qemu_opts_parse(olist, optarg, 1);
|
2559 | 74db920c | Gautham R Shenoy | if (!opts) {
|
2560 | 74db920c | Gautham R Shenoy | fprintf(stderr, "parse error: %s\n", optarg);
|
2561 | 74db920c | Gautham R Shenoy | exit(1);
|
2562 | 74db920c | Gautham R Shenoy | } |
2563 | 74db920c | Gautham R Shenoy | break;
|
2564 | 3d54abc7 | Gautham R Shenoy | case QEMU_OPTION_virtfs: {
|
2565 | e14ea479 | Stefan Hajnoczi | QemuOpts *fsdev; |
2566 | e14ea479 | Stefan Hajnoczi | QemuOpts *device; |
2567 | 3d54abc7 | Gautham R Shenoy | |
2568 | 03b0ba70 | Gerd Hoffmann | olist = qemu_find_opts("virtfs");
|
2569 | 03b0ba70 | Gerd Hoffmann | if (!olist) {
|
2570 | 03b0ba70 | Gerd Hoffmann | fprintf(stderr, "virtfs is not supported by this qemu build.\n");
|
2571 | 03b0ba70 | Gerd Hoffmann | exit(1);
|
2572 | 03b0ba70 | Gerd Hoffmann | } |
2573 | 03b0ba70 | Gerd Hoffmann | opts = qemu_opts_parse(olist, optarg, 1);
|
2574 | 3d54abc7 | Gautham R Shenoy | if (!opts) {
|
2575 | 3d54abc7 | Gautham R Shenoy | fprintf(stderr, "parse error: %s\n", optarg);
|
2576 | 3d54abc7 | Gautham R Shenoy | exit(1);
|
2577 | 3d54abc7 | Gautham R Shenoy | } |
2578 | 3d54abc7 | Gautham R Shenoy | |
2579 | 9ce56db6 | Venkateswararao Jujjuri (JV) | if (qemu_opt_get(opts, "fstype") == NULL || |
2580 | 9ce56db6 | Venkateswararao Jujjuri (JV) | qemu_opt_get(opts, "mount_tag") == NULL || |
2581 | 9ce56db6 | Venkateswararao Jujjuri (JV) | qemu_opt_get(opts, "path") == NULL || |
2582 | 9ce56db6 | Venkateswararao Jujjuri (JV) | qemu_opt_get(opts, "security_model") == NULL) { |
2583 | 9ce56db6 | Venkateswararao Jujjuri (JV) | fprintf(stderr, "Usage: -virtfs fstype,path=/share_path/,"
|
2584 | 12848bfc | Aneesh Kumar K.V | "security_model=[mapped|passthrough|none],"
|
2585 | e14ea479 | Stefan Hajnoczi | "mount_tag=tag.\n");
|
2586 | 9ce56db6 | Venkateswararao Jujjuri (JV) | exit(1);
|
2587 | 9ce56db6 | Venkateswararao Jujjuri (JV) | } |
2588 | 9ce56db6 | Venkateswararao Jujjuri (JV) | |
2589 | e14ea479 | Stefan Hajnoczi | fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
|
2590 | e14ea479 | Stefan Hajnoczi | qemu_opt_get(opts, "mount_tag"), 1); |
2591 | e14ea479 | Stefan Hajnoczi | if (!fsdev) {
|
2592 | e14ea479 | Stefan Hajnoczi | fprintf(stderr, "duplicate fsdev id: %s\n",
|
2593 | e14ea479 | Stefan Hajnoczi | qemu_opt_get(opts, "mount_tag"));
|
2594 | 3d54abc7 | Gautham R Shenoy | exit(1);
|
2595 | 3d54abc7 | Gautham R Shenoy | } |
2596 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(fsdev, "fstype", qemu_opt_get(opts, "fstype")); |
2597 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path")); |
2598 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(fsdev, "security_model",
|
2599 | e14ea479 | Stefan Hajnoczi | qemu_opt_get(opts, "security_model"));
|
2600 | e14ea479 | Stefan Hajnoczi | |
2601 | e14ea479 | Stefan Hajnoczi | device = qemu_opts_create(qemu_find_opts("device"), NULL, 0); |
2602 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(device, "driver", "virtio-9p-pci"); |
2603 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(device, "fsdev",
|
2604 | e14ea479 | Stefan Hajnoczi | qemu_opt_get(opts, "mount_tag"));
|
2605 | e14ea479 | Stefan Hajnoczi | qemu_opt_set(device, "mount_tag",
|
2606 | e14ea479 | Stefan Hajnoczi | qemu_opt_get(opts, "mount_tag"));
|
2607 | 3d54abc7 | Gautham R Shenoy | break;
|
2608 | 3d54abc7 | Gautham R Shenoy | } |
2609 | 82c643ff | bellard | case QEMU_OPTION_serial:
|
2610 | 998bbd74 | Gerd Hoffmann | add_device_config(DEV_SERIAL, optarg); |
2611 | 998bbd74 | Gerd Hoffmann | default_serial = 0;
|
2612 | 18141ed6 | Jan Kiszka | if (strncmp(optarg, "mon:", 4) == 0) { |
2613 | 18141ed6 | Jan Kiszka | default_monitor = 0;
|
2614 | 18141ed6 | Jan Kiszka | } |
2615 | 82c643ff | bellard | break;
|
2616 | 9dd986cc | Richard W.M. Jones | case QEMU_OPTION_watchdog:
|
2617 | 09aaa160 | Markus Armbruster | if (watchdog) {
|
2618 | 09aaa160 | Markus Armbruster | fprintf(stderr, |
2619 | 09aaa160 | Markus Armbruster | "qemu: only one watchdog option may be given\n");
|
2620 | 09aaa160 | Markus Armbruster | return 1; |
2621 | 09aaa160 | Markus Armbruster | } |
2622 | 09aaa160 | Markus Armbruster | watchdog = optarg; |
2623 | 9dd986cc | Richard W.M. Jones | break;
|
2624 | 9dd986cc | Richard W.M. Jones | case QEMU_OPTION_watchdog_action:
|
2625 | 9dd986cc | Richard W.M. Jones | if (select_watchdog_action(optarg) == -1) { |
2626 | 9dd986cc | Richard W.M. Jones | fprintf(stderr, "Unknown -watchdog-action parameter\n");
|
2627 | 9dd986cc | Richard W.M. Jones | exit(1);
|
2628 | 9dd986cc | Richard W.M. Jones | } |
2629 | 9dd986cc | Richard W.M. Jones | break;
|
2630 | 51ecf136 | aliguori | case QEMU_OPTION_virtiocon:
|
2631 | aee1b935 | Gerd Hoffmann | add_device_config(DEV_VIRTCON, optarg); |
2632 | aee1b935 | Gerd Hoffmann | default_virtcon = 0;
|
2633 | 18141ed6 | Jan Kiszka | if (strncmp(optarg, "mon:", 4) == 0) { |
2634 | 18141ed6 | Jan Kiszka | default_monitor = 0;
|
2635 | 18141ed6 | Jan Kiszka | } |
2636 | 51ecf136 | aliguori | break;
|
2637 | 6508fe59 | bellard | case QEMU_OPTION_parallel:
|
2638 | 6a5e8b0e | Gerd Hoffmann | add_device_config(DEV_PARALLEL, optarg); |
2639 | 6a5e8b0e | Gerd Hoffmann | default_parallel = 0;
|
2640 | 18141ed6 | Jan Kiszka | if (strncmp(optarg, "mon:", 4) == 0) { |
2641 | 18141ed6 | Jan Kiszka | default_monitor = 0;
|
2642 | 18141ed6 | Jan Kiszka | } |
2643 | 6508fe59 | bellard | break;
|
2644 | c9f398e5 | H. Peter Anvin | case QEMU_OPTION_debugcon:
|
2645 | c9f398e5 | H. Peter Anvin | add_device_config(DEV_DEBUGCON, optarg); |
2646 | c9f398e5 | H. Peter Anvin | break;
|
2647 | d63d307f | bellard | case QEMU_OPTION_loadvm:
|
2648 | d63d307f | bellard | loadvm = optarg; |
2649 | d63d307f | bellard | break;
|
2650 | d63d307f | bellard | case QEMU_OPTION_full_screen:
|
2651 | d63d307f | bellard | full_screen = 1;
|
2652 | d63d307f | bellard | break;
|
2653 | 667accab | ths | #ifdef CONFIG_SDL
|
2654 | 43523e93 | ths | case QEMU_OPTION_no_frame:
|
2655 | 43523e93 | ths | no_frame = 1;
|
2656 | 43523e93 | ths | break;
|
2657 | 3780e197 | ths | case QEMU_OPTION_alt_grab:
|
2658 | 3780e197 | ths | alt_grab = 1;
|
2659 | 3780e197 | ths | break;
|
2660 | 0ca9f8a4 | Dustin Kirkland | case QEMU_OPTION_ctrl_grab:
|
2661 | 0ca9f8a4 | Dustin Kirkland | ctrl_grab = 1;
|
2662 | 0ca9f8a4 | Dustin Kirkland | break;
|
2663 | 667accab | ths | case QEMU_OPTION_no_quit:
|
2664 | 667accab | ths | no_quit = 1;
|
2665 | 667accab | ths | break;
|
2666 | 7d957bd8 | aliguori | case QEMU_OPTION_sdl:
|
2667 | 993fbfdb | Anthony Liguori | display_type = DT_SDL; |
2668 | 7d957bd8 | aliguori | break;
|
2669 | 58fc096c | Jes Sorensen | #else
|
2670 | 58fc096c | Jes Sorensen | case QEMU_OPTION_no_frame:
|
2671 | 58fc096c | Jes Sorensen | case QEMU_OPTION_alt_grab:
|
2672 | 58fc096c | Jes Sorensen | case QEMU_OPTION_ctrl_grab:
|
2673 | 58fc096c | Jes Sorensen | case QEMU_OPTION_no_quit:
|
2674 | 58fc096c | Jes Sorensen | case QEMU_OPTION_sdl:
|
2675 | 58fc096c | Jes Sorensen | fprintf(stderr, "SDL support is disabled\n");
|
2676 | 58fc096c | Jes Sorensen | exit(1);
|
2677 | 667accab | ths | #endif
|
2678 | f7cce898 | bellard | case QEMU_OPTION_pidfile:
|
2679 | 93815bc2 | ths | pid_file = optarg; |
2680 | f7cce898 | bellard | break;
|
2681 | a09db21f | bellard | case QEMU_OPTION_win2k_hack:
|
2682 | a09db21f | bellard | win2k_install_hack = 1;
|
2683 | a09db21f | bellard | break;
|
2684 | 73822ec8 | aliguori | case QEMU_OPTION_rtc_td_hack:
|
2685 | 73822ec8 | aliguori | rtc_td_hack = 1;
|
2686 | 73822ec8 | aliguori | break;
|
2687 | 8a92ea2f | aliguori | case QEMU_OPTION_acpitable:
|
2688 | de06f8d1 | Blue Swirl | do_acpitable_option(optarg); |
2689 | 8a92ea2f | aliguori | break;
|
2690 | b6f6e3d3 | aliguori | case QEMU_OPTION_smbios:
|
2691 | de06f8d1 | Blue Swirl | do_smbios_option(optarg); |
2692 | b6f6e3d3 | aliguori | break;
|
2693 | 7ba1e619 | aliguori | case QEMU_OPTION_enable_kvm:
|
2694 | 303d4e86 | Anthony PERARD | olist = qemu_find_opts("machine");
|
2695 | 303d4e86 | Anthony PERARD | qemu_opts_reset(olist); |
2696 | 303d4e86 | Anthony PERARD | qemu_opts_parse(olist, "accel=kvm", 0); |
2697 | 303d4e86 | Anthony PERARD | break;
|
2698 | 303d4e86 | Anthony PERARD | case QEMU_OPTION_machine:
|
2699 | 303d4e86 | Anthony PERARD | olist = qemu_find_opts("machine");
|
2700 | 303d4e86 | Anthony PERARD | qemu_opts_reset(olist); |
2701 | 303d4e86 | Anthony PERARD | opts = qemu_opts_parse(olist, optarg, 0);
|
2702 | 303d4e86 | Anthony PERARD | if (!opts) {
|
2703 | 303d4e86 | Anthony PERARD | fprintf(stderr, "parse error: %s\n", optarg);
|
2704 | 303d4e86 | Anthony PERARD | exit(1);
|
2705 | 303d4e86 | Anthony PERARD | } |
2706 | 7ba1e619 | aliguori | break;
|
2707 | bb36d470 | bellard | case QEMU_OPTION_usb:
|
2708 | bb36d470 | bellard | usb_enabled = 1;
|
2709 | bb36d470 | bellard | break;
|
2710 | a594cfbf | bellard | case QEMU_OPTION_usbdevice:
|
2711 | a594cfbf | bellard | usb_enabled = 1;
|
2712 | bd3c948d | Gerd Hoffmann | add_device_config(DEV_USB, optarg); |
2713 | bd3c948d | Gerd Hoffmann | break;
|
2714 | bd3c948d | Gerd Hoffmann | case QEMU_OPTION_device:
|
2715 | 3329f07b | Gerd Hoffmann | if (!qemu_opts_parse(qemu_find_opts("device"), optarg, 1)) { |
2716 | f31d07d1 | Gerd Hoffmann | exit(1);
|
2717 | f31d07d1 | Gerd Hoffmann | } |
2718 | a594cfbf | bellard | break;
|
2719 | 6a00d601 | bellard | case QEMU_OPTION_smp:
|
2720 | dc6b1c09 | Andre Przywara | smp_parse(optarg); |
2721 | b2097003 | aliguori | if (smp_cpus < 1) { |
2722 | 6a00d601 | bellard | fprintf(stderr, "Invalid number of CPUs\n");
|
2723 | 6a00d601 | bellard | exit(1);
|
2724 | 6a00d601 | bellard | } |
2725 | 6be68d7e | Jes Sorensen | if (max_cpus < smp_cpus) {
|
2726 | 6be68d7e | Jes Sorensen | fprintf(stderr, "maxcpus must be equal to or greater than "
|
2727 | 6be68d7e | Jes Sorensen | "smp\n");
|
2728 | 6be68d7e | Jes Sorensen | exit(1);
|
2729 | 6be68d7e | Jes Sorensen | } |
2730 | 6be68d7e | Jes Sorensen | if (max_cpus > 255) { |
2731 | 6be68d7e | Jes Sorensen | fprintf(stderr, "Unsupported number of maxcpus\n");
|
2732 | 6be68d7e | Jes Sorensen | exit(1);
|
2733 | 6be68d7e | Jes Sorensen | } |
2734 | 6a00d601 | bellard | break;
|
2735 | 24236869 | bellard | case QEMU_OPTION_vnc:
|
2736 | 821601ea | Jes Sorensen | #ifdef CONFIG_VNC
|
2737 | 6b62dc2d | Gerd Hoffmann | display_remote++; |
2738 | 821601ea | Jes Sorensen | vnc_display = optarg; |
2739 | 821601ea | Jes Sorensen | #else
|
2740 | 821601ea | Jes Sorensen | fprintf(stderr, "VNC support is disabled\n");
|
2741 | 821601ea | Jes Sorensen | exit(1);
|
2742 | 821601ea | Jes Sorensen | #endif
|
2743 | 821601ea | Jes Sorensen | break;
|
2744 | 6515b203 | bellard | case QEMU_OPTION_no_acpi:
|
2745 | 6515b203 | bellard | acpi_enabled = 0;
|
2746 | 6515b203 | bellard | break;
|
2747 | 16b29ae1 | aliguori | case QEMU_OPTION_no_hpet:
|
2748 | 16b29ae1 | aliguori | no_hpet = 1;
|
2749 | 16b29ae1 | aliguori | break;
|
2750 | 7d4c3d53 | Markus Armbruster | case QEMU_OPTION_balloon:
|
2751 | 7d4c3d53 | Markus Armbruster | if (balloon_parse(optarg) < 0) { |
2752 | 7d4c3d53 | Markus Armbruster | fprintf(stderr, "Unknown -balloon argument %s\n", optarg);
|
2753 | 7d4c3d53 | Markus Armbruster | exit(1);
|
2754 | 7d4c3d53 | Markus Armbruster | } |
2755 | df97b920 | Eduardo Habkost | break;
|
2756 | d1beab82 | bellard | case QEMU_OPTION_no_reboot:
|
2757 | d1beab82 | bellard | no_reboot = 1;
|
2758 | d1beab82 | bellard | break;
|
2759 | b2f76161 | aurel32 | case QEMU_OPTION_no_shutdown:
|
2760 | b2f76161 | aurel32 | no_shutdown = 1;
|
2761 | b2f76161 | aurel32 | break;
|
2762 | 9467cd46 | balrog | case QEMU_OPTION_show_cursor:
|
2763 | 9467cd46 | balrog | cursor_hide = 0;
|
2764 | 9467cd46 | balrog | break;
|
2765 | 8fcb1b90 | blueswir1 | case QEMU_OPTION_uuid:
|
2766 | 8fcb1b90 | blueswir1 | if(qemu_uuid_parse(optarg, qemu_uuid) < 0) { |
2767 | 8fcb1b90 | blueswir1 | fprintf(stderr, "Fail to parse UUID string."
|
2768 | 8fcb1b90 | blueswir1 | " Wrong format.\n");
|
2769 | 8fcb1b90 | blueswir1 | exit(1);
|
2770 | 8fcb1b90 | blueswir1 | } |
2771 | 8fcb1b90 | blueswir1 | break;
|
2772 | 9ae02555 | ths | case QEMU_OPTION_option_rom:
|
2773 | 9ae02555 | ths | if (nb_option_roms >= MAX_OPTION_ROMS) {
|
2774 | 9ae02555 | ths | fprintf(stderr, "Too many option ROMs\n");
|
2775 | 9ae02555 | ths | exit(1);
|
2776 | 9ae02555 | ths | } |
2777 | 2e55e842 | Gleb Natapov | opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1); |
2778 | 2e55e842 | Gleb Natapov | option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile");
|
2779 | 2e55e842 | Gleb Natapov | option_rom[nb_option_roms].bootindex = |
2780 | 2e55e842 | Gleb Natapov | qemu_opt_get_number(opts, "bootindex", -1); |
2781 | 2e55e842 | Gleb Natapov | if (!option_rom[nb_option_roms].name) {
|
2782 | 2e55e842 | Gleb Natapov | fprintf(stderr, "Option ROM file is not specified\n");
|
2783 | 2e55e842 | Gleb Natapov | exit(1);
|
2784 | 2e55e842 | Gleb Natapov | } |
2785 | 9ae02555 | ths | nb_option_roms++; |
2786 | 9ae02555 | ths | break;
|
2787 | 8e71621f | pbrook | case QEMU_OPTION_semihosting:
|
2788 | 8e71621f | pbrook | semihosting_enabled = 1;
|
2789 | 8e71621f | pbrook | break;
|
2790 | c35734b2 | ths | case QEMU_OPTION_name:
|
2791 | 1889465a | Andi Kleen | qemu_name = qemu_strdup(optarg); |
2792 | 1889465a | Andi Kleen | { |
2793 | 1889465a | Andi Kleen | char *p = strchr(qemu_name, ','); |
2794 | 1889465a | Andi Kleen | if (p != NULL) { |
2795 | 1889465a | Andi Kleen | *p++ = 0;
|
2796 | 1889465a | Andi Kleen | if (strncmp(p, "process=", 8)) { |
2797 | 5697f6ae | Aurelien Jarno | fprintf(stderr, "Unknown subargument %s to -name\n", p);
|
2798 | 1889465a | Andi Kleen | exit(1);
|
2799 | 1889465a | Andi Kleen | } |
2800 | 1889465a | Andi Kleen | p += 8;
|
2801 | ce798cf2 | Jes Sorensen | os_set_proc_name(p); |
2802 | 1889465a | Andi Kleen | } |
2803 | 1889465a | Andi Kleen | } |
2804 | c35734b2 | ths | break;
|
2805 | 66508601 | blueswir1 | case QEMU_OPTION_prom_env:
|
2806 | 66508601 | blueswir1 | if (nb_prom_envs >= MAX_PROM_ENVS) {
|
2807 | 66508601 | blueswir1 | fprintf(stderr, "Too many prom variables\n");
|
2808 | 66508601 | blueswir1 | exit(1);
|
2809 | 66508601 | blueswir1 | } |
2810 | 66508601 | blueswir1 | prom_envs[nb_prom_envs] = optarg; |
2811 | 66508601 | blueswir1 | nb_prom_envs++; |
2812 | 66508601 | blueswir1 | break;
|
2813 | 2b8f2d41 | balrog | case QEMU_OPTION_old_param:
|
2814 | 2b8f2d41 | balrog | old_param = 1;
|
2815 | 05ebd537 | ths | break;
|
2816 | f3dcfada | ths | case QEMU_OPTION_clock:
|
2817 | f3dcfada | ths | configure_alarms(optarg); |
2818 | f3dcfada | ths | break;
|
2819 | 7e0af5d0 | bellard | case QEMU_OPTION_startdate:
|
2820 | 1ed2fc1f | Jan Kiszka | configure_rtc_date_offset(optarg, 1);
|
2821 | 1ed2fc1f | Jan Kiszka | break;
|
2822 | 1ed2fc1f | Jan Kiszka | case QEMU_OPTION_rtc:
|
2823 | 3329f07b | Gerd Hoffmann | opts = qemu_opts_parse(qemu_find_opts("rtc"), optarg, 0); |
2824 | 1ed2fc1f | Jan Kiszka | if (!opts) {
|
2825 | 1ed2fc1f | Jan Kiszka | exit(1);
|
2826 | 7e0af5d0 | bellard | } |
2827 | 1ed2fc1f | Jan Kiszka | configure_rtc(opts); |
2828 | 7e0af5d0 | bellard | break;
|
2829 | 26a5f13b | bellard | case QEMU_OPTION_tb_size:
|
2830 | 26a5f13b | bellard | tb_size = strtol(optarg, NULL, 0); |
2831 | 26a5f13b | bellard | if (tb_size < 0) |
2832 | 26a5f13b | bellard | tb_size = 0;
|
2833 | 26a5f13b | bellard | break;
|
2834 | 2e70f6ef | pbrook | case QEMU_OPTION_icount:
|
2835 | 4e3de9e9 | Paolo Bonzini | icount_option = optarg; |
2836 | 2e70f6ef | pbrook | break;
|
2837 | 5bb7910a | aliguori | case QEMU_OPTION_incoming:
|
2838 | 5bb7910a | aliguori | incoming = optarg; |
2839 | 8e84865e | Amit Shah | incoming_expected = true;
|
2840 | 5bb7910a | aliguori | break;
|
2841 | d8c208dd | Gerd Hoffmann | case QEMU_OPTION_nodefaults:
|
2842 | d8c208dd | Gerd Hoffmann | default_serial = 0;
|
2843 | d8c208dd | Gerd Hoffmann | default_parallel = 0;
|
2844 | aee1b935 | Gerd Hoffmann | default_virtcon = 0;
|
2845 | d8c208dd | Gerd Hoffmann | default_monitor = 0;
|
2846 | d8c208dd | Gerd Hoffmann | default_vga = 0;
|
2847 | cb4522cc | Gerd Hoffmann | default_net = 0;
|
2848 | ac33f8fa | Gerd Hoffmann | default_floppy = 0;
|
2849 | ac33f8fa | Gerd Hoffmann | default_cdrom = 0;
|
2850 | ac33f8fa | Gerd Hoffmann | default_sdcard = 0;
|
2851 | d8c208dd | Gerd Hoffmann | break;
|
2852 | e37630ca | aliguori | case QEMU_OPTION_xen_domid:
|
2853 | ad96090a | Blue Swirl | if (!(xen_available())) {
|
2854 | ad96090a | Blue Swirl | printf("Option %s not supported for this target\n", popt->name);
|
2855 | ad96090a | Blue Swirl | exit(1);
|
2856 | ad96090a | Blue Swirl | } |
2857 | e37630ca | aliguori | xen_domid = atoi(optarg); |
2858 | e37630ca | aliguori | break;
|
2859 | e37630ca | aliguori | case QEMU_OPTION_xen_create:
|
2860 | ad96090a | Blue Swirl | if (!(xen_available())) {
|
2861 | ad96090a | Blue Swirl | printf("Option %s not supported for this target\n", popt->name);
|
2862 | ad96090a | Blue Swirl | exit(1);
|
2863 | ad96090a | Blue Swirl | } |
2864 | e37630ca | aliguori | xen_mode = XEN_CREATE; |
2865 | e37630ca | aliguori | break;
|
2866 | e37630ca | aliguori | case QEMU_OPTION_xen_attach:
|
2867 | ad96090a | Blue Swirl | if (!(xen_available())) {
|
2868 | ad96090a | Blue Swirl | printf("Option %s not supported for this target\n", popt->name);
|
2869 | ad96090a | Blue Swirl | exit(1);
|
2870 | ad96090a | Blue Swirl | } |
2871 | e37630ca | aliguori | xen_mode = XEN_ATTACH; |
2872 | e37630ca | aliguori | break;
|
2873 | ab6540d5 | Prerna Saxena | #ifdef CONFIG_SIMPLE_TRACE
|
2874 | ab6540d5 | Prerna Saxena | case QEMU_OPTION_trace:
|
2875 | ab6540d5 | Prerna Saxena | opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 0); |
2876 | ab6540d5 | Prerna Saxena | if (opts) {
|
2877 | ab6540d5 | Prerna Saxena | trace_file = qemu_opt_get(opts, "file");
|
2878 | ab6540d5 | Prerna Saxena | } |
2879 | ab6540d5 | Prerna Saxena | break;
|
2880 | ab6540d5 | Prerna Saxena | #endif
|
2881 | 715a664a | Gerd Hoffmann | case QEMU_OPTION_readconfig:
|
2882 | 715a664a | Gerd Hoffmann | { |
2883 | dcfb0939 | Kevin Wolf | int ret = qemu_read_config_file(optarg);
|
2884 | dcfb0939 | Kevin Wolf | if (ret < 0) { |
2885 | dcfb0939 | Kevin Wolf | fprintf(stderr, "read config %s: %s\n", optarg,
|
2886 | dcfb0939 | Kevin Wolf | strerror(-ret)); |
2887 | 715a664a | Gerd Hoffmann | exit(1);
|
2888 | 715a664a | Gerd Hoffmann | } |
2889 | 715a664a | Gerd Hoffmann | break;
|
2890 | 715a664a | Gerd Hoffmann | } |
2891 | 29b0040b | Gerd Hoffmann | case QEMU_OPTION_spice:
|
2892 | 29b0040b | Gerd Hoffmann | olist = qemu_find_opts("spice");
|
2893 | 29b0040b | Gerd Hoffmann | if (!olist) {
|
2894 | 29b0040b | Gerd Hoffmann | fprintf(stderr, "spice is not supported by this qemu build.\n");
|
2895 | 29b0040b | Gerd Hoffmann | exit(1);
|
2896 | 29b0040b | Gerd Hoffmann | } |
2897 | 29b0040b | Gerd Hoffmann | opts = qemu_opts_parse(olist, optarg, 0);
|
2898 | 29b0040b | Gerd Hoffmann | if (!opts) {
|
2899 | 29b0040b | Gerd Hoffmann | fprintf(stderr, "parse error: %s\n", optarg);
|
2900 | 29b0040b | Gerd Hoffmann | exit(1);
|
2901 | 29b0040b | Gerd Hoffmann | } |
2902 | 29b0040b | Gerd Hoffmann | break;
|
2903 | 715a664a | Gerd Hoffmann | case QEMU_OPTION_writeconfig:
|
2904 | 715a664a | Gerd Hoffmann | { |
2905 | 715a664a | Gerd Hoffmann | FILE *fp; |
2906 | 715a664a | Gerd Hoffmann | if (strcmp(optarg, "-") == 0) { |
2907 | 715a664a | Gerd Hoffmann | fp = stdout; |
2908 | 715a664a | Gerd Hoffmann | } else {
|
2909 | 715a664a | Gerd Hoffmann | fp = fopen(optarg, "w");
|
2910 | 715a664a | Gerd Hoffmann | if (fp == NULL) { |
2911 | 715a664a | Gerd Hoffmann | fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
|
2912 | 715a664a | Gerd Hoffmann | exit(1);
|
2913 | 715a664a | Gerd Hoffmann | } |
2914 | 715a664a | Gerd Hoffmann | } |
2915 | 715a664a | Gerd Hoffmann | qemu_config_write(fp); |
2916 | 715a664a | Gerd Hoffmann | fclose(fp); |
2917 | 715a664a | Gerd Hoffmann | break;
|
2918 | 715a664a | Gerd Hoffmann | } |
2919 | 59a5264b | Jes Sorensen | default:
|
2920 | 59a5264b | Jes Sorensen | os_parse_cmd_args(popt->index, optarg); |
2921 | cd6f1169 | bellard | } |
2922 | 0824d6fc | bellard | } |
2923 | 0824d6fc | bellard | } |
2924 | 0f0bc3f1 | Markus Armbruster | loc_set_none(); |
2925 | c235d738 | Matthew Fernandez | |
2926 | c235d738 | Matthew Fernandez | /* Open the logfile at this point, if necessary. We can't open the logfile
|
2927 | c235d738 | Matthew Fernandez | * when encountering either of the logging options (-d or -D) because the
|
2928 | c235d738 | Matthew Fernandez | * other one may be encountered later on the command line, changing the
|
2929 | c235d738 | Matthew Fernandez | * location or level of logging.
|
2930 | c235d738 | Matthew Fernandez | */
|
2931 | c235d738 | Matthew Fernandez | if (log_mask) {
|
2932 | c235d738 | Matthew Fernandez | if (log_file) {
|
2933 | c235d738 | Matthew Fernandez | set_cpu_log_filename(log_file); |
2934 | c235d738 | Matthew Fernandez | } |
2935 | c235d738 | Matthew Fernandez | set_cpu_log(log_mask); |
2936 | c235d738 | Matthew Fernandez | } |
2937 | 330d0414 | bellard | |
2938 | 31d3c9b8 | Stefan Hajnoczi | if (!st_init(trace_file)) {
|
2939 | 31d3c9b8 | Stefan Hajnoczi | fprintf(stderr, "warning: unable to initialize simple trace backend\n");
|
2940 | 31d3c9b8 | Stefan Hajnoczi | } |
2941 | 0b5538c3 | Stefan Hajnoczi | |
2942 | 5cea8590 | Paul Brook | /* If no data_dir is specified then try to find it relative to the
|
2943 | 5cea8590 | Paul Brook | executable path. */
|
2944 | 5cea8590 | Paul Brook | if (!data_dir) {
|
2945 | 6170540b | Jes Sorensen | data_dir = os_find_datadir(argv[0]);
|
2946 | 5cea8590 | Paul Brook | } |
2947 | 5cea8590 | Paul Brook | /* If all else fails use the install patch specified when building. */
|
2948 | 5cea8590 | Paul Brook | if (!data_dir) {
|
2949 | 1dabe05c | Paolo Bonzini | data_dir = CONFIG_QEMU_DATADIR; |
2950 | 5cea8590 | Paul Brook | } |
2951 | 5cea8590 | Paul Brook | |
2952 | 6be68d7e | Jes Sorensen | /*
|
2953 | 6be68d7e | Jes Sorensen | * Default to max_cpus = smp_cpus, in case the user doesn't
|
2954 | 6be68d7e | Jes Sorensen | * specify a max_cpus value.
|
2955 | 6be68d7e | Jes Sorensen | */
|
2956 | 6be68d7e | Jes Sorensen | if (!max_cpus)
|
2957 | 6be68d7e | Jes Sorensen | max_cpus = smp_cpus; |
2958 | 6be68d7e | Jes Sorensen | |
2959 | 3d878caa | balrog | machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */ |
2960 | b2097003 | aliguori | if (smp_cpus > machine->max_cpus) {
|
2961 | b2097003 | aliguori | fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
|
2962 | b2097003 | aliguori | "supported by machine `%s' (%d)\n", smp_cpus, machine->name,
|
2963 | b2097003 | aliguori | machine->max_cpus); |
2964 | b2097003 | aliguori | exit(1);
|
2965 | b2097003 | aliguori | } |
2966 | b2097003 | aliguori | |
2967 | 67b724e6 | Anthony PERARD | /*
|
2968 | 67b724e6 | Anthony PERARD | * Get the default machine options from the machine if it is not already
|
2969 | 67b724e6 | Anthony PERARD | * specified either by the configuration file or by the command line.
|
2970 | 67b724e6 | Anthony PERARD | */
|
2971 | 67b724e6 | Anthony PERARD | if (machine->default_machine_opts) {
|
2972 | 67b724e6 | Anthony PERARD | QemuOptsList *list = qemu_find_opts("machine");
|
2973 | 67b724e6 | Anthony PERARD | const char *p = NULL; |
2974 | 67b724e6 | Anthony PERARD | |
2975 | 67b724e6 | Anthony PERARD | if (!QTAILQ_EMPTY(&list->head)) {
|
2976 | 67b724e6 | Anthony PERARD | p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
|
2977 | 67b724e6 | Anthony PERARD | } |
2978 | 67b724e6 | Anthony PERARD | if (p == NULL) { |
2979 | 67b724e6 | Anthony PERARD | opts = qemu_opts_parse(qemu_find_opts("machine"),
|
2980 | 67b724e6 | Anthony PERARD | machine->default_machine_opts, 0);
|
2981 | 67b724e6 | Anthony PERARD | if (!opts) {
|
2982 | 67b724e6 | Anthony PERARD | fprintf(stderr, "parse error for machine %s: %s\n",
|
2983 | 67b724e6 | Anthony PERARD | machine->name, machine->default_machine_opts); |
2984 | 67b724e6 | Anthony PERARD | exit(1);
|
2985 | 67b724e6 | Anthony PERARD | } |
2986 | 67b724e6 | Anthony PERARD | } |
2987 | 67b724e6 | Anthony PERARD | } |
2988 | 67b724e6 | Anthony PERARD | |
2989 | 3329f07b | Gerd Hoffmann | qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0); |
2990 | 3329f07b | Gerd Hoffmann | qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0); |
2991 | 998bbd74 | Gerd Hoffmann | |
2992 | 986c5f78 | Gerd Hoffmann | if (machine->no_serial) {
|
2993 | 986c5f78 | Gerd Hoffmann | default_serial = 0;
|
2994 | 986c5f78 | Gerd Hoffmann | } |
2995 | 986c5f78 | Gerd Hoffmann | if (machine->no_parallel) {
|
2996 | 986c5f78 | Gerd Hoffmann | default_parallel = 0;
|
2997 | 986c5f78 | Gerd Hoffmann | } |
2998 | 986c5f78 | Gerd Hoffmann | if (!machine->use_virtcon) {
|
2999 | 986c5f78 | Gerd Hoffmann | default_virtcon = 0;
|
3000 | 986c5f78 | Gerd Hoffmann | } |
3001 | 986c5f78 | Gerd Hoffmann | if (machine->no_vga) {
|
3002 | 986c5f78 | Gerd Hoffmann | default_vga = 0;
|
3003 | 986c5f78 | Gerd Hoffmann | } |
3004 | ac33f8fa | Gerd Hoffmann | if (machine->no_floppy) {
|
3005 | ac33f8fa | Gerd Hoffmann | default_floppy = 0;
|
3006 | ac33f8fa | Gerd Hoffmann | } |
3007 | ac33f8fa | Gerd Hoffmann | if (machine->no_cdrom) {
|
3008 | ac33f8fa | Gerd Hoffmann | default_cdrom = 0;
|
3009 | ac33f8fa | Gerd Hoffmann | } |
3010 | ac33f8fa | Gerd Hoffmann | if (machine->no_sdcard) {
|
3011 | ac33f8fa | Gerd Hoffmann | default_sdcard = 0;
|
3012 | ac33f8fa | Gerd Hoffmann | } |
3013 | 986c5f78 | Gerd Hoffmann | |
3014 | 993fbfdb | Anthony Liguori | if (display_type == DT_NOGRAPHIC) {
|
3015 | 6a5e8b0e | Gerd Hoffmann | if (default_parallel)
|
3016 | 6a5e8b0e | Gerd Hoffmann | add_device_config(DEV_PARALLEL, "null");
|
3017 | e1c09175 | Gerd Hoffmann | if (default_serial && default_monitor) {
|
3018 | e1c09175 | Gerd Hoffmann | add_device_config(DEV_SERIAL, "mon:stdio");
|
3019 | 986c5f78 | Gerd Hoffmann | } else if (default_virtcon && default_monitor) { |
3020 | 986c5f78 | Gerd Hoffmann | add_device_config(DEV_VIRTCON, "mon:stdio");
|
3021 | e1c09175 | Gerd Hoffmann | } else {
|
3022 | e1c09175 | Gerd Hoffmann | if (default_serial)
|
3023 | e1c09175 | Gerd Hoffmann | add_device_config(DEV_SERIAL, "stdio");
|
3024 | 986c5f78 | Gerd Hoffmann | if (default_virtcon)
|
3025 | 986c5f78 | Gerd Hoffmann | add_device_config(DEV_VIRTCON, "stdio");
|
3026 | e1c09175 | Gerd Hoffmann | if (default_monitor)
|
3027 | 6ca5582d | Gerd Hoffmann | monitor_parse("stdio", "readline"); |
3028 | e1c09175 | Gerd Hoffmann | } |
3029 | 998bbd74 | Gerd Hoffmann | } else {
|
3030 | 998bbd74 | Gerd Hoffmann | if (default_serial)
|
3031 | 998bbd74 | Gerd Hoffmann | add_device_config(DEV_SERIAL, "vc:80Cx24C");
|
3032 | 6a5e8b0e | Gerd Hoffmann | if (default_parallel)
|
3033 | 6a5e8b0e | Gerd Hoffmann | add_device_config(DEV_PARALLEL, "vc:80Cx24C");
|
3034 | abdeed06 | Gerd Hoffmann | if (default_monitor)
|
3035 | 6ca5582d | Gerd Hoffmann | monitor_parse("vc:80Cx24C", "readline"); |
3036 | 38536da1 | Alexander Graf | if (default_virtcon)
|
3037 | 38536da1 | Alexander Graf | add_device_config(DEV_VIRTCON, "vc:80Cx24C");
|
3038 | bc0129d9 | aliguori | } |
3039 | 64465297 | Gerd Hoffmann | if (default_vga)
|
3040 | 64465297 | Gerd Hoffmann | vga_interface_type = VGA_CIRRUS; |
3041 | bc0129d9 | aliguori | |
3042 | a5829fd9 | TeLeMan | socket_init(); |
3043 | a5829fd9 | TeLeMan | |
3044 | 3329f07b | Gerd Hoffmann | if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0) |
3045 | 1a688d3b | Gerd Hoffmann | exit(1);
|
3046 | 758e8e38 | Venkateswararao Jujjuri (JV) | #ifdef CONFIG_VIRTFS
|
3047 | 3329f07b | Gerd Hoffmann | if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) { |
3048 | 74db920c | Gautham R Shenoy | exit(1);
|
3049 | 74db920c | Gautham R Shenoy | } |
3050 | 74db920c | Gautham R Shenoy | #endif
|
3051 | 1a688d3b | Gerd Hoffmann | |
3052 | eb505be1 | Jes Sorensen | os_daemonize(); |
3053 | 71e3ceb8 | ths | |
3054 | aa26bb2d | ths | if (pid_file && qemu_create_pidfile(pid_file) != 0) { |
3055 | eb505be1 | Jes Sorensen | os_pidfile_error(); |
3056 | 93815bc2 | ths | exit(1);
|
3057 | 93815bc2 | ths | } |
3058 | 93815bc2 | ths | |
3059 | 303d4e86 | Anthony PERARD | configure_accelerator(); |
3060 | 214910a7 | Marcelo Tosatti | |
3061 | 3fcf7b6b | aliguori | if (qemu_init_main_loop()) {
|
3062 | 3fcf7b6b | aliguori | fprintf(stderr, "qemu_init_main_loop failed\n");
|
3063 | 3fcf7b6b | aliguori | exit(1);
|
3064 | 3fcf7b6b | aliguori | } |
3065 | a20dd508 | bellard | linux_boot = (kernel_filename != NULL);
|
3066 | 6c41b272 | balrog | |
3067 | f8d39c01 | ths | if (!linux_boot && *kernel_cmdline != '\0') { |
3068 | f8d39c01 | ths | fprintf(stderr, "-append only allowed with -kernel option\n");
|
3069 | f8d39c01 | ths | exit(1);
|
3070 | f8d39c01 | ths | } |
3071 | f8d39c01 | ths | |
3072 | f8d39c01 | ths | if (!linux_boot && initrd_filename != NULL) { |
3073 | f8d39c01 | ths | fprintf(stderr, "-initrd only allowed with -kernel option\n");
|
3074 | f8d39c01 | ths | exit(1);
|
3075 | f8d39c01 | ths | } |
3076 | f8d39c01 | ths | |
3077 | 9156d763 | Jes Sorensen | os_set_line_buffering(); |
3078 | 3b46e624 | ths | |
3079 | 7183b4b4 | aliguori | if (init_timer_alarm() < 0) { |
3080 | 7183b4b4 | aliguori | fprintf(stderr, "could not initialize alarm timer\n");
|
3081 | 7183b4b4 | aliguori | exit(1);
|
3082 | 7183b4b4 | aliguori | } |
3083 | 4e3de9e9 | Paolo Bonzini | configure_icount(icount_option); |
3084 | 634fce96 | pbrook | |
3085 | dc1c9fe8 | Mark McLoughlin | if (net_init_clients() < 0) { |
3086 | dc1c9fe8 | Mark McLoughlin | exit(1);
|
3087 | 702c651c | bellard | } |
3088 | f1510b2c | bellard | |
3089 | dc72ac14 | balrog | /* init the bluetooth world */
|
3090 | bd3c948d | Gerd Hoffmann | if (foreach_device_config(DEV_BT, bt_parse))
|
3091 | bd3c948d | Gerd Hoffmann | exit(1);
|
3092 | dc72ac14 | balrog | |
3093 | 0824d6fc | bellard | /* init the memory */
|
3094 | 94a6b54f | pbrook | if (ram_size == 0) |
3095 | 94a6b54f | pbrook | ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; |
3096 | 9ae02555 | ths | |
3097 | 26a5f13b | bellard | /* init the dynamic translator */
|
3098 | 26a5f13b | bellard | cpu_exec_init_all(tb_size * 1024 * 1024); |
3099 | 26a5f13b | bellard | |
3100 | eb852011 | Markus Armbruster | bdrv_init_with_whitelist(); |
3101 | c4b1fcc0 | bellard | |
3102 | c163b5ca | lirans@il.ibm.com | blk_mig_init(); |
3103 | c163b5ca | lirans@il.ibm.com | |
3104 | e4bcb14c | ths | /* open the virtual block devices */
|
3105 | 9dfd7c7a | Gerd Hoffmann | if (snapshot)
|
3106 | 3329f07b | Gerd Hoffmann | qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0); |
3107 | 3329f07b | Gerd Hoffmann | if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine->use_scsi, 1) != 0) |
3108 | 9dfd7c7a | Gerd Hoffmann | exit(1);
|
3109 | 3e3d5815 | balrog | |
3110 | 4e5d9b57 | Markus Armbruster | default_drive(default_cdrom, snapshot, machine->use_scsi, |
3111 | 4e5d9b57 | Markus Armbruster | IF_DEFAULT, 2, CDROM_OPTS);
|
3112 | 4e5d9b57 | Markus Armbruster | default_drive(default_floppy, snapshot, machine->use_scsi, |
3113 | 4e5d9b57 | Markus Armbruster | IF_FLOPPY, 0, FD_OPTS);
|
3114 | 4e5d9b57 | Markus Armbruster | default_drive(default_sdcard, snapshot, machine->use_scsi, |
3115 | 4e5d9b57 | Markus Armbruster | IF_SD, 0, SD_OPTS);
|
3116 | 4e5d9b57 | Markus Armbruster | |
3117 | 97ab12d4 | Alex Williamson | register_savevm_live(NULL, "ram", 0, 4, NULL, ram_save_live, NULL, |
3118 | c163b5ca | lirans@il.ibm.com | ram_load, NULL);
|
3119 | 8a7ddc38 | bellard | |
3120 | 268a362c | aliguori | if (nb_numa_nodes > 0) { |
3121 | 268a362c | aliguori | int i;
|
3122 | 268a362c | aliguori | |
3123 | 268a362c | aliguori | if (nb_numa_nodes > smp_cpus) {
|
3124 | 268a362c | aliguori | nb_numa_nodes = smp_cpus; |
3125 | 268a362c | aliguori | } |
3126 | 268a362c | aliguori | |
3127 | 268a362c | aliguori | /* If no memory size if given for any node, assume the default case
|
3128 | 268a362c | aliguori | * and distribute the available memory equally across all nodes
|
3129 | 268a362c | aliguori | */
|
3130 | 268a362c | aliguori | for (i = 0; i < nb_numa_nodes; i++) { |
3131 | 268a362c | aliguori | if (node_mem[i] != 0) |
3132 | 268a362c | aliguori | break;
|
3133 | 268a362c | aliguori | } |
3134 | 268a362c | aliguori | if (i == nb_numa_nodes) {
|
3135 | 268a362c | aliguori | uint64_t usedmem = 0;
|
3136 | 268a362c | aliguori | |
3137 | 268a362c | aliguori | /* On Linux, the each node's border has to be 8MB aligned,
|
3138 | 268a362c | aliguori | * the final node gets the rest.
|
3139 | 268a362c | aliguori | */
|
3140 | 268a362c | aliguori | for (i = 0; i < nb_numa_nodes - 1; i++) { |
3141 | 268a362c | aliguori | node_mem[i] = (ram_size / nb_numa_nodes) & ~((1 << 23UL) - 1); |
3142 | 268a362c | aliguori | usedmem += node_mem[i]; |
3143 | 268a362c | aliguori | } |
3144 | 268a362c | aliguori | node_mem[i] = ram_size - usedmem; |
3145 | 268a362c | aliguori | } |
3146 | 268a362c | aliguori | |
3147 | 268a362c | aliguori | for (i = 0; i < nb_numa_nodes; i++) { |
3148 | 268a362c | aliguori | if (node_cpumask[i] != 0) |
3149 | 268a362c | aliguori | break;
|
3150 | 268a362c | aliguori | } |
3151 | 268a362c | aliguori | /* assigning the VCPUs round-robin is easier to implement, guest OSes
|
3152 | 268a362c | aliguori | * must cope with this anyway, because there are BIOSes out there in
|
3153 | 268a362c | aliguori | * real machines which also use this scheme.
|
3154 | 268a362c | aliguori | */
|
3155 | 268a362c | aliguori | if (i == nb_numa_nodes) {
|
3156 | 268a362c | aliguori | for (i = 0; i < smp_cpus; i++) { |
3157 | 268a362c | aliguori | node_cpumask[i % nb_numa_nodes] |= 1 << i;
|
3158 | 268a362c | aliguori | } |
3159 | 268a362c | aliguori | } |
3160 | 268a362c | aliguori | } |
3161 | 268a362c | aliguori | |
3162 | 3329f07b | Gerd Hoffmann | if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) { |
3163 | 157b9319 | Jan Kiszka | exit(1);
|
3164 | 157b9319 | Jan Kiszka | } |
3165 | 157b9319 | Jan Kiszka | |
3166 | 998bbd74 | Gerd Hoffmann | if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) |
3167 | 998bbd74 | Gerd Hoffmann | exit(1);
|
3168 | 6a5e8b0e | Gerd Hoffmann | if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0) |
3169 | 6a5e8b0e | Gerd Hoffmann | exit(1);
|
3170 | aee1b935 | Gerd Hoffmann | if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0) |
3171 | aee1b935 | Gerd Hoffmann | exit(1);
|
3172 | c9f398e5 | H. Peter Anvin | if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) |
3173 | c9f398e5 | H. Peter Anvin | exit(1);
|
3174 | 2796dae0 | aliguori | |
3175 | aae9460e | Paul Brook | module_call_init(MODULE_INIT_DEVICE); |
3176 | aae9460e | Paul Brook | |
3177 | 3329f07b | Gerd Hoffmann | if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0) |
3178 | ff952ba2 | Markus Armbruster | exit(0);
|
3179 | ff952ba2 | Markus Armbruster | |
3180 | 09aaa160 | Markus Armbruster | if (watchdog) {
|
3181 | 09aaa160 | Markus Armbruster | i = select_watchdog(watchdog); |
3182 | 09aaa160 | Markus Armbruster | if (i > 0) |
3183 | 09aaa160 | Markus Armbruster | exit (i == 1 ? 1 : 0); |
3184 | 09aaa160 | Markus Armbruster | } |
3185 | 09aaa160 | Markus Armbruster | |
3186 | b6b61144 | Gerd Hoffmann | if (machine->compat_props) {
|
3187 | 458fb679 | Gerd Hoffmann | qdev_prop_register_global_list(machine->compat_props); |
3188 | b6b61144 | Gerd Hoffmann | } |
3189 | d0fef6fb | Gerd Hoffmann | qemu_add_globals(); |
3190 | d0fef6fb | Gerd Hoffmann | |
3191 | fbe1b595 | Paul Brook | machine->init(ram_size, boot_devices, |
3192 | 3023f332 | aliguori | kernel_filename, kernel_cmdline, initrd_filename, cpu_model); |
3193 | 3023f332 | aliguori | |
3194 | ea375f9a | Jan Kiszka | cpu_synchronize_all_post_init(); |
3195 | 268a362c | aliguori | |
3196 | 87d0a28e | Blue Swirl | set_numa_modes(); |
3197 | 268a362c | aliguori | |
3198 | 6f338c34 | aliguori | current_machine = machine; |
3199 | 6f338c34 | aliguori | |
3200 | 3023f332 | aliguori | /* init USB devices */
|
3201 | 3023f332 | aliguori | if (usb_enabled) {
|
3202 | 0752706d | Markus Armbruster | if (foreach_device_config(DEV_USB, usb_parse) < 0) |
3203 | 0752706d | Markus Armbruster | exit(1);
|
3204 | 3023f332 | aliguori | } |
3205 | 3023f332 | aliguori | |
3206 | bd3c948d | Gerd Hoffmann | /* init generic devices */
|
3207 | 3329f07b | Gerd Hoffmann | if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0) |
3208 | bd3c948d | Gerd Hoffmann | exit(1);
|
3209 | bd3c948d | Gerd Hoffmann | |
3210 | 668680f7 | Markus Armbruster | net_check_clients(); |
3211 | 668680f7 | Markus Armbruster | |
3212 | 3023f332 | aliguori | /* just use the first displaystate for the moment */
|
3213 | b473df6e | Paolo Bonzini | ds = get_displaystate(); |
3214 | 993fbfdb | Anthony Liguori | |
3215 | a3e22260 | Gerd Hoffmann | if (using_spice)
|
3216 | a3e22260 | Gerd Hoffmann | display_remote++; |
3217 | 6b62dc2d | Gerd Hoffmann | if (display_type == DT_DEFAULT && !display_remote) {
|
3218 | 993fbfdb | Anthony Liguori | #if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
|
3219 | 993fbfdb | Anthony Liguori | display_type = DT_SDL; |
3220 | 821601ea | Jes Sorensen | #elif defined(CONFIG_VNC)
|
3221 | 993fbfdb | Anthony Liguori | vnc_display = "localhost:0,to=99";
|
3222 | 993fbfdb | Anthony Liguori | show_vnc_port = 1;
|
3223 | 821601ea | Jes Sorensen | #else
|
3224 | 821601ea | Jes Sorensen | display_type = DT_NONE; |
3225 | 993fbfdb | Anthony Liguori | #endif
|
3226 | 993fbfdb | Anthony Liguori | } |
3227 | 821601ea | Jes Sorensen | |
3228 | 993fbfdb | Anthony Liguori | |
3229 | 6b62dc2d | Gerd Hoffmann | /* init local displays */
|
3230 | 993fbfdb | Anthony Liguori | switch (display_type) {
|
3231 | 993fbfdb | Anthony Liguori | case DT_NOGRAPHIC:
|
3232 | 993fbfdb | Anthony Liguori | break;
|
3233 | 4d3b6f6e | balrog | #if defined(CONFIG_CURSES)
|
3234 | 993fbfdb | Anthony Liguori | case DT_CURSES:
|
3235 | 993fbfdb | Anthony Liguori | curses_display_init(ds, full_screen); |
3236 | 993fbfdb | Anthony Liguori | break;
|
3237 | 4d3b6f6e | balrog | #endif
|
3238 | 5b0753e0 | bellard | #if defined(CONFIG_SDL)
|
3239 | 993fbfdb | Anthony Liguori | case DT_SDL:
|
3240 | 993fbfdb | Anthony Liguori | sdl_display_init(ds, full_screen, no_frame); |
3241 | 993fbfdb | Anthony Liguori | break;
|
3242 | 5b0753e0 | bellard | #elif defined(CONFIG_COCOA)
|
3243 | 993fbfdb | Anthony Liguori | case DT_SDL:
|
3244 | 993fbfdb | Anthony Liguori | cocoa_display_init(ds, full_screen); |
3245 | 993fbfdb | Anthony Liguori | break;
|
3246 | 313aa567 | bellard | #endif
|
3247 | 6b62dc2d | Gerd Hoffmann | default:
|
3248 | 6b62dc2d | Gerd Hoffmann | break;
|
3249 | 6b62dc2d | Gerd Hoffmann | } |
3250 | 6b62dc2d | Gerd Hoffmann | |
3251 | 0ce235a7 | Gleb Natapov | /* must be after terminal init, SDL library changes signal handlers */
|
3252 | 0ce235a7 | Gleb Natapov | os_setup_signal_handling(); |
3253 | 0ce235a7 | Gleb Natapov | |
3254 | 821601ea | Jes Sorensen | #ifdef CONFIG_VNC
|
3255 | 6b62dc2d | Gerd Hoffmann | /* init remote displays */
|
3256 | 6b62dc2d | Gerd Hoffmann | if (vnc_display) {
|
3257 | 993fbfdb | Anthony Liguori | vnc_display_init(ds); |
3258 | 993fbfdb | Anthony Liguori | if (vnc_display_open(ds, vnc_display) < 0) |
3259 | 993fbfdb | Anthony Liguori | exit(1);
|
3260 | f92f8afe | Anthony Liguori | |
3261 | 993fbfdb | Anthony Liguori | if (show_vnc_port) {
|
3262 | 993fbfdb | Anthony Liguori | printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
|
3263 | f92f8afe | Anthony Liguori | } |
3264 | 313aa567 | bellard | } |
3265 | 821601ea | Jes Sorensen | #endif
|
3266 | a3e22260 | Gerd Hoffmann | #ifdef CONFIG_SPICE
|
3267 | a19cbfb3 | Gerd Hoffmann | if (using_spice && !qxl_enabled) {
|
3268 | a3e22260 | Gerd Hoffmann | qemu_spice_display_init(ds); |
3269 | a3e22260 | Gerd Hoffmann | } |
3270 | a3e22260 | Gerd Hoffmann | #endif
|
3271 | 5b08fc10 | aliguori | |
3272 | 6b62dc2d | Gerd Hoffmann | /* display setup */
|
3273 | 6b62dc2d | Gerd Hoffmann | dpy_resize(ds); |
3274 | 3023f332 | aliguori | dcl = ds->listeners; |
3275 | 3023f332 | aliguori | while (dcl != NULL) { |
3276 | 3023f332 | aliguori | if (dcl->dpy_refresh != NULL) { |
3277 | 7bd427d8 | Paolo Bonzini | ds->gui_timer = qemu_new_timer_ms(rt_clock, gui_update, ds); |
3278 | 7bd427d8 | Paolo Bonzini | qemu_mod_timer(ds->gui_timer, qemu_get_clock_ms(rt_clock)); |
3279 | 0f2ad63f | Isaku Yamahata | break;
|
3280 | 20d8a3ed | ths | } |
3281 | 3023f332 | aliguori | dcl = dcl->next; |
3282 | 20d8a3ed | ths | } |
3283 | 6b62dc2d | Gerd Hoffmann | if (ds->gui_timer == NULL) { |
3284 | 7bd427d8 | Paolo Bonzini | nographic_timer = qemu_new_timer_ms(rt_clock, nographic_update, NULL);
|
3285 | 7bd427d8 | Paolo Bonzini | qemu_mod_timer(nographic_timer, qemu_get_clock_ms(rt_clock)); |
3286 | 9043b62d | blueswir1 | } |
3287 | b473df6e | Paolo Bonzini | text_consoles_set_display(ds); |
3288 | 2796dae0 | aliguori | |
3289 | 59030a8c | aliguori | if (gdbstub_dev && gdbserver_start(gdbstub_dev) < 0) { |
3290 | 59030a8c | aliguori | fprintf(stderr, "qemu: could not open gdbserver on device '%s'\n",
|
3291 | 59030a8c | aliguori | gdbstub_dev); |
3292 | 59030a8c | aliguori | exit(1);
|
3293 | 45669e00 | balrog | } |
3294 | 45669e00 | balrog | |
3295 | 3418bd25 | Gerd Hoffmann | qdev_machine_creation_done(); |
3296 | 3418bd25 | Gerd Hoffmann | |
3297 | 15ff7705 | Gerd Hoffmann | if (rom_load_all() != 0) { |
3298 | 15ff7705 | Gerd Hoffmann | fprintf(stderr, "rom loading failed\n");
|
3299 | 15ff7705 | Gerd Hoffmann | exit(1);
|
3300 | 15ff7705 | Gerd Hoffmann | } |
3301 | 45a50b16 | Gerd Hoffmann | |
3302 | 80376c3f | Isaku Yamahata | /* TODO: once all bus devices are qdevified, this should be done
|
3303 | 80376c3f | Isaku Yamahata | * when bus is created by qdev.c */
|
3304 | 80376c3f | Isaku Yamahata | qemu_register_reset(qbus_reset_all_fn, sysbus_get_default()); |
3305 | 4cab946a | Gleb Natapov | qemu_run_machine_init_done_notifiers(); |
3306 | 4cab946a | Gleb Natapov | |
3307 | e063eb1f | Jan Kiszka | qemu_system_reset(VMRESET_SILENT); |
3308 | 05f2401e | Juan Quintela | if (loadvm) {
|
3309 | 03cd4655 | Markus Armbruster | if (load_vmstate(loadvm) < 0) { |
3310 | 05f2401e | Juan Quintela | autostart = 0;
|
3311 | 05f2401e | Juan Quintela | } |
3312 | 05f2401e | Juan Quintela | } |
3313 | d63d307f | bellard | |
3314 | 2bb8c10c | Glauber Costa | if (incoming) {
|
3315 | 8ca5e801 | Juan Quintela | int ret = qemu_start_incoming_migration(incoming);
|
3316 | 8ca5e801 | Juan Quintela | if (ret < 0) { |
3317 | 8ca5e801 | Juan Quintela | fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
|
3318 | 8ca5e801 | Juan Quintela | incoming, ret); |
3319 | 8ca5e801 | Juan Quintela | exit(ret); |
3320 | 8ca5e801 | Juan Quintela | } |
3321 | 6b99dadc | Avi Kivity | } else if (autostart) { |
3322 | c0f4ce77 | aliguori | vm_start(); |
3323 | 6b99dadc | Avi Kivity | } |
3324 | ffd843bc | ths | |
3325 | eb505be1 | Jes Sorensen | os_setup_post(); |
3326 | 71e3ceb8 | ths | |
3327 | 8a7ddc38 | bellard | main_loop(); |
3328 | 40c3bac3 | bellard | quit_timers(); |
3329 | 63a01ef8 | aliguori | net_cleanup(); |
3330 | b46a8906 | ths | |
3331 | 0824d6fc | bellard | return 0; |
3332 | 0824d6fc | bellard | } |