From patchwork Mon Mar 4 13:53:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin O'Connor X-Patchwork-Id: 224724 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 9ED1A2C031E for ; Tue, 5 Mar 2013 00:54:12 +1100 (EST) Received: from localhost ([::1]:54393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCVqE-0007en-MT for incoming@patchwork.ozlabs.org; Mon, 04 Mar 2013 08:54:10 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCVpw-0007eZ-EV for qemu-devel@nongnu.org; Mon, 04 Mar 2013 08:53:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCVpu-00032y-5Y for qemu-devel@nongnu.org; Mon, 04 Mar 2013 08:53:52 -0500 Received: from mail-qa0-f44.google.com ([209.85.216.44]:52475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCVpu-00032j-1F for qemu-devel@nongnu.org; Mon, 04 Mar 2013 08:53:50 -0500 Received: by mail-qa0-f44.google.com with SMTP id bv4so1150170qab.17 for ; Mon, 04 Mar 2013 05:53:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent:x-gm-message-state; bh=XY2mny0U3E3nUmfL2z/CbLQb2ZjsO6KipUCp8peiYYU=; b=YVWTRQD5fuuSMe5lSnSlT5s0diSVb3p6UI6h1qe3LqTN1MFM84ZCijhmq212Ksq+/H 0UTuHSKxuf6P7YQTDtTua3eHxkwP4kBIsDU8KnMxAWP3Qi+d5aDTus0Xh7Y2NY2OXYC5 oeArR7Fi1WytrfH4nXWIOcizor1zhbhsc0aclxleg0lrjdXVr/i69sm5jwNui1W+Vl91 JwrcELc+jlkBCUG7LAJx5NKK7Qp9Qxm1t5HzU0frWha68pZljP+RsSDjM1YxnuaZDCPi CLnBQLCszEVYuG9XUvKzhc+lnoGiCu4Hy5iOvBMc2fmDBJ9uE9wT0RX1XYXfiTfiitGv +3NQ== X-Received: by 10.224.95.131 with SMTP id d3mr21215666qan.0.1362405229058; Mon, 04 Mar 2013 05:53:49 -0800 (PST) Received: from localhost (207-172-165-101.c3-0.avec-ubr1.nyr-avec.ny.cable.rcn.com. [207.172.165.101]) by mx.google.com with ESMTPS id q5sm37129656qaz.2.2013.03.04.05.53.48 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 04 Mar 2013 05:53:48 -0800 (PST) Date: Mon, 4 Mar 2013 08:53:47 -0500 From: Kevin O'Connor To: Amos Kong Message-ID: <20130304135347.GA17628@morn.localdomain> References: <20130304094502.GA10725@t430s.nay.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130304094502.GA10725@t430s.nay.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQlVlcMZ3eKsRKScOPnrouKjP1PWsCGRkKzEj+qsf4QmIHx62xhG6sGUxldsKioHpv2aGess X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.216.44 Cc: seabios@seabios.org, qemu-devel@nongnu.org Subject: Re: [Qemu-devel] seabios bug: fail to find etc/boot-fail-wait 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 On Mon, Mar 04, 2013 at 05:45:02PM +0800, Amos Kong wrote: > ./qemu-upstream-latest -boot reboot-timeout=1000 ... > (after boot failed, VM waits for 1000 ms and try to reboot) [...] > romfile_add() is used to add rom files in the list. > When seabios calls boot_fail(), the list becomes empty, > romfile_find("etc/boot-fail-wait", ..) returns NULL. > it seems the list items are released prematurely. Yes - memory allocated with malloc_tmp() can't be used after the POST phase. The patch below should fix this. It would be nice if we could compile-time check for this kind of thing. I'll have to give that some thought. -Kevin diff --git a/src/boot.c b/src/boot.c index ec411b7..325fac0 100644 --- a/src/boot.c +++ b/src/boot.c @@ -235,6 +235,7 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun) * Boot setup ****************************************************************/ +static int BootRetryTime; static int CheckFloppySig = 1; #define DEFAULT_PRIO 9999 @@ -271,6 +272,8 @@ boot_init(void) } } + BootRetryTime = romfile_loadint("etc/boot-fail-wait", 60*1000); + loadBootOrder(); } @@ -629,15 +632,15 @@ boot_rom(u32 vector) static void boot_fail(void) { - u32 retrytime = romfile_loadint("etc/boot-fail-wait", 60*1000); - if (retrytime == (u32)-1) + if (BootRetryTime == (u32)-1) printf("No bootable device.\n"); else - printf("No bootable device. Retrying in %d seconds.\n", retrytime/1000); + printf("No bootable device. Retrying in %d seconds.\n" + , BootRetryTime/1000); // Wait for 'retrytime' milliseconds and then reboot. - u32 end = calc_future_timer(retrytime); + u32 end = calc_future_timer(BootRetryTime); for (;;) { - if (retrytime != (u32)-1 && check_timer(end)) + if (BootRetryTime != (u32)-1 && check_timer(end)) break; yield_toirq(); }