4 * Copyright (c) 2003-2008 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #include "qemu/osdep.h"
26 #include "qemu-common.h"
27 #include "qemu/datadir.h"
28 #include "qemu/units.h"
29 #include "exec/cpu-common.h"
30 #include "hw/boards.h"
31 #include "hw/qdev-properties.h"
32 #include "qapi/error.h"
33 #include "qemu-version.h"
34 #include "qemu/cutils.h"
35 #include "qemu/help_option.h"
36 #include "qemu/uuid.h"
37 #include "sysemu/reset.h"
38 #include "sysemu/runstate.h"
39 #include "sysemu/seccomp.h"
40 #include "sysemu/tcg.h"
41 #include "sysemu/xen.h"
43 #include "qemu/error-report.h"
44 #include "qemu/sockets.h"
45 #include "sysemu/accel.h"
47 #include "hw/isa/isa.h"
48 #include "hw/scsi/scsi.h"
49 #include "hw/display/vga.h"
50 #include "sysemu/watchdog.h"
51 #include "hw/firmware/smbios.h"
52 #include "hw/acpi/acpi.h"
53 #include "hw/xen/xen.h"
54 #include "hw/loader.h"
55 #include "monitor/qdev.h"
57 #include "net/slirp.h"
58 #include "monitor/monitor.h"
59 #include "ui/console.h"
61 #include "sysemu/sysemu.h"
62 #include "sysemu/numa.h"
63 #include "sysemu/hostmem.h"
64 #include "exec/gdbstub.h"
65 #include "qemu/timer.h"
66 #include "chardev/char.h"
67 #include "qemu/bitmap.h"
69 #include "sysemu/blockdev.h"
70 #include "hw/block/block.h"
71 #include "hw/i386/x86.h"
72 #include "hw/i386/pc.h"
73 #include "migration/misc.h"
74 #include "migration/snapshot.h"
75 #include "migration/global_state.h"
76 #include "sysemu/tpm.h"
77 #include "sysemu/dma.h"
78 #include "hw/audio/soundhw.h"
79 #include "audio/audio.h"
80 #include "sysemu/cpus.h"
81 #include "sysemu/cpu-timers.h"
82 #include "migration/colo.h"
83 #include "migration/postcopy-ram.h"
84 #include "sysemu/kvm.h"
85 #include "sysemu/hax.h"
86 #include "qapi/qobject-input-visitor.h"
87 #include "qemu/option.h"
88 #include "qemu/config-file.h"
89 #include "qemu-options.h"
90 #include "qemu/main-loop.h"
92 #include "fsdev/qemu-fsdev.h"
94 #include "sysemu/qtest.h"
96 #include "disas/disas.h"
99 #include "trace/control.h"
100 #include "qemu/plugin.h"
101 #include "qemu/queue.h"
102 #include "sysemu/arch_init.h"
104 #include "ui/qemu-spice.h"
105 #include "qapi/string-input-visitor.h"
106 #include "qapi/opts-visitor.h"
107 #include "qapi/clone-visitor.h"
108 #include "qom/object_interfaces.h"
109 #include "hw/semihosting/semihost.h"
110 #include "crypto/init.h"
111 #include "sysemu/replay.h"
112 #include "qapi/qapi-events-run-state.h"
113 #include "qapi/qapi-visit-block-core.h"
114 #include "qapi/qapi-visit-ui.h"
115 #include "qapi/qapi-commands-block-core.h"
116 #include "qapi/qapi-commands-migration.h"
117 #include "qapi/qapi-commands-misc.h"
118 #include "qapi/qapi-commands-ui.h"
119 #include "qapi/qmp/qerror.h"
120 #include "sysemu/iothread.h"
121 #include "qemu/guest-random.h"
123 #define MAX_VIRTIO_CONSOLES 1
125 typedef struct BlockdevOptionsQueueEntry
{
126 BlockdevOptions
*bdo
;
128 QSIMPLEQ_ENTRY(BlockdevOptionsQueueEntry
) entry
;
129 } BlockdevOptionsQueueEntry
;
131 typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry
) BlockdevOptionsQueue
;
133 static const char *cpu_option
;
134 static const char *mem_path
;
135 static const char *incoming
;
136 static const char *loadvm
;
137 static ram_addr_t maxram_size
;
138 static uint64_t ram_slots
;
139 static int display_remote
;
141 static bool preconfig_requested
;
142 static QemuPluginList plugin_list
= QTAILQ_HEAD_INITIALIZER(plugin_list
);
143 static BlockdevOptionsQueue bdo_queue
= QSIMPLEQ_HEAD_INITIALIZER(bdo_queue
);
144 static bool nographic
= false;
145 static int mem_prealloc
; /* force preallocation of physical target memory */
146 static ram_addr_t ram_size
;
147 static const char *vga_model
= NULL
;
148 static DisplayOptions dpy
;
149 static int num_serial_hds
;
150 static Chardev
**serial_hds
;
151 static const char *log_mask
;
152 static const char *log_file
;
153 static bool list_data_dirs
;
154 static const char *watchdog
;
155 static const char *qtest_chrdev
;
156 static const char *qtest_log
;
158 static int has_defaults
= 1;
159 static int default_serial
= 1;
160 static int default_parallel
= 1;
161 static int default_monitor
= 1;
162 static int default_floppy
= 1;
163 static int default_cdrom
= 1;
164 static int default_sdcard
= 1;
165 static int default_vga
= 1;
166 static int default_net
= 1;
172 { .driver
= "isa-serial", .flag
= &default_serial
},
173 { .driver
= "isa-parallel", .flag
= &default_parallel
},
174 { .driver
= "isa-fdc", .flag
= &default_floppy
},
175 { .driver
= "floppy", .flag
= &default_floppy
},
176 { .driver
= "ide-cd", .flag
= &default_cdrom
},
177 { .driver
= "ide-hd", .flag
= &default_cdrom
},
178 { .driver
= "ide-drive", .flag
= &default_cdrom
},
179 { .driver
= "scsi-cd", .flag
= &default_cdrom
},
180 { .driver
= "scsi-hd", .flag
= &default_cdrom
},
181 { .driver
= "VGA", .flag
= &default_vga
},
182 { .driver
= "isa-vga", .flag
= &default_vga
},
183 { .driver
= "cirrus-vga", .flag
= &default_vga
},
184 { .driver
= "isa-cirrus-vga", .flag
= &default_vga
},
185 { .driver
= "vmware-svga", .flag
= &default_vga
},
186 { .driver
= "qxl-vga", .flag
= &default_vga
},
187 { .driver
= "virtio-vga", .flag
= &default_vga
},
188 { .driver
= "ati-vga", .flag
= &default_vga
},
189 { .driver
= "vhost-user-vga", .flag
= &default_vga
},
192 static QemuOptsList qemu_rtc_opts
= {
194 .head
= QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts
.head
),
199 .type
= QEMU_OPT_STRING
,
202 .type
= QEMU_OPT_STRING
,
205 .type
= QEMU_OPT_STRING
,
207 { /* end of list */ }
211 static QemuOptsList qemu_option_rom_opts
= {
212 .name
= "option-rom",
213 .implied_opt_name
= "romfile",
214 .head
= QTAILQ_HEAD_INITIALIZER(qemu_option_rom_opts
.head
),
218 .type
= QEMU_OPT_NUMBER
,
221 .type
= QEMU_OPT_STRING
,
223 { /* end of list */ }
227 static QemuOptsList qemu_machine_opts
= {
229 .implied_opt_name
= "type",
231 .head
= QTAILQ_HEAD_INITIALIZER(qemu_machine_opts
.head
),
234 * no elements => accept any
235 * sanity checking will happen later
236 * when setting machine properties
242 static QemuOptsList qemu_accel_opts
= {
244 .implied_opt_name
= "accel",
245 .head
= QTAILQ_HEAD_INITIALIZER(qemu_accel_opts
.head
),
248 * no elements => accept any
249 * sanity checking will happen later
250 * when setting accelerator properties
256 static QemuOptsList qemu_boot_opts
= {
258 .implied_opt_name
= "order",
260 .head
= QTAILQ_HEAD_INITIALIZER(qemu_boot_opts
.head
),
264 .type
= QEMU_OPT_STRING
,
267 .type
= QEMU_OPT_STRING
,
270 .type
= QEMU_OPT_BOOL
,
273 .type
= QEMU_OPT_STRING
,
275 .name
= "splash-time",
276 .type
= QEMU_OPT_NUMBER
,
278 .name
= "reboot-timeout",
279 .type
= QEMU_OPT_NUMBER
,
282 .type
= QEMU_OPT_BOOL
,
288 static QemuOptsList qemu_add_fd_opts
= {
290 .head
= QTAILQ_HEAD_INITIALIZER(qemu_add_fd_opts
.head
),
294 .type
= QEMU_OPT_NUMBER
,
295 .help
= "file descriptor of which a duplicate is added to fd set",
298 .type
= QEMU_OPT_NUMBER
,
299 .help
= "ID of the fd set to add fd to",
302 .type
= QEMU_OPT_STRING
,
303 .help
= "free-form string used to describe fd",
305 { /* end of list */ }
309 static QemuOptsList qemu_object_opts
= {
311 .implied_opt_name
= "qom-type",
312 .head
= QTAILQ_HEAD_INITIALIZER(qemu_object_opts
.head
),
318 static QemuOptsList qemu_tpmdev_opts
= {
320 .implied_opt_name
= "type",
321 .head
= QTAILQ_HEAD_INITIALIZER(qemu_tpmdev_opts
.head
),
323 /* options are defined in the TPM backends */
324 { /* end of list */ }
328 static QemuOptsList qemu_realtime_opts
= {
330 .head
= QTAILQ_HEAD_INITIALIZER(qemu_realtime_opts
.head
),
334 .type
= QEMU_OPT_BOOL
,
336 { /* end of list */ }
340 static QemuOptsList qemu_overcommit_opts
= {
341 .name
= "overcommit",
342 .head
= QTAILQ_HEAD_INITIALIZER(qemu_overcommit_opts
.head
),
346 .type
= QEMU_OPT_BOOL
,
350 .type
= QEMU_OPT_BOOL
,
352 { /* end of list */ }
356 static QemuOptsList qemu_msg_opts
= {
358 .head
= QTAILQ_HEAD_INITIALIZER(qemu_msg_opts
.head
),
362 .type
= QEMU_OPT_BOOL
,
365 .name
= "guest-name",
366 .type
= QEMU_OPT_BOOL
,
367 .help
= "Prepends guest name for error messages but only if "
368 "-name guest is set otherwise option is ignored\n",
370 { /* end of list */ }
374 static QemuOptsList qemu_name_opts
= {
376 .implied_opt_name
= "guest",
378 .head
= QTAILQ_HEAD_INITIALIZER(qemu_name_opts
.head
),
382 .type
= QEMU_OPT_STRING
,
383 .help
= "Sets the name of the guest.\n"
384 "This name will be displayed in the SDL window caption.\n"
385 "The name will also be used for the VNC server",
388 .type
= QEMU_OPT_STRING
,
389 .help
= "Sets the name of the QEMU process, as shown in top etc",
391 .name
= "debug-threads",
392 .type
= QEMU_OPT_BOOL
,
393 .help
= "When enabled, name the individual threads; defaults off.\n"
394 "NOTE: The thread names are for debugging and not a\n"
397 { /* End of list */ }
401 static QemuOptsList qemu_mem_opts
= {
403 .implied_opt_name
= "size",
404 .head
= QTAILQ_HEAD_INITIALIZER(qemu_mem_opts
.head
),
409 .type
= QEMU_OPT_SIZE
,
413 .type
= QEMU_OPT_NUMBER
,
417 .type
= QEMU_OPT_SIZE
,
419 { /* end of list */ }
423 static QemuOptsList qemu_icount_opts
= {
425 .implied_opt_name
= "shift",
427 .head
= QTAILQ_HEAD_INITIALIZER(qemu_icount_opts
.head
),
431 .type
= QEMU_OPT_STRING
,
434 .type
= QEMU_OPT_BOOL
,
437 .type
= QEMU_OPT_BOOL
,
440 .type
= QEMU_OPT_STRING
,
443 .type
= QEMU_OPT_STRING
,
445 .name
= "rrsnapshot",
446 .type
= QEMU_OPT_STRING
,
448 { /* end of list */ }
452 static QemuOptsList qemu_fw_cfg_opts
= {
454 .implied_opt_name
= "name",
455 .head
= QTAILQ_HEAD_INITIALIZER(qemu_fw_cfg_opts
.head
),
459 .type
= QEMU_OPT_STRING
,
460 .help
= "Sets the fw_cfg name of the blob to be inserted",
463 .type
= QEMU_OPT_STRING
,
464 .help
= "Sets the name of the file from which "
465 "the fw_cfg blob will be loaded",
468 .type
= QEMU_OPT_STRING
,
469 .help
= "Sets content of the blob to be inserted from a string",
472 .type
= QEMU_OPT_STRING
,
473 .help
= "Sets id of the object generating the fw_cfg blob "
476 { /* end of list */ }
481 * Get machine options
483 * Returns: machine options (never null).
485 QemuOpts
*qemu_get_machine_opts(void)
487 return qemu_find_opts_singleton("machine");
490 const char *qemu_get_vm_name(void)
495 static int default_driver_check(void *opaque
, QemuOpts
*opts
, Error
**errp
)
497 const char *driver
= qemu_opt_get(opts
, "driver");
502 for (i
= 0; i
< ARRAY_SIZE(default_list
); i
++) {
503 if (strcmp(default_list
[i
].driver
, driver
) != 0)
505 *(default_list
[i
].flag
) = 0;
510 static int parse_name(void *opaque
, QemuOpts
*opts
, Error
**errp
)
512 const char *proc_name
;
514 if (qemu_opt_get(opts
, "debug-threads")) {
515 qemu_thread_naming(qemu_opt_get_bool(opts
, "debug-threads", false));
517 qemu_name
= qemu_opt_get(opts
, "guest");
519 proc_name
= qemu_opt_get(opts
, "process");
521 os_set_proc_name(proc_name
);
527 bool defaults_enabled(void)
533 static int parse_add_fd(void *opaque
, QemuOpts
*opts
, Error
**errp
)
535 int fd
, dupfd
, flags
;
537 const char *fd_opaque
= NULL
;
540 fd
= qemu_opt_get_number(opts
, "fd", -1);
541 fdset_id
= qemu_opt_get_number(opts
, "set", -1);
542 fd_opaque
= qemu_opt_get(opts
, "opaque");
545 error_setg(errp
, "fd option is required and must be non-negative");
549 if (fd
<= STDERR_FILENO
) {
550 error_setg(errp
, "fd cannot be a standard I/O stream");
555 * All fds inherited across exec() necessarily have FD_CLOEXEC
556 * clear, while qemu sets FD_CLOEXEC on all other fds used internally.
558 flags
= fcntl(fd
, F_GETFD
);
559 if (flags
== -1 || (flags
& FD_CLOEXEC
)) {
560 error_setg(errp
, "fd is not valid or already in use");
565 error_setg(errp
, "set option is required and must be non-negative");
569 #ifdef F_DUPFD_CLOEXEC
570 dupfd
= fcntl(fd
, F_DUPFD_CLOEXEC
, 0);
574 qemu_set_cloexec(dupfd
);
578 error_setg(errp
, "error duplicating fd: %s", strerror(errno
));
582 /* add the duplicate fd, and optionally the opaque string, to the fd set */
583 fdinfo
= monitor_fdset_add_fd(dupfd
, true, fdset_id
, !!fd_opaque
, fd_opaque
,
590 static int cleanup_add_fd(void *opaque
, QemuOpts
*opts
, Error
**errp
)
594 fd
= qemu_opt_get_number(opts
, "fd", -1);
601 /***********************************************************/
602 /* QEMU Block devices */
604 #define HD_OPTS "media=disk"
605 #define CDROM_OPTS "media=cdrom"
607 #define PFLASH_OPTS ""
611 static int drive_init_func(void *opaque
, QemuOpts
*opts
, Error
**errp
)
613 BlockInterfaceType
*block_default_type
= opaque
;
615 return drive_new(opts
, *block_default_type
, errp
) == NULL
;
618 static int drive_enable_snapshot(void *opaque
, QemuOpts
*opts
, Error
**errp
)
620 if (qemu_opt_get(opts
, "snapshot") == NULL
) {
621 qemu_opt_set(opts
, "snapshot", "on", &error_abort
);
626 static void default_drive(int enable
, int snapshot
, BlockInterfaceType type
,
627 int index
, const char *optstr
)
632 if (!enable
|| drive_get_by_index(type
, index
)) {
636 opts
= drive_add(type
, index
, NULL
, optstr
);
638 drive_enable_snapshot(NULL
, opts
, NULL
);
641 dinfo
= drive_new(opts
, type
, &error_abort
);
642 dinfo
->is_default
= true;
646 static void configure_blockdev(BlockdevOptionsQueue
*bdo_queue
,
647 MachineClass
*machine_class
, int snapshot
)
650 * If the currently selected machine wishes to override the
651 * units-per-bus property of its default HBA interface type, do so
654 if (machine_class
->units_per_default_bus
) {
655 override_max_devs(machine_class
->block_default_type
,
656 machine_class
->units_per_default_bus
);
659 /* open the virtual block devices */
660 while (!QSIMPLEQ_EMPTY(bdo_queue
)) {
661 BlockdevOptionsQueueEntry
*bdo
= QSIMPLEQ_FIRST(bdo_queue
);
663 QSIMPLEQ_REMOVE_HEAD(bdo_queue
, entry
);
664 loc_push_restore(&bdo
->loc
);
665 qmp_blockdev_add(bdo
->bdo
, &error_fatal
);
667 qapi_free_BlockdevOptions(bdo
->bdo
);
671 qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot
,
674 if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func
,
675 &machine_class
->block_default_type
, &error_fatal
)) {
676 /* We printed help */
680 default_drive(default_cdrom
, snapshot
, machine_class
->block_default_type
, 2,
682 default_drive(default_floppy
, snapshot
, IF_FLOPPY
, 0, FD_OPTS
);
683 default_drive(default_sdcard
, snapshot
, IF_SD
, 0, SD_OPTS
);
687 static QemuOptsList qemu_smp_opts
= {
689 .implied_opt_name
= "cpus",
691 .head
= QTAILQ_HEAD_INITIALIZER(qemu_smp_opts
.head
),
695 .type
= QEMU_OPT_NUMBER
,
698 .type
= QEMU_OPT_NUMBER
,
701 .type
= QEMU_OPT_NUMBER
,
704 .type
= QEMU_OPT_NUMBER
,
707 .type
= QEMU_OPT_NUMBER
,
710 .type
= QEMU_OPT_NUMBER
,
716 static void realtime_init(void)
719 if (os_mlock() < 0) {
720 error_report("locking memory failed");
727 static void configure_msg(QemuOpts
*opts
)
729 error_with_timestamp
= qemu_opt_get_bool(opts
, "timestamp", false);
730 error_with_guestname
= qemu_opt_get_bool(opts
, "guest-name", false);
734 /***********************************************************/
737 static int usb_device_add(const char *devname
)
739 USBDevice
*dev
= NULL
;
741 if (!machine_usb(current_machine
)) {
745 dev
= usbdevice_create(devname
);
752 static int usb_parse(const char *cmdline
)
755 r
= usb_device_add(cmdline
);
757 error_report("could not add USB device '%s'", cmdline
);
762 /***********************************************************/
763 /* machine registration */
765 static MachineClass
*find_machine(const char *name
, GSList
*machines
)
769 for (el
= machines
; el
; el
= el
->next
) {
770 MachineClass
*mc
= el
->data
;
772 if (!strcmp(mc
->name
, name
) || !g_strcmp0(mc
->alias
, name
)) {
780 static MachineClass
*find_default_machine(GSList
*machines
)
783 MachineClass
*default_machineclass
= NULL
;
785 for (el
= machines
; el
; el
= el
->next
) {
786 MachineClass
*mc
= el
->data
;
788 if (mc
->is_default
) {
789 assert(default_machineclass
== NULL
&& "Multiple default machines");
790 default_machineclass
= mc
;
794 return default_machineclass
;
797 static int machine_help_func(QemuOpts
*opts
, MachineState
*machine
)
799 ObjectProperty
*prop
;
800 ObjectPropertyIterator iter
;
802 if (!qemu_opt_has_help_opt(opts
)) {
806 object_property_iter_init(&iter
, OBJECT(machine
));
807 while ((prop
= object_property_iter_next(&iter
))) {
812 printf("%s.%s=%s", MACHINE_GET_CLASS(machine
)->name
,
813 prop
->name
, prop
->type
);
814 if (prop
->description
) {
815 printf(" (%s)\n", prop
->description
);
824 static void version(void)
826 printf("QEMU emulator version " QEMU_FULL_VERSION
"\n"
827 QEMU_COPYRIGHT
"\n");
830 static void help(int exitcode
)
833 printf("usage: %s [options] [disk_image]\n\n"
834 "'disk_image' is a raw hard disk image for IDE hard disk 0\n\n",
835 error_get_progname());
837 #define QEMU_OPTIONS_GENERATE_HELP
838 #include "qemu-options-wrapper.h"
840 printf("\nDuring emulation, the following keys are useful:\n"
841 "ctrl-alt-f toggle full screen\n"
842 "ctrl-alt-n switch to virtual console 'n'\n"
843 "ctrl-alt toggle mouse and keyboard grab\n"
845 "When using -nographic, press 'ctrl-a h' to get some help.\n"
847 QEMU_HELP_BOTTOM
"\n");
852 #define HAS_ARG 0x0001
854 typedef struct QEMUOption
{
861 static const QEMUOption qemu_options
[] = {
862 { "h", 0, QEMU_OPTION_h
, QEMU_ARCH_ALL
},
863 #define QEMU_OPTIONS_GENERATE_OPTIONS
864 #include "qemu-options-wrapper.h"
868 typedef struct VGAInterfaceInfo
{
869 const char *opt_name
; /* option name */
870 const char *name
; /* human-readable name */
871 /* Class names indicating that support is available.
872 * If no class is specified, the interface is always available */
873 const char *class_names
[2];
876 static const VGAInterfaceInfo vga_interfaces
[VGA_TYPE_MAX
] = {
879 .name
= "no graphic card",
883 .name
= "standard VGA",
884 .class_names
= { "VGA", "isa-vga" },
887 .opt_name
= "cirrus",
888 .name
= "Cirrus VGA",
889 .class_names
= { "cirrus-vga", "isa-cirrus-vga" },
892 .opt_name
= "vmware",
893 .name
= "VMWare SVGA",
894 .class_names
= { "vmware-svga" },
897 .opt_name
= "virtio",
898 .name
= "Virtio VGA",
899 .class_names
= { "virtio-vga" },
904 .class_names
= { "qxl-vga" },
908 .name
= "TCX framebuffer",
909 .class_names
= { "SUNW,tcx" },
913 .name
= "CG3 framebuffer",
914 .class_names
= { "cgthree" },
918 .name
= "Xen paravirtualized framebuffer",
922 static bool vga_interface_available(VGAInterfaceType t
)
924 const VGAInterfaceInfo
*ti
= &vga_interfaces
[t
];
926 assert(t
< VGA_TYPE_MAX
);
927 return !ti
->class_names
[0] ||
928 module_object_class_by_name(ti
->class_names
[0]) ||
929 module_object_class_by_name(ti
->class_names
[1]);
933 get_default_vga_model(const MachineClass
*machine_class
)
935 if (machine_class
->default_display
) {
936 return machine_class
->default_display
;
937 } else if (vga_interface_available(VGA_CIRRUS
)) {
939 } else if (vga_interface_available(VGA_STD
)) {
946 static void select_vgahw(const MachineClass
*machine_class
, const char *p
)
951 if (g_str_equal(p
, "help")) {
952 const char *def
= get_default_vga_model(machine_class
);
954 for (t
= 0; t
< VGA_TYPE_MAX
; t
++) {
955 const VGAInterfaceInfo
*ti
= &vga_interfaces
[t
];
957 if (vga_interface_available(t
) && ti
->opt_name
) {
958 printf("%-20s %s%s\n", ti
->opt_name
, ti
->name
?: "",
959 g_str_equal(ti
->opt_name
, def
) ? " (default)" : "");
965 assert(vga_interface_type
== VGA_NONE
);
966 for (t
= 0; t
< VGA_TYPE_MAX
; t
++) {
967 const VGAInterfaceInfo
*ti
= &vga_interfaces
[t
];
968 if (ti
->opt_name
&& strstart(p
, ti
->opt_name
, &opts
)) {
969 if (!vga_interface_available(t
)) {
970 error_report("%s not available", ti
->name
);
973 vga_interface_type
= t
;
977 if (t
== VGA_TYPE_MAX
) {
979 error_report("unknown vga type: %s", p
);
985 if (strstart(opts
, ",retrace=", &nextopt
)) {
987 if (strstart(opts
, "dumb", &nextopt
))
988 vga_retrace_method
= VGA_RETRACE_DUMB
;
989 else if (strstart(opts
, "precise", &nextopt
))
990 vga_retrace_method
= VGA_RETRACE_PRECISE
;
991 else goto invalid_vga
;
992 } else goto invalid_vga
;
997 static void parse_display_qapi(const char *optarg
)
999 DisplayOptions
*opts
;
1002 v
= qobject_input_visitor_new_str(optarg
, "type", &error_fatal
);
1004 visit_type_DisplayOptions(v
, NULL
, &opts
, &error_fatal
);
1005 QAPI_CLONE_MEMBERS(DisplayOptions
, &dpy
, opts
);
1007 qapi_free_DisplayOptions(opts
);
1011 DisplayOptions
*qmp_query_display_options(Error
**errp
)
1013 return QAPI_CLONE(DisplayOptions
, &dpy
);
1016 static void parse_display(const char *p
)
1020 if (is_help_option(p
)) {
1021 qemu_display_help();
1025 if (strstart(p
, "sdl", &opts
)) {
1027 * sdl DisplayType needs hand-crafted parser instead of
1028 * parse_display_qapi() due to some options not in
1029 * DisplayOptions, specifically:
1031 * Already deprecated.
1032 * - ctrl_grab + alt_grab
1033 * Not clear yet what happens to them long-term. Should
1034 * replaced by something better or deprecated and dropped.
1036 dpy
.type
= DISPLAY_TYPE_SDL
;
1038 const char *nextopt
;
1040 if (strstart(opts
, ",alt_grab=", &nextopt
)) {
1042 if (strstart(opts
, "on", &nextopt
)) {
1044 } else if (strstart(opts
, "off", &nextopt
)) {
1047 goto invalid_sdl_args
;
1049 } else if (strstart(opts
, ",ctrl_grab=", &nextopt
)) {
1051 if (strstart(opts
, "on", &nextopt
)) {
1053 } else if (strstart(opts
, "off", &nextopt
)) {
1056 goto invalid_sdl_args
;
1058 } else if (strstart(opts
, ",window_close=", &nextopt
)) {
1060 dpy
.has_window_close
= true;
1061 if (strstart(opts
, "on", &nextopt
)) {
1062 dpy
.window_close
= true;
1063 } else if (strstart(opts
, "off", &nextopt
)) {
1064 dpy
.window_close
= false;
1066 goto invalid_sdl_args
;
1068 } else if (strstart(opts
, ",show-cursor=", &nextopt
)) {
1070 dpy
.has_show_cursor
= true;
1071 if (strstart(opts
, "on", &nextopt
)) {
1072 dpy
.show_cursor
= true;
1073 } else if (strstart(opts
, "off", &nextopt
)) {
1074 dpy
.show_cursor
= false;
1076 goto invalid_sdl_args
;
1078 } else if (strstart(opts
, ",gl=", &nextopt
)) {
1081 if (strstart(opts
, "on", &nextopt
)) {
1082 dpy
.gl
= DISPLAYGL_MODE_ON
;
1083 } else if (strstart(opts
, "core", &nextopt
)) {
1084 dpy
.gl
= DISPLAYGL_MODE_CORE
;
1085 } else if (strstart(opts
, "es", &nextopt
)) {
1086 dpy
.gl
= DISPLAYGL_MODE_ES
;
1087 } else if (strstart(opts
, "off", &nextopt
)) {
1088 dpy
.gl
= DISPLAYGL_MODE_OFF
;
1090 goto invalid_sdl_args
;
1094 error_report("invalid SDL option string");
1099 } else if (strstart(p
, "vnc", &opts
)) {
1101 * vnc isn't a (local) DisplayType but a protocol for remote
1105 vnc_parse(opts
+ 1, &error_fatal
);
1107 error_report("VNC requires a display argument vnc=<display>");
1111 parse_display_qapi(p
);
1115 static inline bool nonempty_str(const char *str
)
1120 static int parse_fw_cfg(void *opaque
, QemuOpts
*opts
, Error
**errp
)
1124 const char *name
, *file
, *str
, *gen_id
;
1125 FWCfgState
*fw_cfg
= (FWCfgState
*) opaque
;
1127 if (fw_cfg
== NULL
) {
1128 error_setg(errp
, "fw_cfg device not available");
1131 name
= qemu_opt_get(opts
, "name");
1132 file
= qemu_opt_get(opts
, "file");
1133 str
= qemu_opt_get(opts
, "string");
1134 gen_id
= qemu_opt_get(opts
, "gen_id");
1136 /* we need the name, and exactly one of: file, content string, gen_id */
1137 if (!nonempty_str(name
) ||
1138 nonempty_str(file
) + nonempty_str(str
) + nonempty_str(gen_id
) != 1) {
1139 error_setg(errp
, "name, plus exactly one of file,"
1140 " string and gen_id, are needed");
1143 if (strlen(name
) > FW_CFG_MAX_FILE_PATH
- 1) {
1144 error_setg(errp
, "name too long (max. %d char)",
1145 FW_CFG_MAX_FILE_PATH
- 1);
1148 if (nonempty_str(gen_id
)) {
1150 * In this particular case where the content is populated
1151 * internally, the "etc/" namespace protection is relaxed,
1152 * so do not emit a warning.
1154 } else if (strncmp(name
, "opt/", 4) != 0) {
1155 warn_report("externally provided fw_cfg item names "
1156 "should be prefixed with \"opt/\"");
1158 if (nonempty_str(str
)) {
1159 size
= strlen(str
); /* NUL terminator NOT included in fw_cfg blob */
1160 buf
= g_memdup(str
, size
);
1161 } else if (nonempty_str(gen_id
)) {
1162 if (!fw_cfg_add_from_generator(fw_cfg
, name
, gen_id
, errp
)) {
1168 if (!g_file_get_contents(file
, &buf
, &size
, &err
)) {
1169 error_setg(errp
, "can't load %s: %s", file
, err
->message
);
1174 /* For legacy, keep user files in a specific global order. */
1175 fw_cfg_set_order_override(fw_cfg
, FW_CFG_ORDER_OVERRIDE_USER
);
1176 fw_cfg_add_file(fw_cfg
, name
, buf
, size
);
1177 fw_cfg_reset_order_override(fw_cfg
);
1181 static int device_help_func(void *opaque
, QemuOpts
*opts
, Error
**errp
)
1183 return qdev_device_help(opts
);
1186 static int device_init_func(void *opaque
, QemuOpts
*opts
, Error
**errp
)
1190 dev
= qdev_device_add(opts
, errp
);
1191 if (!dev
&& *errp
) {
1192 error_report_err(*errp
);
1195 object_unref(OBJECT(dev
));
1200 static int chardev_init_func(void *opaque
, QemuOpts
*opts
, Error
**errp
)
1202 Error
*local_err
= NULL
;
1204 if (!qemu_chr_new_from_opts(opts
, NULL
, &local_err
)) {
1206 error_propagate(errp
, local_err
);
1214 #ifdef CONFIG_VIRTFS
1215 static int fsdev_init_func(void *opaque
, QemuOpts
*opts
, Error
**errp
)
1217 return qemu_fsdev_add(opts
, errp
);
1221 static int mon_init_func(void *opaque
, QemuOpts
*opts
, Error
**errp
)
1223 return monitor_init_opts(opts
, errp
);
1226 static void monitor_parse(const char *optarg
, const char *mode
, bool pretty
)
1228 static int monitor_device_index
= 0;
1233 if (strstart(optarg
, "chardev:", &p
)) {
1234 snprintf(label
, sizeof(label
), "%s", p
);
1236 snprintf(label
, sizeof(label
), "compat_monitor%d",
1237 monitor_device_index
);
1238 opts
= qemu_chr_parse_compat(label
, optarg
, true);
1240 error_report("parse error: %s", optarg
);
1245 opts
= qemu_opts_create(qemu_find_opts("mon"), label
, 1, &error_fatal
);
1246 qemu_opt_set(opts
, "mode", mode
, &error_abort
);
1247 qemu_opt_set(opts
, "chardev", label
, &error_abort
);
1248 if (!strcmp(mode
, "control")) {
1249 qemu_opt_set_bool(opts
, "pretty", pretty
, &error_abort
);
1251 assert(pretty
== false);
1253 monitor_device_index
++;
1256 struct device_config
{
1258 DEV_USB
, /* -usbdevice */
1259 DEV_SERIAL
, /* -serial */
1260 DEV_PARALLEL
, /* -parallel */
1261 DEV_DEBUGCON
, /* -debugcon */
1262 DEV_GDB
, /* -gdb, -s */
1263 DEV_SCLP
, /* s390 sclp */
1265 const char *cmdline
;
1267 QTAILQ_ENTRY(device_config
) next
;
1270 static QTAILQ_HEAD(, device_config
) device_configs
=
1271 QTAILQ_HEAD_INITIALIZER(device_configs
);
1273 static void add_device_config(int type
, const char *cmdline
)
1275 struct device_config
*conf
;
1277 conf
= g_malloc0(sizeof(*conf
));
1279 conf
->cmdline
= cmdline
;
1280 loc_save(&conf
->loc
);
1281 QTAILQ_INSERT_TAIL(&device_configs
, conf
, next
);
1284 static int foreach_device_config(int type
, int (*func
)(const char *cmdline
))
1286 struct device_config
*conf
;
1289 QTAILQ_FOREACH(conf
, &device_configs
, next
) {
1290 if (conf
->type
!= type
)
1292 loc_push_restore(&conf
->loc
);
1293 rc
= func(conf
->cmdline
);
1294 loc_pop(&conf
->loc
);
1302 static void qemu_disable_default_devices(void)
1304 MachineClass
*machine_class
= MACHINE_GET_CLASS(current_machine
);
1306 qemu_opts_foreach(qemu_find_opts("device"),
1307 default_driver_check
, NULL
, NULL
);
1308 qemu_opts_foreach(qemu_find_opts("global"),
1309 default_driver_check
, NULL
, NULL
);
1311 if (!vga_model
&& !default_vga
) {
1312 vga_interface_type
= VGA_DEVICE
;
1314 if (!has_defaults
|| machine_class
->no_serial
) {
1317 if (!has_defaults
|| machine_class
->no_parallel
) {
1318 default_parallel
= 0;
1320 if (!has_defaults
|| machine_class
->no_floppy
) {
1323 if (!has_defaults
|| machine_class
->no_cdrom
) {
1326 if (!has_defaults
|| machine_class
->no_sdcard
) {
1329 if (!has_defaults
) {
1330 default_monitor
= 0;
1336 static void qemu_create_default_devices(void)
1338 MachineClass
*machine_class
= MACHINE_GET_CLASS(current_machine
);
1340 if (is_daemonized()) {
1341 /* According to documentation and historically, -nographic redirects
1342 * serial port, parallel port and monitor to stdio, which does not work
1343 * with -daemonize. We can redirect these to null instead, but since
1344 * -nographic is legacy, let's just error out.
1345 * We disallow -nographic only if all other ports are not redirected
1346 * explicitly, to not break existing legacy setups which uses
1347 * -nographic _and_ redirects all ports explicitly - this is valid
1348 * usage, -nographic is just a no-op in this case.
1351 && (default_parallel
|| default_serial
|| default_monitor
)) {
1352 error_report("-nographic cannot be used with -daemonize");
1358 if (default_parallel
)
1359 add_device_config(DEV_PARALLEL
, "null");
1360 if (default_serial
&& default_monitor
) {
1361 add_device_config(DEV_SERIAL
, "mon:stdio");
1364 add_device_config(DEV_SERIAL
, "stdio");
1365 if (default_monitor
)
1366 monitor_parse("stdio", "readline", false);
1370 add_device_config(DEV_SERIAL
, "vc:80Cx24C");
1371 if (default_parallel
)
1372 add_device_config(DEV_PARALLEL
, "vc:80Cx24C");
1373 if (default_monitor
)
1374 monitor_parse("vc:80Cx24C", "readline", false);
1378 QemuOptsList
*net
= qemu_find_opts("net");
1379 qemu_opts_parse(net
, "nic", true, &error_abort
);
1381 qemu_opts_parse(net
, "user", true, &error_abort
);
1385 #if defined(CONFIG_VNC)
1386 if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head
))) {
1390 if (dpy
.type
== DISPLAY_TYPE_DEFAULT
&& !display_remote
) {
1391 if (!qemu_display_find_default(&dpy
)) {
1392 dpy
.type
= DISPLAY_TYPE_NONE
;
1393 #if defined(CONFIG_VNC)
1394 vnc_parse("localhost:0,to=99,id=default", &error_abort
);
1398 if (dpy
.type
== DISPLAY_TYPE_DEFAULT
) {
1399 dpy
.type
= DISPLAY_TYPE_NONE
;
1402 /* If no default VGA is requested, the default is "none". */
1404 vga_model
= get_default_vga_model(machine_class
);
1407 select_vgahw(machine_class
, vga_model
);
1411 static int serial_parse(const char *devname
)
1413 int index
= num_serial_hds
;
1416 if (strcmp(devname
, "none") == 0)
1418 snprintf(label
, sizeof(label
), "serial%d", index
);
1419 serial_hds
= g_renew(Chardev
*, serial_hds
, index
+ 1);
1421 serial_hds
[index
] = qemu_chr_new_mux_mon(label
, devname
, NULL
);
1422 if (!serial_hds
[index
]) {
1423 error_report("could not connect serial device"
1424 " to character backend '%s'", devname
);
1431 Chardev
*serial_hd(int i
)
1434 if (i
< num_serial_hds
) {
1435 return serial_hds
[i
];
1440 static int parallel_parse(const char *devname
)
1442 static int index
= 0;
1445 if (strcmp(devname
, "none") == 0)
1447 if (index
== MAX_PARALLEL_PORTS
) {
1448 error_report("too many parallel ports");
1451 snprintf(label
, sizeof(label
), "parallel%d", index
);
1452 parallel_hds
[index
] = qemu_chr_new_mux_mon(label
, devname
, NULL
);
1453 if (!parallel_hds
[index
]) {
1454 error_report("could not connect parallel device"
1455 " to character backend '%s'", devname
);
1462 static int debugcon_parse(const char *devname
)
1466 if (!qemu_chr_new_mux_mon("debugcon", devname
, NULL
)) {
1467 error_report("invalid character backend '%s'", devname
);
1470 opts
= qemu_opts_create(qemu_find_opts("device"), "debugcon", 1, NULL
);
1472 error_report("already have a debugcon device");
1475 qemu_opt_set(opts
, "driver", "isa-debugcon", &error_abort
);
1476 qemu_opt_set(opts
, "chardev", "debugcon", &error_abort
);
1480 static gint
machine_class_cmp(gconstpointer a
, gconstpointer b
)
1482 const MachineClass
*mc1
= a
, *mc2
= b
;
1485 if (mc1
->family
== NULL
) {
1486 if (mc2
->family
== NULL
) {
1487 /* Compare standalone machine types against each other; they sort
1488 * in increasing order.
1490 return strcmp(object_class_get_name(OBJECT_CLASS(mc1
)),
1491 object_class_get_name(OBJECT_CLASS(mc2
)));
1494 /* Standalone machine types sort after families. */
1498 if (mc2
->family
== NULL
) {
1499 /* Families sort before standalone machine types. */
1503 /* Families sort between each other alphabetically increasingly. */
1504 res
= strcmp(mc1
->family
, mc2
->family
);
1509 /* Within the same family, machine types sort in decreasing order. */
1510 return strcmp(object_class_get_name(OBJECT_CLASS(mc2
)),
1511 object_class_get_name(OBJECT_CLASS(mc1
)));
1514 static MachineClass
*machine_parse(const char *name
, GSList
*machines
)
1519 if (is_help_option(name
)) {
1520 printf("Supported machines are:\n");
1521 machines
= g_slist_sort(machines
, machine_class_cmp
);
1522 for (el
= machines
; el
; el
= el
->next
) {
1523 MachineClass
*mc
= el
->data
;
1525 printf("%-20s %s (alias of %s)\n", mc
->alias
, mc
->desc
, mc
->name
);
1527 printf("%-20s %s%s%s\n", mc
->name
, mc
->desc
,
1528 mc
->is_default
? " (default)" : "",
1529 mc
->deprecation_reason
? " (deprecated)" : "");
1534 mc
= find_machine(name
, machines
);
1536 error_report("unsupported machine type");
1537 error_printf("Use -machine help to list supported machines\n");
1543 static const char *pid_file
;
1544 static Notifier qemu_unlink_pidfile_notifier
;
1546 static void qemu_unlink_pidfile(Notifier
*n
, void *data
)
1553 static const QEMUOption
*lookup_opt(int argc
, char **argv
,
1554 const char **poptarg
, int *poptind
)
1556 const QEMUOption
*popt
;
1557 int optind
= *poptind
;
1558 char *r
= argv
[optind
];
1561 loc_set_cmdline(argv
, optind
, 1);
1563 /* Treat --foo the same as -foo. */
1566 popt
= qemu_options
;
1569 error_report("invalid option");
1572 if (!strcmp(popt
->name
, r
+ 1))
1576 if (popt
->flags
& HAS_ARG
) {
1577 if (optind
>= argc
) {
1578 error_report("requires an argument");
1581 optarg
= argv
[optind
++];
1582 loc_set_cmdline(argv
, optind
- 2, 2);
1593 static MachineClass
*select_machine(void)
1595 GSList
*machines
= object_class_get_list(TYPE_MACHINE
, false);
1596 MachineClass
*machine_class
= find_default_machine(machines
);
1601 loc_push_none(&loc
);
1603 opts
= qemu_get_machine_opts();
1604 qemu_opts_loc_restore(opts
);
1606 optarg
= qemu_opt_get(opts
, "type");
1608 machine_class
= machine_parse(optarg
, machines
);
1611 if (!machine_class
) {
1612 error_report("No machine specified, and there is no default");
1613 error_printf("Use -machine help to list supported machines\n");
1618 g_slist_free(machines
);
1619 return machine_class
;
1622 static int object_parse_property_opt(Object
*obj
,
1623 const char *name
, const char *value
,
1624 const char *skip
, Error
**errp
)
1626 if (g_str_equal(name
, skip
)) {
1630 if (!object_property_parse(obj
, name
, value
, errp
)) {
1637 static int machine_set_property(void *opaque
,
1638 const char *name
, const char *value
,
1641 g_autofree
char *qom_name
= g_strdup(name
);
1644 for (p
= qom_name
; *p
; p
++) {
1650 /* Legacy options do not correspond to MachineState properties. */
1651 if (g_str_equal(qom_name
, "accel")) {
1654 if (g_str_equal(qom_name
, "igd-passthru")) {
1655 object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name
, value
);
1658 if (g_str_equal(qom_name
, "kvm-shadow-mem")) {
1659 object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name
, value
);
1662 if (g_str_equal(qom_name
, "kernel-irqchip")) {
1663 object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name
, value
);
1664 object_register_sugar_prop(ACCEL_CLASS_NAME("whpx"), qom_name
, value
);
1668 return object_parse_property_opt(opaque
, name
, value
, "type", errp
);
1672 * Initial object creation happens before all other
1673 * QEMU data types are created. The majority of objects
1674 * can be created at this point. The rng-egd object
1675 * cannot be created here, as it depends on the chardev
1678 static bool object_create_early(const char *type
, QemuOpts
*opts
)
1680 if (user_creatable_print_help(type
, opts
)) {
1685 * Objects should not be made "delayed" without a reason. If you
1686 * add one, state the reason in a comment!
1689 /* Reason: rng-egd property "chardev" */
1690 if (g_str_equal(type
, "rng-egd")) {
1694 #if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX)
1695 /* Reason: cryptodev-vhost-user property "chardev" */
1696 if (g_str_equal(type
, "cryptodev-vhost-user")) {
1701 /* Reason: vhost-user-blk-server property "node-name" */
1702 if (g_str_equal(type
, "vhost-user-blk-server")) {
1706 * Reason: filter-* property "netdev" etc.
1708 if (g_str_equal(type
, "filter-buffer") ||
1709 g_str_equal(type
, "filter-dump") ||
1710 g_str_equal(type
, "filter-mirror") ||
1711 g_str_equal(type
, "filter-redirector") ||
1712 g_str_equal(type
, "colo-compare") ||
1713 g_str_equal(type
, "filter-rewriter") ||
1714 g_str_equal(type
, "filter-replay")) {
1718 /* Memory allocation by backends needs to be done
1719 * after configure_accelerator() (due to the tcg_enabled()
1720 * checks at memory_region_init_*()).
1722 * Also, allocation of large amounts of memory may delay
1723 * chardev initialization for too long, and trigger timeouts
1724 * on software that waits for a monitor socket to be created
1727 if (g_str_has_prefix(type
, "memory-backend-")) {
1734 static void qemu_apply_machine_options(void)
1736 MachineClass
*machine_class
= MACHINE_GET_CLASS(current_machine
);
1737 QemuOpts
*machine_opts
= qemu_get_machine_opts();
1738 const char *boot_order
= NULL
;
1739 const char *boot_once
= NULL
;
1742 qemu_opt_foreach(machine_opts
, machine_set_property
, current_machine
,
1744 current_machine
->ram_size
= ram_size
;
1745 current_machine
->maxram_size
= maxram_size
;
1746 current_machine
->ram_slots
= ram_slots
;
1748 opts
= qemu_opts_find(qemu_find_opts("boot-opts"), NULL
);
1750 boot_order
= qemu_opt_get(opts
, "order");
1752 validate_bootdevices(boot_order
, &error_fatal
);
1755 boot_once
= qemu_opt_get(opts
, "once");
1757 validate_bootdevices(boot_once
, &error_fatal
);
1760 boot_menu
= qemu_opt_get_bool(opts
, "menu", boot_menu
);
1761 boot_strict
= qemu_opt_get_bool(opts
, "strict", false);
1765 boot_order
= machine_class
->default_boot_order
;
1768 current_machine
->boot_order
= boot_order
;
1769 current_machine
->boot_once
= boot_once
;
1771 if (semihosting_enabled() && !semihosting_get_argc()) {
1772 const char *kernel_filename
= qemu_opt_get(machine_opts
, "kernel");
1773 const char *kernel_cmdline
= qemu_opt_get(machine_opts
, "append") ?: "";
1774 /* fall back to the -kernel/-append */
1775 semihosting_arg_fallback(kernel_filename
, kernel_cmdline
);
1779 static void qemu_create_early_backends(void)
1781 MachineClass
*machine_class
= MACHINE_GET_CLASS(current_machine
);
1783 if ((alt_grab
|| ctrl_grab
) && dpy
.type
!= DISPLAY_TYPE_SDL
) {
1784 error_report("-alt-grab and -ctrl-grab are only valid "
1785 "for SDL, ignoring option");
1787 if (dpy
.has_window_close
&&
1788 (dpy
.type
!= DISPLAY_TYPE_GTK
&& dpy
.type
!= DISPLAY_TYPE_SDL
)) {
1789 error_report("-no-quit is only valid for GTK and SDL, "
1793 qemu_display_early_init(&dpy
);
1794 qemu_console_early_init();
1796 if (dpy
.has_gl
&& dpy
.gl
!= DISPLAYGL_MODE_OFF
&& display_opengl
== 0) {
1797 #if defined(CONFIG_OPENGL)
1798 error_report("OpenGL is not supported by the display");
1800 error_report("OpenGL support is disabled");
1805 qemu_opts_foreach(qemu_find_opts("object"),
1806 user_creatable_add_opts_foreach
,
1807 object_create_early
, &error_fatal
);
1809 /* spice needs the timers to be initialized by this point */
1810 /* spice must initialize before audio as it changes the default auiodev */
1811 /* spice must initialize before chardevs (for spicevmc and spiceport) */
1814 qemu_opts_foreach(qemu_find_opts("chardev"),
1815 chardev_init_func
, NULL
, &error_fatal
);
1817 #ifdef CONFIG_VIRTFS
1818 qemu_opts_foreach(qemu_find_opts("fsdev"),
1819 fsdev_init_func
, NULL
, &error_fatal
);
1823 * Note: we need to create audio and block backends before
1824 * machine_set_property(), so machine properties can refer to
1827 configure_blockdev(&bdo_queue
, machine_class
, snapshot
);
1828 audio_init_audiodevs();
1833 * The remainder of object creation happens after the
1834 * creation of chardev, fsdev, net clients and device data types.
1836 static bool object_create_late(const char *type
, QemuOpts
*opts
)
1838 return !object_create_early(type
, opts
);
1841 static void qemu_create_late_backends(void)
1844 qtest_server_init(qtest_chrdev
, qtest_log
, &error_fatal
);
1847 net_init_clients(&error_fatal
);
1849 qemu_opts_foreach(qemu_find_opts("object"),
1850 user_creatable_add_opts_foreach
,
1851 object_create_late
, &error_fatal
);
1853 if (tpm_init() < 0) {
1857 qemu_opts_foreach(qemu_find_opts("mon"),
1858 mon_init_func
, NULL
, &error_fatal
);
1860 if (foreach_device_config(DEV_SERIAL
, serial_parse
) < 0)
1862 if (foreach_device_config(DEV_PARALLEL
, parallel_parse
) < 0)
1864 if (foreach_device_config(DEV_DEBUGCON
, debugcon_parse
) < 0)
1867 /* now chardevs have been created we may have semihosting to connect */
1868 qemu_semihosting_connect_chardevs();
1869 qemu_semihosting_console_init();
1872 static bool have_custom_ram_size(void)
1874 QemuOpts
*opts
= qemu_find_opts_singleton("memory");
1875 return !!qemu_opt_get_size(opts
, "size", 0);
1878 static void qemu_resolve_machine_memdev(void)
1880 if (current_machine
->ram_memdev_id
) {
1882 ram_addr_t backend_size
;
1884 backend
= object_resolve_path_type(current_machine
->ram_memdev_id
,
1885 TYPE_MEMORY_BACKEND
, NULL
);
1887 error_report("Memory backend '%s' not found",
1888 current_machine
->ram_memdev_id
);
1891 backend_size
= object_property_get_uint(backend
, "size", &error_abort
);
1892 if (have_custom_ram_size() && backend_size
!= ram_size
) {
1893 error_report("Size specified by -m option must match size of "
1894 "explicitly specified 'memory-backend' property");
1898 error_report("'-mem-path' can't be used together with"
1899 "'-machine memory-backend'");
1902 ram_size
= backend_size
;
1905 if (!xen_enabled()) {
1906 /* On 32-bit hosts, QEMU is limited by virtual address space */
1907 if (ram_size
> (2047 << 20) && HOST_LONG_BITS
== 32) {
1908 error_report("at most 2047 MB RAM can be simulated");
1914 static void set_memory_options(MachineClass
*mc
)
1917 const char *mem_str
;
1918 const ram_addr_t default_ram_size
= mc
->default_ram_size
;
1919 QemuOpts
*opts
= qemu_find_opts_singleton("memory");
1922 loc_push_none(&loc
);
1923 qemu_opts_loc_restore(opts
);
1926 mem_str
= qemu_opt_get(opts
, "size");
1929 error_report("missing 'size' option value");
1933 sz
= qemu_opt_get_size(opts
, "size", ram_size
);
1935 /* Fix up legacy suffix-less format */
1936 if (g_ascii_isdigit(mem_str
[strlen(mem_str
) - 1])) {
1937 uint64_t overflow_check
= sz
;
1940 if (sz
/ MiB
!= overflow_check
) {
1941 error_report("too large 'size' option value");
1947 /* backward compatibility behaviour for case "-m 0" */
1949 sz
= default_ram_size
;
1952 sz
= QEMU_ALIGN_UP(sz
, 8192);
1953 if (mc
->fixup_ram_size
) {
1954 sz
= mc
->fixup_ram_size(sz
);
1957 if (ram_size
!= sz
) {
1958 error_report("ram size too large");
1962 /* store value for the future use */
1963 qemu_opt_set_number(opts
, "size", ram_size
, &error_abort
);
1964 maxram_size
= ram_size
;
1966 if (qemu_opt_get(opts
, "maxmem")) {
1969 sz
= qemu_opt_get_size(opts
, "maxmem", 0);
1970 slots
= qemu_opt_get_number(opts
, "slots", 0);
1971 if (sz
< ram_size
) {
1972 error_report("invalid value of -m option maxmem: "
1973 "maximum memory size (0x%" PRIx64
") must be at least "
1974 "the initial memory size (0x" RAM_ADDR_FMT
")",
1977 } else if (slots
&& sz
== ram_size
) {
1978 error_report("invalid value of -m option maxmem: "
1979 "memory slots were specified but maximum memory size "
1980 "(0x%" PRIx64
") is equal to the initial memory size "
1981 "(0x" RAM_ADDR_FMT
")", sz
, ram_size
);
1987 } else if (qemu_opt_get(opts
, "slots")) {
1988 error_report("invalid -m option value: missing 'maxmem' option");
1995 static void qemu_create_machine(MachineClass
*machine_class
)
1997 object_set_machine_compat_props(machine_class
->compat_props
);
1999 set_memory_options(machine_class
);
2001 current_machine
= MACHINE(object_new_with_class(OBJECT_CLASS(machine_class
)));
2002 if (machine_help_func(qemu_get_machine_opts(), current_machine
)) {
2005 object_property_add_child(object_get_root(), "machine",
2006 OBJECT(current_machine
));
2007 object_property_add_child(container_get(OBJECT(current_machine
),
2009 "sysbus", OBJECT(sysbus_get_default()));
2011 if (machine_class
->minimum_page_bits
) {
2012 if (!set_preferred_target_page_bits(machine_class
->minimum_page_bits
)) {
2013 /* This would be a board error: specifying a minimum smaller than
2014 * a target's compile-time fixed setting.
2016 g_assert_not_reached();
2020 cpu_exec_init_all();
2023 if (machine_class
->hw_version
) {
2024 qemu_set_hw_version(machine_class
->hw_version
);
2027 machine_smp_parse(current_machine
,
2028 qemu_opts_find(qemu_find_opts("smp-opts"), NULL
), &error_fatal
);
2031 * Get the default machine options from the machine if it is not already
2032 * specified either by the configuration file or by the command line.
2034 if (machine_class
->default_machine_opts
) {
2035 qemu_opts_set_defaults(qemu_find_opts("machine"),
2036 machine_class
->default_machine_opts
, 0);
2040 static int global_init_func(void *opaque
, QemuOpts
*opts
, Error
**errp
)
2044 g
= g_malloc0(sizeof(*g
));
2045 g
->driver
= qemu_opt_get(opts
, "driver");
2046 g
->property
= qemu_opt_get(opts
, "property");
2047 g
->value
= qemu_opt_get(opts
, "value");
2048 qdev_prop_register_global(g
);
2052 static int qemu_read_default_config_file(void)
2055 g_autofree
char *file
= get_relocated_path(CONFIG_QEMU_CONFDIR
"/qemu.conf");
2057 ret
= qemu_read_config_file(file
);
2058 if (ret
< 0 && ret
!= -ENOENT
) {
2065 static int qemu_set_option(const char *str
)
2067 Error
*local_err
= NULL
;
2068 char group
[64], id
[64], arg
[64];
2073 rc
= sscanf(str
, "%63[^.].%63[^.].%63[^=]%n", group
, id
, arg
, &offset
);
2074 if (rc
< 3 || str
[offset
] != '=') {
2075 error_report("can't parse: \"%s\"", str
);
2079 list
= qemu_find_opts(group
);
2084 opts
= qemu_opts_find(list
, id
);
2086 error_report("there is no %s \"%s\" defined",
2091 if (!qemu_opt_set(opts
, arg
, str
+ offset
+ 1, &local_err
)) {
2092 error_report_err(local_err
);
2098 static void user_register_global_props(void)
2100 qemu_opts_foreach(qemu_find_opts("global"),
2101 global_init_func
, NULL
, NULL
);
2104 static int do_configure_icount(void *opaque
, QemuOpts
*opts
, Error
**errp
)
2106 icount_configure(opts
, errp
);
2110 static int accelerator_set_property(void *opaque
,
2111 const char *name
, const char *value
,
2114 return object_parse_property_opt(opaque
, name
, value
, "accel", errp
);
2117 static int do_configure_accelerator(void *opaque
, QemuOpts
*opts
, Error
**errp
)
2119 bool *p_init_failed
= opaque
;
2120 const char *acc
= qemu_opt_get(opts
, "accel");
2121 AccelClass
*ac
= accel_find(acc
);
2124 bool qtest_with_kvm
;
2126 qtest_with_kvm
= g_str_equal(acc
, "kvm") && qtest_chrdev
!= NULL
;
2129 *p_init_failed
= true;
2130 if (!qtest_with_kvm
) {
2131 error_report("invalid accelerator %s", acc
);
2135 accel
= ACCEL(object_new_with_class(OBJECT_CLASS(ac
)));
2136 object_apply_compat_props(OBJECT(accel
));
2137 qemu_opt_foreach(opts
, accelerator_set_property
,
2141 ret
= accel_init_machine(accel
, current_machine
);
2143 *p_init_failed
= true;
2144 if (!qtest_with_kvm
|| ret
!= -ENOENT
) {
2145 error_report("failed to initialize %s: %s", acc
, strerror(-ret
));
2153 static void configure_accelerators(const char *progname
)
2156 bool init_failed
= false;
2158 qemu_opts_foreach(qemu_find_opts("icount"),
2159 do_configure_icount
, NULL
, &error_fatal
);
2161 accel
= qemu_opt_get(qemu_get_machine_opts(), "accel");
2162 if (QTAILQ_EMPTY(&qemu_accel_opts
.head
)) {
2163 char **accel_list
, **tmp
;
2165 if (accel
== NULL
) {
2166 /* Select the default accelerator */
2167 bool have_tcg
= accel_find("tcg");
2168 bool have_kvm
= accel_find("kvm");
2170 if (have_tcg
&& have_kvm
) {
2171 if (g_str_has_suffix(progname
, "kvm")) {
2172 /* If the program name ends with "kvm", we prefer KVM */
2177 } else if (have_kvm
) {
2179 } else if (have_tcg
) {
2182 error_report("No accelerator selected and"
2183 " no default accelerator available");
2187 accel_list
= g_strsplit(accel
, ":", 0);
2189 for (tmp
= accel_list
; *tmp
; tmp
++) {
2191 * Filter invalid accelerators here, to prevent obscenities
2192 * such as "-machine accel=tcg,,thread=single".
2194 if (accel_find(*tmp
)) {
2195 qemu_opts_parse_noisily(qemu_find_opts("accel"), *tmp
, true);
2198 error_report("invalid accelerator %s", *tmp
);
2201 g_strfreev(accel_list
);
2203 if (accel
!= NULL
) {
2204 error_report("The -accel and \"-machine accel=\" options are incompatible");
2209 if (!qemu_opts_foreach(qemu_find_opts("accel"),
2210 do_configure_accelerator
, &init_failed
, &error_fatal
)) {
2212 error_report("no accelerator found");
2217 if (init_failed
&& !qtest_chrdev
) {
2218 AccelClass
*ac
= ACCEL_GET_CLASS(current_accel());
2219 error_report("falling back to %s", ac
->name
);
2222 if (icount_enabled() && !tcg_enabled()) {
2223 error_report("-icount is not allowed with hardware virtualization");
2228 static void create_default_memdev(MachineState
*ms
, const char *path
)
2231 MachineClass
*mc
= MACHINE_GET_CLASS(ms
);
2233 obj
= object_new(path
? TYPE_MEMORY_BACKEND_FILE
: TYPE_MEMORY_BACKEND_RAM
);
2235 object_property_set_str(obj
, "mem-path", path
, &error_fatal
);
2237 object_property_set_int(obj
, "size", ms
->ram_size
, &error_fatal
);
2238 object_property_add_child(object_get_objects_root(), mc
->default_ram_id
,
2240 /* Ensure backend's memory region name is equal to mc->default_ram_id */
2241 object_property_set_bool(obj
, "x-use-canonical-path-for-ramblock-id",
2242 false, &error_fatal
);
2243 user_creatable_complete(USER_CREATABLE(obj
), &error_fatal
);
2245 object_property_set_str(OBJECT(ms
), "memory-backend", mc
->default_ram_id
,
2249 static void qemu_validate_options(void)
2251 QemuOpts
*machine_opts
= qemu_get_machine_opts();
2252 const char *kernel_filename
= qemu_opt_get(machine_opts
, "kernel");
2253 const char *initrd_filename
= qemu_opt_get(machine_opts
, "initrd");
2254 const char *kernel_cmdline
= qemu_opt_get(machine_opts
, "append");
2256 if (kernel_filename
== NULL
) {
2257 if (kernel_cmdline
!= NULL
) {
2258 error_report("-append only allowed with -kernel option");
2262 if (initrd_filename
!= NULL
) {
2263 error_report("-initrd only allowed with -kernel option");
2268 if (loadvm
&& preconfig_requested
) {
2269 error_report("'preconfig' and 'loadvm' options are "
2270 "mutually exclusive");
2273 if (incoming
&& preconfig_requested
&& strcmp(incoming
, "defer") != 0) {
2274 error_report("'preconfig' supports '-incoming defer' only");
2278 #ifdef CONFIG_CURSES
2279 if (is_daemonized() && dpy
.type
== DISPLAY_TYPE_CURSES
) {
2280 error_report("curses display cannot be used with -daemonize");
2286 static void qemu_process_sugar_options(void)
2291 val
= g_strdup_printf("%d",
2292 (uint32_t) qemu_opt_get_number(qemu_find_opts_singleton("smp-opts"), "cpus", 1));
2293 object_register_sugar_prop("memory-backend", "prealloc-threads", val
);
2295 object_register_sugar_prop("memory-backend", "prealloc", "on");
2299 int i
= select_watchdog(watchdog
);
2301 exit (i
== 1 ? 1 : 0);
2305 static void qemu_process_early_options(void)
2307 #ifdef CONFIG_SECCOMP
2308 QemuOptsList
*olist
= qemu_find_opts_err("sandbox", NULL
);
2310 qemu_opts_foreach(olist
, parse_sandbox
, NULL
, &error_fatal
);
2314 qemu_opts_foreach(qemu_find_opts("name"),
2315 parse_name
, NULL
, &error_fatal
);
2318 qemu_opts_foreach(qemu_find_opts("add-fd"),
2319 parse_add_fd
, NULL
, &error_fatal
);
2321 qemu_opts_foreach(qemu_find_opts("add-fd"),
2322 cleanup_add_fd
, NULL
, &error_fatal
);
2325 if (!trace_init_backends()) {
2330 /* Open the logfile at this point and set the log mask if necessary. */
2331 qemu_set_log_filename(log_file
, &error_fatal
);
2334 mask
= qemu_str_to_log_mask(log_mask
);
2336 qemu_print_log_usage(stdout
);
2344 qemu_add_default_firmwarepath();
2347 static void qemu_process_help_options(void)
2350 * Check for -cpu help and -device help before we call select_machine(),
2351 * which will return an error if the architecture has no default machine
2352 * type and the user did not specify one, so that the user doesn't need
2353 * to say '-cpu help -machine something'.
2355 if (cpu_option
&& is_help_option(cpu_option
)) {
2356 list_cpus(cpu_option
);
2360 if (qemu_opts_foreach(qemu_find_opts("device"),
2361 device_help_func
, NULL
, NULL
)) {
2365 /* -L help lists the data directories and exits. */
2366 if (list_data_dirs
) {
2367 qemu_list_data_dirs();
2372 static void qemu_maybe_daemonize(const char *pid_file
)
2377 rcu_disable_atfork();
2379 if (pid_file
&& !qemu_write_pidfile(pid_file
, &err
)) {
2380 error_reportf_err(err
, "cannot create PID file: ");
2384 qemu_unlink_pidfile_notifier
.notify
= qemu_unlink_pidfile
;
2385 qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier
);
2388 static void qemu_init_displays(void)
2392 /* init local displays */
2393 ds
= init_displaystate();
2394 qemu_display_init(ds
, &dpy
);
2396 /* must be after terminal init, SDL library changes signal handlers */
2397 os_setup_signal_handling();
2399 /* init remote displays */
2401 qemu_opts_foreach(qemu_find_opts("vnc"),
2402 vnc_init_func
, NULL
, &error_fatal
);
2406 qemu_spice
.display_init();
2411 * Called after leaving preconfig state. From here on runstate is
2412 * RUN_STATE_PRELAUNCH or RUN_STATE_INMIGRATE.
2414 static void qemu_init_board(void)
2416 MachineClass
*machine_class
= MACHINE_GET_CLASS(current_machine
);
2418 if (machine_class
->default_ram_id
&& current_machine
->ram_size
&&
2419 numa_uses_legacy_mem() && !current_machine
->ram_memdev_id
) {
2420 create_default_memdev(current_machine
, mem_path
);
2423 /* process plugin before CPUs are created, but once -smp has been parsed */
2424 if (qemu_plugin_load_list(&plugin_list
)) {
2428 machine_run_board_init(current_machine
);
2431 * TODO To drop support for deprecated bogus if=..., move
2432 * drive_check_orphaned() here, replacing this call. Also drop
2433 * its deprecation warning, along with DriveInfo member
2434 * @claimed_by_board.
2436 drive_mark_claimed_by_board();
2440 if (hax_enabled()) {
2441 /* FIXME: why isn't cpu_synchronize_all_post_init enough? */
2446 static void qemu_create_cli_devices(void)
2450 qemu_opts_foreach(qemu_find_opts("fw_cfg"),
2451 parse_fw_cfg
, fw_cfg_find(), &error_fatal
);
2453 /* init USB devices */
2454 if (machine_usb(current_machine
)) {
2455 if (foreach_device_config(DEV_USB
, usb_parse
) < 0)
2459 /* init generic devices */
2460 rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE
);
2461 qemu_opts_foreach(qemu_find_opts("device"),
2462 device_init_func
, NULL
, &error_fatal
);
2463 rom_reset_order_override();
2466 static void qemu_machine_creation_done(void)
2468 cpu_synchronize_all_post_init();
2470 /* Did we create any drives that we failed to create a device for? */
2471 drive_check_orphaned();
2473 /* Don't warn about the default network setup that you get if
2474 * no command line -net or -netdev options are specified. There
2475 * are two cases that we would otherwise complain about:
2476 * (1) board doesn't support a NIC but the implicit "-net nic"
2478 * (2) CONFIG_SLIRP not set, in which case the implicit "-net nic"
2479 * sets up a nic that isn't connected to anything.
2481 if (!default_net
&& (!qtest_enabled() || has_defaults
)) {
2482 net_check_clients();
2485 qdev_prop_check_globals();
2487 if (current_machine
->boot_once
) {
2488 qemu_boot_set(current_machine
->boot_once
, &error_fatal
);
2489 qemu_register_reset(restore_boot_order
, g_strdup(current_machine
->boot_order
));
2492 if (foreach_device_config(DEV_GDB
, gdbserver_start
) < 0) {
2496 qdev_machine_creation_done();
2498 /* TODO: once all bus devices are qdevified, this should be done
2499 * when bus is created by qdev.c */
2501 * TODO: If we had a main 'reset container' that the whole system
2502 * lived in, we could reset that using the multi-phase reset
2503 * APIs. For the moment, we just reset the sysbus, which will cause
2504 * all devices hanging off it (and all their child buses, recursively)
2505 * to be reset. Note that this will *not* reset any Device objects
2506 * which are not attached to some part of the qbus tree!
2508 qemu_register_reset(resettable_cold_reset_fn
, sysbus_get_default());
2509 qemu_run_machine_init_done_notifiers();
2511 if (rom_check_and_register_reset() != 0) {
2512 error_report("rom check and register reset failed");
2518 /* This checkpoint is required by replay to separate prior clock
2519 reading from the other reads, because timer polling functions query
2520 clock values from the log. */
2521 replay_checkpoint(CHECKPOINT_RESET
);
2522 qemu_system_reset(SHUTDOWN_CAUSE_NONE
);
2523 register_global_state();
2526 void qmp_x_exit_preconfig(Error
**errp
)
2529 error_setg(errp
, "The command is permitted only before machine initialization");
2534 qemu_create_cli_devices();
2535 qemu_machine_creation_done();
2538 Error
*local_err
= NULL
;
2539 if (load_snapshot(loadvm
, &local_err
) < 0) {
2540 error_report_err(local_err
);
2545 if (replay_mode
!= REPLAY_MODE_NONE
) {
2546 replay_vmstate_init();
2550 Error
*local_err
= NULL
;
2551 if (strcmp(incoming
, "defer") != 0) {
2552 qmp_migrate_incoming(incoming
, &local_err
);
2554 error_reportf_err(local_err
, "-incoming %s: ", incoming
);
2558 } else if (autostart
) {
2563 void qemu_init(int argc
, char **argv
, char **envp
)
2566 QemuOpts
*icount_opts
= NULL
, *accel_opts
= NULL
;
2567 QemuOptsList
*olist
;
2570 MachineClass
*machine_class
;
2571 bool userconfig
= true;
2572 FILE *vmstate_dump_file
= NULL
;
2574 qemu_add_opts(&qemu_drive_opts
);
2575 qemu_add_drive_opts(&qemu_legacy_drive_opts
);
2576 qemu_add_drive_opts(&qemu_common_drive_opts
);
2577 qemu_add_drive_opts(&qemu_drive_opts
);
2578 qemu_add_drive_opts(&bdrv_runtime_opts
);
2579 qemu_add_opts(&qemu_chardev_opts
);
2580 qemu_add_opts(&qemu_device_opts
);
2581 qemu_add_opts(&qemu_netdev_opts
);
2582 qemu_add_opts(&qemu_nic_opts
);
2583 qemu_add_opts(&qemu_net_opts
);
2584 qemu_add_opts(&qemu_rtc_opts
);
2585 qemu_add_opts(&qemu_global_opts
);
2586 qemu_add_opts(&qemu_mon_opts
);
2587 qemu_add_opts(&qemu_trace_opts
);
2588 qemu_plugin_add_opts();
2589 qemu_add_opts(&qemu_option_rom_opts
);
2590 qemu_add_opts(&qemu_machine_opts
);
2591 qemu_add_opts(&qemu_accel_opts
);
2592 qemu_add_opts(&qemu_mem_opts
);
2593 qemu_add_opts(&qemu_smp_opts
);
2594 qemu_add_opts(&qemu_boot_opts
);
2595 qemu_add_opts(&qemu_add_fd_opts
);
2596 qemu_add_opts(&qemu_object_opts
);
2597 qemu_add_opts(&qemu_tpmdev_opts
);
2598 qemu_add_opts(&qemu_realtime_opts
);
2599 qemu_add_opts(&qemu_overcommit_opts
);
2600 qemu_add_opts(&qemu_msg_opts
);
2601 qemu_add_opts(&qemu_name_opts
);
2602 qemu_add_opts(&qemu_numa_opts
);
2603 qemu_add_opts(&qemu_icount_opts
);
2604 qemu_add_opts(&qemu_semihosting_config_opts
);
2605 qemu_add_opts(&qemu_fw_cfg_opts
);
2606 module_call_init(MODULE_INIT_OPTS
);
2608 error_init(argv
[0]);
2609 qemu_init_exec_dir(argv
[0]);
2611 qemu_init_subsystems();
2613 /* first pass of option parsing */
2615 while (optind
< argc
) {
2616 if (argv
[optind
][0] != '-') {
2620 const QEMUOption
*popt
;
2622 popt
= lookup_opt(argc
, argv
, &optarg
, &optind
);
2623 switch (popt
->index
) {
2624 case QEMU_OPTION_nouserconfig
:
2632 if (qemu_read_default_config_file() < 0) {
2637 /* second pass of option parsing */
2642 if (argv
[optind
][0] != '-') {
2643 loc_set_cmdline(argv
, optind
, 1);
2644 drive_add(IF_DEFAULT
, 0, argv
[optind
++], HD_OPTS
);
2646 const QEMUOption
*popt
;
2648 popt
= lookup_opt(argc
, argv
, &optarg
, &optind
);
2649 if (!(popt
->arch_mask
& arch_type
)) {
2650 error_report("Option not supported for this target");
2653 switch(popt
->index
) {
2654 case QEMU_OPTION_cpu
:
2655 /* hw initialization will check this */
2656 cpu_option
= optarg
;
2658 case QEMU_OPTION_hda
:
2659 case QEMU_OPTION_hdb
:
2660 case QEMU_OPTION_hdc
:
2661 case QEMU_OPTION_hdd
:
2662 drive_add(IF_DEFAULT
, popt
->index
- QEMU_OPTION_hda
, optarg
,
2665 case QEMU_OPTION_blockdev
:
2668 BlockdevOptionsQueueEntry
*bdo
;
2670 v
= qobject_input_visitor_new_str(optarg
, "driver",
2673 bdo
= g_new(BlockdevOptionsQueueEntry
, 1);
2674 visit_type_BlockdevOptions(v
, NULL
, &bdo
->bdo
,
2677 loc_save(&bdo
->loc
);
2678 QSIMPLEQ_INSERT_TAIL(&bdo_queue
, bdo
, entry
);
2681 case QEMU_OPTION_drive
:
2682 if (drive_def(optarg
) == NULL
) {
2686 case QEMU_OPTION_set
:
2687 if (qemu_set_option(optarg
) != 0)
2690 case QEMU_OPTION_global
:
2691 if (qemu_global_option(optarg
) != 0)
2694 case QEMU_OPTION_mtdblock
:
2695 drive_add(IF_MTD
, -1, optarg
, MTD_OPTS
);
2697 case QEMU_OPTION_sd
:
2698 drive_add(IF_SD
, -1, optarg
, SD_OPTS
);
2700 case QEMU_OPTION_pflash
:
2701 drive_add(IF_PFLASH
, -1, optarg
, PFLASH_OPTS
);
2703 case QEMU_OPTION_snapshot
:
2705 Error
*blocker
= NULL
;
2707 error_setg(&blocker
, QERR_REPLAY_NOT_SUPPORTED
,
2709 replay_add_blocker(blocker
);
2712 case QEMU_OPTION_numa
:
2713 opts
= qemu_opts_parse_noisily(qemu_find_opts("numa"),
2719 case QEMU_OPTION_display
:
2720 parse_display(optarg
);
2722 case QEMU_OPTION_nographic
:
2723 olist
= qemu_find_opts("machine");
2724 qemu_opts_parse_noisily(olist
, "graphics=off", false);
2726 dpy
.type
= DISPLAY_TYPE_NONE
;
2728 case QEMU_OPTION_curses
:
2729 #ifdef CONFIG_CURSES
2730 dpy
.type
= DISPLAY_TYPE_CURSES
;
2732 error_report("curses or iconv support is disabled");
2736 case QEMU_OPTION_portrait
:
2737 graphic_rotate
= 90;
2739 case QEMU_OPTION_rotate
:
2740 graphic_rotate
= strtol(optarg
, (char **) &optarg
, 10);
2741 if (graphic_rotate
!= 0 && graphic_rotate
!= 90 &&
2742 graphic_rotate
!= 180 && graphic_rotate
!= 270) {
2743 error_report("only 90, 180, 270 deg rotation is available");
2747 case QEMU_OPTION_kernel
:
2748 qemu_opts_set(qemu_find_opts("machine"), "kernel", optarg
, &error_abort
);
2750 case QEMU_OPTION_initrd
:
2751 qemu_opts_set(qemu_find_opts("machine"), "initrd", optarg
, &error_abort
);
2753 case QEMU_OPTION_append
:
2754 qemu_opts_set(qemu_find_opts("machine"), "append", optarg
, &error_abort
);
2756 case QEMU_OPTION_dtb
:
2757 qemu_opts_set(qemu_find_opts("machine"), "dtb", optarg
, &error_abort
);
2759 case QEMU_OPTION_cdrom
:
2760 drive_add(IF_DEFAULT
, 2, optarg
, CDROM_OPTS
);
2762 case QEMU_OPTION_boot
:
2763 opts
= qemu_opts_parse_noisily(qemu_find_opts("boot-opts"),
2769 case QEMU_OPTION_fda
:
2770 case QEMU_OPTION_fdb
:
2771 drive_add(IF_FLOPPY
, popt
->index
- QEMU_OPTION_fda
,
2774 case QEMU_OPTION_no_fd_bootchk
:
2777 case QEMU_OPTION_netdev
:
2779 if (net_client_parse(qemu_find_opts("netdev"), optarg
) == -1) {
2783 case QEMU_OPTION_nic
:
2785 if (net_client_parse(qemu_find_opts("nic"), optarg
) == -1) {
2789 case QEMU_OPTION_net
:
2791 if (net_client_parse(qemu_find_opts("net"), optarg
) == -1) {
2795 #ifdef CONFIG_LIBISCSI
2796 case QEMU_OPTION_iscsi
:
2797 opts
= qemu_opts_parse_noisily(qemu_find_opts("iscsi"),
2804 case QEMU_OPTION_audio_help
:
2805 audio_legacy_help();
2808 case QEMU_OPTION_audiodev
:
2809 audio_parse_option(optarg
);
2811 case QEMU_OPTION_soundhw
:
2812 select_soundhw (optarg
);
2817 case QEMU_OPTION_version
:
2822 opts
= qemu_opts_parse_noisily(qemu_find_opts("memory"),
2829 case QEMU_OPTION_tpmdev
:
2830 if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg
) < 0) {
2835 case QEMU_OPTION_mempath
:
2838 case QEMU_OPTION_mem_prealloc
:
2847 case QEMU_OPTION_DFILTER
:
2848 qemu_set_dfilter_ranges(optarg
, &error_fatal
);
2850 case QEMU_OPTION_seed
:
2851 qemu_guest_random_seed_main(optarg
, &error_fatal
);
2854 add_device_config(DEV_GDB
, "tcp::" DEFAULT_GDBSTUB_PORT
);
2856 case QEMU_OPTION_gdb
:
2857 add_device_config(DEV_GDB
, optarg
);
2860 if (is_help_option(optarg
)) {
2861 list_data_dirs
= true;
2863 qemu_add_data_dir(g_strdup(optarg
));
2866 case QEMU_OPTION_bios
:
2867 qemu_opts_set(qemu_find_opts("machine"), "firmware", optarg
, &error_abort
);
2869 case QEMU_OPTION_singlestep
:
2876 keyboard_layout
= optarg
;
2878 case QEMU_OPTION_vga
:
2887 w
= strtol(p
, (char **)&p
, 10);
2890 error_report("invalid resolution or depth");
2896 h
= strtol(p
, (char **)&p
, 10);
2901 depth
= strtol(p
, (char **)&p
, 10);
2902 if (depth
!= 1 && depth
!= 2 && depth
!= 4 &&
2903 depth
!= 8 && depth
!= 15 && depth
!= 16 &&
2904 depth
!= 24 && depth
!= 32)
2906 } else if (*p
== '\0') {
2907 depth
= graphic_depth
;
2914 graphic_depth
= depth
;
2917 case QEMU_OPTION_echr
:
2920 term_escape_char
= strtol(optarg
, &r
, 0);
2922 printf("Bad argument to echr\n");
2925 case QEMU_OPTION_monitor
:
2926 default_monitor
= 0;
2927 if (strncmp(optarg
, "none", 4)) {
2928 monitor_parse(optarg
, "readline", false);
2931 case QEMU_OPTION_qmp
:
2932 monitor_parse(optarg
, "control", false);
2933 default_monitor
= 0;
2935 case QEMU_OPTION_qmp_pretty
:
2936 monitor_parse(optarg
, "control", true);
2937 default_monitor
= 0;
2939 case QEMU_OPTION_mon
:
2940 opts
= qemu_opts_parse_noisily(qemu_find_opts("mon"), optarg
,
2945 default_monitor
= 0;
2947 case QEMU_OPTION_chardev
:
2948 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"),
2954 case QEMU_OPTION_fsdev
:
2955 olist
= qemu_find_opts("fsdev");
2957 error_report("fsdev support is disabled");
2960 opts
= qemu_opts_parse_noisily(olist
, optarg
, true);
2965 case QEMU_OPTION_virtfs
: {
2968 const char *writeout
, *sock_fd
, *socket
, *path
, *security_model
,
2971 olist
= qemu_find_opts("virtfs");
2973 error_report("virtfs support is disabled");
2976 opts
= qemu_opts_parse_noisily(olist
, optarg
, true);
2981 if (qemu_opt_get(opts
, "fsdriver") == NULL
||
2982 qemu_opt_get(opts
, "mount_tag") == NULL
) {
2983 error_report("Usage: -virtfs fsdriver,mount_tag=tag");
2986 fsdev
= qemu_opts_create(qemu_find_opts("fsdev"),
2987 qemu_opts_id(opts
) ?:
2988 qemu_opt_get(opts
, "mount_tag"),
2991 error_report("duplicate or invalid fsdev id: %s",
2992 qemu_opt_get(opts
, "mount_tag"));
2996 writeout
= qemu_opt_get(opts
, "writeout");
2998 #ifdef CONFIG_SYNC_FILE_RANGE
2999 qemu_opt_set(fsdev
, "writeout", writeout
, &error_abort
);
3001 error_report("writeout=immediate not supported "
3002 "on this platform");
3006 qemu_opt_set(fsdev
, "fsdriver",
3007 qemu_opt_get(opts
, "fsdriver"), &error_abort
);
3008 path
= qemu_opt_get(opts
, "path");
3010 qemu_opt_set(fsdev
, "path", path
, &error_abort
);
3012 security_model
= qemu_opt_get(opts
, "security_model");
3013 if (security_model
) {
3014 qemu_opt_set(fsdev
, "security_model", security_model
,
3017 socket
= qemu_opt_get(opts
, "socket");
3019 qemu_opt_set(fsdev
, "socket", socket
, &error_abort
);
3021 sock_fd
= qemu_opt_get(opts
, "sock_fd");
3023 qemu_opt_set(fsdev
, "sock_fd", sock_fd
, &error_abort
);
3026 qemu_opt_set_bool(fsdev
, "readonly",
3027 qemu_opt_get_bool(opts
, "readonly", 0),
3029 multidevs
= qemu_opt_get(opts
, "multidevs");
3031 qemu_opt_set(fsdev
, "multidevs", multidevs
, &error_abort
);
3033 device
= qemu_opts_create(qemu_find_opts("device"), NULL
, 0,
3035 qemu_opt_set(device
, "driver", "virtio-9p-pci", &error_abort
);
3036 qemu_opt_set(device
, "fsdev",
3037 qemu_opts_id(fsdev
), &error_abort
);
3038 qemu_opt_set(device
, "mount_tag",
3039 qemu_opt_get(opts
, "mount_tag"), &error_abort
);
3042 case QEMU_OPTION_serial
:
3043 add_device_config(DEV_SERIAL
, optarg
);
3045 if (strncmp(optarg
, "mon:", 4) == 0) {
3046 default_monitor
= 0;
3049 case QEMU_OPTION_watchdog
:
3051 error_report("only one watchdog option may be given");
3056 case QEMU_OPTION_watchdog_action
:
3057 if (select_watchdog_action(optarg
) == -1) {
3058 error_report("unknown -watchdog-action parameter");
3062 case QEMU_OPTION_parallel
:
3063 add_device_config(DEV_PARALLEL
, optarg
);
3064 default_parallel
= 0;
3065 if (strncmp(optarg
, "mon:", 4) == 0) {
3066 default_monitor
= 0;
3069 case QEMU_OPTION_debugcon
:
3070 add_device_config(DEV_DEBUGCON
, optarg
);
3072 case QEMU_OPTION_loadvm
:
3075 case QEMU_OPTION_full_screen
:
3076 dpy
.has_full_screen
= true;
3077 dpy
.full_screen
= true;
3079 case QEMU_OPTION_alt_grab
:
3082 case QEMU_OPTION_ctrl_grab
:
3085 case QEMU_OPTION_no_quit
:
3086 dpy
.has_window_close
= true;
3087 dpy
.window_close
= false;
3089 case QEMU_OPTION_sdl
:
3091 dpy
.type
= DISPLAY_TYPE_SDL
;
3094 error_report("SDL support is disabled");
3097 case QEMU_OPTION_pidfile
:
3100 case QEMU_OPTION_win2k_hack
:
3101 win2k_install_hack
= 1;
3103 case QEMU_OPTION_acpitable
:
3104 opts
= qemu_opts_parse_noisily(qemu_find_opts("acpi"),
3109 acpi_table_add(opts
, &error_fatal
);
3111 case QEMU_OPTION_smbios
:
3112 opts
= qemu_opts_parse_noisily(qemu_find_opts("smbios"),
3117 smbios_entry_add(opts
, &error_fatal
);
3119 case QEMU_OPTION_fwcfg
:
3120 opts
= qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"),
3126 case QEMU_OPTION_preconfig
:
3127 preconfig_requested
= true;
3129 case QEMU_OPTION_enable_kvm
:
3130 olist
= qemu_find_opts("machine");
3131 qemu_opts_parse_noisily(olist
, "accel=kvm", false);
3134 case QEMU_OPTION_machine
:
3135 olist
= qemu_find_opts("machine");
3136 opts
= qemu_opts_parse_noisily(olist
, optarg
, true);
3141 case QEMU_OPTION_accel
:
3142 accel_opts
= qemu_opts_parse_noisily(qemu_find_opts("accel"),
3144 optarg
= qemu_opt_get(accel_opts
, "accel");
3145 if (!optarg
|| is_help_option(optarg
)) {
3146 printf("Accelerators supported in QEMU binary:\n");
3147 GSList
*el
, *accel_list
= object_class_get_list(TYPE_ACCEL
,
3149 for (el
= accel_list
; el
; el
= el
->next
) {
3150 gchar
*typename
= g_strdup(object_class_get_name(
3151 OBJECT_CLASS(el
->data
)));
3152 /* omit qtest which is used for tests only */
3153 if (g_strcmp0(typename
, ACCEL_CLASS_NAME("qtest")) &&
3154 g_str_has_suffix(typename
, ACCEL_CLASS_SUFFIX
)) {
3155 gchar
**optname
= g_strsplit(typename
,
3156 ACCEL_CLASS_SUFFIX
, 0);
3157 printf("%s\n", optname
[0]);
3158 g_strfreev(optname
);
3162 g_slist_free(accel_list
);
3166 case QEMU_OPTION_usb
:
3167 olist
= qemu_find_opts("machine");
3168 qemu_opts_parse_noisily(olist
, "usb=on", false);
3170 case QEMU_OPTION_usbdevice
:
3171 error_report("'-usbdevice' is deprecated, please use "
3172 "'-device usb-...' instead");
3173 olist
= qemu_find_opts("machine");
3174 qemu_opts_parse_noisily(olist
, "usb=on", false);
3175 add_device_config(DEV_USB
, optarg
);
3177 case QEMU_OPTION_device
:
3178 if (!qemu_opts_parse_noisily(qemu_find_opts("device"),
3183 case QEMU_OPTION_smp
:
3184 if (!qemu_opts_parse_noisily(qemu_find_opts("smp-opts"),
3189 case QEMU_OPTION_vnc
:
3190 vnc_parse(optarg
, &error_fatal
);
3192 case QEMU_OPTION_no_acpi
:
3193 olist
= qemu_find_opts("machine");
3194 qemu_opts_parse_noisily(olist
, "acpi=off", false);
3196 case QEMU_OPTION_no_hpet
:
3197 olist
= qemu_find_opts("machine");
3198 qemu_opts_parse_noisily(olist
, "hpet=off", false);
3200 case QEMU_OPTION_no_reboot
:
3203 case QEMU_OPTION_no_shutdown
:
3206 case QEMU_OPTION_show_cursor
:
3207 warn_report("The -show-cursor option is deprecated. Please "
3208 "add show-cursor=on to your -display options.");
3209 warn_report("When using the default display you can use "
3210 "-display default,show-cursor=on");
3211 dpy
.has_show_cursor
= true;
3212 dpy
.show_cursor
= true;
3214 case QEMU_OPTION_uuid
:
3215 if (qemu_uuid_parse(optarg
, &qemu_uuid
) < 0) {
3216 error_report("failed to parse UUID string: wrong format");
3219 qemu_uuid_set
= true;
3221 case QEMU_OPTION_option_rom
:
3222 if (nb_option_roms
>= MAX_OPTION_ROMS
) {
3223 error_report("too many option ROMs");
3226 opts
= qemu_opts_parse_noisily(qemu_find_opts("option-rom"),
3231 option_rom
[nb_option_roms
].name
= qemu_opt_get(opts
, "romfile");
3232 option_rom
[nb_option_roms
].bootindex
=
3233 qemu_opt_get_number(opts
, "bootindex", -1);
3234 if (!option_rom
[nb_option_roms
].name
) {
3235 error_report("Option ROM file is not specified");
3240 case QEMU_OPTION_semihosting
:
3241 qemu_semihosting_enable();
3243 case QEMU_OPTION_semihosting_config
:
3244 if (qemu_semihosting_config_options(optarg
) != 0) {
3248 case QEMU_OPTION_name
:
3249 opts
= qemu_opts_parse_noisily(qemu_find_opts("name"),
3254 /* Capture guest name if -msg guest-name is used later */
3255 error_guest_name
= qemu_opt_get(opts
, "guest");
3257 case QEMU_OPTION_prom_env
:
3258 if (nb_prom_envs
>= MAX_PROM_ENVS
) {
3259 error_report("too many prom variables");
3262 prom_envs
[nb_prom_envs
] = optarg
;
3265 case QEMU_OPTION_old_param
:
3268 case QEMU_OPTION_rtc
:
3269 opts
= qemu_opts_parse_noisily(qemu_find_opts("rtc"), optarg
,
3275 case QEMU_OPTION_tb_size
:
3277 error_report("TCG is disabled");
3280 warn_report("The -tb-size option is deprecated, use -accel tcg,tb-size instead");
3281 object_register_sugar_prop(ACCEL_CLASS_NAME("tcg"), "tb-size", optarg
);
3283 case QEMU_OPTION_icount
:
3284 icount_opts
= qemu_opts_parse_noisily(qemu_find_opts("icount"),
3290 case QEMU_OPTION_incoming
:
3292 runstate_set(RUN_STATE_INMIGRATE
);
3296 case QEMU_OPTION_only_migratable
:
3297 only_migratable
= 1;
3299 case QEMU_OPTION_nodefaults
:
3302 case QEMU_OPTION_xen_domid
:
3303 if (!(xen_available())) {
3304 error_report("Option not supported for this target");
3307 xen_domid
= atoi(optarg
);
3309 case QEMU_OPTION_xen_attach
:
3310 if (!(xen_available())) {
3311 error_report("Option not supported for this target");
3314 xen_mode
= XEN_ATTACH
;
3316 case QEMU_OPTION_xen_domid_restrict
:
3317 if (!(xen_available())) {
3318 error_report("Option not supported for this target");
3321 xen_domid_restrict
= true;
3323 case QEMU_OPTION_trace
:
3324 trace_opt_parse(optarg
);
3326 case QEMU_OPTION_plugin
:
3327 qemu_plugin_opt_parse(optarg
, &plugin_list
);
3329 case QEMU_OPTION_readconfig
:
3331 int ret
= qemu_read_config_file(optarg
);
3333 error_report("read config %s: %s", optarg
,
3339 case QEMU_OPTION_spice
:
3340 olist
= qemu_find_opts_err("spice", NULL
);
3342 ui_module_load_one("spice-core");
3343 olist
= qemu_find_opts("spice");
3346 error_report("spice support is disabled");
3349 opts
= qemu_opts_parse_noisily(olist
, optarg
, false);
3355 case QEMU_OPTION_writeconfig
:
3358 if (strcmp(optarg
, "-") == 0) {
3361 fp
= fopen(optarg
, "w");
3363 error_report("open %s: %s", optarg
,
3368 qemu_config_write(fp
);
3374 case QEMU_OPTION_qtest
:
3375 qtest_chrdev
= optarg
;
3377 case QEMU_OPTION_qtest_log
:
3380 case QEMU_OPTION_sandbox
:
3381 olist
= qemu_find_opts("sandbox");
3383 #ifndef CONFIG_SECCOMP
3384 error_report("-sandbox support is not enabled "
3385 "in this QEMU binary");
3390 opts
= qemu_opts_parse_noisily(olist
, optarg
, true);
3395 case QEMU_OPTION_add_fd
:
3397 opts
= qemu_opts_parse_noisily(qemu_find_opts("add-fd"),
3403 error_report("File descriptor passing is disabled on this "
3408 case QEMU_OPTION_object
:
3409 opts
= qemu_opts_parse_noisily(qemu_find_opts("object"),
3415 case QEMU_OPTION_realtime
:
3416 warn_report("'-realtime mlock=...' is deprecated, please use "
3417 "'-overcommit mem-lock=...' instead");
3418 opts
= qemu_opts_parse_noisily(qemu_find_opts("realtime"),
3423 /* Don't override the -overcommit option if set */
3424 enable_mlock
= enable_mlock
||
3425 qemu_opt_get_bool(opts
, "mlock", true);
3427 case QEMU_OPTION_overcommit
:
3428 opts
= qemu_opts_parse_noisily(qemu_find_opts("overcommit"),
3433 /* Don't override the -realtime option if set */
3434 enable_mlock
= enable_mlock
||
3435 qemu_opt_get_bool(opts
, "mem-lock", false);
3436 enable_cpu_pm
= qemu_opt_get_bool(opts
, "cpu-pm", false);
3438 case QEMU_OPTION_msg
:
3439 opts
= qemu_opts_parse_noisily(qemu_find_opts("msg"), optarg
,
3444 configure_msg(opts
);
3446 case QEMU_OPTION_dump_vmstate
:
3447 if (vmstate_dump_file
) {
3448 error_report("only one '-dump-vmstate' "
3449 "option may be given");
3452 vmstate_dump_file
= fopen(optarg
, "w");
3453 if (vmstate_dump_file
== NULL
) {
3454 error_report("open %s: %s", optarg
, strerror(errno
));
3458 case QEMU_OPTION_enable_sync_profile
:
3461 case QEMU_OPTION_nouserconfig
:
3462 /* Nothing to be parsed here. Especially, do not error out below. */
3465 if (os_parse_cmd_args(popt
->index
, optarg
)) {
3466 error_report("Option not supported in this build");
3473 * Clear error location left behind by the loop.
3474 * Best done right after the loop. Do not insert code here!
3478 qemu_validate_options();
3479 qemu_process_sugar_options();
3482 * These options affect everything else and should be processed
3483 * before daemonizing.
3485 qemu_process_early_options();
3487 qemu_process_help_options();
3488 qemu_maybe_daemonize(pid_file
);
3490 qemu_init_main_loop(&error_fatal
);
3493 user_register_global_props();
3494 replay_configure(icount_opts
);
3496 configure_rtc(qemu_find_opts_singleton("rtc"));
3498 qemu_create_machine(select_machine());
3500 qemu_disable_default_devices();
3501 qemu_create_default_devices();
3502 qemu_create_early_backends();
3504 qemu_apply_machine_options();
3507 * Note: uses machine properties such as kernel-irqchip, must run
3508 * after machine_set_property().
3510 configure_accelerators(argv
[0]);
3513 * Beware, QOM objects created before this point miss global and
3514 * compat properties.
3516 * Global properties get set up by qdev_prop_register_global(),
3517 * called from user_register_global_props(), and certain option
3518 * desugaring. Also in CPU feature desugaring (buried in
3519 * parse_cpu_option()), which happens below this point, but may
3520 * only target the CPU type, which can only be created after
3521 * parse_cpu_option() returned the type.
3523 * Machine compat properties: object_set_machine_compat_props().
3524 * Accelerator compat props: object_set_accelerator_compat_props(),
3525 * called from configure_accelerator().
3528 machine_class
= MACHINE_GET_CLASS(current_machine
);
3529 if (!qtest_enabled() && machine_class
->deprecation_reason
) {
3530 error_report("Machine type '%s' is deprecated: %s",
3531 machine_class
->name
, machine_class
->deprecation_reason
);
3535 * Note: creates a QOM object, must run only after global and
3536 * compat properties have been set up.
3538 migration_object_init();
3540 qemu_create_late_backends();
3542 /* parse features once if machine provides default cpu_type */
3543 current_machine
->cpu_type
= machine_class
->default_cpu_type
;
3545 current_machine
->cpu_type
= parse_cpu_option(cpu_option
);
3548 qemu_resolve_machine_memdev();
3549 parse_numa_opts(current_machine
);
3551 if (vmstate_dump_file
) {
3553 dump_vmstate_json_to_file(vmstate_dump_file
);
3557 qemu_init_displays();
3558 if (!preconfig_requested
) {
3559 qmp_x_exit_preconfig(&error_fatal
);
3561 accel_setup_post(current_machine
);