From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LvzgB-00071i-Og for qemu-devel@nongnu.org; Mon, 20 Apr 2009 16:01:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lvzg7-0006zu-0M for qemu-devel@nongnu.org; Mon, 20 Apr 2009 16:01:23 -0400 Received: from [199.232.76.173] (port=39796 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lvzg6-0006zp-Tb for qemu-devel@nongnu.org; Mon, 20 Apr 2009 16:01:18 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:49161) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lvzg5-0005Rd-OT for qemu-devel@nongnu.org; Mon, 20 Apr 2009 16:01:18 -0400 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate01.web.de (Postfix) with ESMTP id 45A6710052C81 for ; Mon, 20 Apr 2009 22:01:16 +0200 (CEST) Received: from [88.65.38.201] (helo=[192.168.1.123]) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #277) id 1Lvzg3-0003dZ-00 for qemu-devel@nongnu.org; Mon, 20 Apr 2009 22:01:15 +0200 Message-ID: <49ECD485.9010002@web.de> Date: Mon, 20 Apr 2009 22:01:09 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <49ECAB4A.2090106@siemens.com> <49ECB940.5060100@codemonkey.ws> <49ECC01E.80605@web.de> <49ECC1E9.8020708@redhat.com> In-Reply-To: <49ECC1E9.8020708@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigAD533B8967572FFFB86F71C5" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH 1/2 -v] Rework -boot option Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigAD533B8967572FFFB86F71C5 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable 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 orde= r >> 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. N= ot >> much simpler, but a bit. And comes with the chance to drop the legacy = at >> some point. Any naming suggestions welcome! >> =20 >=20 > I suggest keeping /boot. And slightly change Anthony's proposal to: >=20 > - if no '=3D' 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=3Ddrives][,interactive=3Don|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 --- 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_po= rt, 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_interactiv= e); =20 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 =20 #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 =20 DEF("boot", HAS_ARG, QEMU_OPTION_boot, - "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or n= etwork (n)\n") + "-boot [order=3Ddrives][,interactive=3Don|off]\n" + " 'drives': floppy (a), hard disk (c), CD-ROM (d), ne= twork (n)\n") STEXI -@item -boot [a|c|d|n] -Boot on floppy (a), hard disk (c), CD-ROM (d), or Etherboot (n). Hard di= sk boot -is the default. +@item -boot [order=3D@var{drives}][,interactive=3Don|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=3Dnc +@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 =20 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; =20 #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; =20 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 =3D ""; + char boot_devices[33] =3D ""; 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 =3D optarg; - /* We just do some generic consistency checks */ { - /* Could easily be extended to 64 devices if needed = */ - const char *p; - =20 - boot_devices_bitmap =3D 0; - for (p =3D boot_devices; *p !=3D '\0'; p++) { - /* Allowed boot devices are: - * a b : floppy disk drives - * c ... f : IDE disk drives - * g ... m : machine implementation dependant dr= ives - * n ... p : network devices - * It's up to each machine implementation to che= ck - * if the given boot devices match the actual ha= rdware - * implementation and firmware features. - */ - if (*p < 'a' || *p > 'q') { - fprintf(stderr, "Invalid boot device '%c'\n"= , *p); - exit(1); + static const char * const params[] =3D { + "order", "interactive", NULL + }; + int legacy =3D 0; + char buf[16]; + + if (!strchr(optarg, '=3D')) { + legacy =3D 1; + pstrcpy(boot_devices, sizeof(boot_devices), opta= rg); + } else if (check_params(buf, sizeof(buf), params, op= targ) < 0) { + fprintf(stderr, + "qemu: unknown boot parameter '%s' in '%= s'\n", + buf, optarg); + exit(1); + } + + if (legacy || + get_param_value(boot_devices, sizeof(boot_device= s), + "order", optarg)) { + /* We just do some generic consistency checks */= + const char *p; + + boot_devices_bitmap =3D 0; + for (p =3D boot_devices; *p !=3D '\0'; p++) { + /* Allowed boot devices are: + * a-b: floppy disk drives + * c-f: IDE disk drives + * g-m: machine implementation dependant dri= ves + * n-p: network devices + * It's up to each machine implementation to= check + * if the given boot devices match the actua= l + * hardware implementation and firmware feat= ures. + */ + 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 twic= e\n", + *p); + exit(1); + } + boot_devices_bitmap |=3D 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 =3D 1; + } else if (!strcmp(buf, "off")) { + boot_interactive =3D 0; + } else { + fprintf(stderr, + "qemu: invalid option value '%s'\n", = buf); + exit(1); } - boot_devices_bitmap |=3D 1 << (*p - 'a'); } } break; @@ -5074,7 +5107,7 @@ int main(int argc, char **argv, char **envp) =20 /* boot to floppy or the default cd if no hard disk defined yet */ if (!boot_devices[0]) { - boot_devices =3D "cad"; + strcpy(boot_devices, "cad"); } setvbuf(stdout, NULL, _IOLBF, 0); =20 --------------enigAD533B8967572FFFB86F71C5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkns1IsACgkQniDOoMHTA+mCuACbB/CtMhdruzuQfCNqxWIh24sq PdEAn2bnu94bw6mls6FRLjttJL8wKPYe =3YG2 -----END PGP SIGNATURE----- --------------enigAD533B8967572FFFB86F71C5--