int boot_menu;
bool boot_strict;
uint8_t *boot_splash_filedata;
-size_t boot_splash_filedata_size;
+int only_migratable; /* turn it off unless user states otherwise */
bool wakeup_suspend_enabled;
int icount_align_option;
{ .driver = "vmware-svga", .flag = &default_vga },
{ .driver = "qxl-vga", .flag = &default_vga },
{ .driver = "virtio-vga", .flag = &default_vga },
+ { .driver = "ati-vga", .flag = &default_vga },
};
static QemuOptsList qemu_rtc_opts = {
assert(new_state < RUN_STATE__MAX);
trace_runstate_set(current_run_state, RunState_str(current_run_state),
- new_state, RunState_str(current_run_state));
+ new_state, RunState_str(new_state));
if (current_run_state == new_state) {
return;
}
+typedef struct BlockdevOptionsQueueEntry {
+ BlockdevOptions *bdo;
+ Location loc;
+ QSIMPLEQ_ENTRY(BlockdevOptionsQueueEntry) entry;
+} BlockdevOptionsQueueEntry;
+
+typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue;
+
+static void configure_blockdev(BlockdevOptionsQueue *bdo_queue,
+ MachineClass *machine_class, int snapshot)
+{
+ /*
+ * If the currently selected machine wishes to override the
+ * units-per-bus property of its default HBA interface type, do so
+ * now.
+ */
+ if (machine_class->units_per_default_bus) {
+ override_max_devs(machine_class->block_default_type,
+ machine_class->units_per_default_bus);
+ }
+
+ /* open the virtual block devices */
+ while (!QSIMPLEQ_EMPTY(bdo_queue)) {
+ BlockdevOptionsQueueEntry *bdo = QSIMPLEQ_FIRST(bdo_queue);
+
+ QSIMPLEQ_REMOVE_HEAD(bdo_queue, entry);
+ loc_push_restore(&bdo->loc);
+ qmp_blockdev_add(bdo->bdo, &error_fatal);
+ loc_pop(&bdo->loc);
+ qapi_free_BlockdevOptions(bdo->bdo);
+ g_free(bdo);
+ }
+ if (snapshot || replay_mode != REPLAY_MODE_NONE) {
+ qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot,
+ NULL, NULL);
+ }
+ if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func,
+ &machine_class->block_default_type, &error_fatal)) {
+ /* We printed help */
+ exit(0);
+ }
+
+ default_drive(default_cdrom, snapshot, machine_class->block_default_type, 2,
+ CDROM_OPTS);
+ default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
+ default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
+
+}
+
static QemuOptsList qemu_smp_opts = {
.name = "smp-opts",
.implied_opt_name = "cpus",
MachineState *current_machine;
-static MachineClass *find_machine(const char *name)
+static MachineClass *find_machine(const char *name, GSList *machines)
{
- GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
- MachineClass *mc = NULL;
+ GSList *el;
for (el = machines; el; el = el->next) {
- MachineClass *temp = el->data;
+ MachineClass *mc = el->data;
- if (!strcmp(temp->name, name)) {
- mc = temp;
- break;
- }
- if (temp->alias &&
- !strcmp(temp->alias, name)) {
- mc = temp;
- break;
+ if (!strcmp(mc->name, name) || !g_strcmp0(mc->alias, name)) {
+ return mc;
}
}
- g_slist_free(machines);
- return mc;
+ return NULL;
}
-MachineClass *find_default_machine(void)
+static MachineClass *find_default_machine(GSList *machines)
{
- GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
- MachineClass *mc = NULL;
+ GSList *el;
for (el = machines; el; el = el->next) {
- MachineClass *temp = el->data;
+ MachineClass *mc = el->data;
- if (temp->is_default) {
- mc = temp;
- break;
+ if (mc->is_default) {
+ return mc;
}
}
- g_slist_free(machines);
- return mc;
+ return NULL;
}
MachineInfoList *qmp_query_machines(Error **errp)
continue;
}
- error_printf("%s.%s=%s", MACHINE_GET_CLASS(machine)->name,
- prop->name, prop->type);
+ printf("%s.%s=%s", MACHINE_GET_CLASS(machine)->name,
+ prop->name, prop->type);
if (prop->description) {
- error_printf(" (%s)\n", prop->description);
+ printf(" (%s)\n", prop->description);
} else {
- error_printf("\n");
+ printf("\n");
}
}
const char *class_names[2];
} VGAInterfaceInfo;
-static VGAInterfaceInfo vga_interfaces[VGA_TYPE_MAX] = {
+static const VGAInterfaceInfo vga_interfaces[VGA_TYPE_MAX] = {
[VGA_NONE] = {
.opt_name = "none",
+ .name = "no graphic card",
},
[VGA_STD] = {
.opt_name = "std",
},
[VGA_XENFB] = {
.opt_name = "xenfb",
+ .name = "Xen paravirtualized framebuffer",
},
};
static bool vga_interface_available(VGAInterfaceType t)
{
- VGAInterfaceInfo *ti = &vga_interfaces[t];
+ const VGAInterfaceInfo *ti = &vga_interfaces[t];
assert(t < VGA_TYPE_MAX);
return !ti->class_names[0] ||
object_class_by_name(ti->class_names[1]);
}
-static void select_vgahw(const char *p)
+static const char *
+get_default_vga_model(const MachineClass *machine_class)
+{
+ if (machine_class->default_display) {
+ return machine_class->default_display;
+ } else if (vga_interface_available(VGA_CIRRUS)) {
+ return "cirrus";
+ } else if (vga_interface_available(VGA_STD)) {
+ return "std";
+ }
+
+ return NULL;
+}
+
+static void select_vgahw(const MachineClass *machine_class, const char *p)
{
const char *opts;
int t;
+ if (g_str_equal(p, "help")) {
+ const char *def = get_default_vga_model(machine_class);
+
+ for (t = 0; t < VGA_TYPE_MAX; t++) {
+ const VGAInterfaceInfo *ti = &vga_interfaces[t];
+
+ if (vga_interface_available(t) && ti->opt_name) {
+ printf("%-20s %s%s\n", ti->opt_name, ti->name ?: "",
+ g_str_equal(ti->opt_name, def) ? " (default)" : "");
+ }
+ }
+ exit(0);
+ }
+
assert(vga_interface_type == VGA_NONE);
for (t = 0; t < VGA_TYPE_MAX; t++) {
- VGAInterfaceInfo *ti = &vga_interfaces[t];
+ const VGAInterfaceInfo *ti = &vga_interfaces[t];
if (ti->opt_name && strstart(p, ti->opt_name, &opts)) {
if (!vga_interface_available(t)) {
error_report("%s not available", ti->name);
object_class_get_name(OBJECT_CLASS(mc1)));
}
- static MachineClass *machine_parse(const char *name)
+static MachineClass *machine_parse(const char *name, GSList *machines)
{
- MachineClass *mc = NULL;
- GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
+ MachineClass *mc;
+ GSList *el;
- if (name) {
- mc = find_machine(name);
- }
- if (mc) {
- g_slist_free(machines);
- return mc;
- }
- if (name && !is_help_option(name)) {
- error_report("unsupported machine type");
- error_printf("Use -machine help to list supported machines\n");
- } else {
+ if (is_help_option(name)) {
printf("Supported machines are:\n");
machines = g_slist_sort(machines, machine_class_cmp);
for (el = machines; el; el = el->next) {
mc->is_default ? " (default)" : "",
mc->deprecation_reason ? " (deprecated)" : "");
}
+ exit(0);
}
- g_slist_free(machines);
- exit(!name || !is_help_option(name));
+ mc = find_machine(name, machines);
+ if (!mc) {
+ error_report("unsupported machine type");
+ error_printf("Use -machine help to list supported machines\n");
+ exit(1);
+ }
+ return mc;
}
void qemu_add_exit_notifier(Notifier *notify)
static MachineClass *select_machine(void)
{
- MachineClass *machine_class = find_default_machine();
+ GSList *machines = object_class_get_list(TYPE_MACHINE, false);
+ MachineClass *machine_class = find_default_machine(machines);
const char *optarg;
QemuOpts *opts;
Location loc;
optarg = qemu_opt_get(opts, "type");
if (optarg) {
- machine_class = machine_parse(optarg);
+ machine_class = machine_parse(optarg, machines);
}
if (!machine_class) {
}
loc_pop(&loc);
+ g_slist_free(machines);
return machine_class;
}
global_init_func, NULL, NULL);
}
-/*
- * Note: we should see that these properties are actually having a
- * priority: accel < machine < user. This means e.g. when user
- * specifies something in "-global", it'll always be used with highest
- * priority than either machine/accelerator compat properties.
- */
-static void register_global_properties(MachineState *ms)
-{
- user_register_global_props();
-}
-
int main(int argc, char **argv, char **envp)
{
int i;
const char *optarg;
const char *loadvm = NULL;
MachineClass *machine_class;
- const char *cpu_model;
+ const char *cpu_option;
const char *vga_model = NULL;
const char *qtest_chrdev = NULL;
const char *qtest_log = NULL;
Error *err = NULL;
bool list_data_dirs = false;
char *dir, **dirs;
- typedef struct BlockdevOptions_queue {
- BlockdevOptions *bdo;
- Location loc;
- QSIMPLEQ_ENTRY(BlockdevOptions_queue) entry;
- } BlockdevOptions_queue;
- QSIMPLEQ_HEAD(, BlockdevOptions_queue) bdo_queue
- = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
+ BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
+ error_init(argv[0]);
module_call_init(MODULE_INIT_TRACE);
qemu_init_cpu_list();
qemu_mutex_lock_iothread();
atexit(qemu_run_exit_notifiers);
- error_set_progname(argv[0]);
qemu_init_exec_dir(argv[0]);
module_call_init(MODULE_INIT_QOM);
QLIST_INIT (&vm_change_state_head);
os_setup_early_signal_handling();
- cpu_model = NULL;
+ cpu_option = NULL;
snapshot = 0;
nb_nics = 0;
if (optind >= argc)
break;
if (argv[optind][0] != '-') {
+ loc_set_cmdline(argv, optind, 1);
drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
} else {
const QEMUOption *popt;
switch(popt->index) {
case QEMU_OPTION_cpu:
/* hw initialization will check this */
- cpu_model = optarg;
+ cpu_option = optarg;
break;
case QEMU_OPTION_hda:
case QEMU_OPTION_hdb:
case QEMU_OPTION_blockdev:
{
Visitor *v;
- BlockdevOptions_queue *bdo;
+ BlockdevOptionsQueueEntry *bdo;
v = qobject_input_visitor_new_str(optarg, "driver",
&error_fatal);
- bdo = g_new(BlockdevOptions_queue, 1);
+ bdo = g_new(BlockdevOptionsQueueEntry, 1);
visit_type_BlockdevOptions(v, NULL, &bdo->bdo,
&error_fatal);
visit_free(v);
#ifdef CONFIG_CURSES
dpy.type = DISPLAY_TYPE_CURSES;
#else
- error_report("curses support is disabled");
+ error_report("curses or iconv support is disabled");
exit(1);
#endif
break;
QemuOpts *fsdev;
QemuOpts *device;
+ warn_report("'-virtfs_synth' is deprecated, please use "
+ "'-fsdev synth' and '-device virtio-9p-...' "
+ "instead");
+
fsdev = qemu_opts_create(qemu_find_opts("fsdev"), "v_synth",
1, NULL);
if (!fsdev) {
optarg, true);
optarg = qemu_opt_get(accel_opts, "accel");
if (!optarg || is_help_option(optarg)) {
- error_printf("Possible accelerators: kvm, xen, hax, tcg\n");
+ printf("Possible accelerators: kvm, xen, hax, tcg\n");
exit(0);
}
opts = qemu_opts_create(qemu_find_opts("machine"), NULL,
incoming = optarg;
break;
case QEMU_OPTION_only_migratable:
- /*
- * TODO: we can remove this option one day, and we
- * should all use:
- *
- * "-global migration.only-migratable=true"
- */
- qemu_global_option("migration.only-migratable=true");
+ only_migratable = 1;
break;
case QEMU_OPTION_nodefaults:
has_defaults = 0;
qtest_log = optarg;
break;
case QEMU_OPTION_sandbox:
-#ifdef CONFIG_SECCOMP
- opts = qemu_opts_parse_noisily(qemu_find_opts("sandbox"),
- optarg, true);
+ olist = qemu_find_opts("sandbox");
+ if (!olist) {
+#ifndef CONFIG_SECCOMP
+ error_report("-sandbox support is not enabled "
+ "in this QEMU binary");
+#endif
+ exit(1);
+ }
+
+ opts = qemu_opts_parse_noisily(olist, optarg, true);
if (!opts) {
exit(1);
}
-#else
- error_report("-sandbox support is not enabled "
- "in this QEMU binary");
- exit(1);
-#endif
break;
case QEMU_OPTION_add_fd:
#ifndef _WIN32
}
break;
case QEMU_OPTION_realtime:
+ warn_report("'-realtime mlock=...' is deprecated, please use "
+ "'-overcommit mem-lock=...' instead");
opts = qemu_opts_parse_noisily(qemu_find_opts("realtime"),
optarg, false);
if (!opts) {
*/
loc_set_none();
+ user_register_global_props();
+
replay_configure(icount_opts);
if (incoming && !preconfig_exit_requested) {
configure_rtc(qemu_find_opts_singleton("rtc"));
machine_class = select_machine();
+ object_set_machine_compat_props(machine_class->compat_props);
set_memory_options(&ram_slots, &maxram_size, machine_class);
}
object_property_add_child(object_get_root(), "machine",
OBJECT(current_machine), &error_abort);
+ object_property_add_child(container_get(OBJECT(current_machine),
+ "/unattached"),
+ "sysbus", OBJECT(sysbus_get_default()),
+ NULL);
if (machine_class->minimum_page_bits) {
if (!set_preferred_target_page_bits(machine_class->minimum_page_bits)) {
qemu_set_hw_version(machine_class->hw_version);
}
- if (cpu_model && is_help_option(cpu_model)) {
- list_cpus(stdout, &fprintf, cpu_model);
+ if (cpu_option && is_help_option(cpu_option)) {
+ list_cpus(cpu_option);
exit(0);
}
exit(0);
}
+ /*
+ * Note: we need to create block backends before
+ * machine_set_property(), so machine properties can refer to
+ * them.
+ */
+ configure_blockdev(&bdo_queue, machine_class, snapshot);
+
machine_opts = qemu_get_machine_opts();
qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
&error_fatal);
current_machine->maxram_size = maxram_size;
current_machine->ram_slots = ram_slots;
+ /*
+ * Note: uses machine properties such as kernel-irqchip, must run
+ * after machine_set_property().
+ */
configure_accelerator(current_machine, argv[0]);
+ /*
+ * Beware, QOM objects created before this point miss global and
+ * compat properties.
+ *
+ * Global properties get set up by qdev_prop_register_global(),
+ * called from user_register_global_props(), and certain option
+ * desugaring. Also in CPU feature desugaring (buried in
+ * parse_cpu_option()), which happens below this point, but may
+ * only target the CPU type, which can only be created after
+ * parse_cpu_option() returned the type.
+ *
+ * Machine compat properties: object_set_machine_compat_props().
+ * Accelerator compat props: object_set_accelerator_compat_props(),
+ * called from configure_accelerator().
+ */
+
if (!qtest_enabled() && machine_class->deprecation_reason) {
error_report("Machine type '%s' is deprecated: %s",
machine_class->name, machine_class->deprecation_reason);
}
/*
- * Register all the global properties, including accel properties,
- * machine properties, and user-specified ones.
- */
- register_global_properties(current_machine);
-
- /*
- * Migration object can only be created after global properties
- * are applied correctly.
+ * Note: creates a QOM object, must run only after global and
+ * compat properties have been set up.
*/
migration_object_init();
ram_mig_init();
dirty_bitmap_mig_init();
- /* If the currently selected machine wishes to override the units-per-bus
- * property of its default HBA interface type, do so now. */
- if (machine_class->units_per_default_bus) {
- override_max_devs(machine_class->block_default_type,
- machine_class->units_per_default_bus);
- }
-
- /* open the virtual block devices */
- while (!QSIMPLEQ_EMPTY(&bdo_queue)) {
- BlockdevOptions_queue *bdo = QSIMPLEQ_FIRST(&bdo_queue);
-
- QSIMPLEQ_REMOVE_HEAD(&bdo_queue, entry);
- loc_push_restore(&bdo->loc);
- qmp_blockdev_add(bdo->bdo, &error_fatal);
- loc_pop(&bdo->loc);
- qapi_free_BlockdevOptions(bdo->bdo);
- g_free(bdo);
- }
- if (snapshot || replay_mode != REPLAY_MODE_NONE) {
- qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot,
- NULL, NULL);
- }
- if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func,
- &machine_class->block_default_type, &error_fatal)) {
- /* We printed help */
- exit(0);
- }
-
- default_drive(default_cdrom, snapshot, machine_class->block_default_type, 2,
- CDROM_OPTS);
- default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
- default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
-
qemu_opts_foreach(qemu_find_opts("mon"),
mon_init_func, NULL, &error_fatal);
/* If no default VGA is requested, the default is "none". */
if (default_vga) {
- if (machine_class->default_display) {
- vga_model = machine_class->default_display;
- } else if (vga_interface_available(VGA_CIRRUS)) {
- vga_model = "cirrus";
- } else if (vga_interface_available(VGA_STD)) {
- vga_model = "std";
- }
+ vga_model = get_default_vga_model(machine_class);
}
if (vga_model) {
- select_vgahw(vga_model);
+ select_vgahw(machine_class, vga_model);
}
if (watchdog) {
/* parse features once if machine provides default cpu_type */
current_machine->cpu_type = machine_class->default_cpu_type;
- if (cpu_model) {
- current_machine->cpu_type = parse_cpu_model(cpu_model);
+ if (cpu_option) {
+ current_machine->cpu_type = parse_cpu_option(cpu_option);
}
parse_numa_opts(current_machine);