Index: vl.c =================================================================== RCS file: /sources/qemu/qemu/vl.c,v retrieving revision 1.353 diff -u -d -d -p -r1.353 vl.c --- vl.c 31 Oct 2007 01:54:03 -0000 1.353 +++ vl.c 31 Oct 2007 22:39:27 -0000 @@ -162,12 +162,6 @@ static DisplayState display_state; int nographic; const char* keyboard_layout = NULL; int64_t ticks_per_sec; -#if defined(TARGET_I386) -#define MAX_BOOT_DEVICES 3 -#else -#define MAX_BOOT_DEVICES 1 -#endif -static char boot_device[MAX_BOOT_DEVICES + 1]; int ram_size; int pit_min_timer_count = 0; int nb_nics; @@ -7564,6 +7560,7 @@ int main(int argc, char **argv) const char *sd_filename; const char *mtd_filename; const char *kernel_filename, *kernel_cmdline; + const char *boot_devices = ""; DisplayState *ds = &display_state; int cyls, heads, secs, translation; char net_clients[MAX_NET_CLIENTS][256]; @@ -7815,20 +7812,31 @@ int main(int argc, char **argv) } break; case QEMU_OPTION_boot: - if (strlen(optarg) > MAX_BOOT_DEVICES) { - fprintf(stderr, "qemu: too many boot devices\n"); - exit(1); - } - strncpy(boot_device, optarg, MAX_BOOT_DEVICES); -#if defined(TARGET_SPARC) || defined(TARGET_I386) -#define BOOTCHARS "acdn" -#else -#define BOOTCHARS "acd" -#endif - if (strlen(boot_device) != strspn(boot_device, BOOTCHARS)) { - fprintf(stderr, "qemu: invalid boot device " - "sequence '%s'\n", boot_device); - exit(1); + boot_devices = optarg; + /* We just do some generic consistency checks */ + { + /* Could easily be extended to 64 devices if needed */ + const unsigned char *p; + uint32_t boot_devices_bitmap = 0; + + for (p = boot_devices; *p != '\0'; p++) { + /* Note this could easily be extended in a way like: + * if (*p < 'a' || (*p > 'e' && *p != 'n')) + * then provide at least the ability to boot from + * any floppy or IDE drive for targets that can + * handle it. + */ + if (*p != 'a' && *p != 'c' && *p != 'd' && *p != 'n') { + fprintf(stderr, "Invalid boot device '%c'\n", *p); + exit(1); + } + if (boot_devices_bitmap & (1 << (*p - 'a'))) { + fprintf(stderr, + "Boot device '%c' was given twice\n",*p); + exit(1); + } + boot_devices_bitmap |= 1 << (p - 'a'); + } } break; case QEMU_OPTION_fda: @@ -8178,21 +8186,20 @@ int main(int argc, char **argv) linux_boot = (kernel_filename != NULL); if (!linux_boot && - (!strchr(boot_device, 'n')) && + (!strchr(boot_devices, 'n')) && hd_filename[0] == '\0' && (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') && fd_filename[0] == '\0') help(1); /* boot to floppy or the default cd if no hard disk defined yet */ - if (!boot_device[0]) { + if (!boot_devices[0]) { if (hd_filename[0] != '\0') - boot_device[0] = 'c'; + boot_devices = "c"; else if (fd_filename[0] != '\0') - boot_device[0] = 'a'; + boot_devices = "a"; else - boot_device[0] = 'd'; - boot_device[1] = 0; + boot_devices = "d"; } setvbuf(stdout, NULL, _IOLBF, 0); @@ -8232,7 +8239,7 @@ int main(int argc, char **argv) } #ifdef TARGET_I386 - if (strchr(boot_device, 'n')) { + if (strchr(boot_devices, 'n')) { for (i = 0; i < nb_nics; i++) { const char *model = nd_table[i].model; char buf[1024]; @@ -8425,7 +8432,7 @@ int main(int argc, char **argv) } } - machine->init(ram_size, vga_ram_size, boot_device, + machine->init(ram_size, vga_ram_size, boot_devices, ds, fd_filename, snapshot, kernel_filename, kernel_cmdline, initrd_filename, cpu_model);