Revision 3329f07b

b/blockdev.c
50 50
    vsnprintf(optstr, sizeof(optstr), fmt, ap);
51 51
    va_end(ap);
52 52

  
53
    opts = qemu_opts_parse(&qemu_drive_opts, optstr, 0);
53
    opts = qemu_opts_parse(qemu_find_opts("drive"), optstr, 0);
54 54
    if (!opts) {
55 55
        return NULL;
56 56
    }
......
451 451
        break;
452 452
    case IF_VIRTIO:
453 453
        /* add virtio block device */
454
        opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
454
        opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
455 455
        qemu_opt_set(opts, "driver", "virtio-blk-pci");
456 456
        qemu_opt_set(opts, "drive", dinfo->id);
457 457
        if (devaddr)
b/hw/pci-hotplug.c
51 51
        return NULL;
52 52
    }
53 53

  
54
    opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", 0);
54
    opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
55 55
    if (!opts) {
56 56
        return NULL;
57 57
    }
b/hw/qdev-properties.c
772 772

  
773 773
void qemu_add_globals(void)
774 774
{
775
    qemu_opts_foreach(&qemu_global_opts, qdev_add_one_global, NULL, 0);
775
    qemu_opts_foreach(qemu_find_opts("global"), qdev_add_one_global, NULL, 0);
776 776
}
b/hw/qdev.c
792 792
{
793 793
    QemuOpts *opts;
794 794

  
795
    opts = qemu_opts_from_qdict(&qemu_device_opts, qdict);
795
    opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict);
796 796
    if (!opts) {
797 797
        return -1;
798 798
    }
b/hw/usb-msd.c
575 575

  
576 576
    /* parse -usbdevice disk: syntax into drive opts */
577 577
    snprintf(id, sizeof(id), "usb%d", nr++);
578
    opts = qemu_opts_create(&qemu_drive_opts, id, 0);
578
    opts = qemu_opts_create(qemu_find_opts("drive"), id, 0);
579 579

  
580 580
    p1 = strchr(filename, ':');
581 581
    if (p1++) {
b/hw/usb-net.c
1472 1472
    QemuOpts *opts;
1473 1473
    int idx;
1474 1474

  
1475
    opts = qemu_opts_parse(&qemu_net_opts, cmdline, 0);
1475
    opts = qemu_opts_parse(qemu_find_opts("net"), cmdline, 0);
1476 1476
    if (!opts) {
1477 1477
        return NULL;
1478 1478
    }
b/hw/watchdog.c
66 66
    QLIST_FOREACH(model, &watchdog_list, entry) {
67 67
        if (strcasecmp(model->wdt_name, p) == 0) {
68 68
            /* add the device */
69
            opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
69
            opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
70 70
            qemu_opt_set(opts, "driver", p);
71 71
            return 0;
72 72
        }
b/net.c
1168 1168
        return;
1169 1169
    }
1170 1170

  
1171
    opts = qemu_opts_parse(&qemu_net_opts, opts_str ? opts_str : "", 0);
1171
    opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
1172 1172
    if (!opts) {
1173 1173
        return;
1174 1174
    }
......
1202 1202
    QemuOpts *opts;
1203 1203
    int res;
1204 1204

  
1205
    opts = qemu_opts_from_qdict(&qemu_netdev_opts, qdict);
1205
    opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict);
1206 1206
    if (!opts) {
1207 1207
        return -1;
1208 1208
    }
......
1226 1226
        return -1;
1227 1227
    }
1228 1228
    qemu_del_vlan_client(vc);
1229
    qemu_opts_del(qemu_opts_find(&qemu_netdev_opts, id));
1229
    qemu_opts_del(qemu_opts_find(qemu_find_opts("netdev"), id));
1230 1230
    return 0;
1231 1231
}
1232 1232

  
......
1349 1349

  
1350 1350
int net_init_clients(void)
1351 1351
{
1352
    QemuOptsList *net = qemu_find_opts("net");
1353

  
1352 1354
    if (default_net) {
1353 1355
        /* if no clients, we use a default config */
1354
        qemu_opts_set(&qemu_net_opts, NULL, "type", "nic");
1356
        qemu_opts_set(net, NULL, "type", "nic");
1355 1357
#ifdef CONFIG_SLIRP
1356
        qemu_opts_set(&qemu_net_opts, NULL, "type", "user");
1358
        qemu_opts_set(net, NULL, "type", "user");
1357 1359
#endif
1358 1360
    }
1359 1361

  
1360 1362
    QTAILQ_INIT(&vlans);
1361 1363
    QTAILQ_INIT(&non_vlan_clients);
1362 1364

  
1363
    if (qemu_opts_foreach(&qemu_netdev_opts, net_init_netdev, NULL, 1) == -1)
1365
    if (qemu_opts_foreach(qemu_find_opts("netdev"), net_init_netdev, NULL, 1) == -1)
1364 1366
        return -1;
1365 1367

  
1366
    if (qemu_opts_foreach(&qemu_net_opts, net_init_client, NULL, 1) == -1) {
1368
    if (qemu_opts_foreach(net, net_init_client, NULL, 1) == -1) {
1367 1369
        return -1;
1368 1370
    }
1369 1371

  
b/qemu-char.c
2286 2286
    const char *p;
2287 2287
    QemuOpts *opts;
2288 2288

  
2289
    opts = qemu_opts_create(&qemu_chardev_opts, label, 1);
2289
    opts = qemu_opts_create(qemu_find_opts("chardev"), label, 1);
2290 2290
    if (NULL == opts)
2291 2291
        return NULL;
2292 2292

  
b/qemu-config.c
5 5
#include "sysemu.h"
6 6
#include "hw/qdev.h"
7 7

  
8
QemuOptsList qemu_drive_opts = {
8
static QemuOptsList qemu_drive_opts = {
9 9
    .name = "drive",
10 10
    .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head),
11 11
    .desc = {
......
84 84
    },
85 85
};
86 86

  
87
QemuOptsList qemu_chardev_opts = {
87
static QemuOptsList qemu_chardev_opts = {
88 88
    .name = "chardev",
89 89
    .implied_opt_name = "backend",
90 90
    .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head),
......
151 151
    },
152 152
};
153 153

  
154
#ifdef CONFIG_LINUX
155 154
QemuOptsList qemu_fsdev_opts = {
156 155
    .name = "fsdev",
157 156
    .implied_opt_name = "fstype",
......
170 169
        { /*End of list */ }
171 170
    },
172 171
};
173
#endif
174 172

  
175
#ifdef CONFIG_LINUX
176 173
QemuOptsList qemu_virtfs_opts = {
177 174
    .name = "virtfs",
178 175
    .implied_opt_name = "fstype",
......
195 192
        { /*End of list */ }
196 193
    },
197 194
};
198
#endif
199 195

  
200
QemuOptsList qemu_device_opts = {
196
static QemuOptsList qemu_device_opts = {
201 197
    .name = "device",
202 198
    .implied_opt_name = "driver",
203 199
    .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head),
......
211 207
    },
212 208
};
213 209

  
214
QemuOptsList qemu_netdev_opts = {
210
static QemuOptsList qemu_netdev_opts = {
215 211
    .name = "netdev",
216 212
    .implied_opt_name = "type",
217 213
    .head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head),
......
224 220
    },
225 221
};
226 222

  
227
QemuOptsList qemu_net_opts = {
223
static QemuOptsList qemu_net_opts = {
228 224
    .name = "net",
229 225
    .implied_opt_name = "type",
230 226
    .head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head),
......
237 233
    },
238 234
};
239 235

  
240
QemuOptsList qemu_rtc_opts = {
236
static QemuOptsList qemu_rtc_opts = {
241 237
    .name = "rtc",
242 238
    .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head),
243 239
    .desc = {
......
255 251
    },
256 252
};
257 253

  
258
QemuOptsList qemu_global_opts = {
254
static QemuOptsList qemu_global_opts = {
259 255
    .name = "global",
260 256
    .head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head),
261 257
    .desc = {
......
273 269
    },
274 270
};
275 271

  
276
QemuOptsList qemu_mon_opts = {
272
static QemuOptsList qemu_mon_opts = {
277 273
    .name = "mon",
278 274
    .implied_opt_name = "chardev",
279 275
    .head = QTAILQ_HEAD_INITIALIZER(qemu_mon_opts.head),
......
292 288
    },
293 289
};
294 290

  
295
QemuOptsList qemu_cpudef_opts = {
291
static QemuOptsList qemu_cpudef_opts = {
296 292
    .name = "cpudef",
297 293
    .head = QTAILQ_HEAD_INITIALIZER(qemu_cpudef_opts.head),
298 294
    .desc = {
b/qemu-config.h
1 1
#ifndef QEMU_CONFIG_H
2 2
#define QEMU_CONFIG_H
3 3

  
4
extern QemuOptsList qemu_drive_opts;
5
extern QemuOptsList qemu_chardev_opts;
6
#ifdef CONFIG_LINUX
7 4
extern QemuOptsList qemu_fsdev_opts;
8 5
extern QemuOptsList qemu_virtfs_opts;
9
#endif
10
extern QemuOptsList qemu_device_opts;
11
extern QemuOptsList qemu_netdev_opts;
12
extern QemuOptsList qemu_net_opts;
13
extern QemuOptsList qemu_rtc_opts;
14
extern QemuOptsList qemu_global_opts;
15
extern QemuOptsList qemu_mon_opts;
16
extern QemuOptsList qemu_cpudef_opts;
17 6

  
18 7
QemuOptsList *qemu_find_opts(const char *group);
19 8
void qemu_add_opts(QemuOptsList *list);
b/target-i386/cpuid.c
965 965
        x86_defs = &builtin_x86_defs[i];
966 966
    }
967 967
#if !defined(CONFIG_USER_ONLY)
968
    qemu_opts_foreach(&qemu_cpudef_opts, cpudef_register, NULL, 0);
968
    qemu_opts_foreach(qemu_find_opts("cpudef"), cpudef_register, NULL, 0);
969 969
#endif
970 970
}
971 971

  
b/vl.c
1461 1461
    if (!strncmp(arg, "virtio", 6)) {
1462 1462
        if (arg[6] == ',') {
1463 1463
            /* have params -> parse them */
1464
            opts = qemu_opts_parse(&qemu_device_opts, arg+7, 0);
1464
            opts = qemu_opts_parse(qemu_find_opts("device"), arg+7, 0);
1465 1465
            if (!opts)
1466 1466
                return  -1;
1467 1467
        } else {
1468 1468
            /* create empty opts */
1469
            opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
1469
            opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
1470 1470
        }
1471 1471
        qemu_opt_set(opts, "driver", "virtio-balloon-pci");
1472 1472
        return 0;
......
1598 1598
        }
1599 1599
    }
1600 1600

  
1601
    opts = qemu_opts_create(&qemu_mon_opts, label, 1);
1601
    opts = qemu_opts_create(qemu_find_opts("mon"), label, 1);
1602 1602
    if (!opts) {
1603 1603
        fprintf(stderr, "duplicate chardev: %s\n", label);
1604 1604
        exit(1);
......
1695 1695

  
1696 1696
static int virtcon_parse(const char *devname)
1697 1697
{
1698
    QemuOptsList *device = qemu_find_opts("device");
1698 1699
    static int index = 0;
1699 1700
    char label[32];
1700 1701
    QemuOpts *bus_opts, *dev_opts;
......
1706 1707
        exit(1);
1707 1708
    }
1708 1709

  
1709
    bus_opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
1710
    bus_opts = qemu_opts_create(device, NULL, 0);
1710 1711
    qemu_opt_set(bus_opts, "driver", "virtio-serial");
1711 1712

  
1712
    dev_opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
1713
    dev_opts = qemu_opts_create(device, NULL, 0);
1713 1714
    qemu_opt_set(dev_opts, "driver", "virtconsole");
1714 1715

  
1715 1716
    snprintf(label, sizeof(label), "virtcon%d", index);
......
1732 1733
    if (!qemu_chr_open("debugcon", devname, NULL)) {
1733 1734
        exit(1);
1734 1735
    }
1735
    opts = qemu_opts_create(&qemu_device_opts, "debugcon", 1);
1736
    opts = qemu_opts_create(qemu_find_opts("device"), "debugcon", 1);
1736 1737
    if (!opts) {
1737 1738
        fprintf(stderr, "qemu: already have a debugcon device\n");
1738 1739
        exit(1);
......
1853 1854
    tb_size = 0;
1854 1855
    autostart= 1;
1855 1856

  
1857
#ifdef CONFIG_VIRTFS
1858
    qemu_add_opts(&qemu_fsdev_opts);
1859
    qemu_add_opts(&qemu_virtfs_opts);
1860
#endif
1861

  
1856 1862
    /* first pass of option parsing */
1857 1863
    optind = 1;
1858 1864
    while (optind < argc) {
......
2104 2110
                fd_bootchk = 0;
2105 2111
                break;
2106 2112
            case QEMU_OPTION_netdev:
2107
                if (net_client_parse(&qemu_netdev_opts, optarg) == -1) {
2113
                if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) {
2108 2114
                    exit(1);
2109 2115
                }
2110 2116
                break;
2111 2117
            case QEMU_OPTION_net:
2112
                if (net_client_parse(&qemu_net_opts, optarg) == -1) {
2118
                if (net_client_parse(qemu_find_opts("net"), optarg) == -1) {
2113 2119
                    exit(1);
2114 2120
                }
2115 2121
                break;
......
2268 2274
                default_monitor = 0;
2269 2275
                break;
2270 2276
            case QEMU_OPTION_mon:
2271
                opts = qemu_opts_parse(&qemu_mon_opts, optarg, 1);
2277
                opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1);
2272 2278
                if (!opts) {
2273 2279
                    exit(1);
2274 2280
                }
2275 2281
                default_monitor = 0;
2276 2282
                break;
2277 2283
            case QEMU_OPTION_chardev:
2278
                opts = qemu_opts_parse(&qemu_chardev_opts, optarg, 1);
2284
                opts = qemu_opts_parse(qemu_find_opts("chardev"), optarg, 1);
2279 2285
                if (!opts) {
2280 2286
                    exit(1);
2281 2287
                }
2282 2288
                break;
2283 2289
#ifdef CONFIG_VIRTFS
2284 2290
            case QEMU_OPTION_fsdev:
2285
                opts = qemu_opts_parse(&qemu_fsdev_opts, optarg, 1);
2291
                opts = qemu_opts_parse(qemu_find_opts("fsdev"), optarg, 1);
2286 2292
                if (!opts) {
2287 2293
                    fprintf(stderr, "parse error: %s\n", optarg);
2288 2294
                    exit(1);
......
2293 2299
                char *arg_9p = NULL;
2294 2300
                int len = 0;
2295 2301

  
2296
                opts = qemu_opts_parse(&qemu_virtfs_opts, optarg, 1);
2302
                opts = qemu_opts_parse(qemu_find_opts("virtfs"), optarg, 1);
2297 2303
                if (!opts) {
2298 2304
                    fprintf(stderr, "parse error: %s\n", optarg);
2299 2305
                    exit(1);
......
2330 2336
                                qemu_opt_get(opts, "mount_tag"),
2331 2337
                                qemu_opt_get(opts, "mount_tag"));
2332 2338

  
2333
                if (!qemu_opts_parse(&qemu_fsdev_opts, arg_fsdev, 1)) {
2339
                if (!qemu_opts_parse(qemu_find_opts("fsdev"), arg_fsdev, 1)) {
2334 2340
                    fprintf(stderr, "parse error [fsdev]: %s\n", optarg);
2335 2341
                    exit(1);
2336 2342
                }
2337 2343

  
2338
                if (!qemu_opts_parse(&qemu_device_opts, arg_9p, 1)) {
2344
                if (!qemu_opts_parse(qemu_find_opts("device"), arg_9p, 1)) {
2339 2345
                    fprintf(stderr, "parse error [device]: %s\n", optarg);
2340 2346
                    exit(1);
2341 2347
                }
......
2432 2438
                add_device_config(DEV_USB, optarg);
2433 2439
                break;
2434 2440
            case QEMU_OPTION_device:
2435
                if (!qemu_opts_parse(&qemu_device_opts, optarg, 1)) {
2441
                if (!qemu_opts_parse(qemu_find_opts("device"), optarg, 1)) {
2436 2442
                    exit(1);
2437 2443
                }
2438 2444
                break;
......
2528 2534
                configure_rtc_date_offset(optarg, 1);
2529 2535
                break;
2530 2536
            case QEMU_OPTION_rtc:
2531
                opts = qemu_opts_parse(&qemu_rtc_opts, optarg, 0);
2537
                opts = qemu_opts_parse(qemu_find_opts("rtc"), optarg, 0);
2532 2538
                if (!opts) {
2533 2539
                    exit(1);
2534 2540
                }
......
2636 2642
        exit(1);
2637 2643
    }
2638 2644

  
2639
    qemu_opts_foreach(&qemu_device_opts, default_driver_check, NULL, 0);
2640
    qemu_opts_foreach(&qemu_global_opts, default_driver_check, NULL, 0);
2645
    qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
2646
    qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
2641 2647

  
2642 2648
    if (machine->no_serial) {
2643 2649
        default_serial = 0;
......
2691 2697

  
2692 2698
    socket_init();
2693 2699

  
2694
    if (qemu_opts_foreach(&qemu_chardev_opts, chardev_init_func, NULL, 1) != 0)
2700
    if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
2695 2701
        exit(1);
2696 2702
#ifdef CONFIG_VIRTFS
2697
    if (qemu_opts_foreach(&qemu_fsdev_opts, fsdev_init_func, NULL, 1) != 0) {
2703
    if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
2698 2704
        exit(1);
2699 2705
    }
2700 2706
#endif
......
2778 2784

  
2779 2785
    /* open the virtual block devices */
2780 2786
    if (snapshot)
2781
        qemu_opts_foreach(&qemu_drive_opts, drive_enable_snapshot, NULL, 0);
2782
    if (qemu_opts_foreach(&qemu_drive_opts, drive_init_func, &machine->use_scsi, 1) != 0)
2787
        qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0);
2788
    if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine->use_scsi, 1) != 0)
2783 2789
        exit(1);
2784 2790

  
2785 2791
    register_savevm_live(NULL, "ram", 0, 4, NULL, ram_save_live, NULL,
......
2827 2833
        }
2828 2834
    }
2829 2835

  
2830
    if (qemu_opts_foreach(&qemu_mon_opts, mon_init_func, NULL, 1) != 0) {
2836
    if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) {
2831 2837
        exit(1);
2832 2838
    }
2833 2839

  
......
2842 2848

  
2843 2849
    module_call_init(MODULE_INIT_DEVICE);
2844 2850

  
2845
    if (qemu_opts_foreach(&qemu_device_opts, device_help_func, NULL, 0) != 0)
2851
    if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0)
2846 2852
        exit(0);
2847 2853

  
2848 2854
    if (watchdog) {
......
2875 2881
    }
2876 2882

  
2877 2883
    /* init generic devices */
2878
    if (qemu_opts_foreach(&qemu_device_opts, device_init_func, NULL, 1) != 0)
2884
    if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0)
2879 2885
        exit(1);
2880 2886

  
2881 2887
    net_check_clients();

Also available in: Unified diff