Gerd Hoffmann | 7282a03 | 2009-07-31 12:25:35 +0200 | [diff] [blame] | 1 | #include "qemu-common.h" |
Markus Armbruster | 2f79201 | 2010-02-18 16:24:31 +0100 | [diff] [blame] | 2 | #include "qemu-error.h" |
Gerd Hoffmann | 7282a03 | 2009-07-31 12:25:35 +0200 | [diff] [blame] | 3 | #include "qemu-option.h" |
| 4 | #include "qemu-config.h" |
Gerd Hoffmann | a861c45 | 2009-09-25 21:42:40 +0200 | [diff] [blame] | 5 | #include "sysemu.h" |
Gerd Hoffmann | d0fef6f | 2009-12-08 13:11:34 +0100 | [diff] [blame] | 6 | #include "hw/qdev.h" |
Gerd Hoffmann | 7282a03 | 2009-07-31 12:25:35 +0200 | [diff] [blame] | 7 | |
Gerd Hoffmann | 3329f07 | 2010-08-20 13:52:01 +0200 | [diff] [blame] | 8 | static QemuOptsList qemu_drive_opts = { |
Gerd Hoffmann | 7282a03 | 2009-07-31 12:25:35 +0200 | [diff] [blame] | 9 | .name = "drive", |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 10 | .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head), |
Gerd Hoffmann | 7282a03 | 2009-07-31 12:25:35 +0200 | [diff] [blame] | 11 | .desc = { |
| 12 | { |
| 13 | .name = "bus", |
| 14 | .type = QEMU_OPT_NUMBER, |
| 15 | .help = "bus number", |
| 16 | },{ |
| 17 | .name = "unit", |
| 18 | .type = QEMU_OPT_NUMBER, |
| 19 | .help = "unit number (i.e. lun for scsi)", |
| 20 | },{ |
| 21 | .name = "if", |
| 22 | .type = QEMU_OPT_STRING, |
| 23 | .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)", |
| 24 | },{ |
| 25 | .name = "index", |
| 26 | .type = QEMU_OPT_NUMBER, |
| 27 | },{ |
| 28 | .name = "cyls", |
| 29 | .type = QEMU_OPT_NUMBER, |
| 30 | .help = "number of cylinders (ide disk geometry)", |
| 31 | },{ |
| 32 | .name = "heads", |
| 33 | .type = QEMU_OPT_NUMBER, |
| 34 | .help = "number of heads (ide disk geometry)", |
| 35 | },{ |
| 36 | .name = "secs", |
| 37 | .type = QEMU_OPT_NUMBER, |
| 38 | .help = "number of sectors (ide disk geometry)", |
| 39 | },{ |
| 40 | .name = "trans", |
| 41 | .type = QEMU_OPT_STRING, |
| 42 | .help = "chs translation (auto, lba. none)", |
| 43 | },{ |
| 44 | .name = "media", |
| 45 | .type = QEMU_OPT_STRING, |
| 46 | .help = "media type (disk, cdrom)", |
| 47 | },{ |
| 48 | .name = "snapshot", |
| 49 | .type = QEMU_OPT_BOOL, |
| 50 | },{ |
| 51 | .name = "file", |
| 52 | .type = QEMU_OPT_STRING, |
| 53 | .help = "disk image", |
| 54 | },{ |
| 55 | .name = "cache", |
| 56 | .type = QEMU_OPT_STRING, |
Alexander Graf | 016f5cf | 2010-05-26 17:51:49 +0200 | [diff] [blame] | 57 | .help = "host cache usage (none, writeback, writethrough, unsafe)", |
Gerd Hoffmann | 7282a03 | 2009-07-31 12:25:35 +0200 | [diff] [blame] | 58 | },{ |
Christoph Hellwig | 5c6c3a6 | 2009-08-20 16:58:35 +0200 | [diff] [blame] | 59 | .name = "aio", |
| 60 | .type = QEMU_OPT_STRING, |
| 61 | .help = "host AIO implementation (threads, native)", |
| 62 | },{ |
Gerd Hoffmann | 7282a03 | 2009-07-31 12:25:35 +0200 | [diff] [blame] | 63 | .name = "format", |
| 64 | .type = QEMU_OPT_STRING, |
| 65 | .help = "disk format (raw, qcow2, ...)", |
| 66 | },{ |
| 67 | .name = "serial", |
| 68 | .type = QEMU_OPT_STRING, |
| 69 | },{ |
Kevin Wolf | e9b2e81 | 2009-11-27 13:25:37 +0100 | [diff] [blame] | 70 | .name = "rerror", |
| 71 | .type = QEMU_OPT_STRING, |
| 72 | },{ |
Gerd Hoffmann | 7282a03 | 2009-07-31 12:25:35 +0200 | [diff] [blame] | 73 | .name = "werror", |
| 74 | .type = QEMU_OPT_STRING, |
| 75 | },{ |
| 76 | .name = "addr", |
| 77 | .type = QEMU_OPT_STRING, |
| 78 | .help = "pci address (virtio only)", |
Naphtali Sprei | 59f2689 | 2009-10-26 16:25:16 +0200 | [diff] [blame] | 79 | },{ |
| 80 | .name = "readonly", |
| 81 | .type = QEMU_OPT_BOOL, |
Gerd Hoffmann | 7282a03 | 2009-07-31 12:25:35 +0200 | [diff] [blame] | 82 | }, |
Jes Sorensen | 26056e0 | 2010-08-31 09:30:35 +0200 | [diff] [blame] | 83 | { /* end of list */ } |
Gerd Hoffmann | 7282a03 | 2009-07-31 12:25:35 +0200 | [diff] [blame] | 84 | }, |
| 85 | }; |
| 86 | |
Gerd Hoffmann | 3329f07 | 2010-08-20 13:52:01 +0200 | [diff] [blame] | 87 | static QemuOptsList qemu_chardev_opts = { |
Gerd Hoffmann | 191bc01 | 2009-09-10 10:58:35 +0200 | [diff] [blame] | 88 | .name = "chardev", |
Markus Armbruster | 8212c64 | 2010-02-10 19:52:18 +0100 | [diff] [blame] | 89 | .implied_opt_name = "backend", |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 90 | .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head), |
Gerd Hoffmann | 191bc01 | 2009-09-10 10:58:35 +0200 | [diff] [blame] | 91 | .desc = { |
Gerd Hoffmann | 7d31544 | 2009-09-10 10:58:36 +0200 | [diff] [blame] | 92 | { |
| 93 | .name = "backend", |
| 94 | .type = QEMU_OPT_STRING, |
| 95 | },{ |
| 96 | .name = "path", |
| 97 | .type = QEMU_OPT_STRING, |
Gerd Hoffmann | aeb2c47 | 2009-09-10 10:58:42 +0200 | [diff] [blame] | 98 | },{ |
| 99 | .name = "host", |
| 100 | .type = QEMU_OPT_STRING, |
| 101 | },{ |
| 102 | .name = "port", |
| 103 | .type = QEMU_OPT_STRING, |
| 104 | },{ |
Gerd Hoffmann | 7e1b35b | 2009-09-10 10:58:51 +0200 | [diff] [blame] | 105 | .name = "localaddr", |
| 106 | .type = QEMU_OPT_STRING, |
| 107 | },{ |
| 108 | .name = "localport", |
| 109 | .type = QEMU_OPT_STRING, |
| 110 | },{ |
Gerd Hoffmann | aeb2c47 | 2009-09-10 10:58:42 +0200 | [diff] [blame] | 111 | .name = "to", |
| 112 | .type = QEMU_OPT_NUMBER, |
| 113 | },{ |
| 114 | .name = "ipv4", |
| 115 | .type = QEMU_OPT_BOOL, |
| 116 | },{ |
| 117 | .name = "ipv6", |
| 118 | .type = QEMU_OPT_BOOL, |
| 119 | },{ |
| 120 | .name = "wait", |
| 121 | .type = QEMU_OPT_BOOL, |
| 122 | },{ |
| 123 | .name = "server", |
| 124 | .type = QEMU_OPT_BOOL, |
| 125 | },{ |
| 126 | .name = "delay", |
| 127 | .type = QEMU_OPT_BOOL, |
| 128 | },{ |
| 129 | .name = "telnet", |
| 130 | .type = QEMU_OPT_BOOL, |
Gerd Hoffmann | 6ea314d | 2009-09-10 10:58:49 +0200 | [diff] [blame] | 131 | },{ |
| 132 | .name = "width", |
| 133 | .type = QEMU_OPT_NUMBER, |
| 134 | },{ |
| 135 | .name = "height", |
| 136 | .type = QEMU_OPT_NUMBER, |
| 137 | },{ |
| 138 | .name = "cols", |
| 139 | .type = QEMU_OPT_NUMBER, |
| 140 | },{ |
| 141 | .name = "rows", |
| 142 | .type = QEMU_OPT_NUMBER, |
Gerd Hoffmann | c845f40 | 2009-09-10 10:58:52 +0200 | [diff] [blame] | 143 | },{ |
| 144 | .name = "mux", |
| 145 | .type = QEMU_OPT_BOOL, |
Kusanagi Kouichi | 5989020 | 2009-10-16 22:31:38 +0900 | [diff] [blame] | 146 | },{ |
| 147 | .name = "signal", |
| 148 | .type = QEMU_OPT_BOOL, |
Gerd Hoffmann | 7d31544 | 2009-09-10 10:58:36 +0200 | [diff] [blame] | 149 | }, |
Jes Sorensen | 26056e0 | 2010-08-31 09:30:35 +0200 | [diff] [blame] | 150 | { /* end of list */ } |
Gerd Hoffmann | 191bc01 | 2009-09-10 10:58:35 +0200 | [diff] [blame] | 151 | }, |
| 152 | }; |
| 153 | |
Gautham R Shenoy | 74db920 | 2010-04-29 17:44:43 +0530 | [diff] [blame] | 154 | QemuOptsList qemu_fsdev_opts = { |
| 155 | .name = "fsdev", |
| 156 | .implied_opt_name = "fstype", |
| 157 | .head = QTAILQ_HEAD_INITIALIZER(qemu_fsdev_opts.head), |
| 158 | .desc = { |
| 159 | { |
| 160 | .name = "fstype", |
| 161 | .type = QEMU_OPT_STRING, |
| 162 | }, { |
| 163 | .name = "path", |
| 164 | .type = QEMU_OPT_STRING, |
Venkateswararao Jujjuri (JV) | 9ce56db | 2010-06-14 13:34:40 -0700 | [diff] [blame] | 165 | }, { |
| 166 | .name = "security_model", |
| 167 | .type = QEMU_OPT_STRING, |
Gautham R Shenoy | 74db920 | 2010-04-29 17:44:43 +0530 | [diff] [blame] | 168 | }, |
| 169 | { /*End of list */ } |
| 170 | }, |
| 171 | }; |
Gautham R Shenoy | 74db920 | 2010-04-29 17:44:43 +0530 | [diff] [blame] | 172 | |
Gautham R Shenoy | 3d54abc | 2010-04-29 17:45:03 +0530 | [diff] [blame] | 173 | QemuOptsList qemu_virtfs_opts = { |
| 174 | .name = "virtfs", |
| 175 | .implied_opt_name = "fstype", |
| 176 | .head = QTAILQ_HEAD_INITIALIZER(qemu_virtfs_opts.head), |
| 177 | .desc = { |
| 178 | { |
| 179 | .name = "fstype", |
| 180 | .type = QEMU_OPT_STRING, |
| 181 | }, { |
| 182 | .name = "path", |
| 183 | .type = QEMU_OPT_STRING, |
| 184 | }, { |
| 185 | .name = "mount_tag", |
| 186 | .type = QEMU_OPT_STRING, |
Venkateswararao Jujjuri (JV) | 9ce56db | 2010-06-14 13:34:40 -0700 | [diff] [blame] | 187 | }, { |
| 188 | .name = "security_model", |
| 189 | .type = QEMU_OPT_STRING, |
Gautham R Shenoy | 3d54abc | 2010-04-29 17:45:03 +0530 | [diff] [blame] | 190 | }, |
| 191 | |
| 192 | { /*End of list */ } |
| 193 | }, |
| 194 | }; |
Gautham R Shenoy | 3d54abc | 2010-04-29 17:45:03 +0530 | [diff] [blame] | 195 | |
Gerd Hoffmann | 3329f07 | 2010-08-20 13:52:01 +0200 | [diff] [blame] | 196 | static QemuOptsList qemu_device_opts = { |
Gerd Hoffmann | f31d07d | 2009-07-31 12:25:37 +0200 | [diff] [blame] | 197 | .name = "device", |
Markus Armbruster | 8212c64 | 2010-02-10 19:52:18 +0100 | [diff] [blame] | 198 | .implied_opt_name = "driver", |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 199 | .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head), |
Gerd Hoffmann | f31d07d | 2009-07-31 12:25:37 +0200 | [diff] [blame] | 200 | .desc = { |
| 201 | /* |
| 202 | * no elements => accept any |
| 203 | * sanity checking will happen later |
| 204 | * when setting device properties |
| 205 | */ |
Jes Sorensen | 26056e0 | 2010-08-31 09:30:35 +0200 | [diff] [blame] | 206 | { /* end of list */ } |
Gerd Hoffmann | f31d07d | 2009-07-31 12:25:37 +0200 | [diff] [blame] | 207 | }, |
| 208 | }; |
| 209 | |
Gerd Hoffmann | 3329f07 | 2010-08-20 13:52:01 +0200 | [diff] [blame] | 210 | static QemuOptsList qemu_netdev_opts = { |
Mark McLoughlin | a1ea458 | 2009-10-08 19:58:26 +0100 | [diff] [blame] | 211 | .name = "netdev", |
Markus Armbruster | 8212c64 | 2010-02-10 19:52:18 +0100 | [diff] [blame] | 212 | .implied_opt_name = "type", |
Mark McLoughlin | a1ea458 | 2009-10-08 19:58:26 +0100 | [diff] [blame] | 213 | .head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head), |
| 214 | .desc = { |
| 215 | /* |
| 216 | * no elements => accept any params |
| 217 | * validation will happen later |
| 218 | */ |
| 219 | { /* end of list */ } |
| 220 | }, |
| 221 | }; |
| 222 | |
Gerd Hoffmann | 3329f07 | 2010-08-20 13:52:01 +0200 | [diff] [blame] | 223 | static QemuOptsList qemu_net_opts = { |
Mark McLoughlin | 8119b33 | 2009-10-06 12:17:05 +0100 | [diff] [blame] | 224 | .name = "net", |
Markus Armbruster | 8212c64 | 2010-02-10 19:52:18 +0100 | [diff] [blame] | 225 | .implied_opt_name = "type", |
Mark McLoughlin | 8119b33 | 2009-10-06 12:17:05 +0100 | [diff] [blame] | 226 | .head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head), |
| 227 | .desc = { |
| 228 | /* |
| 229 | * no elements => accept any params |
| 230 | * validation will happen later |
| 231 | */ |
| 232 | { /* end of list */ } |
| 233 | }, |
| 234 | }; |
| 235 | |
Gerd Hoffmann | 3329f07 | 2010-08-20 13:52:01 +0200 | [diff] [blame] | 236 | static QemuOptsList qemu_rtc_opts = { |
Jan Kiszka | 1ed2fc1 | 2009-09-15 13:36:04 +0200 | [diff] [blame] | 237 | .name = "rtc", |
| 238 | .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head), |
| 239 | .desc = { |
| 240 | { |
| 241 | .name = "base", |
| 242 | .type = QEMU_OPT_STRING, |
Jan Kiszka | 6875204 | 2009-09-15 13:36:04 +0200 | [diff] [blame] | 243 | },{ |
| 244 | .name = "clock", |
| 245 | .type = QEMU_OPT_STRING, |
Jan Kiszka | 1ed2fc1 | 2009-09-15 13:36:04 +0200 | [diff] [blame] | 246 | },{ |
| 247 | .name = "driftfix", |
| 248 | .type = QEMU_OPT_STRING, |
Jan Kiszka | 1ed2fc1 | 2009-09-15 13:36:04 +0200 | [diff] [blame] | 249 | }, |
Jes Sorensen | 26056e0 | 2010-08-31 09:30:35 +0200 | [diff] [blame] | 250 | { /* end of list */ } |
Jan Kiszka | 1ed2fc1 | 2009-09-15 13:36:04 +0200 | [diff] [blame] | 251 | }, |
| 252 | }; |
| 253 | |
Gerd Hoffmann | 3329f07 | 2010-08-20 13:52:01 +0200 | [diff] [blame] | 254 | static QemuOptsList qemu_global_opts = { |
Gerd Hoffmann | d0fef6f | 2009-12-08 13:11:34 +0100 | [diff] [blame] | 255 | .name = "global", |
| 256 | .head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head), |
| 257 | .desc = { |
| 258 | { |
| 259 | .name = "driver", |
| 260 | .type = QEMU_OPT_STRING, |
| 261 | },{ |
| 262 | .name = "property", |
| 263 | .type = QEMU_OPT_STRING, |
| 264 | },{ |
| 265 | .name = "value", |
| 266 | .type = QEMU_OPT_STRING, |
| 267 | }, |
Jes Sorensen | 26056e0 | 2010-08-31 09:30:35 +0200 | [diff] [blame] | 268 | { /* end of list */ } |
Gerd Hoffmann | d0fef6f | 2009-12-08 13:11:34 +0100 | [diff] [blame] | 269 | }, |
| 270 | }; |
| 271 | |
Gerd Hoffmann | 3329f07 | 2010-08-20 13:52:01 +0200 | [diff] [blame] | 272 | static QemuOptsList qemu_mon_opts = { |
Gerd Hoffmann | 8858934 | 2009-12-08 13:11:50 +0100 | [diff] [blame] | 273 | .name = "mon", |
Markus Armbruster | 8212c64 | 2010-02-10 19:52:18 +0100 | [diff] [blame] | 274 | .implied_opt_name = "chardev", |
Gerd Hoffmann | 8858934 | 2009-12-08 13:11:50 +0100 | [diff] [blame] | 275 | .head = QTAILQ_HEAD_INITIALIZER(qemu_mon_opts.head), |
| 276 | .desc = { |
| 277 | { |
| 278 | .name = "mode", |
| 279 | .type = QEMU_OPT_STRING, |
| 280 | },{ |
| 281 | .name = "chardev", |
| 282 | .type = QEMU_OPT_STRING, |
| 283 | },{ |
| 284 | .name = "default", |
| 285 | .type = QEMU_OPT_BOOL, |
Daniel P. Berrange | 39eaab9 | 2010-06-07 15:42:31 +0100 | [diff] [blame] | 286 | },{ |
| 287 | .name = "pretty", |
| 288 | .type = QEMU_OPT_BOOL, |
Gerd Hoffmann | 8858934 | 2009-12-08 13:11:50 +0100 | [diff] [blame] | 289 | }, |
Jes Sorensen | 26056e0 | 2010-08-31 09:30:35 +0200 | [diff] [blame] | 290 | { /* end of list */ } |
Gerd Hoffmann | 8858934 | 2009-12-08 13:11:50 +0100 | [diff] [blame] | 291 | }, |
| 292 | }; |
| 293 | |
Prerna Saxena | ab6540d | 2010-08-09 11:48:32 +0100 | [diff] [blame] | 294 | #ifdef CONFIG_SIMPLE_TRACE |
| 295 | static QemuOptsList qemu_trace_opts = { |
| 296 | .name = "trace", |
| 297 | .implied_opt_name = "trace", |
| 298 | .head = QTAILQ_HEAD_INITIALIZER(qemu_trace_opts.head), |
| 299 | .desc = { |
| 300 | { |
| 301 | .name = "file", |
| 302 | .type = QEMU_OPT_STRING, |
| 303 | }, |
| 304 | { /* end if list */ } |
| 305 | }, |
| 306 | }; |
| 307 | #endif |
| 308 | |
Gerd Hoffmann | 3329f07 | 2010-08-20 13:52:01 +0200 | [diff] [blame] | 309 | static QemuOptsList qemu_cpudef_opts = { |
john cooper | b5ec5ce | 2010-02-20 11:14:59 -0600 | [diff] [blame] | 310 | .name = "cpudef", |
| 311 | .head = QTAILQ_HEAD_INITIALIZER(qemu_cpudef_opts.head), |
| 312 | .desc = { |
| 313 | { |
| 314 | .name = "name", |
| 315 | .type = QEMU_OPT_STRING, |
| 316 | },{ |
| 317 | .name = "level", |
| 318 | .type = QEMU_OPT_NUMBER, |
| 319 | },{ |
| 320 | .name = "vendor", |
| 321 | .type = QEMU_OPT_STRING, |
| 322 | },{ |
| 323 | .name = "family", |
| 324 | .type = QEMU_OPT_NUMBER, |
| 325 | },{ |
| 326 | .name = "model", |
| 327 | .type = QEMU_OPT_NUMBER, |
| 328 | },{ |
| 329 | .name = "stepping", |
| 330 | .type = QEMU_OPT_NUMBER, |
| 331 | },{ |
| 332 | .name = "feature_edx", /* cpuid 0000_0001.edx */ |
| 333 | .type = QEMU_OPT_STRING, |
| 334 | },{ |
| 335 | .name = "feature_ecx", /* cpuid 0000_0001.ecx */ |
| 336 | .type = QEMU_OPT_STRING, |
| 337 | },{ |
| 338 | .name = "extfeature_edx", /* cpuid 8000_0001.edx */ |
| 339 | .type = QEMU_OPT_STRING, |
| 340 | },{ |
| 341 | .name = "extfeature_ecx", /* cpuid 8000_0001.ecx */ |
| 342 | .type = QEMU_OPT_STRING, |
| 343 | },{ |
| 344 | .name = "xlevel", |
| 345 | .type = QEMU_OPT_NUMBER, |
| 346 | },{ |
| 347 | .name = "model_id", |
| 348 | .type = QEMU_OPT_STRING, |
| 349 | },{ |
| 350 | .name = "vendor_override", |
| 351 | .type = QEMU_OPT_NUMBER, |
| 352 | }, |
| 353 | { /* end of list */ } |
| 354 | }, |
| 355 | }; |
| 356 | |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 357 | QemuOptsList qemu_spice_opts = { |
| 358 | .name = "spice", |
| 359 | .head = QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head), |
| 360 | .desc = { |
| 361 | { |
| 362 | .name = "port", |
| 363 | .type = QEMU_OPT_NUMBER, |
| 364 | },{ |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 365 | .name = "tls-port", |
| 366 | .type = QEMU_OPT_NUMBER, |
| 367 | },{ |
Gerd Hoffmann | 333b0ee | 2010-08-27 14:29:16 +0200 | [diff] [blame] | 368 | .name = "addr", |
| 369 | .type = QEMU_OPT_STRING, |
| 370 | },{ |
| 371 | .name = "ipv4", |
| 372 | .type = QEMU_OPT_BOOL, |
| 373 | },{ |
| 374 | .name = "ipv6", |
| 375 | .type = QEMU_OPT_BOOL, |
| 376 | },{ |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 377 | .name = "password", |
| 378 | .type = QEMU_OPT_STRING, |
| 379 | },{ |
| 380 | .name = "disable-ticketing", |
| 381 | .type = QEMU_OPT_BOOL, |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 382 | },{ |
| 383 | .name = "x509-dir", |
| 384 | .type = QEMU_OPT_STRING, |
| 385 | },{ |
| 386 | .name = "x509-key-file", |
| 387 | .type = QEMU_OPT_STRING, |
| 388 | },{ |
| 389 | .name = "x509-key-password", |
| 390 | .type = QEMU_OPT_STRING, |
| 391 | },{ |
| 392 | .name = "x509-cert-file", |
| 393 | .type = QEMU_OPT_STRING, |
| 394 | },{ |
| 395 | .name = "x509-cacert-file", |
| 396 | .type = QEMU_OPT_STRING, |
| 397 | },{ |
| 398 | .name = "x509-dh-key-file", |
| 399 | .type = QEMU_OPT_STRING, |
| 400 | },{ |
| 401 | .name = "tls-ciphers", |
| 402 | .type = QEMU_OPT_STRING, |
Yonit Halperin | 9f04e09 | 2010-07-14 13:26:34 +0300 | [diff] [blame] | 403 | },{ |
Gerd Hoffmann | 17b6dea | 2010-08-27 14:09:56 +0200 | [diff] [blame] | 404 | .name = "tls-channel", |
| 405 | .type = QEMU_OPT_STRING, |
| 406 | },{ |
| 407 | .name = "plaintext-channel", |
| 408 | .type = QEMU_OPT_STRING, |
| 409 | },{ |
Yonit Halperin | 9f04e09 | 2010-07-14 13:26:34 +0300 | [diff] [blame] | 410 | .name = "image-compression", |
| 411 | .type = QEMU_OPT_STRING, |
| 412 | },{ |
| 413 | .name = "jpeg-wan-compression", |
| 414 | .type = QEMU_OPT_STRING, |
| 415 | },{ |
| 416 | .name = "zlib-glz-wan-compression", |
| 417 | .type = QEMU_OPT_STRING, |
Gerd Hoffmann | 84a23f2 | 2010-08-30 16:36:53 +0200 | [diff] [blame] | 418 | },{ |
| 419 | .name = "streaming-video", |
| 420 | .type = QEMU_OPT_STRING, |
| 421 | },{ |
| 422 | .name = "agent-mouse", |
| 423 | .type = QEMU_OPT_BOOL, |
| 424 | },{ |
| 425 | .name = "playback-compression", |
| 426 | .type = QEMU_OPT_BOOL, |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 427 | }, |
| 428 | { /* end if list */ } |
| 429 | }, |
| 430 | }; |
| 431 | |
Gleb Natapov | 2e55e84 | 2010-12-08 13:35:07 +0200 | [diff] [blame] | 432 | QemuOptsList qemu_option_rom_opts = { |
| 433 | .name = "option-rom", |
| 434 | .implied_opt_name = "romfile", |
| 435 | .head = QTAILQ_HEAD_INITIALIZER(qemu_option_rom_opts.head), |
| 436 | .desc = { |
| 437 | { |
| 438 | .name = "bootindex", |
| 439 | .type = QEMU_OPT_NUMBER, |
| 440 | }, { |
| 441 | .name = "romfile", |
| 442 | .type = QEMU_OPT_STRING, |
| 443 | }, |
| 444 | { /* end if list */ } |
| 445 | }, |
| 446 | }; |
| 447 | |
Gerd Hoffmann | dfe795e | 2010-08-20 13:52:00 +0200 | [diff] [blame] | 448 | static QemuOptsList *vm_config_groups[32] = { |
Gerd Hoffmann | d058fe0 | 2009-07-31 12:25:36 +0200 | [diff] [blame] | 449 | &qemu_drive_opts, |
Gerd Hoffmann | 191bc01 | 2009-09-10 10:58:35 +0200 | [diff] [blame] | 450 | &qemu_chardev_opts, |
Gerd Hoffmann | f31d07d | 2009-07-31 12:25:37 +0200 | [diff] [blame] | 451 | &qemu_device_opts, |
Mark McLoughlin | a1ea458 | 2009-10-08 19:58:26 +0100 | [diff] [blame] | 452 | &qemu_netdev_opts, |
Mark McLoughlin | 8119b33 | 2009-10-06 12:17:05 +0100 | [diff] [blame] | 453 | &qemu_net_opts, |
Jan Kiszka | 5fdfbf7 | 2009-10-06 12:16:50 +0100 | [diff] [blame] | 454 | &qemu_rtc_opts, |
Gerd Hoffmann | d0fef6f | 2009-12-08 13:11:34 +0100 | [diff] [blame] | 455 | &qemu_global_opts, |
Gerd Hoffmann | 8858934 | 2009-12-08 13:11:50 +0100 | [diff] [blame] | 456 | &qemu_mon_opts, |
john cooper | b5ec5ce | 2010-02-20 11:14:59 -0600 | [diff] [blame] | 457 | &qemu_cpudef_opts, |
Prerna Saxena | ab6540d | 2010-08-09 11:48:32 +0100 | [diff] [blame] | 458 | #ifdef CONFIG_SIMPLE_TRACE |
| 459 | &qemu_trace_opts, |
| 460 | #endif |
Gleb Natapov | 2e55e84 | 2010-12-08 13:35:07 +0200 | [diff] [blame] | 461 | &qemu_option_rom_opts, |
Gerd Hoffmann | d058fe0 | 2009-07-31 12:25:36 +0200 | [diff] [blame] | 462 | NULL, |
| 463 | }; |
| 464 | |
Kevin Wolf | 490b648 | 2010-03-05 18:21:56 +0100 | [diff] [blame] | 465 | static QemuOptsList *find_list(QemuOptsList **lists, const char *group) |
Gerd Hoffmann | d058fe0 | 2009-07-31 12:25:36 +0200 | [diff] [blame] | 466 | { |
Gerd Hoffmann | ddc9785 | 2009-10-14 10:39:25 +0200 | [diff] [blame] | 467 | int i; |
Gerd Hoffmann | d058fe0 | 2009-07-31 12:25:36 +0200 | [diff] [blame] | 468 | |
| 469 | for (i = 0; lists[i] != NULL; i++) { |
| 470 | if (strcmp(lists[i]->name, group) == 0) |
| 471 | break; |
| 472 | } |
| 473 | if (lists[i] == NULL) { |
Markus Armbruster | 1ecda02 | 2010-02-18 17:25:24 +0100 | [diff] [blame] | 474 | error_report("there is no option group \"%s\"", group); |
Gerd Hoffmann | ddc9785 | 2009-10-14 10:39:25 +0200 | [diff] [blame] | 475 | } |
| 476 | return lists[i]; |
| 477 | } |
| 478 | |
Kevin Wolf | 490b648 | 2010-03-05 18:21:56 +0100 | [diff] [blame] | 479 | QemuOptsList *qemu_find_opts(const char *group) |
| 480 | { |
| 481 | return find_list(vm_config_groups, group); |
| 482 | } |
| 483 | |
Gerd Hoffmann | dfe795e | 2010-08-20 13:52:00 +0200 | [diff] [blame] | 484 | void qemu_add_opts(QemuOptsList *list) |
| 485 | { |
| 486 | int entries, i; |
| 487 | |
| 488 | entries = ARRAY_SIZE(vm_config_groups); |
| 489 | entries--; /* keep list NULL terminated */ |
| 490 | for (i = 0; i < entries; i++) { |
| 491 | if (vm_config_groups[i] == NULL) { |
| 492 | vm_config_groups[i] = list; |
| 493 | return; |
| 494 | } |
| 495 | } |
| 496 | fprintf(stderr, "ran out of space in vm_config_groups"); |
| 497 | abort(); |
| 498 | } |
| 499 | |
Gerd Hoffmann | ddc9785 | 2009-10-14 10:39:25 +0200 | [diff] [blame] | 500 | int qemu_set_option(const char *str) |
| 501 | { |
| 502 | char group[64], id[64], arg[64]; |
| 503 | QemuOptsList *list; |
| 504 | QemuOpts *opts; |
| 505 | int rc, offset; |
| 506 | |
| 507 | rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset); |
| 508 | if (rc < 3 || str[offset] != '=') { |
Markus Armbruster | 1ecda02 | 2010-02-18 17:25:24 +0100 | [diff] [blame] | 509 | error_report("can't parse: \"%s\"", str); |
Gerd Hoffmann | d058fe0 | 2009-07-31 12:25:36 +0200 | [diff] [blame] | 510 | return -1; |
| 511 | } |
| 512 | |
Markus Armbruster | 304329e | 2010-02-10 20:09:14 +0100 | [diff] [blame] | 513 | list = qemu_find_opts(group); |
Gerd Hoffmann | ddc9785 | 2009-10-14 10:39:25 +0200 | [diff] [blame] | 514 | if (list == NULL) { |
| 515 | return -1; |
| 516 | } |
| 517 | |
| 518 | opts = qemu_opts_find(list, id); |
Gerd Hoffmann | d058fe0 | 2009-07-31 12:25:36 +0200 | [diff] [blame] | 519 | if (!opts) { |
Markus Armbruster | 1ecda02 | 2010-02-18 17:25:24 +0100 | [diff] [blame] | 520 | error_report("there is no %s \"%s\" defined", |
| 521 | list->name, id); |
Gerd Hoffmann | d058fe0 | 2009-07-31 12:25:36 +0200 | [diff] [blame] | 522 | return -1; |
| 523 | } |
| 524 | |
Mark McLoughlin | 3df04ac | 2009-09-23 11:24:05 +0100 | [diff] [blame] | 525 | if (qemu_opt_set(opts, arg, str+offset+1) == -1) { |
Gerd Hoffmann | d058fe0 | 2009-07-31 12:25:36 +0200 | [diff] [blame] | 526 | return -1; |
| 527 | } |
| 528 | return 0; |
| 529 | } |
| 530 | |
Gerd Hoffmann | d0fef6f | 2009-12-08 13:11:34 +0100 | [diff] [blame] | 531 | int qemu_global_option(const char *str) |
| 532 | { |
| 533 | char driver[64], property[64]; |
| 534 | QemuOpts *opts; |
| 535 | int rc, offset; |
| 536 | |
| 537 | rc = sscanf(str, "%63[^.].%63[^=]%n", driver, property, &offset); |
| 538 | if (rc < 2 || str[offset] != '=') { |
Markus Armbruster | 1ecda02 | 2010-02-18 17:25:24 +0100 | [diff] [blame] | 539 | error_report("can't parse: \"%s\"", str); |
Gerd Hoffmann | d0fef6f | 2009-12-08 13:11:34 +0100 | [diff] [blame] | 540 | return -1; |
| 541 | } |
| 542 | |
| 543 | opts = qemu_opts_create(&qemu_global_opts, NULL, 0); |
| 544 | qemu_opt_set(opts, "driver", driver); |
| 545 | qemu_opt_set(opts, "property", property); |
| 546 | qemu_opt_set(opts, "value", str+offset+1); |
| 547 | return 0; |
| 548 | } |
| 549 | |
Gerd Hoffmann | 9d99339 | 2009-10-14 10:39:26 +0200 | [diff] [blame] | 550 | struct ConfigWriteData { |
| 551 | QemuOptsList *list; |
| 552 | FILE *fp; |
| 553 | }; |
| 554 | |
| 555 | static int config_write_opt(const char *name, const char *value, void *opaque) |
| 556 | { |
| 557 | struct ConfigWriteData *data = opaque; |
| 558 | |
| 559 | fprintf(data->fp, " %s = \"%s\"\n", name, value); |
| 560 | return 0; |
| 561 | } |
| 562 | |
| 563 | static int config_write_opts(QemuOpts *opts, void *opaque) |
| 564 | { |
| 565 | struct ConfigWriteData *data = opaque; |
| 566 | const char *id = qemu_opts_id(opts); |
| 567 | |
| 568 | if (id) { |
| 569 | fprintf(data->fp, "[%s \"%s\"]\n", data->list->name, id); |
| 570 | } else { |
| 571 | fprintf(data->fp, "[%s]\n", data->list->name); |
| 572 | } |
| 573 | qemu_opt_foreach(opts, config_write_opt, data, 0); |
| 574 | fprintf(data->fp, "\n"); |
| 575 | return 0; |
| 576 | } |
| 577 | |
| 578 | void qemu_config_write(FILE *fp) |
| 579 | { |
| 580 | struct ConfigWriteData data = { .fp = fp }; |
Kevin Wolf | 490b648 | 2010-03-05 18:21:56 +0100 | [diff] [blame] | 581 | QemuOptsList **lists = vm_config_groups; |
Gerd Hoffmann | 9d99339 | 2009-10-14 10:39:26 +0200 | [diff] [blame] | 582 | int i; |
| 583 | |
| 584 | fprintf(fp, "# qemu config file\n\n"); |
| 585 | for (i = 0; lists[i] != NULL; i++) { |
| 586 | data.list = lists[i]; |
| 587 | qemu_opts_foreach(data.list, config_write_opts, &data, 0); |
| 588 | } |
| 589 | } |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 590 | |
Kevin Wolf | 490b648 | 2010-03-05 18:21:56 +0100 | [diff] [blame] | 591 | int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname) |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 592 | { |
| 593 | char line[1024], group[64], id[64], arg[64], value[1024]; |
Markus Armbruster | cf5a65a | 2010-02-18 19:48:33 +0100 | [diff] [blame] | 594 | Location loc; |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 595 | QemuOptsList *list = NULL; |
| 596 | QemuOpts *opts = NULL; |
Markus Armbruster | cf5a65a | 2010-02-18 19:48:33 +0100 | [diff] [blame] | 597 | int res = -1, lno = 0; |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 598 | |
Markus Armbruster | cf5a65a | 2010-02-18 19:48:33 +0100 | [diff] [blame] | 599 | loc_push_none(&loc); |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 600 | while (fgets(line, sizeof(line), fp) != NULL) { |
Markus Armbruster | cf5a65a | 2010-02-18 19:48:33 +0100 | [diff] [blame] | 601 | loc_set_file(fname, ++lno); |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 602 | if (line[0] == '\n') { |
| 603 | /* skip empty lines */ |
| 604 | continue; |
| 605 | } |
| 606 | if (line[0] == '#') { |
| 607 | /* comment */ |
| 608 | continue; |
| 609 | } |
| 610 | if (sscanf(line, "[%63s \"%63[^\"]\"]", group, id) == 2) { |
| 611 | /* group with id */ |
Kevin Wolf | 490b648 | 2010-03-05 18:21:56 +0100 | [diff] [blame] | 612 | list = find_list(lists, group); |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 613 | if (list == NULL) |
Markus Armbruster | cf5a65a | 2010-02-18 19:48:33 +0100 | [diff] [blame] | 614 | goto out; |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 615 | opts = qemu_opts_create(list, id, 1); |
| 616 | continue; |
| 617 | } |
| 618 | if (sscanf(line, "[%63[^]]]", group) == 1) { |
| 619 | /* group without id */ |
Kevin Wolf | 490b648 | 2010-03-05 18:21:56 +0100 | [diff] [blame] | 620 | list = find_list(lists, group); |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 621 | if (list == NULL) |
Markus Armbruster | cf5a65a | 2010-02-18 19:48:33 +0100 | [diff] [blame] | 622 | goto out; |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 623 | opts = qemu_opts_create(list, NULL, 0); |
| 624 | continue; |
| 625 | } |
| 626 | if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) { |
| 627 | /* arg = value */ |
| 628 | if (opts == NULL) { |
Markus Armbruster | cf5a65a | 2010-02-18 19:48:33 +0100 | [diff] [blame] | 629 | error_report("no group defined"); |
| 630 | goto out; |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 631 | } |
| 632 | if (qemu_opt_set(opts, arg, value) != 0) { |
Markus Armbruster | cf5a65a | 2010-02-18 19:48:33 +0100 | [diff] [blame] | 633 | goto out; |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 634 | } |
| 635 | continue; |
| 636 | } |
Markus Armbruster | cf5a65a | 2010-02-18 19:48:33 +0100 | [diff] [blame] | 637 | error_report("parse error"); |
| 638 | goto out; |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 639 | } |
Markus Armbruster | ef82516 | 2010-02-18 19:56:01 +0100 | [diff] [blame] | 640 | if (ferror(fp)) { |
| 641 | error_report("error reading file"); |
| 642 | goto out; |
| 643 | } |
Markus Armbruster | cf5a65a | 2010-02-18 19:48:33 +0100 | [diff] [blame] | 644 | res = 0; |
| 645 | out: |
| 646 | loc_pop(&loc); |
| 647 | return res; |
Gerd Hoffmann | 42262ba | 2009-10-14 10:39:27 +0200 | [diff] [blame] | 648 | } |
Kevin Wolf | dcfb093 | 2010-03-05 17:25:55 +0100 | [diff] [blame] | 649 | |
| 650 | int qemu_read_config_file(const char *filename) |
| 651 | { |
| 652 | FILE *f = fopen(filename, "r"); |
Kevin Wolf | 019e78b | 2010-05-17 10:36:47 +0200 | [diff] [blame] | 653 | int ret; |
| 654 | |
Kevin Wolf | dcfb093 | 2010-03-05 17:25:55 +0100 | [diff] [blame] | 655 | if (f == NULL) { |
| 656 | return -errno; |
| 657 | } |
| 658 | |
Kevin Wolf | 019e78b | 2010-05-17 10:36:47 +0200 | [diff] [blame] | 659 | ret = qemu_config_parse(f, vm_config_groups, filename); |
Kevin Wolf | dcfb093 | 2010-03-05 17:25:55 +0100 | [diff] [blame] | 660 | fclose(f); |
| 661 | |
Kevin Wolf | 019e78b | 2010-05-17 10:36:47 +0200 | [diff] [blame] | 662 | if (ret == 0) { |
| 663 | return 0; |
| 664 | } else { |
| 665 | return -EINVAL; |
| 666 | } |
Kevin Wolf | dcfb093 | 2010-03-05 17:25:55 +0100 | [diff] [blame] | 667 | } |