]>
Commit | Line | Data |
---|---|---|
7282a033 GH |
1 | #include "qemu-common.h" |
2 | #include "qemu-option.h" | |
3 | #include "qemu-config.h" | |
a861c453 | 4 | #include "sysemu.h" |
7282a033 GH |
5 | |
6 | QemuOptsList qemu_drive_opts = { | |
7 | .name = "drive", | |
72cf2d4f | 8 | .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head), |
7282a033 GH |
9 | .desc = { |
10 | { | |
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)", | |
5c6c3a6c CH |
56 | },{ |
57 | .name = "aio", | |
58 | .type = QEMU_OPT_STRING, | |
59 | .help = "host AIO implementation (threads, native)", | |
7282a033 GH |
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 | { /* end if list */ } | |
76 | }, | |
77 | }; | |
78 | ||
191bc01b GH |
79 | QemuOptsList qemu_chardev_opts = { |
80 | .name = "chardev", | |
72cf2d4f | 81 | .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head), |
191bc01b | 82 | .desc = { |
7d31544f GH |
83 | { |
84 | .name = "backend", | |
85 | .type = QEMU_OPT_STRING, | |
86 | },{ | |
87 | .name = "path", | |
88 | .type = QEMU_OPT_STRING, | |
aeb2c47a GH |
89 | },{ |
90 | .name = "host", | |
91 | .type = QEMU_OPT_STRING, | |
92 | },{ | |
93 | .name = "port", | |
94 | .type = QEMU_OPT_STRING, | |
7e1b35b4 GH |
95 | },{ |
96 | .name = "localaddr", | |
97 | .type = QEMU_OPT_STRING, | |
98 | },{ | |
99 | .name = "localport", | |
100 | .type = QEMU_OPT_STRING, | |
aeb2c47a GH |
101 | },{ |
102 | .name = "to", | |
103 | .type = QEMU_OPT_NUMBER, | |
104 | },{ | |
105 | .name = "ipv4", | |
106 | .type = QEMU_OPT_BOOL, | |
107 | },{ | |
108 | .name = "ipv6", | |
109 | .type = QEMU_OPT_BOOL, | |
110 | },{ | |
111 | .name = "wait", | |
112 | .type = QEMU_OPT_BOOL, | |
113 | },{ | |
114 | .name = "server", | |
115 | .type = QEMU_OPT_BOOL, | |
116 | },{ | |
117 | .name = "delay", | |
118 | .type = QEMU_OPT_BOOL, | |
119 | },{ | |
120 | .name = "telnet", | |
121 | .type = QEMU_OPT_BOOL, | |
6ea314d9 GH |
122 | },{ |
123 | .name = "width", | |
124 | .type = QEMU_OPT_NUMBER, | |
125 | },{ | |
126 | .name = "height", | |
127 | .type = QEMU_OPT_NUMBER, | |
128 | },{ | |
129 | .name = "cols", | |
130 | .type = QEMU_OPT_NUMBER, | |
131 | },{ | |
132 | .name = "rows", | |
133 | .type = QEMU_OPT_NUMBER, | |
c845f401 GH |
134 | },{ |
135 | .name = "mux", | |
136 | .type = QEMU_OPT_BOOL, | |
5989020b KK |
137 | },{ |
138 | .name = "signal", | |
139 | .type = QEMU_OPT_BOOL, | |
7d31544f | 140 | }, |
191bc01b GH |
141 | { /* end if list */ } |
142 | }, | |
143 | }; | |
144 | ||
f31d07d1 GH |
145 | QemuOptsList qemu_device_opts = { |
146 | .name = "device", | |
72cf2d4f | 147 | .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head), |
f31d07d1 GH |
148 | .desc = { |
149 | /* | |
150 | * no elements => accept any | |
151 | * sanity checking will happen later | |
152 | * when setting device properties | |
153 | */ | |
154 | { /* end if list */ } | |
155 | }, | |
156 | }; | |
157 | ||
a1ea458f MM |
158 | QemuOptsList qemu_netdev_opts = { |
159 | .name = "netdev", | |
160 | .head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head), | |
161 | .desc = { | |
162 | /* | |
163 | * no elements => accept any params | |
164 | * validation will happen later | |
165 | */ | |
166 | { /* end of list */ } | |
167 | }, | |
168 | }; | |
169 | ||
8119b33d MM |
170 | QemuOptsList qemu_net_opts = { |
171 | .name = "net", | |
172 | .head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head), | |
173 | .desc = { | |
174 | /* | |
175 | * no elements => accept any params | |
176 | * validation will happen later | |
177 | */ | |
178 | { /* end of list */ } | |
179 | }, | |
180 | }; | |
181 | ||
1ed2fc1f JK |
182 | QemuOptsList qemu_rtc_opts = { |
183 | .name = "rtc", | |
184 | .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head), | |
185 | .desc = { | |
186 | { | |
187 | .name = "base", | |
188 | .type = QEMU_OPT_STRING, | |
6875204c JK |
189 | },{ |
190 | .name = "clock", | |
191 | .type = QEMU_OPT_STRING, | |
1ed2fc1f JK |
192 | #ifdef TARGET_I386 |
193 | },{ | |
194 | .name = "driftfix", | |
195 | .type = QEMU_OPT_STRING, | |
196 | #endif | |
197 | }, | |
198 | { /* end if list */ } | |
199 | }, | |
200 | }; | |
201 | ||
d058fe03 GH |
202 | static QemuOptsList *lists[] = { |
203 | &qemu_drive_opts, | |
191bc01b | 204 | &qemu_chardev_opts, |
f31d07d1 | 205 | &qemu_device_opts, |
a1ea458f | 206 | &qemu_netdev_opts, |
8119b33d | 207 | &qemu_net_opts, |
5fdfbf7e | 208 | &qemu_rtc_opts, |
d058fe03 GH |
209 | NULL, |
210 | }; | |
211 | ||
212 | int qemu_set_option(const char *str) | |
213 | { | |
214 | char group[64], id[64], arg[64]; | |
215 | QemuOpts *opts; | |
216 | int i, rc, offset; | |
217 | ||
218 | rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset); | |
219 | if (rc < 3 || str[offset] != '=') { | |
a861c453 | 220 | qemu_error("can't parse: \"%s\"\n", str); |
d058fe03 GH |
221 | return -1; |
222 | } | |
223 | ||
224 | for (i = 0; lists[i] != NULL; i++) { | |
225 | if (strcmp(lists[i]->name, group) == 0) | |
226 | break; | |
227 | } | |
228 | if (lists[i] == NULL) { | |
a861c453 | 229 | qemu_error("there is no option group \"%s\"\n", group); |
d058fe03 GH |
230 | return -1; |
231 | } | |
232 | ||
233 | opts = qemu_opts_find(lists[i], id); | |
234 | if (!opts) { | |
a861c453 | 235 | qemu_error("there is no %s \"%s\" defined\n", |
d058fe03 GH |
236 | lists[i]->name, id); |
237 | return -1; | |
238 | } | |
239 | ||
3df04ac3 | 240 | if (qemu_opt_set(opts, arg, str+offset+1) == -1) { |
d058fe03 GH |
241 | return -1; |
242 | } | |
243 | return 0; | |
244 | } | |
245 |