aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blockdev.c4
-rw-r--r--hw/pci-hotplug.c2
-rw-r--r--hw/qdev-properties.c2
-rw-r--r--hw/qdev.c2
-rw-r--r--hw/usb-msd.c2
-rw-r--r--hw/usb-net.c2
-rw-r--r--hw/watchdog.c2
-rw-r--r--net.c16
-rw-r--r--qemu-char.c2
-rw-r--r--qemu-config.c22
-rw-r--r--qemu-config.h11
-rw-r--r--target-i386/cpuid.c2
-rw-r--r--vl.c56
13 files changed, 59 insertions, 66 deletions
diff --git a/blockdev.c b/blockdev.c
index 01e402bf3d..ff7602be2c 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -50,7 +50,7 @@ QemuOpts *drive_add(const char *file, const char *fmt, ...)
vsnprintf(optstr, sizeof(optstr), fmt, ap);
va_end(ap);
- opts = qemu_opts_parse(&qemu_drive_opts, optstr, 0);
+ opts = qemu_opts_parse(qemu_find_opts("drive"), optstr, 0);
if (!opts) {
return NULL;
}
@@ -451,7 +451,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error)
break;
case IF_VIRTIO:
/* add virtio block device */
- opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
+ opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(opts, "driver", "virtio-blk-pci");
qemu_opt_set(opts, "drive", dinfo->id);
if (devaddr)
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index c38f47fbf1..6a5e3b883b 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -51,7 +51,7 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
return NULL;
}
- opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", 0);
+ opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
if (!opts) {
return NULL;
}
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 9219cd7a60..2d600f5eeb 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -772,5 +772,5 @@ static int qdev_add_one_global(QemuOpts *opts, void *opaque)
void qemu_add_globals(void)
{
- qemu_opts_foreach(&qemu_global_opts, qdev_add_one_global, NULL, 0);
+ qemu_opts_foreach(qemu_find_opts("global"), qdev_add_one_global, NULL, 0);
}
diff --git a/hw/qdev.c b/hw/qdev.c
index e99c73f0d9..d1acf86c4a 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -792,7 +792,7 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
QemuOpts *opts;
- opts = qemu_opts_from_qdict(&qemu_device_opts, qdict);
+ opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict);
if (!opts) {
return -1;
}
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 65e9624e54..8b510cf90d 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -575,7 +575,7 @@ static USBDevice *usb_msd_init(const char *filename)
/* parse -usbdevice disk: syntax into drive opts */
snprintf(id, sizeof(id), "usb%d", nr++);
- opts = qemu_opts_create(&qemu_drive_opts, id, 0);
+ opts = qemu_opts_create(qemu_find_opts("drive"), id, 0);
p1 = strchr(filename, ':');
if (p1++) {
diff --git a/hw/usb-net.c b/hw/usb-net.c
index a43bd17636..70f9263291 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1472,7 +1472,7 @@ static USBDevice *usb_net_init(const char *cmdline)
QemuOpts *opts;
int idx;
- opts = qemu_opts_parse(&qemu_net_opts, cmdline, 0);
+ opts = qemu_opts_parse(qemu_find_opts("net"), cmdline, 0);
if (!opts) {
return NULL;
}
diff --git a/hw/watchdog.c b/hw/watchdog.c
index aebb08a0ee..e9dd56e229 100644
--- a/hw/watchdog.c
+++ b/hw/watchdog.c
@@ -66,7 +66,7 @@ int select_watchdog(const char *p)
QLIST_FOREACH(model, &watchdog_list, entry) {
if (strcasecmp(model->wdt_name, p) == 0) {
/* add the device */
- opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
+ opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(opts, "driver", p);
return 0;
}
diff --git a/net.c b/net.c
index 8ddf872a6f..3d0fde77b2 100644
--- a/net.c
+++ b/net.c
@@ -1168,7 +1168,7 @@ void net_host_device_add(Monitor *mon, const QDict *qdict)
return;
}
- opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", 0);
+ opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
if (!opts) {
return;
}
@@ -1202,7 +1202,7 @@ int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
QemuOpts *opts;
int res;
- opts = qemu_opts_from_qdict(&qemu_netdev_opts, qdict);
+ opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict);
if (!opts) {
return -1;
}
@@ -1226,7 +1226,7 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
return -1;
}
qemu_del_vlan_client(vc);
- qemu_opts_del(qemu_opts_find(&qemu_netdev_opts, id));
+ qemu_opts_del(qemu_opts_find(qemu_find_opts("netdev"), id));
return 0;
}
@@ -1349,21 +1349,23 @@ static int net_init_netdev(QemuOpts *opts, void *dummy)
int net_init_clients(void)
{
+ QemuOptsList *net = qemu_find_opts("net");
+
if (default_net) {
/* if no clients, we use a default config */
- qemu_opts_set(&qemu_net_opts, NULL, "type", "nic");
+ qemu_opts_set(net, NULL, "type", "nic");
#ifdef CONFIG_SLIRP
- qemu_opts_set(&qemu_net_opts, NULL, "type", "user");
+ qemu_opts_set(net, NULL, "type", "user");
#endif
}
QTAILQ_INIT(&vlans);
QTAILQ_INIT(&non_vlan_clients);
- if (qemu_opts_foreach(&qemu_netdev_opts, net_init_netdev, NULL, 1) == -1)
+ if (qemu_opts_foreach(qemu_find_opts("netdev"), net_init_netdev, NULL, 1) == -1)
return -1;
- if (qemu_opts_foreach(&qemu_net_opts, net_init_client, NULL, 1) == -1) {
+ if (qemu_opts_foreach(net, net_init_client, NULL, 1) == -1) {
return -1;
}
diff --git a/qemu-char.c b/qemu-char.c
index 33f2237540..6d2dce7a9b 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2286,7 +2286,7 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
const char *p;
QemuOpts *opts;
- opts = qemu_opts_create(&qemu_chardev_opts, label, 1);
+ opts = qemu_opts_create(qemu_find_opts("chardev"), label, 1);
if (NULL == opts)
return NULL;
diff --git a/qemu-config.c b/qemu-config.c
index e84e15e375..3abe6555c2 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -5,7 +5,7 @@
#include "sysemu.h"
#include "hw/qdev.h"
-QemuOptsList qemu_drive_opts = {
+static QemuOptsList qemu_drive_opts = {
.name = "drive",
.head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head),
.desc = {
@@ -84,7 +84,7 @@ QemuOptsList qemu_drive_opts = {
},
};
-QemuOptsList qemu_chardev_opts = {
+static QemuOptsList qemu_chardev_opts = {
.name = "chardev",
.implied_opt_name = "backend",
.head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head),
@@ -151,7 +151,6 @@ QemuOptsList qemu_chardev_opts = {
},
};
-#ifdef CONFIG_LINUX
QemuOptsList qemu_fsdev_opts = {
.name = "fsdev",
.implied_opt_name = "fstype",
@@ -170,9 +169,7 @@ QemuOptsList qemu_fsdev_opts = {
{ /*End of list */ }
},
};
-#endif
-#ifdef CONFIG_LINUX
QemuOptsList qemu_virtfs_opts = {
.name = "virtfs",
.implied_opt_name = "fstype",
@@ -195,9 +192,8 @@ QemuOptsList qemu_virtfs_opts = {
{ /*End of list */ }
},
};
-#endif
-QemuOptsList qemu_device_opts = {
+static QemuOptsList qemu_device_opts = {
.name = "device",
.implied_opt_name = "driver",
.head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head),
@@ -211,7 +207,7 @@ QemuOptsList qemu_device_opts = {
},
};
-QemuOptsList qemu_netdev_opts = {
+static QemuOptsList qemu_netdev_opts = {
.name = "netdev",
.implied_opt_name = "type",
.head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head),
@@ -224,7 +220,7 @@ QemuOptsList qemu_netdev_opts = {
},
};
-QemuOptsList qemu_net_opts = {
+static QemuOptsList qemu_net_opts = {
.name = "net",
.implied_opt_name = "type",
.head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head),
@@ -237,7 +233,7 @@ QemuOptsList qemu_net_opts = {
},
};
-QemuOptsList qemu_rtc_opts = {
+static QemuOptsList qemu_rtc_opts = {
.name = "rtc",
.head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head),
.desc = {
@@ -255,7 +251,7 @@ QemuOptsList qemu_rtc_opts = {
},
};
-QemuOptsList qemu_global_opts = {
+static QemuOptsList qemu_global_opts = {
.name = "global",
.head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head),
.desc = {
@@ -273,7 +269,7 @@ QemuOptsList qemu_global_opts = {
},
};
-QemuOptsList qemu_mon_opts = {
+static QemuOptsList qemu_mon_opts = {
.name = "mon",
.implied_opt_name = "chardev",
.head = QTAILQ_HEAD_INITIALIZER(qemu_mon_opts.head),
@@ -292,7 +288,7 @@ QemuOptsList qemu_mon_opts = {
},
};
-QemuOptsList qemu_cpudef_opts = {
+static QemuOptsList qemu_cpudef_opts = {
.name = "cpudef",
.head = QTAILQ_HEAD_INITIALIZER(qemu_cpudef_opts.head),
.desc = {
diff --git a/qemu-config.h b/qemu-config.h
index bf9bcc2714..533a049276 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -1,19 +1,8 @@
#ifndef QEMU_CONFIG_H
#define QEMU_CONFIG_H
-extern QemuOptsList qemu_drive_opts;
-extern QemuOptsList qemu_chardev_opts;
-#ifdef CONFIG_LINUX
extern QemuOptsList qemu_fsdev_opts;
extern QemuOptsList qemu_virtfs_opts;
-#endif
-extern QemuOptsList qemu_device_opts;
-extern QemuOptsList qemu_netdev_opts;
-extern QemuOptsList qemu_net_opts;
-extern QemuOptsList qemu_rtc_opts;
-extern QemuOptsList qemu_global_opts;
-extern QemuOptsList qemu_mon_opts;
-extern QemuOptsList qemu_cpudef_opts;
QemuOptsList *qemu_find_opts(const char *group);
void qemu_add_opts(QemuOptsList *list);
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index dade145807..04ba8d5152 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -965,7 +965,7 @@ void x86_cpudef_setup(void)
x86_defs = &builtin_x86_defs[i];
}
#if !defined(CONFIG_USER_ONLY)
- qemu_opts_foreach(&qemu_cpudef_opts, cpudef_register, NULL, 0);
+ qemu_opts_foreach(qemu_find_opts("cpudef"), cpudef_register, NULL, 0);
#endif
}
diff --git a/vl.c b/vl.c
index ccc8d573db..a330f188fb 100644
--- a/vl.c
+++ b/vl.c
@@ -1461,12 +1461,12 @@ static int balloon_parse(const char *arg)
if (!strncmp(arg, "virtio", 6)) {
if (arg[6] == ',') {
/* have params -> parse them */
- opts = qemu_opts_parse(&qemu_device_opts, arg+7, 0);
+ opts = qemu_opts_parse(qemu_find_opts("device"), arg+7, 0);
if (!opts)
return -1;
} else {
/* create empty opts */
- opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
+ opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
}
qemu_opt_set(opts, "driver", "virtio-balloon-pci");
return 0;
@@ -1598,7 +1598,7 @@ static void monitor_parse(const char *optarg, const char *mode)
}
}
- opts = qemu_opts_create(&qemu_mon_opts, label, 1);
+ opts = qemu_opts_create(qemu_find_opts("mon"), label, 1);
if (!opts) {
fprintf(stderr, "duplicate chardev: %s\n", label);
exit(1);
@@ -1695,6 +1695,7 @@ static int parallel_parse(const char *devname)
static int virtcon_parse(const char *devname)
{
+ QemuOptsList *device = qemu_find_opts("device");
static int index = 0;
char label[32];
QemuOpts *bus_opts, *dev_opts;
@@ -1706,10 +1707,10 @@ static int virtcon_parse(const char *devname)
exit(1);
}
- bus_opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
+ bus_opts = qemu_opts_create(device, NULL, 0);
qemu_opt_set(bus_opts, "driver", "virtio-serial");
- dev_opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
+ dev_opts = qemu_opts_create(device, NULL, 0);
qemu_opt_set(dev_opts, "driver", "virtconsole");
snprintf(label, sizeof(label), "virtcon%d", index);
@@ -1732,7 +1733,7 @@ static int debugcon_parse(const char *devname)
if (!qemu_chr_open("debugcon", devname, NULL)) {
exit(1);
}
- opts = qemu_opts_create(&qemu_device_opts, "debugcon", 1);
+ opts = qemu_opts_create(qemu_find_opts("device"), "debugcon", 1);
if (!opts) {
fprintf(stderr, "qemu: already have a debugcon device\n");
exit(1);
@@ -1853,6 +1854,11 @@ int main(int argc, char **argv, char **envp)
tb_size = 0;
autostart= 1;
+#ifdef CONFIG_VIRTFS
+ qemu_add_opts(&qemu_fsdev_opts);
+ qemu_add_opts(&qemu_virtfs_opts);
+#endif
+
/* first pass of option parsing */
optind = 1;
while (optind < argc) {
@@ -2104,12 +2110,12 @@ int main(int argc, char **argv, char **envp)
fd_bootchk = 0;
break;
case QEMU_OPTION_netdev:
- if (net_client_parse(&qemu_netdev_opts, optarg) == -1) {
+ if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) {
exit(1);
}
break;
case QEMU_OPTION_net:
- if (net_client_parse(&qemu_net_opts, optarg) == -1) {
+ if (net_client_parse(qemu_find_opts("net"), optarg) == -1) {
exit(1);
}
break;
@@ -2268,21 +2274,21 @@ int main(int argc, char **argv, char **envp)
default_monitor = 0;
break;
case QEMU_OPTION_mon:
- opts = qemu_opts_parse(&qemu_mon_opts, optarg, 1);
+ opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1);
if (!opts) {
exit(1);
}
default_monitor = 0;
break;
case QEMU_OPTION_chardev:
- opts = qemu_opts_parse(&qemu_chardev_opts, optarg, 1);
+ opts = qemu_opts_parse(qemu_find_opts("chardev"), optarg, 1);
if (!opts) {
exit(1);
}
break;
#ifdef CONFIG_VIRTFS
case QEMU_OPTION_fsdev:
- opts = qemu_opts_parse(&qemu_fsdev_opts, optarg, 1);
+ opts = qemu_opts_parse(qemu_find_opts("fsdev"), optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
@@ -2293,7 +2299,7 @@ int main(int argc, char **argv, char **envp)
char *arg_9p = NULL;
int len = 0;
- opts = qemu_opts_parse(&qemu_virtfs_opts, optarg, 1);
+ opts = qemu_opts_parse(qemu_find_opts("virtfs"), optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
@@ -2330,12 +2336,12 @@ int main(int argc, char **argv, char **envp)
qemu_opt_get(opts, "mount_tag"),
qemu_opt_get(opts, "mount_tag"));
- if (!qemu_opts_parse(&qemu_fsdev_opts, arg_fsdev, 1)) {
+ if (!qemu_opts_parse(qemu_find_opts("fsdev"), arg_fsdev, 1)) {
fprintf(stderr, "parse error [fsdev]: %s\n", optarg);
exit(1);
}
- if (!qemu_opts_parse(&qemu_device_opts, arg_9p, 1)) {
+ if (!qemu_opts_parse(qemu_find_opts("device"), arg_9p, 1)) {
fprintf(stderr, "parse error [device]: %s\n", optarg);
exit(1);
}
@@ -2432,7 +2438,7 @@ int main(int argc, char **argv, char **envp)
add_device_config(DEV_USB, optarg);
break;
case QEMU_OPTION_device:
- if (!qemu_opts_parse(&qemu_device_opts, optarg, 1)) {
+ if (!qemu_opts_parse(qemu_find_opts("device"), optarg, 1)) {
exit(1);
}
break;
@@ -2528,7 +2534,7 @@ int main(int argc, char **argv, char **envp)
configure_rtc_date_offset(optarg, 1);
break;
case QEMU_OPTION_rtc:
- opts = qemu_opts_parse(&qemu_rtc_opts, optarg, 0);
+ opts = qemu_opts_parse(qemu_find_opts("rtc"), optarg, 0);
if (!opts) {
exit(1);
}
@@ -2636,8 +2642,8 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
- qemu_opts_foreach(&qemu_device_opts, default_driver_check, NULL, 0);
- qemu_opts_foreach(&qemu_global_opts, default_driver_check, NULL, 0);
+ qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
+ qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
if (machine->no_serial) {
default_serial = 0;
@@ -2691,10 +2697,10 @@ int main(int argc, char **argv, char **envp)
socket_init();
- if (qemu_opts_foreach(&qemu_chardev_opts, chardev_init_func, NULL, 1) != 0)
+ if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
exit(1);
#ifdef CONFIG_VIRTFS
- if (qemu_opts_foreach(&qemu_fsdev_opts, fsdev_init_func, NULL, 1) != 0) {
+ if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
exit(1);
}
#endif
@@ -2778,8 +2784,8 @@ int main(int argc, char **argv, char **envp)
/* open the virtual block devices */
if (snapshot)
- qemu_opts_foreach(&qemu_drive_opts, drive_enable_snapshot, NULL, 0);
- if (qemu_opts_foreach(&qemu_drive_opts, drive_init_func, &machine->use_scsi, 1) != 0)
+ qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0);
+ if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine->use_scsi, 1) != 0)
exit(1);
register_savevm_live(NULL, "ram", 0, 4, NULL, ram_save_live, NULL,
@@ -2827,7 +2833,7 @@ int main(int argc, char **argv, char **envp)
}
}
- if (qemu_opts_foreach(&qemu_mon_opts, mon_init_func, NULL, 1) != 0) {
+ if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) {
exit(1);
}
@@ -2842,7 +2848,7 @@ int main(int argc, char **argv, char **envp)
module_call_init(MODULE_INIT_DEVICE);
- if (qemu_opts_foreach(&qemu_device_opts, device_help_func, NULL, 0) != 0)
+ if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0)
exit(0);
if (watchdog) {
@@ -2875,7 +2881,7 @@ int main(int argc, char **argv, char **envp)
}
/* init generic devices */
- if (qemu_opts_foreach(&qemu_device_opts, device_init_func, NULL, 1) != 0)
+ if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0)
exit(1);
net_check_clients();