Commit ef3adf68f802da54b2096da8aa3ce97bde54be2e
Committed by
Anthony Liguori
1 parent
e8b2a1c6
Rework -boot option
This patch changes the boot command line option to the canonical format -boot [order=drives][,...] where 'drives' is using the same format as the old -boot. The format switch allows to add the 'menu' and 'once' options in later patches. The old format is still understood and will be processed at least for a transition time. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
1 changed file
with
50 additions
and
31 deletions
vl.c
... | ... | @@ -2356,6 +2356,35 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) |
2356 | 2356 | return drives_table_idx; |
2357 | 2357 | } |
2358 | 2358 | |
2359 | +static int parse_bootdevices(char *devices) | |
2360 | +{ | |
2361 | + /* We just do some generic consistency checks */ | |
2362 | + const char *p; | |
2363 | + int bitmap = 0; | |
2364 | + | |
2365 | + for (p = devices; *p != '\0'; p++) { | |
2366 | + /* Allowed boot devices are: | |
2367 | + * a-b: floppy disk drives | |
2368 | + * c-f: IDE disk drives | |
2369 | + * g-m: machine implementation dependant drives | |
2370 | + * n-p: network devices | |
2371 | + * It's up to each machine implementation to check if the given boot | |
2372 | + * devices match the actual hardware implementation and firmware | |
2373 | + * features. | |
2374 | + */ | |
2375 | + if (*p < 'a' || *p > 'p') { | |
2376 | + fprintf(stderr, "Invalid boot device '%c'\n", *p); | |
2377 | + exit(1); | |
2378 | + } | |
2379 | + if (bitmap & (1 << (*p - 'a'))) { | |
2380 | + fprintf(stderr, "Boot device '%c' was given twice\n", *p); | |
2381 | + exit(1); | |
2382 | + } | |
2383 | + bitmap |= 1 << (*p - 'a'); | |
2384 | + } | |
2385 | + return bitmap; | |
2386 | +} | |
2387 | + | |
2359 | 2388 | static void numa_add(const char *optarg) |
2360 | 2389 | { |
2361 | 2390 | char option[128]; |
... | ... | @@ -4765,7 +4794,7 @@ int main(int argc, char **argv, char **envp) |
4765 | 4794 | int snapshot, linux_boot, net_boot; |
4766 | 4795 | const char *initrd_filename; |
4767 | 4796 | const char *kernel_filename, *kernel_cmdline; |
4768 | - const char *boot_devices = ""; | |
4797 | + char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */ | |
4769 | 4798 | DisplayState *ds; |
4770 | 4799 | DisplayChangeListener *dcl; |
4771 | 4800 | int cyls, heads, secs, translation; |
... | ... | @@ -5054,33 +5083,27 @@ int main(int argc, char **argv, char **envp) |
5054 | 5083 | drive_add(optarg, CDROM_ALIAS); |
5055 | 5084 | break; |
5056 | 5085 | case QEMU_OPTION_boot: |
5057 | - boot_devices = optarg; | |
5058 | - /* We just do some generic consistency checks */ | |
5059 | 5086 | { |
5060 | - /* Could easily be extended to 64 devices if needed */ | |
5061 | - const char *p; | |
5062 | - | |
5063 | - boot_devices_bitmap = 0; | |
5064 | - for (p = boot_devices; *p != '\0'; p++) { | |
5065 | - /* Allowed boot devices are: | |
5066 | - * a b : floppy disk drives | |
5067 | - * c ... f : IDE disk drives | |
5068 | - * g ... m : machine implementation dependant drives | |
5069 | - * n ... p : network devices | |
5070 | - * It's up to each machine implementation to check | |
5071 | - * if the given boot devices match the actual hardware | |
5072 | - * implementation and firmware features. | |
5073 | - */ | |
5074 | - if (*p < 'a' || *p > 'q') { | |
5075 | - fprintf(stderr, "Invalid boot device '%c'\n", *p); | |
5076 | - exit(1); | |
5077 | - } | |
5078 | - if (boot_devices_bitmap & (1 << (*p - 'a'))) { | |
5079 | - fprintf(stderr, | |
5080 | - "Boot device '%c' was given twice\n",*p); | |
5081 | - exit(1); | |
5082 | - } | |
5083 | - boot_devices_bitmap |= 1 << (*p - 'a'); | |
5087 | + static const char * const params[] = { | |
5088 | + "order", NULL | |
5089 | + }; | |
5090 | + char buf[sizeof(boot_devices)]; | |
5091 | + int legacy = 0; | |
5092 | + | |
5093 | + if (!strchr(optarg, '=')) { | |
5094 | + legacy = 1; | |
5095 | + pstrcpy(buf, sizeof(buf), optarg); | |
5096 | + } else if (check_params(buf, sizeof(buf), params, optarg) < 0) { | |
5097 | + fprintf(stderr, | |
5098 | + "qemu: unknown boot parameter '%s' in '%s'\n", | |
5099 | + buf, optarg); | |
5100 | + exit(1); | |
5101 | + } | |
5102 | + | |
5103 | + if (legacy || | |
5104 | + get_param_value(buf, sizeof(buf), "order", optarg)) { | |
5105 | + boot_devices_bitmap = parse_bootdevices(buf); | |
5106 | + pstrcpy(boot_devices, sizeof(boot_devices), buf); | |
5084 | 5107 | } |
5085 | 5108 | } |
5086 | 5109 | break; |
... | ... | @@ -5649,10 +5672,6 @@ int main(int argc, char **argv, char **envp) |
5649 | 5672 | exit(1); |
5650 | 5673 | } |
5651 | 5674 | |
5652 | - /* boot to floppy or the default cd if no hard disk defined yet */ | |
5653 | - if (!boot_devices[0]) { | |
5654 | - boot_devices = "cad"; | |
5655 | - } | |
5656 | 5675 | setvbuf(stdout, NULL, _IOLBF, 0); |
5657 | 5676 | |
5658 | 5677 | init_timers(); | ... | ... |