]>
Commit | Line | Data |
---|---|---|
7282a033 | 1 | #include "qemu-common.h" |
2f792016 | 2 | #include "qemu-error.h" |
7282a033 GH |
3 | #include "qemu-option.h" |
4 | #include "qemu-config.h" | |
d0fef6fb | 5 | #include "hw/qdev.h" |
2ac20613 | 6 | #include "error.h" |
7282a033 | 7 | |
3329f07b | 8 | static QemuOptsList qemu_drive_opts = { |
7282a033 | 9 | .name = "drive", |
72cf2d4f | 10 | .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head), |
7282a033 GH |
11 | .desc = { |
12 | { | |
13 | .name = "bus", | |
14 | .type = QEMU_OPT_NUMBER, | |
15 | .help = "bus number", | |
16 | },{ | |
17 | .name = "unit", | |
18 | .type = QEMU_OPT_NUMBER, | |
19 | .help = "unit number (i.e. lun for scsi)", | |
20 | },{ | |
21 | .name = "if", | |
22 | .type = QEMU_OPT_STRING, | |
23 | .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)", | |
24 | },{ | |
25 | .name = "index", | |
26 | .type = QEMU_OPT_NUMBER, | |
69d7e218 | 27 | .help = "index number", |
7282a033 GH |
28 | },{ |
29 | .name = "cyls", | |
30 | .type = QEMU_OPT_NUMBER, | |
31 | .help = "number of cylinders (ide disk geometry)", | |
32 | },{ | |
33 | .name = "heads", | |
34 | .type = QEMU_OPT_NUMBER, | |
35 | .help = "number of heads (ide disk geometry)", | |
36 | },{ | |
37 | .name = "secs", | |
38 | .type = QEMU_OPT_NUMBER, | |
39 | .help = "number of sectors (ide disk geometry)", | |
40 | },{ | |
41 | .name = "trans", | |
42 | .type = QEMU_OPT_STRING, | |
43 | .help = "chs translation (auto, lba. none)", | |
44 | },{ | |
45 | .name = "media", | |
46 | .type = QEMU_OPT_STRING, | |
47 | .help = "media type (disk, cdrom)", | |
48 | },{ | |
49 | .name = "snapshot", | |
50 | .type = QEMU_OPT_BOOL, | |
69d7e218 | 51 | .help = "enable/disable snapshot mode", |
7282a033 GH |
52 | },{ |
53 | .name = "file", | |
54 | .type = QEMU_OPT_STRING, | |
55 | .help = "disk image", | |
56 | },{ | |
57 | .name = "cache", | |
58 | .type = QEMU_OPT_STRING, | |
92196b2f SH |
59 | .help = "host cache usage (none, writeback, writethrough, " |
60 | "directsync, unsafe)", | |
5c6c3a6c CH |
61 | },{ |
62 | .name = "aio", | |
63 | .type = QEMU_OPT_STRING, | |
64 | .help = "host AIO implementation (threads, native)", | |
7282a033 GH |
65 | },{ |
66 | .name = "format", | |
67 | .type = QEMU_OPT_STRING, | |
68 | .help = "disk format (raw, qcow2, ...)", | |
69 | },{ | |
70 | .name = "serial", | |
71 | .type = QEMU_OPT_STRING, | |
69d7e218 | 72 | .help = "disk serial number", |
e9b2e818 KW |
73 | },{ |
74 | .name = "rerror", | |
75 | .type = QEMU_OPT_STRING, | |
69d7e218 | 76 | .help = "read error action", |
7282a033 GH |
77 | },{ |
78 | .name = "werror", | |
79 | .type = QEMU_OPT_STRING, | |
69d7e218 | 80 | .help = "write error action", |
7282a033 GH |
81 | },{ |
82 | .name = "addr", | |
83 | .type = QEMU_OPT_STRING, | |
84 | .help = "pci address (virtio only)", | |
59f2689d NS |
85 | },{ |
86 | .name = "readonly", | |
87 | .type = QEMU_OPT_BOOL, | |
69d7e218 | 88 | .help = "open drive file as read-only", |
0563e191 ZYW |
89 | },{ |
90 | .name = "iops", | |
91 | .type = QEMU_OPT_NUMBER, | |
92 | .help = "limit total I/O operations per second", | |
93 | },{ | |
94 | .name = "iops_rd", | |
95 | .type = QEMU_OPT_NUMBER, | |
96 | .help = "limit read operations per second", | |
97 | },{ | |
98 | .name = "iops_wr", | |
99 | .type = QEMU_OPT_NUMBER, | |
100 | .help = "limit write operations per second", | |
101 | },{ | |
102 | .name = "bps", | |
103 | .type = QEMU_OPT_NUMBER, | |
104 | .help = "limit total bytes per second", | |
105 | },{ | |
106 | .name = "bps_rd", | |
107 | .type = QEMU_OPT_NUMBER, | |
108 | .help = "limit read bytes per second", | |
109 | },{ | |
110 | .name = "bps_wr", | |
111 | .type = QEMU_OPT_NUMBER, | |
112 | .help = "limit write bytes per second", | |
fb0490f6 SH |
113 | },{ |
114 | .name = "copy-on-read", | |
115 | .type = QEMU_OPT_BOOL, | |
116 | .help = "copy read data from backing file into image file", | |
7282a033 | 117 | }, |
26056e0c | 118 | { /* end of list */ } |
7282a033 GH |
119 | }, |
120 | }; | |
121 | ||
f9dadc98 RS |
122 | static QemuOptsList qemu_iscsi_opts = { |
123 | .name = "iscsi", | |
124 | .head = QTAILQ_HEAD_INITIALIZER(qemu_iscsi_opts.head), | |
125 | .desc = { | |
126 | { | |
127 | .name = "user", | |
128 | .type = QEMU_OPT_STRING, | |
129 | .help = "username for CHAP authentication to target", | |
130 | },{ | |
131 | .name = "password", | |
132 | .type = QEMU_OPT_STRING, | |
133 | .help = "password for CHAP authentication to target", | |
134 | },{ | |
135 | .name = "header-digest", | |
136 | .type = QEMU_OPT_STRING, | |
137 | .help = "HeaderDigest setting. " | |
138 | "{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}", | |
139 | },{ | |
140 | .name = "initiator-name", | |
141 | .type = QEMU_OPT_STRING, | |
142 | .help = "Initiator iqn name to use when connecting", | |
143 | }, | |
144 | { /* end of list */ } | |
145 | }, | |
146 | }; | |
147 | ||
3329f07b | 148 | static QemuOptsList qemu_chardev_opts = { |
191bc01b | 149 | .name = "chardev", |
8212c64f | 150 | .implied_opt_name = "backend", |
72cf2d4f | 151 | .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head), |
191bc01b | 152 | .desc = { |
7d31544f GH |
153 | { |
154 | .name = "backend", | |
155 | .type = QEMU_OPT_STRING, | |
156 | },{ | |
157 | .name = "path", | |
158 | .type = QEMU_OPT_STRING, | |
aeb2c47a GH |
159 | },{ |
160 | .name = "host", | |
161 | .type = QEMU_OPT_STRING, | |
162 | },{ | |
163 | .name = "port", | |
164 | .type = QEMU_OPT_STRING, | |
7e1b35b4 GH |
165 | },{ |
166 | .name = "localaddr", | |
167 | .type = QEMU_OPT_STRING, | |
168 | },{ | |
169 | .name = "localport", | |
170 | .type = QEMU_OPT_STRING, | |
aeb2c47a GH |
171 | },{ |
172 | .name = "to", | |
173 | .type = QEMU_OPT_NUMBER, | |
174 | },{ | |
175 | .name = "ipv4", | |
176 | .type = QEMU_OPT_BOOL, | |
177 | },{ | |
178 | .name = "ipv6", | |
179 | .type = QEMU_OPT_BOOL, | |
180 | },{ | |
181 | .name = "wait", | |
182 | .type = QEMU_OPT_BOOL, | |
183 | },{ | |
184 | .name = "server", | |
185 | .type = QEMU_OPT_BOOL, | |
186 | },{ | |
187 | .name = "delay", | |
188 | .type = QEMU_OPT_BOOL, | |
189 | },{ | |
190 | .name = "telnet", | |
191 | .type = QEMU_OPT_BOOL, | |
6ea314d9 GH |
192 | },{ |
193 | .name = "width", | |
194 | .type = QEMU_OPT_NUMBER, | |
195 | },{ | |
196 | .name = "height", | |
197 | .type = QEMU_OPT_NUMBER, | |
198 | },{ | |
199 | .name = "cols", | |
200 | .type = QEMU_OPT_NUMBER, | |
201 | },{ | |
202 | .name = "rows", | |
203 | .type = QEMU_OPT_NUMBER, | |
c845f401 GH |
204 | },{ |
205 | .name = "mux", | |
206 | .type = QEMU_OPT_BOOL, | |
5989020b KK |
207 | },{ |
208 | .name = "signal", | |
209 | .type = QEMU_OPT_BOOL, | |
cbcc6336 AL |
210 | },{ |
211 | .name = "name", | |
212 | .type = QEMU_OPT_STRING, | |
213 | },{ | |
214 | .name = "debug", | |
215 | .type = QEMU_OPT_NUMBER, | |
7d31544f | 216 | }, |
26056e0c | 217 | { /* end of list */ } |
191bc01b GH |
218 | }, |
219 | }; | |
220 | ||
74db920c GS |
221 | QemuOptsList qemu_fsdev_opts = { |
222 | .name = "fsdev", | |
fbcbf101 | 223 | .implied_opt_name = "fsdriver", |
74db920c GS |
224 | .head = QTAILQ_HEAD_INITIALIZER(qemu_fsdev_opts.head), |
225 | .desc = { | |
226 | { | |
fbcbf101 | 227 | .name = "fsdriver", |
74db920c GS |
228 | .type = QEMU_OPT_STRING, |
229 | }, { | |
230 | .name = "path", | |
231 | .type = QEMU_OPT_STRING, | |
9ce56db6 VJ |
232 | }, { |
233 | .name = "security_model", | |
234 | .type = QEMU_OPT_STRING, | |
d3ab98e6 AK |
235 | }, { |
236 | .name = "writeout", | |
237 | .type = QEMU_OPT_STRING, | |
2c74c2cb MK |
238 | }, { |
239 | .name = "readonly", | |
240 | .type = QEMU_OPT_BOOL, | |
84a87cc4 MK |
241 | |
242 | }, { | |
243 | .name = "socket", | |
244 | .type = QEMU_OPT_STRING, | |
4c793dda MK |
245 | }, { |
246 | .name = "sock_fd", | |
247 | .type = QEMU_OPT_NUMBER, | |
74db920c | 248 | }, |
2c74c2cb | 249 | |
74db920c GS |
250 | { /*End of list */ } |
251 | }, | |
252 | }; | |
74db920c | 253 | |
3d54abc7 GS |
254 | QemuOptsList qemu_virtfs_opts = { |
255 | .name = "virtfs", | |
fbcbf101 | 256 | .implied_opt_name = "fsdriver", |
3d54abc7 GS |
257 | .head = QTAILQ_HEAD_INITIALIZER(qemu_virtfs_opts.head), |
258 | .desc = { | |
259 | { | |
fbcbf101 | 260 | .name = "fsdriver", |
3d54abc7 GS |
261 | .type = QEMU_OPT_STRING, |
262 | }, { | |
263 | .name = "path", | |
264 | .type = QEMU_OPT_STRING, | |
265 | }, { | |
266 | .name = "mount_tag", | |
267 | .type = QEMU_OPT_STRING, | |
9ce56db6 VJ |
268 | }, { |
269 | .name = "security_model", | |
270 | .type = QEMU_OPT_STRING, | |
d3ab98e6 AK |
271 | }, { |
272 | .name = "writeout", | |
273 | .type = QEMU_OPT_STRING, | |
2c74c2cb MK |
274 | }, { |
275 | .name = "readonly", | |
276 | .type = QEMU_OPT_BOOL, | |
84a87cc4 MK |
277 | }, { |
278 | .name = "socket", | |
279 | .type = QEMU_OPT_STRING, | |
4c793dda MK |
280 | }, { |
281 | .name = "sock_fd", | |
282 | .type = QEMU_OPT_NUMBER, | |
3d54abc7 GS |
283 | }, |
284 | ||
285 | { /*End of list */ } | |
286 | }, | |
287 | }; | |
3d54abc7 | 288 | |
3329f07b | 289 | static QemuOptsList qemu_device_opts = { |
f31d07d1 | 290 | .name = "device", |
8212c64f | 291 | .implied_opt_name = "driver", |
72cf2d4f | 292 | .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head), |
f31d07d1 GH |
293 | .desc = { |
294 | /* | |
295 | * no elements => accept any | |
296 | * sanity checking will happen later | |
297 | * when setting device properties | |
298 | */ | |
26056e0c | 299 | { /* end of list */ } |
f31d07d1 GH |
300 | }, |
301 | }; | |
302 | ||
3329f07b | 303 | static QemuOptsList qemu_netdev_opts = { |
a1ea458f | 304 | .name = "netdev", |
8212c64f | 305 | .implied_opt_name = "type", |
a1ea458f MM |
306 | .head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head), |
307 | .desc = { | |
308 | /* | |
309 | * no elements => accept any params | |
310 | * validation will happen later | |
311 | */ | |
312 | { /* end of list */ } | |
313 | }, | |
314 | }; | |
315 | ||
3329f07b | 316 | static QemuOptsList qemu_net_opts = { |
8119b33d | 317 | .name = "net", |
8212c64f | 318 | .implied_opt_name = "type", |
8119b33d MM |
319 | .head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head), |
320 | .desc = { | |
321 | /* | |
322 | * no elements => accept any params | |
323 | * validation will happen later | |
324 | */ | |
325 | { /* end of list */ } | |
326 | }, | |
327 | }; | |
328 | ||
3329f07b | 329 | static QemuOptsList qemu_rtc_opts = { |
1ed2fc1f JK |
330 | .name = "rtc", |
331 | .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head), | |
332 | .desc = { | |
333 | { | |
334 | .name = "base", | |
335 | .type = QEMU_OPT_STRING, | |
6875204c JK |
336 | },{ |
337 | .name = "clock", | |
338 | .type = QEMU_OPT_STRING, | |
1ed2fc1f JK |
339 | },{ |
340 | .name = "driftfix", | |
341 | .type = QEMU_OPT_STRING, | |
1ed2fc1f | 342 | }, |
26056e0c | 343 | { /* end of list */ } |
1ed2fc1f JK |
344 | }, |
345 | }; | |
346 | ||
3329f07b | 347 | static QemuOptsList qemu_global_opts = { |
d0fef6fb GH |
348 | .name = "global", |
349 | .head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head), | |
350 | .desc = { | |
351 | { | |
352 | .name = "driver", | |
353 | .type = QEMU_OPT_STRING, | |
354 | },{ | |
355 | .name = "property", | |
356 | .type = QEMU_OPT_STRING, | |
357 | },{ | |
358 | .name = "value", | |
359 | .type = QEMU_OPT_STRING, | |
360 | }, | |
26056e0c | 361 | { /* end of list */ } |
d0fef6fb GH |
362 | }, |
363 | }; | |
364 | ||
7d76ad4f EO |
365 | QemuOptsList qemu_sandbox_opts = { |
366 | .name = "sandbox", | |
367 | .implied_opt_name = "enable", | |
368 | .head = QTAILQ_HEAD_INITIALIZER(qemu_sandbox_opts.head), | |
369 | .desc = { | |
370 | { | |
371 | .name = "enable", | |
372 | .type = QEMU_OPT_BOOL, | |
373 | }, | |
374 | { /* end of list */ } | |
375 | }, | |
376 | }; | |
377 | ||
3329f07b | 378 | static QemuOptsList qemu_mon_opts = { |
88589343 | 379 | .name = "mon", |
8212c64f | 380 | .implied_opt_name = "chardev", |
88589343 GH |
381 | .head = QTAILQ_HEAD_INITIALIZER(qemu_mon_opts.head), |
382 | .desc = { | |
383 | { | |
384 | .name = "mode", | |
385 | .type = QEMU_OPT_STRING, | |
386 | },{ | |
387 | .name = "chardev", | |
388 | .type = QEMU_OPT_STRING, | |
389 | },{ | |
390 | .name = "default", | |
391 | .type = QEMU_OPT_BOOL, | |
39eaab9a DB |
392 | },{ |
393 | .name = "pretty", | |
394 | .type = QEMU_OPT_BOOL, | |
88589343 | 395 | }, |
26056e0c | 396 | { /* end of list */ } |
88589343 GH |
397 | }, |
398 | }; | |
399 | ||
ab6540d5 PS |
400 | static QemuOptsList qemu_trace_opts = { |
401 | .name = "trace", | |
402 | .implied_opt_name = "trace", | |
403 | .head = QTAILQ_HEAD_INITIALIZER(qemu_trace_opts.head), | |
404 | .desc = { | |
405 | { | |
23d15e86 LV |
406 | .name = "events", |
407 | .type = QEMU_OPT_STRING, | |
408 | },{ | |
ab6540d5 PS |
409 | .name = "file", |
410 | .type = QEMU_OPT_STRING, | |
411 | }, | |
44bd6907 | 412 | { /* end of list */ } |
ab6540d5 PS |
413 | }, |
414 | }; | |
ab6540d5 | 415 | |
3329f07b | 416 | static QemuOptsList qemu_cpudef_opts = { |
b5ec5ce0 | 417 | .name = "cpudef", |
418 | .head = QTAILQ_HEAD_INITIALIZER(qemu_cpudef_opts.head), | |
419 | .desc = { | |
420 | { | |
421 | .name = "name", | |
422 | .type = QEMU_OPT_STRING, | |
423 | },{ | |
424 | .name = "level", | |
425 | .type = QEMU_OPT_NUMBER, | |
426 | },{ | |
427 | .name = "vendor", | |
428 | .type = QEMU_OPT_STRING, | |
429 | },{ | |
430 | .name = "family", | |
431 | .type = QEMU_OPT_NUMBER, | |
432 | },{ | |
433 | .name = "model", | |
434 | .type = QEMU_OPT_NUMBER, | |
435 | },{ | |
436 | .name = "stepping", | |
437 | .type = QEMU_OPT_NUMBER, | |
438 | },{ | |
439 | .name = "feature_edx", /* cpuid 0000_0001.edx */ | |
440 | .type = QEMU_OPT_STRING, | |
441 | },{ | |
442 | .name = "feature_ecx", /* cpuid 0000_0001.ecx */ | |
443 | .type = QEMU_OPT_STRING, | |
444 | },{ | |
445 | .name = "extfeature_edx", /* cpuid 8000_0001.edx */ | |
446 | .type = QEMU_OPT_STRING, | |
447 | },{ | |
448 | .name = "extfeature_ecx", /* cpuid 8000_0001.ecx */ | |
449 | .type = QEMU_OPT_STRING, | |
450 | },{ | |
451 | .name = "xlevel", | |
452 | .type = QEMU_OPT_NUMBER, | |
453 | },{ | |
454 | .name = "model_id", | |
455 | .type = QEMU_OPT_STRING, | |
456 | },{ | |
457 | .name = "vendor_override", | |
458 | .type = QEMU_OPT_NUMBER, | |
459 | }, | |
460 | { /* end of list */ } | |
461 | }, | |
462 | }; | |
463 | ||
29b0040b GH |
464 | QemuOptsList qemu_spice_opts = { |
465 | .name = "spice", | |
466 | .head = QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head), | |
467 | .desc = { | |
468 | { | |
469 | .name = "port", | |
470 | .type = QEMU_OPT_NUMBER, | |
c448e855 GH |
471 | },{ |
472 | .name = "tls-port", | |
473 | .type = QEMU_OPT_NUMBER, | |
333b0eeb GH |
474 | },{ |
475 | .name = "addr", | |
476 | .type = QEMU_OPT_STRING, | |
477 | },{ | |
478 | .name = "ipv4", | |
479 | .type = QEMU_OPT_BOOL, | |
480 | },{ | |
481 | .name = "ipv6", | |
482 | .type = QEMU_OPT_BOOL, | |
29b0040b GH |
483 | },{ |
484 | .name = "password", | |
485 | .type = QEMU_OPT_STRING, | |
486 | },{ | |
487 | .name = "disable-ticketing", | |
488 | .type = QEMU_OPT_BOOL, | |
d4970b07 HG |
489 | },{ |
490 | .name = "disable-copy-paste", | |
491 | .type = QEMU_OPT_BOOL, | |
48b3ed0a MAL |
492 | },{ |
493 | .name = "sasl", | |
494 | .type = QEMU_OPT_BOOL, | |
c448e855 GH |
495 | },{ |
496 | .name = "x509-dir", | |
497 | .type = QEMU_OPT_STRING, | |
498 | },{ | |
499 | .name = "x509-key-file", | |
500 | .type = QEMU_OPT_STRING, | |
501 | },{ | |
502 | .name = "x509-key-password", | |
503 | .type = QEMU_OPT_STRING, | |
504 | },{ | |
505 | .name = "x509-cert-file", | |
506 | .type = QEMU_OPT_STRING, | |
507 | },{ | |
508 | .name = "x509-cacert-file", | |
509 | .type = QEMU_OPT_STRING, | |
510 | },{ | |
511 | .name = "x509-dh-key-file", | |
512 | .type = QEMU_OPT_STRING, | |
513 | },{ | |
514 | .name = "tls-ciphers", | |
515 | .type = QEMU_OPT_STRING, | |
17b6dea0 GH |
516 | },{ |
517 | .name = "tls-channel", | |
518 | .type = QEMU_OPT_STRING, | |
519 | },{ | |
520 | .name = "plaintext-channel", | |
521 | .type = QEMU_OPT_STRING, | |
9f04e09e YH |
522 | },{ |
523 | .name = "image-compression", | |
524 | .type = QEMU_OPT_STRING, | |
525 | },{ | |
526 | .name = "jpeg-wan-compression", | |
527 | .type = QEMU_OPT_STRING, | |
528 | },{ | |
529 | .name = "zlib-glz-wan-compression", | |
530 | .type = QEMU_OPT_STRING, | |
84a23f25 GH |
531 | },{ |
532 | .name = "streaming-video", | |
533 | .type = QEMU_OPT_STRING, | |
534 | },{ | |
535 | .name = "agent-mouse", | |
536 | .type = QEMU_OPT_BOOL, | |
537 | },{ | |
538 | .name = "playback-compression", | |
539 | .type = QEMU_OPT_BOOL, | |
8c957053 YH |
540 | }, { |
541 | .name = "seamless-migration", | |
542 | .type = QEMU_OPT_BOOL, | |
29b0040b | 543 | }, |
44bd6907 | 544 | { /* end of list */ } |
29b0040b GH |
545 | }, |
546 | }; | |
547 | ||
2e55e842 GN |
548 | QemuOptsList qemu_option_rom_opts = { |
549 | .name = "option-rom", | |
550 | .implied_opt_name = "romfile", | |
551 | .head = QTAILQ_HEAD_INITIALIZER(qemu_option_rom_opts.head), | |
552 | .desc = { | |
553 | { | |
554 | .name = "bootindex", | |
555 | .type = QEMU_OPT_NUMBER, | |
556 | }, { | |
557 | .name = "romfile", | |
558 | .type = QEMU_OPT_STRING, | |
559 | }, | |
44bd6907 | 560 | { /* end of list */ } |
2e55e842 GN |
561 | }, |
562 | }; | |
563 | ||
303d4e86 AP |
564 | static QemuOptsList qemu_machine_opts = { |
565 | .name = "machine", | |
9052ea6b | 566 | .implied_opt_name = "type", |
9de36b1a | 567 | .merge_lists = true, |
303d4e86 AP |
568 | .head = QTAILQ_HEAD_INITIALIZER(qemu_machine_opts.head), |
569 | .desc = { | |
570 | { | |
9052ea6b JK |
571 | .name = "type", |
572 | .type = QEMU_OPT_STRING, | |
573 | .help = "emulated machine" | |
574 | }, { | |
303d4e86 AP |
575 | .name = "accel", |
576 | .type = QEMU_OPT_STRING, | |
577 | .help = "accelerator list", | |
6a48ffaa JK |
578 | }, { |
579 | .name = "kernel_irqchip", | |
580 | .type = QEMU_OPT_BOOL, | |
581 | .help = "use KVM in-kernel irqchip", | |
39d6960a JK |
582 | }, { |
583 | .name = "kvm_shadow_mem", | |
584 | .type = QEMU_OPT_SIZE, | |
585 | .help = "KVM shadow MMU size", | |
a0abe474 PM |
586 | }, { |
587 | .name = "kernel", | |
588 | .type = QEMU_OPT_STRING, | |
589 | .help = "Linux kernel image file", | |
590 | }, { | |
591 | .name = "initrd", | |
592 | .type = QEMU_OPT_STRING, | |
593 | .help = "Linux initial ramdisk file", | |
594 | }, { | |
595 | .name = "append", | |
596 | .type = QEMU_OPT_STRING, | |
597 | .help = "Linux kernel command line", | |
412beee6 GL |
598 | }, { |
599 | .name = "dtb", | |
600 | .type = QEMU_OPT_STRING, | |
601 | .help = "Linux kernel device tree file", | |
25b42708 AG |
602 | }, { |
603 | .name = "dumpdtb", | |
604 | .type = QEMU_OPT_STRING, | |
605 | .help = "Dump current dtb to a file and quit", | |
4b1b1c89 AG |
606 | }, { |
607 | .name = "phandle_start", | |
608 | .type = QEMU_OPT_STRING, | |
609 | .help = "The first phandle ID we may generate dynamically", | |
caedc737 AG |
610 | }, { |
611 | .name = "dt_compatible", | |
612 | .type = QEMU_OPT_STRING, | |
613 | .help = "Overrides the \"compatible\" property of the dt root node", | |
ddb97f1d JB |
614 | }, { |
615 | .name = "dump-guest-core", | |
616 | .type = QEMU_OPT_BOOL, | |
617 | .help = "Include guest memory in a core dump", | |
8490fc78 LC |
618 | }, { |
619 | .name = "mem-merge", | |
620 | .type = QEMU_OPT_BOOL, | |
621 | .help = "enable/disable memory merge support", | |
303d4e86 AP |
622 | }, |
623 | { /* End of list */ } | |
624 | }, | |
625 | }; | |
626 | ||
3d3b8303 WX |
627 | QemuOptsList qemu_boot_opts = { |
628 | .name = "boot-opts", | |
629 | .head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head), | |
630 | .desc = { | |
631 | /* the three names below are not used now */ | |
632 | { | |
633 | .name = "order", | |
634 | .type = QEMU_OPT_STRING, | |
635 | }, { | |
636 | .name = "once", | |
637 | .type = QEMU_OPT_STRING, | |
638 | }, { | |
639 | .name = "menu", | |
640 | .type = QEMU_OPT_STRING, | |
641 | /* following are really used */ | |
642 | }, { | |
643 | .name = "splash", | |
644 | .type = QEMU_OPT_STRING, | |
645 | }, { | |
646 | .name = "splash-time", | |
647 | .type = QEMU_OPT_STRING, | |
648 | }, | |
649 | { /*End of list */ } | |
650 | }, | |
651 | }; | |
652 | ||
dfe795e7 | 653 | static QemuOptsList *vm_config_groups[32] = { |
d058fe03 | 654 | &qemu_drive_opts, |
191bc01b | 655 | &qemu_chardev_opts, |
f31d07d1 | 656 | &qemu_device_opts, |
a1ea458f | 657 | &qemu_netdev_opts, |
8119b33d | 658 | &qemu_net_opts, |
5fdfbf7e | 659 | &qemu_rtc_opts, |
d0fef6fb | 660 | &qemu_global_opts, |
88589343 | 661 | &qemu_mon_opts, |
b5ec5ce0 | 662 | &qemu_cpudef_opts, |
ab6540d5 | 663 | &qemu_trace_opts, |
2e55e842 | 664 | &qemu_option_rom_opts, |
303d4e86 | 665 | &qemu_machine_opts, |
3d3b8303 | 666 | &qemu_boot_opts, |
f9dadc98 | 667 | &qemu_iscsi_opts, |
7d76ad4f | 668 | &qemu_sandbox_opts, |
d058fe03 GH |
669 | NULL, |
670 | }; | |
671 | ||
2ac20613 LC |
672 | static QemuOptsList *find_list(QemuOptsList **lists, const char *group, |
673 | Error **errp) | |
ddc97855 GH |
674 | { |
675 | int i; | |
676 | ||
677 | for (i = 0; lists[i] != NULL; i++) { | |
678 | if (strcmp(lists[i]->name, group) == 0) | |
679 | break; | |
680 | } | |
681 | if (lists[i] == NULL) { | |
2ac20613 | 682 | error_set(errp, QERR_INVALID_OPTION_GROUP, group); |
ddc97855 GH |
683 | } |
684 | return lists[i]; | |
685 | } | |
686 | ||
490b648e KW |
687 | QemuOptsList *qemu_find_opts(const char *group) |
688 | { | |
2ac20613 LC |
689 | QemuOptsList *ret; |
690 | Error *local_err = NULL; | |
691 | ||
692 | ret = find_list(vm_config_groups, group, &local_err); | |
693 | if (error_is_set(&local_err)) { | |
694 | error_report("%s\n", error_get_pretty(local_err)); | |
695 | error_free(local_err); | |
696 | } | |
697 | ||
698 | return ret; | |
490b648e KW |
699 | } |
700 | ||
60d5666f LC |
701 | QemuOptsList *qemu_find_opts_err(const char *group, Error **errp) |
702 | { | |
703 | return find_list(vm_config_groups, group, errp); | |
704 | } | |
705 | ||
dfe795e7 GH |
706 | void qemu_add_opts(QemuOptsList *list) |
707 | { | |
708 | int entries, i; | |
709 | ||
710 | entries = ARRAY_SIZE(vm_config_groups); | |
711 | entries--; /* keep list NULL terminated */ | |
712 | for (i = 0; i < entries; i++) { | |
713 | if (vm_config_groups[i] == NULL) { | |
714 | vm_config_groups[i] = list; | |
715 | return; | |
716 | } | |
717 | } | |
718 | fprintf(stderr, "ran out of space in vm_config_groups"); | |
719 | abort(); | |
720 | } | |
721 | ||
d058fe03 GH |
722 | int qemu_set_option(const char *str) |
723 | { | |
724 | char group[64], id[64], arg[64]; | |
ddc97855 | 725 | QemuOptsList *list; |
d058fe03 | 726 | QemuOpts *opts; |
ddc97855 | 727 | int rc, offset; |
d058fe03 GH |
728 | |
729 | rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset); | |
730 | if (rc < 3 || str[offset] != '=') { | |
1ecda02b | 731 | error_report("can't parse: \"%s\"", str); |
d058fe03 GH |
732 | return -1; |
733 | } | |
734 | ||
304329ee | 735 | list = qemu_find_opts(group); |
ddc97855 | 736 | if (list == NULL) { |
d058fe03 GH |
737 | return -1; |
738 | } | |
739 | ||
ddc97855 | 740 | opts = qemu_opts_find(list, id); |
d058fe03 | 741 | if (!opts) { |
1ecda02b MA |
742 | error_report("there is no %s \"%s\" defined", |
743 | list->name, id); | |
d058fe03 GH |
744 | return -1; |
745 | } | |
746 | ||
3df04ac3 | 747 | if (qemu_opt_set(opts, arg, str+offset+1) == -1) { |
d058fe03 GH |
748 | return -1; |
749 | } | |
750 | return 0; | |
751 | } | |
752 | ||
d0fef6fb GH |
753 | int qemu_global_option(const char *str) |
754 | { | |
755 | char driver[64], property[64]; | |
756 | QemuOpts *opts; | |
757 | int rc, offset; | |
758 | ||
759 | rc = sscanf(str, "%63[^.].%63[^=]%n", driver, property, &offset); | |
760 | if (rc < 2 || str[offset] != '=') { | |
1ecda02b | 761 | error_report("can't parse: \"%s\"", str); |
d0fef6fb GH |
762 | return -1; |
763 | } | |
764 | ||
8be7e7e4 | 765 | opts = qemu_opts_create(&qemu_global_opts, NULL, 0, NULL); |
d0fef6fb GH |
766 | qemu_opt_set(opts, "driver", driver); |
767 | qemu_opt_set(opts, "property", property); | |
768 | qemu_opt_set(opts, "value", str+offset+1); | |
769 | return 0; | |
770 | } | |
771 | ||
9d993394 GH |
772 | struct ConfigWriteData { |
773 | QemuOptsList *list; | |
774 | FILE *fp; | |
775 | }; | |
776 | ||
777 | static int config_write_opt(const char *name, const char *value, void *opaque) | |
778 | { | |
779 | struct ConfigWriteData *data = opaque; | |
780 | ||
781 | fprintf(data->fp, " %s = \"%s\"\n", name, value); | |
782 | return 0; | |
783 | } | |
784 | ||
785 | static int config_write_opts(QemuOpts *opts, void *opaque) | |
786 | { | |
787 | struct ConfigWriteData *data = opaque; | |
788 | const char *id = qemu_opts_id(opts); | |
789 | ||
790 | if (id) { | |
791 | fprintf(data->fp, "[%s \"%s\"]\n", data->list->name, id); | |
792 | } else { | |
793 | fprintf(data->fp, "[%s]\n", data->list->name); | |
794 | } | |
795 | qemu_opt_foreach(opts, config_write_opt, data, 0); | |
796 | fprintf(data->fp, "\n"); | |
797 | return 0; | |
798 | } | |
799 | ||
800 | void qemu_config_write(FILE *fp) | |
801 | { | |
802 | struct ConfigWriteData data = { .fp = fp }; | |
490b648e | 803 | QemuOptsList **lists = vm_config_groups; |
9d993394 GH |
804 | int i; |
805 | ||
806 | fprintf(fp, "# qemu config file\n\n"); | |
807 | for (i = 0; lists[i] != NULL; i++) { | |
808 | data.list = lists[i]; | |
809 | qemu_opts_foreach(data.list, config_write_opts, &data, 0); | |
810 | } | |
811 | } | |
42262ba8 | 812 | |
490b648e | 813 | int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname) |
42262ba8 GH |
814 | { |
815 | char line[1024], group[64], id[64], arg[64], value[1024]; | |
cf5a65aa | 816 | Location loc; |
42262ba8 | 817 | QemuOptsList *list = NULL; |
2ac20613 | 818 | Error *local_err = NULL; |
42262ba8 | 819 | QemuOpts *opts = NULL; |
cf5a65aa | 820 | int res = -1, lno = 0; |
42262ba8 | 821 | |
cf5a65aa | 822 | loc_push_none(&loc); |
42262ba8 | 823 | while (fgets(line, sizeof(line), fp) != NULL) { |
cf5a65aa | 824 | loc_set_file(fname, ++lno); |
42262ba8 GH |
825 | if (line[0] == '\n') { |
826 | /* skip empty lines */ | |
827 | continue; | |
828 | } | |
829 | if (line[0] == '#') { | |
830 | /* comment */ | |
831 | continue; | |
832 | } | |
833 | if (sscanf(line, "[%63s \"%63[^\"]\"]", group, id) == 2) { | |
834 | /* group with id */ | |
2ac20613 LC |
835 | list = find_list(lists, group, &local_err); |
836 | if (error_is_set(&local_err)) { | |
837 | error_report("%s\n", error_get_pretty(local_err)); | |
838 | error_free(local_err); | |
cf5a65aa | 839 | goto out; |
2ac20613 | 840 | } |
8be7e7e4 | 841 | opts = qemu_opts_create(list, id, 1, NULL); |
42262ba8 GH |
842 | continue; |
843 | } | |
844 | if (sscanf(line, "[%63[^]]]", group) == 1) { | |
845 | /* group without id */ | |
2ac20613 LC |
846 | list = find_list(lists, group, &local_err); |
847 | if (error_is_set(&local_err)) { | |
848 | error_report("%s\n", error_get_pretty(local_err)); | |
849 | error_free(local_err); | |
cf5a65aa | 850 | goto out; |
2ac20613 | 851 | } |
8be7e7e4 | 852 | opts = qemu_opts_create(list, NULL, 0, NULL); |
42262ba8 GH |
853 | continue; |
854 | } | |
855 | if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) { | |
856 | /* arg = value */ | |
857 | if (opts == NULL) { | |
cf5a65aa MA |
858 | error_report("no group defined"); |
859 | goto out; | |
42262ba8 GH |
860 | } |
861 | if (qemu_opt_set(opts, arg, value) != 0) { | |
cf5a65aa | 862 | goto out; |
42262ba8 GH |
863 | } |
864 | continue; | |
865 | } | |
cf5a65aa MA |
866 | error_report("parse error"); |
867 | goto out; | |
42262ba8 | 868 | } |
ef82516d MA |
869 | if (ferror(fp)) { |
870 | error_report("error reading file"); | |
871 | goto out; | |
872 | } | |
cf5a65aa MA |
873 | res = 0; |
874 | out: | |
875 | loc_pop(&loc); | |
876 | return res; | |
42262ba8 | 877 | } |
dcfb0939 KW |
878 | |
879 | int qemu_read_config_file(const char *filename) | |
880 | { | |
881 | FILE *f = fopen(filename, "r"); | |
019e78ba KW |
882 | int ret; |
883 | ||
dcfb0939 KW |
884 | if (f == NULL) { |
885 | return -errno; | |
886 | } | |
887 | ||
019e78ba | 888 | ret = qemu_config_parse(f, vm_config_groups, filename); |
dcfb0939 KW |
889 | fclose(f); |
890 | ||
019e78ba KW |
891 | if (ret == 0) { |
892 | return 0; | |
893 | } else { | |
894 | return -EINVAL; | |
895 | } | |
dcfb0939 | 896 | } |