mirror of https://github.com/xemu-project/xemu.git
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>
This commit is contained in:
parent
e8b2a1c648
commit
ef3adf68f8
81
vl.c
81
vl.c
|
@ -2356,6 +2356,35 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
|
||||||
return drives_table_idx;
|
return drives_table_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int parse_bootdevices(char *devices)
|
||||||
|
{
|
||||||
|
/* We just do some generic consistency checks */
|
||||||
|
const char *p;
|
||||||
|
int bitmap = 0;
|
||||||
|
|
||||||
|
for (p = devices; *p != '\0'; p++) {
|
||||||
|
/* Allowed boot devices are:
|
||||||
|
* a-b: floppy disk drives
|
||||||
|
* c-f: IDE disk drives
|
||||||
|
* g-m: machine implementation dependant drives
|
||||||
|
* n-p: network devices
|
||||||
|
* It's up to each machine implementation to check if the given boot
|
||||||
|
* devices match the actual hardware implementation and firmware
|
||||||
|
* features.
|
||||||
|
*/
|
||||||
|
if (*p < 'a' || *p > 'p') {
|
||||||
|
fprintf(stderr, "Invalid boot device '%c'\n", *p);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (bitmap & (1 << (*p - 'a'))) {
|
||||||
|
fprintf(stderr, "Boot device '%c' was given twice\n", *p);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
bitmap |= 1 << (*p - 'a');
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
static void numa_add(const char *optarg)
|
static void numa_add(const char *optarg)
|
||||||
{
|
{
|
||||||
char option[128];
|
char option[128];
|
||||||
|
@ -4765,7 +4794,7 @@ int main(int argc, char **argv, char **envp)
|
||||||
int snapshot, linux_boot, net_boot;
|
int snapshot, linux_boot, net_boot;
|
||||||
const char *initrd_filename;
|
const char *initrd_filename;
|
||||||
const char *kernel_filename, *kernel_cmdline;
|
const char *kernel_filename, *kernel_cmdline;
|
||||||
const char *boot_devices = "";
|
char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */
|
||||||
DisplayState *ds;
|
DisplayState *ds;
|
||||||
DisplayChangeListener *dcl;
|
DisplayChangeListener *dcl;
|
||||||
int cyls, heads, secs, translation;
|
int cyls, heads, secs, translation;
|
||||||
|
@ -5054,33 +5083,27 @@ int main(int argc, char **argv, char **envp)
|
||||||
drive_add(optarg, CDROM_ALIAS);
|
drive_add(optarg, CDROM_ALIAS);
|
||||||
break;
|
break;
|
||||||
case QEMU_OPTION_boot:
|
case QEMU_OPTION_boot:
|
||||||
boot_devices = optarg;
|
|
||||||
/* We just do some generic consistency checks */
|
|
||||||
{
|
{
|
||||||
/* Could easily be extended to 64 devices if needed */
|
static const char * const params[] = {
|
||||||
const char *p;
|
"order", NULL
|
||||||
|
};
|
||||||
boot_devices_bitmap = 0;
|
char buf[sizeof(boot_devices)];
|
||||||
for (p = boot_devices; *p != '\0'; p++) {
|
int legacy = 0;
|
||||||
/* Allowed boot devices are:
|
|
||||||
* a b : floppy disk drives
|
if (!strchr(optarg, '=')) {
|
||||||
* c ... f : IDE disk drives
|
legacy = 1;
|
||||||
* g ... m : machine implementation dependant drives
|
pstrcpy(buf, sizeof(buf), optarg);
|
||||||
* n ... p : network devices
|
} else if (check_params(buf, sizeof(buf), params, optarg) < 0) {
|
||||||
* It's up to each machine implementation to check
|
fprintf(stderr,
|
||||||
* if the given boot devices match the actual hardware
|
"qemu: unknown boot parameter '%s' in '%s'\n",
|
||||||
* implementation and firmware features.
|
buf, optarg);
|
||||||
*/
|
exit(1);
|
||||||
if (*p < 'a' || *p > 'q') {
|
}
|
||||||
fprintf(stderr, "Invalid boot device '%c'\n", *p);
|
|
||||||
exit(1);
|
if (legacy ||
|
||||||
}
|
get_param_value(buf, sizeof(buf), "order", optarg)) {
|
||||||
if (boot_devices_bitmap & (1 << (*p - 'a'))) {
|
boot_devices_bitmap = parse_bootdevices(buf);
|
||||||
fprintf(stderr,
|
pstrcpy(boot_devices, sizeof(boot_devices), buf);
|
||||||
"Boot device '%c' was given twice\n",*p);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
boot_devices_bitmap |= 1 << (*p - 'a');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -5649,10 +5672,6 @@ int main(int argc, char **argv, char **envp)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* boot to floppy or the default cd if no hard disk defined yet */
|
|
||||||
if (!boot_devices[0]) {
|
|
||||||
boot_devices = "cad";
|
|
||||||
}
|
|
||||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||||
|
|
||||||
init_timers();
|
init_timers();
|
||||||
|
|
Loading…
Reference in New Issue