1 #include "qemu-common.h"
2 #include "qemu-option.h"
3 #include "qemu-config.h"
6 QemuOptsList qemu_drive_opts
= {
8 .head
= QTAILQ_HEAD_INITIALIZER(qemu_drive_opts
.head
),
12 .type
= QEMU_OPT_NUMBER
,
16 .type
= QEMU_OPT_NUMBER
,
17 .help
= "unit number (i.e. lun for scsi)",
20 .type
= QEMU_OPT_STRING
,
21 .help
= "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
24 .type
= QEMU_OPT_NUMBER
,
27 .type
= QEMU_OPT_NUMBER
,
28 .help
= "number of cylinders (ide disk geometry)",
31 .type
= QEMU_OPT_NUMBER
,
32 .help
= "number of heads (ide disk geometry)",
35 .type
= QEMU_OPT_NUMBER
,
36 .help
= "number of sectors (ide disk geometry)",
39 .type
= QEMU_OPT_STRING
,
40 .help
= "chs translation (auto, lba. none)",
43 .type
= QEMU_OPT_STRING
,
44 .help
= "media type (disk, cdrom)",
47 .type
= QEMU_OPT_BOOL
,
50 .type
= QEMU_OPT_STRING
,
54 .type
= QEMU_OPT_STRING
,
55 .help
= "host cache usage (none, writeback, writethrough)",
58 .type
= QEMU_OPT_STRING
,
59 .help
= "host AIO implementation (threads, native)",
62 .type
= QEMU_OPT_STRING
,
63 .help
= "disk format (raw, qcow2, ...)",
66 .type
= QEMU_OPT_STRING
,
69 .type
= QEMU_OPT_STRING
,
72 .type
= QEMU_OPT_STRING
,
73 .help
= "pci address (virtio only)",
76 .type
= QEMU_OPT_BOOL
,
77 .help
= "make this a boot drive",
83 QemuOptsList qemu_chardev_opts
= {
85 .head
= QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts
.head
),
89 .type
= QEMU_OPT_STRING
,
92 .type
= QEMU_OPT_STRING
,
95 .type
= QEMU_OPT_STRING
,
98 .type
= QEMU_OPT_STRING
,
101 .type
= QEMU_OPT_STRING
,
104 .type
= QEMU_OPT_STRING
,
107 .type
= QEMU_OPT_NUMBER
,
110 .type
= QEMU_OPT_BOOL
,
113 .type
= QEMU_OPT_BOOL
,
116 .type
= QEMU_OPT_BOOL
,
119 .type
= QEMU_OPT_BOOL
,
122 .type
= QEMU_OPT_BOOL
,
125 .type
= QEMU_OPT_BOOL
,
128 .type
= QEMU_OPT_NUMBER
,
131 .type
= QEMU_OPT_NUMBER
,
134 .type
= QEMU_OPT_NUMBER
,
137 .type
= QEMU_OPT_NUMBER
,
140 .type
= QEMU_OPT_BOOL
,
142 { /* end if list */ }
146 QemuOptsList qemu_device_opts
= {
148 .head
= QTAILQ_HEAD_INITIALIZER(qemu_device_opts
.head
),
151 * no elements => accept any
152 * sanity checking will happen later
153 * when setting device properties
155 { /* end if list */ }
159 QemuOptsList qemu_netdev_opts
= {
161 .head
= QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts
.head
),
164 * no elements => accept any params
165 * validation will happen later
167 { /* end of list */ }
171 QemuOptsList qemu_net_opts
= {
173 .head
= QTAILQ_HEAD_INITIALIZER(qemu_net_opts
.head
),
176 * no elements => accept any params
177 * validation will happen later
179 { /* end of list */ }
183 QemuOptsList qemu_rtc_opts
= {
185 .head
= QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts
.head
),
189 .type
= QEMU_OPT_STRING
,
192 .type
= QEMU_OPT_STRING
,
196 .type
= QEMU_OPT_STRING
,
199 { /* end if list */ }
203 static QemuOptsList
*lists
[] = {
213 int qemu_set_option(const char *str
)
215 char group
[64], id
[64], arg
[64];
219 rc
= sscanf(str
, "%63[^.].%63[^.].%63[^=]%n", group
, id
, arg
, &offset
);
220 if (rc
< 3 || str
[offset
] != '=') {
221 qemu_error("can't parse: \"%s\"\n", str
);
225 for (i
= 0; lists
[i
] != NULL
; i
++) {
226 if (strcmp(lists
[i
]->name
, group
) == 0)
229 if (lists
[i
] == NULL
) {
230 qemu_error("there is no option group \"%s\"\n", group
);
234 opts
= qemu_opts_find(lists
[i
], id
);
236 qemu_error("there is no %s \"%s\" defined\n",
241 if (qemu_opt_set(opts
, arg
, str
+offset
+1) == -1) {