#include "qemu-version.h"
#include "qemu/cutils.h"
#include "qemu/help_option.h"
+#include "qemu/hw-version.h"
#include "qemu/uuid.h"
#include "sysemu/reset.h"
#include "sysemu/runstate.h"
QTAILQ_ENTRY(ObjectOption) next;
} ObjectOption;
+typedef struct DeviceOption {
+ QDict *opts;
+ Location loc;
+ QTAILQ_ENTRY(DeviceOption) next;
+} DeviceOption;
+
static const char *cpu_option;
static const char *mem_path;
static const char *incoming;
static const char *accelerators;
static QDict *machine_opts_dict;
static QTAILQ_HEAD(, ObjectOption) object_opts = QTAILQ_HEAD_INITIALIZER(object_opts);
+static QTAILQ_HEAD(, DeviceOption) device_opts = QTAILQ_HEAD_INITIALIZER(device_opts);
static ram_addr_t maxram_size;
static uint64_t ram_slots;
static int display_remote;
return qemu_name;
}
-static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp)
+static void default_driver_disable(const char *driver)
{
- const char *driver = qemu_opt_get(opts, "driver");
int i;
- if (!driver)
- return 0;
+ if (!driver) {
+ return;
+ }
+
for (i = 0; i < ARRAY_SIZE(default_list); i++) {
if (strcmp(default_list[i].driver, driver) != 0)
continue;
*(default_list[i].flag) = 0;
}
+}
+
+static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp)
+{
+ const char *driver = qemu_opt_get(opts, "driver");
+
+ default_driver_disable(driver);
return 0;
}
+static void default_driver_check_json(void)
+{
+ DeviceOption *opt;
+
+ QTAILQ_FOREACH(opt, &device_opts, next) {
+ const char *driver = qdict_get_try_str(opt->opts, "driver");
+ default_driver_disable(driver);
+ }
+}
+
static int parse_name(void *opaque, QemuOpts *opts, Error **errp)
{
const char *proc_name;
}, {
.name = "dies",
.type = QEMU_OPT_NUMBER,
+ }, {
+ .name = "clusters",
+ .type = QEMU_OPT_NUMBER,
}, {
.name = "cores",
.type = QEMU_OPT_NUMBER,
* parse_display_qapi() due to some options not in
* DisplayOptions, specifically:
* - ctrl_grab + alt_grab
- * Not clear yet what happens to them long-term. Should
- * replaced by something better or deprecated and dropped.
+ * They can't be moved into the QAPI since they use underscores,
+ * thus they will get replaced by "grab-mod" in the long term
*/
#if defined(CONFIG_SDL)
dpy.type = DISPLAY_TYPE_SDL;
while (*opts) {
const char *nextopt;
- if (strstart(opts, ",alt_grab=", &nextopt)) {
+ if (strstart(opts, ",grab-mod=", &nextopt)) {
+ opts = nextopt;
+ if (strstart(opts, "lshift-lctrl-lalt", &nextopt)) {
+ alt_grab = 1;
+ } else if (strstart(opts, "rctrl", &nextopt)) {
+ ctrl_grab = 1;
+ } else {
+ goto invalid_sdl_args;
+ }
+ } else if (strstart(opts, ",alt_grab=", &nextopt)) {
opts = nextopt;
if (strstart(opts, "on", &nextopt)) {
alt_grab = 1;
} else {
goto invalid_sdl_args;
}
+ warn_report("alt_grab is deprecated, use grab-mod instead.");
} else if (strstart(opts, ",ctrl_grab=", &nextopt)) {
opts = nextopt;
if (strstart(opts, "on", &nextopt)) {
} else {
goto invalid_sdl_args;
}
+ warn_report("ctrl_grab is deprecated, use grab-mod instead.");
} else if (strstart(opts, ",window_close=", &nextopt) ||
strstart(opts, ",window-close=", &nextopt)) {
if (strstart(opts, ",window_close=", NULL)) {
{
MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
+ default_driver_check_json();
qemu_opts_foreach(qemu_find_opts("device"),
default_driver_check, NULL, NULL);
qemu_opts_foreach(qemu_find_opts("global"),
"for SDL, ignoring option");
}
if (dpy.has_window_close && !use_gtk && !use_sdl) {
- error_report("-no-quit is only valid for GTK and SDL, "
+ error_report("window-close is only valid for GTK and SDL, "
"ignoring option");
}
object_option_foreach_add(object_create_early);
/* spice needs the timers to be initialized by this point */
- /* spice must initialize before audio as it changes the default auiodev */
+ /* spice must initialize before audio as it changes the default audiodev */
/* spice must initialize before chardevs (for spicevmc and spiceport) */
qemu_spice.init();
static void qemu_create_cli_devices(void)
{
+ DeviceOption *opt;
+
soundhw_init();
qemu_opts_foreach(qemu_find_opts("fw_cfg"),
rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
qemu_opts_foreach(qemu_find_opts("device"),
device_init_func, NULL, &error_fatal);
+ QTAILQ_FOREACH(opt, &device_opts, next) {
+ DeviceState *dev;
+ loc_push_restore(&opt->loc);
+ /*
+ * TODO Eventually we should call qmp_device_add() here to make sure it
+ * behaves the same, but QMP still has to accept incorrectly typed
+ * options until libvirt is fixed and we want to be strict on the CLI
+ * from the start, so call qdev_device_add_from_qdict() directly for
+ * now.
+ */
+ dev = qdev_device_add_from_qdict(opt->opts, true, &error_fatal);
+ object_unref(OBJECT(dev));
+ loc_pop(&opt->loc);
+ }
rom_reset_order_override();
}
error_init(argv[0]);
qemu_init_exec_dir(argv[0]);
-#ifdef CONFIG_MODULES
- module_init_info(qemu_modinfo);
- module_allow_arch(TARGET_NAME);
-#endif
+ qemu_init_arch_modules();
qemu_init_subsystems();
break;
}
case QEMU_OPTION_drive:
- if (drive_def(optarg) == NULL) {
+ opts = qemu_opts_parse_noisily(qemu_find_opts("drive"),
+ optarg, false);
+ if (opts == NULL) {
exit(1);
}
break;
dpy.type = DISPLAY_TYPE_NONE;
break;
case QEMU_OPTION_curses:
+ warn_report("-curses is deprecated, "
+ "use -display curses instead.");
#ifdef CONFIG_CURSES
dpy.type = DISPLAY_TYPE_CURSES;
#else
error_report("only one watchdog option may be given");
exit(1);
}
+ warn_report("-watchdog is deprecated; use -device instead.");
watchdog = optarg;
break;
case QEMU_OPTION_action:
exit(1);
}
break;
- case QEMU_OPTION_watchdog_action:
- if (select_watchdog_action(optarg) == -1) {
- error_report("unknown -watchdog-action parameter");
- exit(1);
- }
+ case QEMU_OPTION_watchdog_action: {
+ QemuOpts *opts;
+ opts = qemu_opts_create(qemu_find_opts("action"), NULL, 0, &error_abort);
+ qemu_opt_set(opts, "watchdog", optarg, &error_abort);
break;
+ }
case QEMU_OPTION_parallel:
add_device_config(DEV_PARALLEL, optarg);
default_parallel = 0;
break;
case QEMU_OPTION_alt_grab:
alt_grab = 1;
+ warn_report("-alt-grab is deprecated, please use "
+ "-display sdl,grab-mod=lshift-lctrl-lalt instead.");
break;
case QEMU_OPTION_ctrl_grab:
ctrl_grab = 1;
- break;
- case QEMU_OPTION_no_quit:
- dpy.has_window_close = true;
- dpy.window_close = false;
- warn_report("-no-quit is deprecated, please use "
- "-display ...,window-close=off instead.");
+ warn_report("-ctrl-grab is deprecated, please use "
+ "-display sdl,grab-mod=rctrl instead.");
break;
case QEMU_OPTION_sdl:
+ warn_report("-sdl is deprecated, use -display sdl instead.");
#ifdef CONFIG_SDL
dpy.type = DISPLAY_TYPE_SDL;
break;
add_device_config(DEV_USB, optarg);
break;
case QEMU_OPTION_device:
- if (!qemu_opts_parse_noisily(qemu_find_opts("device"),
- optarg, true)) {
- exit(1);
+ if (optarg[0] == '{') {
+ QObject *obj = qobject_from_json(optarg, &error_fatal);
+ DeviceOption *opt = g_new0(DeviceOption, 1);
+ opt->opts = qobject_to(QDict, obj);
+ loc_save(&opt->loc);
+ assert(opt->opts != NULL);
+ QTAILQ_INSERT_TAIL(&device_opts, opt, next);
+ } else {
+ if (!qemu_opts_parse_noisily(qemu_find_opts("device"),
+ optarg, true)) {
+ exit(1);
+ }
}
break;
case QEMU_OPTION_smp:
case QEMU_OPTION_readconfig:
qemu_read_config_file(optarg, qemu_parse_config_group, &error_fatal);
break;
+#ifdef CONFIG_SPICE
case QEMU_OPTION_spice:
olist = qemu_find_opts_err("spice", NULL);
if (!olist) {
}
display_remote++;
break;
+#endif
case QEMU_OPTION_writeconfig:
{
FILE *fp;
if (vmstate_dump_file) {
/* dump and exit */
+ module_load_qom_all();
dump_vmstate_json_to_file(vmstate_dump_file);
exit(0);
}