* [Qemu-devel] [PATCH 1/2] Rework -boot option @ 2009-04-20 17:05 Jan Kiszka 2009-04-20 18:04 ` Anthony Liguori 0 siblings, 1 reply; 7+ messages in thread From: Jan Kiszka @ 2009-04-20 17:05 UTC (permalink / raw) To: qemu-devel This patch changes the boot command line option to the canonical format -boot [order=drives][,interactive=on|off] where 'drives' is using the same format as the old -boot. The new format is required in order to add the 'interactive' option and use the existing infrastructure to parse it. The state of 'interactive' is transfered to the firmware via the new configuration value FW_CFG_BOOT_INTERACTIVE. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- hw/fw_cfg.c | 1 + hw/fw_cfg.h | 1 + qemu-options.hx | 19 ++++++++++--- sysemu.h | 1 + vl.c | 80 +++++++++++++++++++++++++++++++++++++------------------ 5 files changed, 72 insertions(+), 30 deletions(-) diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c index e1b19d7..c21cdb3 100644 --- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -279,6 +279,7 @@ void *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)nographic); fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); + fw_cfg_add_i16(s, FW_CFG_BOOT_INTERACTIVE, (uint16_t)boot_interactive); register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s); qemu_register_reset(fw_cfg_reset, s); diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h index 41a3dd0..131dbf2 100644 --- a/hw/fw_cfg.h +++ b/hw/fw_cfg.h @@ -14,6 +14,7 @@ #define FW_CFG_INITRD_ADDR 0x0a #define FW_CFG_INITRD_SIZE 0x0b #define FW_CFG_BOOT_DEVICE 0x0c +#define FW_CFG_BOOT_INTERACTIVE 0x0d #define FW_CFG_MAX_ENTRY 0x10 #define FW_CFG_WRITE_CHANNEL 0x4000 diff --git a/qemu-options.hx b/qemu-options.hx index 4d15f9b..4cfe199 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -210,11 +210,22 @@ Use 'file' as a parallel flash image. ETEXI DEF("boot", HAS_ARG, QEMU_OPTION_boot, - "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n") + "-boot [order=drives][,interactive=on|off]\n" + " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n") STEXI -@item -boot [a|c|d|n] -Boot on floppy (a), hard disk (c), CD-ROM (d), or Etherboot (n). Hard disk boot -is the default. +@item -boot [order=@var{drives}][,interactive=on|off] + +Specify boot order @var{drives} as a string of drive letters. Valid +drive letters depend on the target achitecture. The x86 PC uses: a, b +(floppy 1 and 2), c (first hard disk), d (first CD-ROM), n-p (Etherboot +from network adapter 1-4), hard disk boot is the default. Furthermore, +interactive boot menus/prompts can be enabled as far as firmware/BIOS +supports them. The default is non-interactive boot. + +@example +# try to boot from network first, then from hard disk +qemu -boot order=nc +@end example ETEXI DEF("snapshot", 0, QEMU_OPTION_snapshot, diff --git a/sysemu.h b/sysemu.h index 2b1677c..5aed865 100644 --- a/sysemu.h +++ b/sysemu.h @@ -103,6 +103,7 @@ extern int graphic_rotate; extern int no_quit; extern int semihosting_enabled; extern int old_param; +extern int boot_interactive; #ifdef USE_KQEMU extern int kqemu_allowed; diff --git a/vl.c b/vl.c index 72ea0e4..5b2f2c8 100644 --- a/vl.c +++ b/vl.c @@ -264,6 +264,7 @@ const char *prom_envs[MAX_PROM_ENVS]; #endif int nb_drives_opt; struct drive_opt drives_opt[MAX_DRIVES]; +int boot_interactive; static CPUState *cur_cpu; static CPUState *next_cpu; @@ -4254,7 +4255,7 @@ int main(int argc, char **argv, char **envp) int snapshot, linux_boot, net_boot; const char *initrd_filename; const char *kernel_filename, *kernel_cmdline; - const char *boot_devices = ""; + char boot_devices[33] = ""; DisplayState *ds; DisplayChangeListener *dcl; int cyls, heads, secs, translation; @@ -4529,33 +4530,60 @@ int main(int argc, char **argv, char **envp) drive_add(optarg, CDROM_ALIAS); break; case QEMU_OPTION_boot: - boot_devices = optarg; - /* We just do some generic consistency checks */ { - /* Could easily be extended to 64 devices if needed */ - const char *p; - - boot_devices_bitmap = 0; - for (p = boot_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 > 'q') { - fprintf(stderr, "Invalid boot device '%c'\n", *p); - exit(1); + static const char * const params[] = { + "order", "interactive", NULL + }; + char buf[16]; + + if (check_params(buf, sizeof(buf), params, optarg) < 0) { + fprintf(stderr, + "qemu: unknown boot parameter '%s' in '%s'\n", + buf, optarg); + exit(1); + } + + if (get_param_value(boot_devices, sizeof(boot_devices), + "order", optarg)) { + /* We just do some generic consistency checks */ + const char *p; + + boot_devices_bitmap = 0; + for (p = boot_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 (boot_devices_bitmap & (1 << (*p - 'a'))) { + fprintf(stderr, + "Boot device '%c' was given twice\n", + *p); + exit(1); + } + boot_devices_bitmap |= 1 << (*p - 'a'); } - if (boot_devices_bitmap & (1 << (*p - 'a'))) { - fprintf(stderr, - "Boot device '%c' was given twice\n",*p); - exit(1); + } + if (get_param_value(buf, sizeof(buf), "interactive", + optarg)) { + if (!strcmp(buf, "on")) { + boot_interactive = 1; + } else if (!strcmp(buf, "off")) { + boot_interactive = 0; + } else { + fprintf(stderr, + "qemu: invalid option value '%s'\n", buf); + exit(1); } - boot_devices_bitmap |= 1 << (*p - 'a'); } } break; @@ -5074,7 +5102,7 @@ int main(int argc, char **argv, char **envp) /* boot to floppy or the default cd if no hard disk defined yet */ if (!boot_devices[0]) { - boot_devices = "cad"; + strcpy(boot_devices, "cad"); } setvbuf(stdout, NULL, _IOLBF, 0); ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] Rework -boot option 2009-04-20 17:05 [Qemu-devel] [PATCH 1/2] Rework -boot option Jan Kiszka @ 2009-04-20 18:04 ` Anthony Liguori 2009-04-20 18:34 ` [Qemu-devel] " Jan Kiszka 2009-04-20 18:38 ` [Qemu-devel] " Daniel P. Berrange 0 siblings, 2 replies; 7+ messages in thread From: Anthony Liguori @ 2009-04-20 18:04 UTC (permalink / raw) To: qemu-devel Jan Kiszka wrote: > This patch changes the boot command line option to the canonical format > > -boot [order=drives][,interactive=on|off] > > where 'drives' is using the same format as the old -boot. The new format > is required in order to add the 'interactive' option and use the > existing infrastructure to parse it. > > The state of 'interactive' is transfered to the firmware via the new > configuration value FW_CFG_BOOT_INTERACTIVE. > > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > This breaks compatibility with existing management tools. Can't we do: -boot [order=]drives[,interactive=on|off] Certainly, -drive introduces a precedence for this type of format. Regards, Anthony Liguori > --- > > hw/fw_cfg.c | 1 + > hw/fw_cfg.h | 1 + > qemu-options.hx | 19 ++++++++++--- > sysemu.h | 1 + > vl.c | 80 +++++++++++++++++++++++++++++++++++++------------------ > 5 files changed, 72 insertions(+), 30 deletions(-) > > diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c > index e1b19d7..c21cdb3 100644 > --- a/hw/fw_cfg.c > +++ b/hw/fw_cfg.c > @@ -279,6 +279,7 @@ void *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, > fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); > fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)nographic); > fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); > + fw_cfg_add_i16(s, FW_CFG_BOOT_INTERACTIVE, (uint16_t)boot_interactive); > > register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s); > qemu_register_reset(fw_cfg_reset, s); > diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h > index 41a3dd0..131dbf2 100644 > --- a/hw/fw_cfg.h > +++ b/hw/fw_cfg.h > @@ -14,6 +14,7 @@ > #define FW_CFG_INITRD_ADDR 0x0a > #define FW_CFG_INITRD_SIZE 0x0b > #define FW_CFG_BOOT_DEVICE 0x0c > +#define FW_CFG_BOOT_INTERACTIVE 0x0d > #define FW_CFG_MAX_ENTRY 0x10 > > #define FW_CFG_WRITE_CHANNEL 0x4000 > diff --git a/qemu-options.hx b/qemu-options.hx > index 4d15f9b..4cfe199 100644 > --- a/qemu-options.hx > +++ b/qemu-options.hx > @@ -210,11 +210,22 @@ Use 'file' as a parallel flash image. > ETEXI > > DEF("boot", HAS_ARG, QEMU_OPTION_boot, > - "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n") > + "-boot [order=drives][,interactive=on|off]\n" > + " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n") > STEXI > -@item -boot [a|c|d|n] > -Boot on floppy (a), hard disk (c), CD-ROM (d), or Etherboot (n). Hard disk boot > -is the default. > +@item -boot [order=@var{drives}][,interactive=on|off] > + > +Specify boot order @var{drives} as a string of drive letters. Valid > +drive letters depend on the target achitecture. The x86 PC uses: a, b > +(floppy 1 and 2), c (first hard disk), d (first CD-ROM), n-p (Etherboot > +from network adapter 1-4), hard disk boot is the default. Furthermore, > +interactive boot menus/prompts can be enabled as far as firmware/BIOS > +supports them. The default is non-interactive boot. > + > +@example > +# try to boot from network first, then from hard disk > +qemu -boot order=nc > +@end example > ETEXI > > DEF("snapshot", 0, QEMU_OPTION_snapshot, > diff --git a/sysemu.h b/sysemu.h > index 2b1677c..5aed865 100644 > --- a/sysemu.h > +++ b/sysemu.h > @@ -103,6 +103,7 @@ extern int graphic_rotate; > extern int no_quit; > extern int semihosting_enabled; > extern int old_param; > +extern int boot_interactive; > > #ifdef USE_KQEMU > extern int kqemu_allowed; > diff --git a/vl.c b/vl.c > index 72ea0e4..5b2f2c8 100644 > --- a/vl.c > +++ b/vl.c > @@ -264,6 +264,7 @@ const char *prom_envs[MAX_PROM_ENVS]; > #endif > int nb_drives_opt; > struct drive_opt drives_opt[MAX_DRIVES]; > +int boot_interactive; > > static CPUState *cur_cpu; > static CPUState *next_cpu; > @@ -4254,7 +4255,7 @@ int main(int argc, char **argv, char **envp) > int snapshot, linux_boot, net_boot; > const char *initrd_filename; > const char *kernel_filename, *kernel_cmdline; > - const char *boot_devices = ""; > + char boot_devices[33] = ""; > DisplayState *ds; > DisplayChangeListener *dcl; > int cyls, heads, secs, translation; > @@ -4529,33 +4530,60 @@ int main(int argc, char **argv, char **envp) > drive_add(optarg, CDROM_ALIAS); > break; > case QEMU_OPTION_boot: > - boot_devices = optarg; > - /* We just do some generic consistency checks */ > { > - /* Could easily be extended to 64 devices if needed */ > - const char *p; > - > - boot_devices_bitmap = 0; > - for (p = boot_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 > 'q') { > - fprintf(stderr, "Invalid boot device '%c'\n", *p); > - exit(1); > + static const char * const params[] = { > + "order", "interactive", NULL > + }; > + char buf[16]; > + > + if (check_params(buf, sizeof(buf), params, optarg) < 0) { > + fprintf(stderr, > + "qemu: unknown boot parameter '%s' in '%s'\n", > + buf, optarg); > + exit(1); > + } > + > + if (get_param_value(boot_devices, sizeof(boot_devices), > + "order", optarg)) { > + /* We just do some generic consistency checks */ > + const char *p; > + > + boot_devices_bitmap = 0; > + for (p = boot_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 (boot_devices_bitmap & (1 << (*p - 'a'))) { > + fprintf(stderr, > + "Boot device '%c' was given twice\n", > + *p); > + exit(1); > + } > + boot_devices_bitmap |= 1 << (*p - 'a'); > } > - if (boot_devices_bitmap & (1 << (*p - 'a'))) { > - fprintf(stderr, > - "Boot device '%c' was given twice\n",*p); > - exit(1); > + } > + if (get_param_value(buf, sizeof(buf), "interactive", > + optarg)) { > + if (!strcmp(buf, "on")) { > + boot_interactive = 1; > + } else if (!strcmp(buf, "off")) { > + boot_interactive = 0; > + } else { > + fprintf(stderr, > + "qemu: invalid option value '%s'\n", buf); > + exit(1); > } > - boot_devices_bitmap |= 1 << (*p - 'a'); > } > } > break; > @@ -5074,7 +5102,7 @@ int main(int argc, char **argv, char **envp) > > /* boot to floppy or the default cd if no hard disk defined yet */ > if (!boot_devices[0]) { > - boot_devices = "cad"; > + strcpy(boot_devices, "cad"); > } > setvbuf(stdout, NULL, _IOLBF, 0); > > > > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] Re: [PATCH 1/2] Rework -boot option 2009-04-20 18:04 ` Anthony Liguori @ 2009-04-20 18:34 ` Jan Kiszka 2009-04-20 18:41 ` Avi Kivity 2009-04-20 19:13 ` [Qemu-devel] Re: [PATCH 1/2] " Anthony Liguori 2009-04-20 18:38 ` [Qemu-devel] " Daniel P. Berrange 1 sibling, 2 replies; 7+ messages in thread From: Jan Kiszka @ 2009-04-20 18:34 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 1248 bytes --] Anthony Liguori wrote: > Jan Kiszka wrote: >> This patch changes the boot command line option to the canonical format >> >> -boot [order=drives][,interactive=on|off] >> >> where 'drives' is using the same format as the old -boot. The new format >> is required in order to add the 'interactive' option and use the >> existing infrastructure to parse it. >> >> The state of 'interactive' is transfered to the firmware via the new >> configuration value FW_CFG_BOOT_INTERACTIVE. >> >> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> >> > > This breaks compatibility with existing management tools. Can't we do: > > -boot [order=]drives[,interactive=on|off] > > Certainly, -drive introduces a precedence for this type of format. Everything is possible, but comes with a price: - more complex code - more ugly and inconsistent user interface Is there no precedence for breaking the command line interface in order to clean things up? An alternative could be to keep -boot as is, at least for the next few major releases, and introduce a new option with the proposed format. Not much simpler, but a bit. And comes with the chance to drop the legacy at some point. Any naming suggestions welcome! Jan [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 257 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] Re: [PATCH 1/2] Rework -boot option 2009-04-20 18:34 ` [Qemu-devel] " Jan Kiszka @ 2009-04-20 18:41 ` Avi Kivity 2009-04-20 20:01 ` [Qemu-devel] [PATCH 1/2 -v] " Jan Kiszka 2009-04-20 19:13 ` [Qemu-devel] Re: [PATCH 1/2] " Anthony Liguori 1 sibling, 1 reply; 7+ messages in thread From: Avi Kivity @ 2009-04-20 18:41 UTC (permalink / raw) To: qemu-devel Jan Kiszka wrote: > Everything is possible, but comes with a price: > - more complex code > - more ugly and inconsistent user interface > > Is there no precedence for breaking the command line interface in order > to clean things up? > > An alternative could be to keep -boot as is, at least for the next few > major releases, and introduce a new option with the proposed format. Not > much simpler, but a bit. And comes with the chance to drop the legacy at > some point. Any naming suggestions welcome! > I suggest keeping /boot. And slightly change Anthony's proposal to: - if no '=' is found in the parameter, use the old syntax - otherwise, use the new syntax -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 1/2 -v] Rework -boot option 2009-04-20 18:41 ` Avi Kivity @ 2009-04-20 20:01 ` Jan Kiszka 0 siblings, 0 replies; 7+ messages in thread From: Jan Kiszka @ 2009-04-20 20:01 UTC (permalink / raw) To: qemu-devel [-- Attachment #1: Type: text/plain, Size: 9898 bytes --] Avi Kivity wrote: > Jan Kiszka wrote: >> Everything is possible, but comes with a price: >> - more complex code >> - more ugly and inconsistent user interface >> >> Is there no precedence for breaking the command line interface in order >> to clean things up? >> >> An alternative could be to keep -boot as is, at least for the next few >> major releases, and introduce a new option with the proposed format. Not >> much simpler, but a bit. And comes with the chance to drop the legacy at >> some point. Any naming suggestions welcome! >> > > I suggest keeping /boot. And slightly change Anthony's proposal to: > > - if no '=' is found in the parameter, use the old syntax > - otherwise, use the new syntax Yep, that's precisely what I did now - turned out to be less complex then I expected. -----------> This patch changes the boot command line option to the canonical format -boot [order=drives][,interactive=on|off] where 'drives' is using the same format as the old -boot. The format switch allows to add the 'interactive' option and use the existing infrastructure to parse it. However, the old format is still understood and will be processed at least for a transition time. The state of 'interactive' is transfered to the firmware via the new configuration value FW_CFG_BOOT_INTERACTIVE. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- hw/fw_cfg.c | 1 + hw/fw_cfg.h | 1 + qemu-options.hx | 22 ++++++++++++-- sysemu.h | 1 + vl.c | 85 ++++++++++++++++++++++++++++++++++++++----------------- 5 files changed, 80 insertions(+), 30 deletions(-) diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c index e1b19d7..c21cdb3 100644 --- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -279,6 +279,7 @@ void *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)nographic); fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); + fw_cfg_add_i16(s, FW_CFG_BOOT_INTERACTIVE, (uint16_t)boot_interactive); register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s); qemu_register_reset(fw_cfg_reset, s); diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h index 41a3dd0..131dbf2 100644 --- a/hw/fw_cfg.h +++ b/hw/fw_cfg.h @@ -14,6 +14,7 @@ #define FW_CFG_INITRD_ADDR 0x0a #define FW_CFG_INITRD_SIZE 0x0b #define FW_CFG_BOOT_DEVICE 0x0c +#define FW_CFG_BOOT_INTERACTIVE 0x0d #define FW_CFG_MAX_ENTRY 0x10 #define FW_CFG_WRITE_CHANNEL 0x4000 diff --git a/qemu-options.hx b/qemu-options.hx index 1d783e5..a8ff5f2 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -210,11 +210,25 @@ Use 'file' as a parallel flash image. ETEXI DEF("boot", HAS_ARG, QEMU_OPTION_boot, - "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n") + "-boot [order=drives][,interactive=on|off]\n" + " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n") STEXI -@item -boot [a|c|d|n] -Boot on floppy (a), hard disk (c), CD-ROM (d), or Etherboot (n). Hard disk boot -is the default. +@item -boot [order=@var{drives}][,interactive=on|off] + +Specify boot order @var{drives} as a string of drive letters. Valid +drive letters depend on the target achitecture. The x86 PC uses: a, b +(floppy 1 and 2), c (first hard disk), d (first CD-ROM), n-p (Etherboot +from network adapter 1-4), hard disk boot is the default. Furthermore, +interactive boot menus/prompts can be enabled as far as firmware/BIOS +supports them. The default is non-interactive boot. + +@example +# try to boot from network first, then from hard disk +qemu -boot order=nc +@end example + +Note: The legacy format '-boot @var{drives}' is still supported but its +use is discouraged as it may be removed from future versions. ETEXI DEF("snapshot", 0, QEMU_OPTION_snapshot, diff --git a/sysemu.h b/sysemu.h index 24b4bd1..fd68f4b 100644 --- a/sysemu.h +++ b/sysemu.h @@ -103,6 +103,7 @@ extern int graphic_rotate; extern int no_quit; extern int semihosting_enabled; extern int old_param; +extern int boot_interactive; #ifdef CONFIG_KQEMU extern int kqemu_allowed; diff --git a/vl.c b/vl.c index 55a9bc5..833cc1b 100644 --- a/vl.c +++ b/vl.c @@ -264,6 +264,7 @@ const char *prom_envs[MAX_PROM_ENVS]; #endif int nb_drives_opt; struct drive_opt drives_opt[MAX_DRIVES]; +int boot_interactive; static CPUState *cur_cpu; static CPUState *next_cpu; @@ -4254,7 +4255,7 @@ int main(int argc, char **argv, char **envp) int snapshot, linux_boot, net_boot; const char *initrd_filename; const char *kernel_filename, *kernel_cmdline; - const char *boot_devices = ""; + char boot_devices[33] = ""; DisplayState *ds; DisplayChangeListener *dcl; int cyls, heads, secs, translation; @@ -4529,33 +4530,65 @@ int main(int argc, char **argv, char **envp) drive_add(optarg, CDROM_ALIAS); break; case QEMU_OPTION_boot: - boot_devices = optarg; - /* We just do some generic consistency checks */ { - /* Could easily be extended to 64 devices if needed */ - const char *p; - - boot_devices_bitmap = 0; - for (p = boot_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 > 'q') { - fprintf(stderr, "Invalid boot device '%c'\n", *p); - exit(1); + static const char * const params[] = { + "order", "interactive", NULL + }; + int legacy = 0; + char buf[16]; + + if (!strchr(optarg, '=')) { + legacy = 1; + pstrcpy(boot_devices, sizeof(boot_devices), optarg); + } else if (check_params(buf, sizeof(buf), params, optarg) < 0) { + fprintf(stderr, + "qemu: unknown boot parameter '%s' in '%s'\n", + buf, optarg); + exit(1); + } + + if (legacy || + get_param_value(boot_devices, sizeof(boot_devices), + "order", optarg)) { + /* We just do some generic consistency checks */ + const char *p; + + boot_devices_bitmap = 0; + for (p = boot_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 (boot_devices_bitmap & (1 << (*p - 'a'))) { + fprintf(stderr, + "Boot device '%c' was given twice\n", + *p); + exit(1); + } + boot_devices_bitmap |= 1 << (*p - 'a'); } - if (boot_devices_bitmap & (1 << (*p - 'a'))) { - fprintf(stderr, - "Boot device '%c' was given twice\n",*p); - exit(1); + } + if (!legacy && get_param_value(buf, sizeof(buf), + "interactive", optarg)) { + if (!strcmp(buf, "on")) { + boot_interactive = 1; + } else if (!strcmp(buf, "off")) { + boot_interactive = 0; + } else { + fprintf(stderr, + "qemu: invalid option value '%s'\n", buf); + exit(1); } - boot_devices_bitmap |= 1 << (*p - 'a'); } } break; @@ -5074,7 +5107,7 @@ int main(int argc, char **argv, char **envp) /* boot to floppy or the default cd if no hard disk defined yet */ if (!boot_devices[0]) { - boot_devices = "cad"; + strcpy(boot_devices, "cad"); } setvbuf(stdout, NULL, _IOLBF, 0); [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 257 bytes --] ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] Re: [PATCH 1/2] Rework -boot option 2009-04-20 18:34 ` [Qemu-devel] " Jan Kiszka 2009-04-20 18:41 ` Avi Kivity @ 2009-04-20 19:13 ` Anthony Liguori 1 sibling, 0 replies; 7+ messages in thread From: Anthony Liguori @ 2009-04-20 19:13 UTC (permalink / raw) To: qemu-devel Jan Kiszka wrote: > Everything is possible, but comes with a price: > - more complex code > - more ugly and inconsistent user interface > > Is there no precedence for breaking the command line interface in order > to clean things up? > I'm not opposed to breaking syntax when necessary, but I think the benefits need to be strong and every attempt at preserving compatibility should be made. If you really want a clean separation, introduce a different parameter than -boot and make -boot deprecated. Regards, Anthony Liguori ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] Rework -boot option 2009-04-20 18:04 ` Anthony Liguori 2009-04-20 18:34 ` [Qemu-devel] " Jan Kiszka @ 2009-04-20 18:38 ` Daniel P. Berrange 1 sibling, 0 replies; 7+ messages in thread From: Daniel P. Berrange @ 2009-04-20 18:38 UTC (permalink / raw) To: qemu-devel On Mon, Apr 20, 2009 at 01:04:48PM -0500, Anthony Liguori wrote: > Jan Kiszka wrote: > >This patch changes the boot command line option to the canonical format > > > > -boot [order=drives][,interactive=on|off] > > > >where 'drives' is using the same format as the old -boot. The new format > >is required in order to add the 'interactive' option and use the > >existing infrastructure to parse it. > > > >The state of 'interactive' is transfered to the firmware via the new > >configuration value FW_CFG_BOOT_INTERACTIVE. > > > >Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > > > > This breaks compatibility with existing management tools. Can't we do: > > -boot [order=]drives[,interactive=on|off] > > Certainly, -drive introduces a precedence for this type of format. The 'order=' seems a little overkill - just leave it out entirely, just having: -boot drives,interactive=on|off which is fully back-compatible too. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-04-20 20:01 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-04-20 17:05 [Qemu-devel] [PATCH 1/2] Rework -boot option Jan Kiszka 2009-04-20 18:04 ` Anthony Liguori 2009-04-20 18:34 ` [Qemu-devel] " Jan Kiszka 2009-04-20 18:41 ` Avi Kivity 2009-04-20 20:01 ` [Qemu-devel] [PATCH 1/2 -v] " Jan Kiszka 2009-04-20 19:13 ` [Qemu-devel] Re: [PATCH 1/2] " Anthony Liguori 2009-04-20 18:38 ` [Qemu-devel] " Daniel P. Berrange
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).