virtio-net: fix macaddr config regression
[armpft.git] / qemu-config.c
blobfc73beaef6c7d1f34533ff966e51464fa3160b44
1 #include "qemu-common.h"
2 #include "qemu-option.h"
3 #include "qemu-config.h"
4 #include "sysemu.h"
6 QemuOptsList qemu_drive_opts = {
7 .name = "drive",
8 .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head),
9 .desc = {
11 .name = "bus",
12 .type = QEMU_OPT_NUMBER,
13 .help = "bus number",
14 },{
15 .name = "unit",
16 .type = QEMU_OPT_NUMBER,
17 .help = "unit number (i.e. lun for scsi)",
18 },{
19 .name = "if",
20 .type = QEMU_OPT_STRING,
21 .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
22 },{
23 .name = "index",
24 .type = QEMU_OPT_NUMBER,
25 },{
26 .name = "cyls",
27 .type = QEMU_OPT_NUMBER,
28 .help = "number of cylinders (ide disk geometry)",
29 },{
30 .name = "heads",
31 .type = QEMU_OPT_NUMBER,
32 .help = "number of heads (ide disk geometry)",
33 },{
34 .name = "secs",
35 .type = QEMU_OPT_NUMBER,
36 .help = "number of sectors (ide disk geometry)",
37 },{
38 .name = "trans",
39 .type = QEMU_OPT_STRING,
40 .help = "chs translation (auto, lba. none)",
41 },{
42 .name = "media",
43 .type = QEMU_OPT_STRING,
44 .help = "media type (disk, cdrom)",
45 },{
46 .name = "snapshot",
47 .type = QEMU_OPT_BOOL,
48 },{
49 .name = "file",
50 .type = QEMU_OPT_STRING,
51 .help = "disk image",
52 },{
53 .name = "cache",
54 .type = QEMU_OPT_STRING,
55 .help = "host cache usage (none, writeback, writethrough)",
56 },{
57 .name = "aio",
58 .type = QEMU_OPT_STRING,
59 .help = "host AIO implementation (threads, native)",
60 },{
61 .name = "format",
62 .type = QEMU_OPT_STRING,
63 .help = "disk format (raw, qcow2, ...)",
64 },{
65 .name = "serial",
66 .type = QEMU_OPT_STRING,
67 },{
68 .name = "werror",
69 .type = QEMU_OPT_STRING,
70 },{
71 .name = "addr",
72 .type = QEMU_OPT_STRING,
73 .help = "pci address (virtio only)",
75 { /* end if list */ }
79 QemuOptsList qemu_chardev_opts = {
80 .name = "chardev",
81 .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head),
82 .desc = {
84 .name = "backend",
85 .type = QEMU_OPT_STRING,
86 },{
87 .name = "path",
88 .type = QEMU_OPT_STRING,
89 },{
90 .name = "host",
91 .type = QEMU_OPT_STRING,
92 },{
93 .name = "port",
94 .type = QEMU_OPT_STRING,
95 },{
96 .name = "localaddr",
97 .type = QEMU_OPT_STRING,
98 },{
99 .name = "localport",
100 .type = QEMU_OPT_STRING,
102 .name = "to",
103 .type = QEMU_OPT_NUMBER,
105 .name = "ipv4",
106 .type = QEMU_OPT_BOOL,
108 .name = "ipv6",
109 .type = QEMU_OPT_BOOL,
111 .name = "wait",
112 .type = QEMU_OPT_BOOL,
114 .name = "server",
115 .type = QEMU_OPT_BOOL,
117 .name = "delay",
118 .type = QEMU_OPT_BOOL,
120 .name = "telnet",
121 .type = QEMU_OPT_BOOL,
123 .name = "width",
124 .type = QEMU_OPT_NUMBER,
126 .name = "height",
127 .type = QEMU_OPT_NUMBER,
129 .name = "cols",
130 .type = QEMU_OPT_NUMBER,
132 .name = "rows",
133 .type = QEMU_OPT_NUMBER,
135 .name = "mux",
136 .type = QEMU_OPT_BOOL,
138 .name = "signal",
139 .type = QEMU_OPT_BOOL,
141 { /* end if list */ }
145 QemuOptsList qemu_device_opts = {
146 .name = "device",
147 .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head),
148 .desc = {
150 * no elements => accept any
151 * sanity checking will happen later
152 * when setting device properties
154 { /* end if list */ }
158 QemuOptsList qemu_netdev_opts = {
159 .name = "netdev",
160 .head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head),
161 .desc = {
163 * no elements => accept any params
164 * validation will happen later
166 { /* end of list */ }
170 QemuOptsList qemu_net_opts = {
171 .name = "net",
172 .head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head),
173 .desc = {
175 * no elements => accept any params
176 * validation will happen later
178 { /* end of list */ }
182 QemuOptsList qemu_rtc_opts = {
183 .name = "rtc",
184 .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head),
185 .desc = {
187 .name = "base",
188 .type = QEMU_OPT_STRING,
190 .name = "clock",
191 .type = QEMU_OPT_STRING,
192 #ifdef TARGET_I386
194 .name = "driftfix",
195 .type = QEMU_OPT_STRING,
196 #endif
198 { /* end if list */ }
202 static QemuOptsList *lists[] = {
203 &qemu_drive_opts,
204 &qemu_chardev_opts,
205 &qemu_device_opts,
206 &qemu_netdev_opts,
207 &qemu_net_opts,
208 &qemu_rtc_opts,
209 NULL,
212 int qemu_set_option(const char *str)
214 char group[64], id[64], arg[64];
215 QemuOpts *opts;
216 int i, rc, offset;
218 rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset);
219 if (rc < 3 || str[offset] != '=') {
220 qemu_error("can't parse: \"%s\"\n", str);
221 return -1;
224 for (i = 0; lists[i] != NULL; i++) {
225 if (strcmp(lists[i]->name, group) == 0)
226 break;
228 if (lists[i] == NULL) {
229 qemu_error("there is no option group \"%s\"\n", group);
230 return -1;
233 opts = qemu_opts_find(lists[i], id);
234 if (!opts) {
235 qemu_error("there is no %s \"%s\" defined\n",
236 lists[i]->name, id);
237 return -1;
240 if (qemu_opt_set(opts, arg, str+offset+1) == -1) {
241 return -1;
243 return 0;