root / qemu-config.c @ b53d44e5
History | View | Annotate | Download (5.1 kB)
1 | 7282a033 | Gerd Hoffmann | #include "qemu-common.h" |
---|---|---|---|
2 | 7282a033 | Gerd Hoffmann | #include "qemu-option.h" |
3 | 7282a033 | Gerd Hoffmann | #include "qemu-config.h" |
4 | 7282a033 | Gerd Hoffmann | |
5 | 7282a033 | Gerd Hoffmann | QemuOptsList qemu_drive_opts = { |
6 | 7282a033 | Gerd Hoffmann | .name = "drive",
|
7 | 72cf2d4f | Blue Swirl | .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head), |
8 | 7282a033 | Gerd Hoffmann | .desc = { |
9 | 7282a033 | Gerd Hoffmann | { |
10 | 7282a033 | Gerd Hoffmann | .name = "bus",
|
11 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
12 | 7282a033 | Gerd Hoffmann | .help = "bus number",
|
13 | 7282a033 | Gerd Hoffmann | },{ |
14 | 7282a033 | Gerd Hoffmann | .name = "unit",
|
15 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
16 | 7282a033 | Gerd Hoffmann | .help = "unit number (i.e. lun for scsi)",
|
17 | 7282a033 | Gerd Hoffmann | },{ |
18 | 7282a033 | Gerd Hoffmann | .name = "if",
|
19 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
20 | 7282a033 | Gerd Hoffmann | .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
|
21 | 7282a033 | Gerd Hoffmann | },{ |
22 | 7282a033 | Gerd Hoffmann | .name = "index",
|
23 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
24 | 7282a033 | Gerd Hoffmann | },{ |
25 | 7282a033 | Gerd Hoffmann | .name = "cyls",
|
26 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
27 | 7282a033 | Gerd Hoffmann | .help = "number of cylinders (ide disk geometry)",
|
28 | 7282a033 | Gerd Hoffmann | },{ |
29 | 7282a033 | Gerd Hoffmann | .name = "heads",
|
30 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
31 | 7282a033 | Gerd Hoffmann | .help = "number of heads (ide disk geometry)",
|
32 | 7282a033 | Gerd Hoffmann | },{ |
33 | 7282a033 | Gerd Hoffmann | .name = "secs",
|
34 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
35 | 7282a033 | Gerd Hoffmann | .help = "number of sectors (ide disk geometry)",
|
36 | 7282a033 | Gerd Hoffmann | },{ |
37 | 7282a033 | Gerd Hoffmann | .name = "trans",
|
38 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
39 | 7282a033 | Gerd Hoffmann | .help = "chs translation (auto, lba. none)",
|
40 | 7282a033 | Gerd Hoffmann | },{ |
41 | 7282a033 | Gerd Hoffmann | .name = "media",
|
42 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
43 | 7282a033 | Gerd Hoffmann | .help = "media type (disk, cdrom)",
|
44 | 7282a033 | Gerd Hoffmann | },{ |
45 | 7282a033 | Gerd Hoffmann | .name = "snapshot",
|
46 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_BOOL, |
47 | 7282a033 | Gerd Hoffmann | },{ |
48 | 7282a033 | Gerd Hoffmann | .name = "file",
|
49 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
50 | 7282a033 | Gerd Hoffmann | .help = "disk image",
|
51 | 7282a033 | Gerd Hoffmann | },{ |
52 | 7282a033 | Gerd Hoffmann | .name = "cache",
|
53 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
54 | 7282a033 | Gerd Hoffmann | .help = "host cache usage (none, writeback, writethrough)",
|
55 | 7282a033 | Gerd Hoffmann | },{ |
56 | 5c6c3a6c | Christoph Hellwig | .name = "aio",
|
57 | 5c6c3a6c | Christoph Hellwig | .type = QEMU_OPT_STRING, |
58 | 5c6c3a6c | Christoph Hellwig | .help = "host AIO implementation (threads, native)",
|
59 | 5c6c3a6c | Christoph Hellwig | },{ |
60 | 7282a033 | Gerd Hoffmann | .name = "format",
|
61 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
62 | 7282a033 | Gerd Hoffmann | .help = "disk format (raw, qcow2, ...)",
|
63 | 7282a033 | Gerd Hoffmann | },{ |
64 | 7282a033 | Gerd Hoffmann | .name = "serial",
|
65 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
66 | 7282a033 | Gerd Hoffmann | },{ |
67 | 7282a033 | Gerd Hoffmann | .name = "werror",
|
68 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
69 | 7282a033 | Gerd Hoffmann | },{ |
70 | 7282a033 | Gerd Hoffmann | .name = "addr",
|
71 | 7282a033 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
72 | 7282a033 | Gerd Hoffmann | .help = "pci address (virtio only)",
|
73 | 7282a033 | Gerd Hoffmann | }, |
74 | 7282a033 | Gerd Hoffmann | { /* end if list */ }
|
75 | 7282a033 | Gerd Hoffmann | }, |
76 | 7282a033 | Gerd Hoffmann | }; |
77 | 7282a033 | Gerd Hoffmann | |
78 | 191bc01b | Gerd Hoffmann | QemuOptsList qemu_chardev_opts = { |
79 | 191bc01b | Gerd Hoffmann | .name = "chardev",
|
80 | 72cf2d4f | Blue Swirl | .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head), |
81 | 191bc01b | Gerd Hoffmann | .desc = { |
82 | 7d31544f | Gerd Hoffmann | { |
83 | 7d31544f | Gerd Hoffmann | .name = "backend",
|
84 | 7d31544f | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
85 | 7d31544f | Gerd Hoffmann | },{ |
86 | 7d31544f | Gerd Hoffmann | .name = "path",
|
87 | 7d31544f | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
88 | aeb2c47a | Gerd Hoffmann | },{ |
89 | aeb2c47a | Gerd Hoffmann | .name = "host",
|
90 | aeb2c47a | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
91 | aeb2c47a | Gerd Hoffmann | },{ |
92 | aeb2c47a | Gerd Hoffmann | .name = "port",
|
93 | aeb2c47a | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
94 | aeb2c47a | Gerd Hoffmann | },{ |
95 | 7e1b35b4 | Gerd Hoffmann | .name = "localaddr",
|
96 | 7e1b35b4 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
97 | 7e1b35b4 | Gerd Hoffmann | },{ |
98 | 7e1b35b4 | Gerd Hoffmann | .name = "localport",
|
99 | 7e1b35b4 | Gerd Hoffmann | .type = QEMU_OPT_STRING, |
100 | 7e1b35b4 | Gerd Hoffmann | },{ |
101 | aeb2c47a | Gerd Hoffmann | .name = "to",
|
102 | aeb2c47a | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
103 | aeb2c47a | Gerd Hoffmann | },{ |
104 | aeb2c47a | Gerd Hoffmann | .name = "ipv4",
|
105 | aeb2c47a | Gerd Hoffmann | .type = QEMU_OPT_BOOL, |
106 | aeb2c47a | Gerd Hoffmann | },{ |
107 | aeb2c47a | Gerd Hoffmann | .name = "ipv6",
|
108 | aeb2c47a | Gerd Hoffmann | .type = QEMU_OPT_BOOL, |
109 | aeb2c47a | Gerd Hoffmann | },{ |
110 | aeb2c47a | Gerd Hoffmann | .name = "wait",
|
111 | aeb2c47a | Gerd Hoffmann | .type = QEMU_OPT_BOOL, |
112 | aeb2c47a | Gerd Hoffmann | },{ |
113 | aeb2c47a | Gerd Hoffmann | .name = "server",
|
114 | aeb2c47a | Gerd Hoffmann | .type = QEMU_OPT_BOOL, |
115 | aeb2c47a | Gerd Hoffmann | },{ |
116 | aeb2c47a | Gerd Hoffmann | .name = "delay",
|
117 | aeb2c47a | Gerd Hoffmann | .type = QEMU_OPT_BOOL, |
118 | aeb2c47a | Gerd Hoffmann | },{ |
119 | aeb2c47a | Gerd Hoffmann | .name = "telnet",
|
120 | aeb2c47a | Gerd Hoffmann | .type = QEMU_OPT_BOOL, |
121 | 6ea314d9 | Gerd Hoffmann | },{ |
122 | 6ea314d9 | Gerd Hoffmann | .name = "width",
|
123 | 6ea314d9 | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
124 | 6ea314d9 | Gerd Hoffmann | },{ |
125 | 6ea314d9 | Gerd Hoffmann | .name = "height",
|
126 | 6ea314d9 | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
127 | 6ea314d9 | Gerd Hoffmann | },{ |
128 | 6ea314d9 | Gerd Hoffmann | .name = "cols",
|
129 | 6ea314d9 | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
130 | 6ea314d9 | Gerd Hoffmann | },{ |
131 | 6ea314d9 | Gerd Hoffmann | .name = "rows",
|
132 | 6ea314d9 | Gerd Hoffmann | .type = QEMU_OPT_NUMBER, |
133 | c845f401 | Gerd Hoffmann | },{ |
134 | c845f401 | Gerd Hoffmann | .name = "mux",
|
135 | c845f401 | Gerd Hoffmann | .type = QEMU_OPT_BOOL, |
136 | 7d31544f | Gerd Hoffmann | }, |
137 | 191bc01b | Gerd Hoffmann | { /* end if list */ }
|
138 | 191bc01b | Gerd Hoffmann | }, |
139 | 191bc01b | Gerd Hoffmann | }; |
140 | 191bc01b | Gerd Hoffmann | |
141 | f31d07d1 | Gerd Hoffmann | QemuOptsList qemu_device_opts = { |
142 | f31d07d1 | Gerd Hoffmann | .name = "device",
|
143 | 72cf2d4f | Blue Swirl | .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head), |
144 | f31d07d1 | Gerd Hoffmann | .desc = { |
145 | f31d07d1 | Gerd Hoffmann | /*
|
146 | f31d07d1 | Gerd Hoffmann | * no elements => accept any
|
147 | f31d07d1 | Gerd Hoffmann | * sanity checking will happen later
|
148 | f31d07d1 | Gerd Hoffmann | * when setting device properties
|
149 | f31d07d1 | Gerd Hoffmann | */
|
150 | f31d07d1 | Gerd Hoffmann | { /* end if list */ }
|
151 | f31d07d1 | Gerd Hoffmann | }, |
152 | f31d07d1 | Gerd Hoffmann | }; |
153 | f31d07d1 | Gerd Hoffmann | |
154 | d058fe03 | Gerd Hoffmann | static QemuOptsList *lists[] = {
|
155 | d058fe03 | Gerd Hoffmann | &qemu_drive_opts, |
156 | 191bc01b | Gerd Hoffmann | &qemu_chardev_opts, |
157 | f31d07d1 | Gerd Hoffmann | &qemu_device_opts, |
158 | d058fe03 | Gerd Hoffmann | NULL,
|
159 | d058fe03 | Gerd Hoffmann | }; |
160 | d058fe03 | Gerd Hoffmann | |
161 | d058fe03 | Gerd Hoffmann | int qemu_set_option(const char *str) |
162 | d058fe03 | Gerd Hoffmann | { |
163 | d058fe03 | Gerd Hoffmann | char group[64], id[64], arg[64]; |
164 | d058fe03 | Gerd Hoffmann | QemuOpts *opts; |
165 | d058fe03 | Gerd Hoffmann | int i, rc, offset;
|
166 | d058fe03 | Gerd Hoffmann | |
167 | d058fe03 | Gerd Hoffmann | rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset);
|
168 | d058fe03 | Gerd Hoffmann | if (rc < 3 || str[offset] != '=') { |
169 | d058fe03 | Gerd Hoffmann | fprintf(stderr, "can't parse: \"%s\"\n", str);
|
170 | d058fe03 | Gerd Hoffmann | return -1; |
171 | d058fe03 | Gerd Hoffmann | } |
172 | d058fe03 | Gerd Hoffmann | |
173 | d058fe03 | Gerd Hoffmann | for (i = 0; lists[i] != NULL; i++) { |
174 | d058fe03 | Gerd Hoffmann | if (strcmp(lists[i]->name, group) == 0) |
175 | d058fe03 | Gerd Hoffmann | break;
|
176 | d058fe03 | Gerd Hoffmann | } |
177 | d058fe03 | Gerd Hoffmann | if (lists[i] == NULL) { |
178 | d058fe03 | Gerd Hoffmann | fprintf(stderr, "there is no option group \"%s\"\n", group);
|
179 | d058fe03 | Gerd Hoffmann | return -1; |
180 | d058fe03 | Gerd Hoffmann | } |
181 | d058fe03 | Gerd Hoffmann | |
182 | d058fe03 | Gerd Hoffmann | opts = qemu_opts_find(lists[i], id); |
183 | d058fe03 | Gerd Hoffmann | if (!opts) {
|
184 | d058fe03 | Gerd Hoffmann | fprintf(stderr, "there is no %s \"%s\" defined\n",
|
185 | d058fe03 | Gerd Hoffmann | lists[i]->name, id); |
186 | d058fe03 | Gerd Hoffmann | return -1; |
187 | d058fe03 | Gerd Hoffmann | } |
188 | d058fe03 | Gerd Hoffmann | |
189 | 3df04ac3 | Mark McLoughlin | if (qemu_opt_set(opts, arg, str+offset+1) == -1) { |
190 | d058fe03 | Gerd Hoffmann | fprintf(stderr, "failed to set \"%s\" for %s \"%s\"\n",
|
191 | d058fe03 | Gerd Hoffmann | arg, lists[i]->name, id); |
192 | d058fe03 | Gerd Hoffmann | return -1; |
193 | d058fe03 | Gerd Hoffmann | } |
194 | d058fe03 | Gerd Hoffmann | return 0; |
195 | d058fe03 | Gerd Hoffmann | } |