return NULL;
}
- opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", NULL);
+ opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", 0);
if (!opts) {
monitor_printf(mon, "parsing network options '%s' failed\n",
opts_str ? opts_str : "");
QemuOpts *opts;
opts = qemu_opts_parse(&qemu_device_opts,
- qdict_get_str(qdict, "config"), "driver");
+ qdict_get_str(qdict, "config"), 1);
if (opts) {
if (qdev_device_help(opts) || qdev_device_add(opts) == NULL) {
qemu_opts_del(opts);
QemuOpts *opts;
int idx;
- opts = qemu_opts_parse(&qemu_net_opts, cmdline, NULL);
+ opts = qemu_opts_parse(&qemu_net_opts, cmdline, 0);
if (!opts) {
return NULL;
}
return;
}
- opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", NULL);
+ opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", 0);
if (!opts) {
monitor_printf(mon, "parsing network options '%s' failed\n",
opts_str ? opts_str : "");
}
#endif
- if (!qemu_opts_parse(opts_list, optarg, "type")) {
+ if (!qemu_opts_parse(opts_list, optarg, 1)) {
return -1;
}
QemuOptsList qemu_chardev_opts = {
.name = "chardev",
+ .implied_opt_name = "backend",
.head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head),
.desc = {
{
QemuOptsList qemu_device_opts = {
.name = "device",
+ .implied_opt_name = "driver",
.head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head),
.desc = {
/*
QemuOptsList qemu_netdev_opts = {
.name = "netdev",
+ .implied_opt_name = "type",
.head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head),
.desc = {
/*
QemuOptsList qemu_net_opts = {
.name = "net",
+ .implied_opt_name = "type",
.head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head),
.desc = {
/*
QemuOptsList qemu_mon_opts = {
.name = "mon",
+ .implied_opt_name = "chardev",
.head = QTAILQ_HEAD_INITIALIZER(qemu_mon_opts.head),
.desc = {
{
return 0;
}
-QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, const char *firstname)
+QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
+ int permit_abbrev)
{
+ const char *firstname;
char value[1024], *id = NULL;
const char *p;
QemuOpts *opts;
+ assert(!permit_abbrev || list->implied_opt_name);
+ firstname = permit_abbrev ? list->implied_opt_name : NULL;
+
if (strncmp(params, "id=", 3) == 0) {
get_opt_value(value, sizeof(value), params+3);
id = qemu_strdup(value);
struct QemuOptsList {
const char *name;
+ const char *implied_opt_name;
QTAILQ_HEAD(, QemuOpts) head;
QemuOptDesc desc[];
};
void qemu_opts_del(QemuOpts *opts);
int qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc);
int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname);
-QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, const char *firstname);
+QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev);
QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict);
QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict);
vsnprintf(optstr, sizeof(optstr), fmt, ap);
va_end(ap);
- opts = qemu_opts_parse(&qemu_drive_opts, optstr, NULL);
+ opts = qemu_opts_parse(&qemu_drive_opts, optstr, 0);
if (!opts) {
fprintf(stderr, "%s: huh? duplicate? (%s)\n",
__FUNCTION__, optstr);
if (!strncmp(arg, "virtio", 6)) {
if (arg[6] == ',') {
/* have params -> parse them */
- opts = qemu_opts_parse(&qemu_device_opts, arg+7, NULL);
+ opts = qemu_opts_parse(&qemu_device_opts, arg+7, 0);
if (!opts)
return -1;
} else {
default_monitor = 0;
break;
case QEMU_OPTION_mon:
- opts = qemu_opts_parse(&qemu_mon_opts, optarg, "chardev");
+ opts = qemu_opts_parse(&qemu_mon_opts, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
default_monitor = 0;
break;
case QEMU_OPTION_chardev:
- opts = qemu_opts_parse(&qemu_chardev_opts, optarg, "backend");
+ opts = qemu_opts_parse(&qemu_chardev_opts, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
add_device_config(DEV_USB, optarg);
break;
case QEMU_OPTION_device:
- if (!qemu_opts_parse(&qemu_device_opts, optarg, "driver")) {
+ if (!qemu_opts_parse(&qemu_device_opts, optarg, 1)) {
exit(1);
}
break;
configure_rtc_date_offset(optarg, 1);
break;
case QEMU_OPTION_rtc:
- opts = qemu_opts_parse(&qemu_rtc_opts, optarg, NULL);
+ opts = qemu_opts_parse(&qemu_rtc_opts, optarg, 0);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);