1 #include "qemu-common.h"
2 #include "qemu-option.h"
3 #include "qemu-config.h"
5 QemuOptsList qemu_drive_opts
= {
7 .head
= QTAILQ_HEAD_INITIALIZER(qemu_drive_opts
.head
),
11 .type
= QEMU_OPT_NUMBER
,
15 .type
= QEMU_OPT_NUMBER
,
16 .help
= "unit number (i.e. lun for scsi)",
19 .type
= QEMU_OPT_STRING
,
20 .help
= "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
23 .type
= QEMU_OPT_NUMBER
,
26 .type
= QEMU_OPT_NUMBER
,
27 .help
= "number of cylinders (ide disk geometry)",
30 .type
= QEMU_OPT_NUMBER
,
31 .help
= "number of heads (ide disk geometry)",
34 .type
= QEMU_OPT_NUMBER
,
35 .help
= "number of sectors (ide disk geometry)",
38 .type
= QEMU_OPT_STRING
,
39 .help
= "chs translation (auto, lba. none)",
42 .type
= QEMU_OPT_STRING
,
43 .help
= "media type (disk, cdrom)",
46 .type
= QEMU_OPT_BOOL
,
49 .type
= QEMU_OPT_STRING
,
53 .type
= QEMU_OPT_STRING
,
54 .help
= "host cache usage (none, writeback, writethrough)",
57 .type
= QEMU_OPT_STRING
,
58 .help
= "host AIO implementation (threads, native)",
61 .type
= QEMU_OPT_STRING
,
62 .help
= "disk format (raw, qcow2, ...)",
65 .type
= QEMU_OPT_STRING
,
68 .type
= QEMU_OPT_STRING
,
71 .type
= QEMU_OPT_STRING
,
72 .help
= "pci address (virtio only)",
78 QemuOptsList qemu_chardev_opts
= {
80 .head
= QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts
.head
),
84 .type
= QEMU_OPT_STRING
,
87 .type
= QEMU_OPT_STRING
,
90 .type
= QEMU_OPT_STRING
,
93 .type
= QEMU_OPT_STRING
,
96 .type
= QEMU_OPT_STRING
,
99 .type
= QEMU_OPT_STRING
,
102 .type
= QEMU_OPT_NUMBER
,
105 .type
= QEMU_OPT_BOOL
,
108 .type
= QEMU_OPT_BOOL
,
111 .type
= QEMU_OPT_BOOL
,
114 .type
= QEMU_OPT_BOOL
,
117 .type
= QEMU_OPT_BOOL
,
120 .type
= QEMU_OPT_BOOL
,
123 .type
= QEMU_OPT_NUMBER
,
126 .type
= QEMU_OPT_NUMBER
,
129 .type
= QEMU_OPT_NUMBER
,
132 .type
= QEMU_OPT_NUMBER
,
135 .type
= QEMU_OPT_BOOL
,
137 { /* end if list */ }
141 QemuOptsList qemu_device_opts
= {
143 .head
= QTAILQ_HEAD_INITIALIZER(qemu_device_opts
.head
),
146 * no elements => accept any
147 * sanity checking will happen later
148 * when setting device properties
150 { /* end if list */ }
154 QemuOptsList qemu_rtc_opts
= {
156 .head
= QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts
.head
),
160 .type
= QEMU_OPT_STRING
,
163 .type
= QEMU_OPT_STRING
,
167 .type
= QEMU_OPT_STRING
,
170 { /* end if list */ }
174 static QemuOptsList
*lists
[] = {
181 int qemu_set_option(const char *str
)
183 char group
[64], id
[64], arg
[64];
187 rc
= sscanf(str
, "%63[^.].%63[^.].%63[^=]%n", group
, id
, arg
, &offset
);
188 if (rc
< 3 || str
[offset
] != '=') {
189 fprintf(stderr
, "can't parse: \"%s\"\n", str
);
193 for (i
= 0; lists
[i
] != NULL
; i
++) {
194 if (strcmp(lists
[i
]->name
, group
) == 0)
197 if (lists
[i
] == NULL
) {
198 fprintf(stderr
, "there is no option group \"%s\"\n", group
);
202 opts
= qemu_opts_find(lists
[i
], id
);
204 fprintf(stderr
, "there is no %s \"%s\" defined\n",
209 if (qemu_opt_set(opts
, arg
, str
+offset
+1) == -1) {
210 fprintf(stderr
, "failed to set \"%s\" for %s \"%s\"\n",
211 arg
, lists
[i
]->name
, id
);