e1000: intermediate merge fixup
[qemu-kvm/markmc.git] / qemu-config.c
blob4fb7898113736e680271eed7d107b552f6fd0244
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)",
74 },{
75 .name = "boot",
76 .type = QEMU_OPT_BOOL,
77 .help = "make this a boot drive",
79 { /* end if list */ }
83 QemuOptsList qemu_chardev_opts = {
84 .name = "chardev",
85 .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head),
86 .desc = {
88 .name = "backend",
89 .type = QEMU_OPT_STRING,
90 },{
91 .name = "path",
92 .type = QEMU_OPT_STRING,
93 },{
94 .name = "host",
95 .type = QEMU_OPT_STRING,
96 },{
97 .name = "port",
98 .type = QEMU_OPT_STRING,
99 },{
100 .name = "localaddr",
101 .type = QEMU_OPT_STRING,
103 .name = "localport",
104 .type = QEMU_OPT_STRING,
106 .name = "to",
107 .type = QEMU_OPT_NUMBER,
109 .name = "ipv4",
110 .type = QEMU_OPT_BOOL,
112 .name = "ipv6",
113 .type = QEMU_OPT_BOOL,
115 .name = "wait",
116 .type = QEMU_OPT_BOOL,
118 .name = "server",
119 .type = QEMU_OPT_BOOL,
121 .name = "delay",
122 .type = QEMU_OPT_BOOL,
124 .name = "telnet",
125 .type = QEMU_OPT_BOOL,
127 .name = "width",
128 .type = QEMU_OPT_NUMBER,
130 .name = "height",
131 .type = QEMU_OPT_NUMBER,
133 .name = "cols",
134 .type = QEMU_OPT_NUMBER,
136 .name = "rows",
137 .type = QEMU_OPT_NUMBER,
139 .name = "mux",
140 .type = QEMU_OPT_BOOL,
142 { /* end if list */ }
146 QemuOptsList qemu_device_opts = {
147 .name = "device",
148 .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head),
149 .desc = {
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 = {
160 .name = "netdev",
161 .head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head),
162 .desc = {
164 * no elements => accept any params
165 * validation will happen later
167 { /* end of list */ }
171 QemuOptsList qemu_net_opts = {
172 .name = "net",
173 .head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head),
174 .desc = {
176 * no elements => accept any params
177 * validation will happen later
179 { /* end of list */ }
183 QemuOptsList qemu_rtc_opts = {
184 .name = "rtc",
185 .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head),
186 .desc = {
188 .name = "base",
189 .type = QEMU_OPT_STRING,
191 .name = "clock",
192 .type = QEMU_OPT_STRING,
193 #ifdef TARGET_I386
195 .name = "driftfix",
196 .type = QEMU_OPT_STRING,
197 #endif
199 { /* end if list */ }
203 static QemuOptsList *lists[] = {
204 &qemu_drive_opts,
205 &qemu_chardev_opts,
206 &qemu_device_opts,
207 &qemu_netdev_opts,
208 &qemu_net_opts,
209 &qemu_rtc_opts,
210 NULL,
213 int qemu_set_option(const char *str)
215 char group[64], id[64], arg[64];
216 QemuOpts *opts;
217 int i, rc, offset;
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);
222 return -1;
225 for (i = 0; lists[i] != NULL; i++) {
226 if (strcmp(lists[i]->name, group) == 0)
227 break;
229 if (lists[i] == NULL) {
230 qemu_error("there is no option group \"%s\"\n", group);
231 return -1;
234 opts = qemu_opts_find(lists[i], id);
235 if (!opts) {
236 qemu_error("there is no %s \"%s\" defined\n",
237 lists[i]->name, id);
238 return -1;
241 if (qemu_opt_set(opts, arg, str+offset+1) == -1) {
242 return -1;
244 return 0;