From patchwork Tue Mar 19 06:23:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 228917 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 849892C00BE for ; Tue, 19 Mar 2013 17:24:42 +1100 (EST) Received: from localhost ([::1]:45844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHpyS-0003cC-OH for incoming@patchwork.ozlabs.org; Tue, 19 Mar 2013 02:24:40 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHpyD-0003bt-Un for qemu-devel@nongnu.org; Tue, 19 Mar 2013 02:24:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHpyB-0005U6-2b for qemu-devel@nongnu.org; Tue, 19 Mar 2013 02:24:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39453) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHpyA-0005TC-Qc for qemu-devel@nongnu.org; Tue, 19 Mar 2013 02:24:22 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2J6OLZJ031864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 19 Mar 2013 02:24:21 -0400 Received: from dhcp-8-167.nay.redhat.com ([10.66.4.143]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2J6OIIK015554; Tue, 19 Mar 2013 02:24:19 -0400 From: Amos Kong To: qemu-devel@nongnu.org, aliguori@us.ibm.com Date: Tue, 19 Mar 2013 14:23:27 +0800 Message-Id: <1363674207-31496-1-git-send-email-akong@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: libvir-list@redhat.com Subject: [Qemu-devel] [PATCH v3] add a boot option to do strict boot X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Seabios already added a new device type to halt booting. Qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from all selected devices. This patch added a new boot option to configure if boot from un-selected devices. This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices. v2: add HALT entry in get_boot_devices_list() v3: rebase to latest qemu upstream Signed-off-by: Amos Kong --- As we discussed in the past, we need to introduce a general query-config command to tell libvirt the supported options. Anthony will do it? http://lists.nongnu.org/archive/html/qemu-devel/2013-03/msg00349.html --- qemu-options.hx | 8 ++++++-- vl.c | 25 ++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 30fb85d..06dd565 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -161,14 +161,14 @@ ETEXI DEF("boot", HAS_ARG, QEMU_OPTION_boot, "-boot [order=drives][,once=drives][,menu=on|off]\n" - " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n" + " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n" " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n" " 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n" " 'sp_time': the period that splash picture last if menu=on, unit is ms\n" " 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n", QEMU_ARCH_ALL) STEXI -@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}] +@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}][,strict=on|off] @findex -boot 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 @@ -192,6 +192,10 @@ when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not reboot, qemu passes '-1' to bios by default. Currently Seabios for X86 system support it. +Do strict boot via @option{strict=on} as far as firmware/BIOS +supports it. This only effects when boot priority is changed by +bootindex options. The default is non-strict boot. + @example # try to boot from network first, then from hard disk qemu-system-i386 -boot order=nc diff --git a/vl.c b/vl.c index ce51e65..aeed7f4 100644 --- a/vl.c +++ b/vl.c @@ -234,6 +234,7 @@ int ctrl_grab = 0; unsigned int nb_prom_envs = 0; const char *prom_envs[MAX_PROM_ENVS]; int boot_menu; +bool boot_strict; uint8_t *boot_splash_filedata; size_t boot_splash_filedata_size; uint8_t qemu_extra_params_fw[2]; @@ -458,6 +459,9 @@ static QemuOptsList qemu_boot_opts = { }, { .name = "reboot-timeout", .type = QEMU_OPT_STRING, + }, { + .name = "strict", + .type = QEMU_OPT_STRING, }, { /*End of list */ } }, @@ -1267,6 +1271,12 @@ char *get_boot_devices_list(size_t *size) *size = total; + if (boot_strict && *size > 0) { + list[total-1] = '\n'; + list = g_realloc(list, total + 4); + memcpy(&list[total], "HALT", 4); + *size = total + 4; + } return list; } @@ -3131,7 +3141,7 @@ int main(int argc, char **argv, char **envp) static const char * const params[] = { "order", "once", "menu", "splash", "splash-time", - "reboot-timeout", NULL + "reboot-timeout", "strict", NULL }; char buf[sizeof(boot_devices)]; char *standard_boot_devices; @@ -3174,6 +3184,19 @@ int main(int argc, char **argv, char **envp) exit(1); } } + if (get_param_value(buf, sizeof(buf), + "strict", optarg)) { + if (!strcmp(buf, "on")) { + boot_strict = true; + } else if (!strcmp(buf, "off")) { + boot_strict = false; + } else { + fprintf(stderr, + "qemu: invalid option value '%s'\n", + buf); + exit(1); + } + } if (!qemu_opts_parse(qemu_find_opts("boot-opts"), optarg, 0)) { exit(1);