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(); }