* Re: [Qemu-devel] seabios bug: fail to find etc/boot-fail-wait
2013-03-04 9:45 [Qemu-devel] seabios bug: fail to find etc/boot-fail-wait Amos Kong
@ 2013-03-04 13:53 ` Kevin O'Connor
2013-03-05 2:06 ` [Qemu-devel] [Seabios PATCH] make reboot-timeout to static for using it after POST phase Amos Kong
2013-03-05 9:52 ` [Qemu-devel] [Seabios PATCH v2] " Amos Kong
2 siblings, 0 replies; 6+ messages in thread
From: Kevin O'Connor @ 2013-03-04 13:53 UTC (permalink / raw)
To: Amos Kong; +Cc: seabios, qemu-devel
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();
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [Seabios PATCH] make reboot-timeout to static for using it after POST phase
2013-03-04 9:45 [Qemu-devel] seabios bug: fail to find etc/boot-fail-wait Amos Kong
2013-03-04 13:53 ` Kevin O'Connor
@ 2013-03-05 2:06 ` Amos Kong
2013-03-05 9:03 ` [Qemu-devel] [SeaBIOS] " li guang
2013-03-05 9:52 ` [Qemu-devel] [Seabios PATCH v2] " Amos Kong
2 siblings, 1 reply; 6+ messages in thread
From: Amos Kong @ 2013-03-05 2:06 UTC (permalink / raw)
To: kevin; +Cc: seabios, qemu-devel
From: Kevin O'Connor <kevin@koconnor.net>
Memory allocated with malloc_tmp() can't be used after the POST
phase. The reboot-timeout inside romfile could not be loaded in
boot_fail(). The patch saved reboot-timeout to a static variable,
it fixed the regression bug introduced by commit 59d6ca52
I already tested this patch, reboot-timeout parameter of qemu
works now.
@ qemu -boot reboot-timeout=1000 ...
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Amos Kong <akong@redhat.com>
---
src/boot.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
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();
}
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [SeaBIOS] [Seabios PATCH] make reboot-timeout to static for using it after POST phase
2013-03-05 2:06 ` [Qemu-devel] [Seabios PATCH] make reboot-timeout to static for using it after POST phase Amos Kong
@ 2013-03-05 9:03 ` li guang
0 siblings, 0 replies; 6+ messages in thread
From: li guang @ 2013-03-05 9:03 UTC (permalink / raw)
To: Amos Kong; +Cc: kevin, seabios, qemu-devel
在 2013-03-05二的 10:06 +0800,Amos Kong写道:
> From: Kevin O'Connor <kevin@koconnor.net>
>
> Memory allocated with malloc_tmp() can't be used after the POST
> phase. The reboot-timeout inside romfile could not be loaded in
> boot_fail(). The patch saved reboot-timeout to a static variable,
> it fixed the regression bug introduced by commit 59d6ca52
>
> I already tested this patch, reboot-timeout parameter of qemu
> works now.
> @ qemu -boot reboot-timeout=1000 ...
>
> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
> src/boot.c | 13 ++++++++-----
> 1 files changed, 8 insertions(+), 5 deletions(-)
>
> 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.
s/retrytime/BootRetryTime
> - 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();
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Seabios PATCH v2] make reboot-timeout to static for using it after POST phase
2013-03-04 9:45 [Qemu-devel] seabios bug: fail to find etc/boot-fail-wait Amos Kong
2013-03-04 13:53 ` Kevin O'Connor
2013-03-05 2:06 ` [Qemu-devel] [Seabios PATCH] make reboot-timeout to static for using it after POST phase Amos Kong
@ 2013-03-05 9:52 ` Amos Kong
2013-03-07 1:07 ` Kevin O'Connor
2 siblings, 1 reply; 6+ messages in thread
From: Amos Kong @ 2013-03-05 9:52 UTC (permalink / raw)
To: kevin; +Cc: seabios, qemu-devel
From: Kevin O'Connor <kevin@koconnor.net>
Memory allocated with malloc_tmp() can't be used after the POST
phase. The reboot-timeout inside romfile could not be loaded in
boot_fail(). The patch saved reboot-timeout to a static variable,
it fixed the regression bug introduced by commit 59d6ca52
I already tested this patch, reboot-timeout parameter of qemu
works now.
@ qemu -boot reboot-timeout=1000 ...
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Amos Kong <akong@redhat.com>
--
V2: trivial fix in comment (li guang)
---
src/boot.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/boot.c b/src/boot.c
index ec411b7..3370c2d 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);
- // Wait for 'retrytime' milliseconds and then reboot.
- u32 end = calc_future_timer(retrytime);
+ printf("No bootable device. Retrying in %d seconds.\n"
+ , BootRetryTime/1000);
+ // Wait for 'BootRetryTime' milliseconds and then reboot.
+ u32 end = calc_future_timer(BootRetryTime);
for (;;) {
- if (retrytime != (u32)-1 && check_timer(end))
+ if (BootRetryTime != (u32)-1 && check_timer(end))
break;
yield_toirq();
}
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [Seabios PATCH v2] make reboot-timeout to static for using it after POST phase
2013-03-05 9:52 ` [Qemu-devel] [Seabios PATCH v2] " Amos Kong
@ 2013-03-07 1:07 ` Kevin O'Connor
0 siblings, 0 replies; 6+ messages in thread
From: Kevin O'Connor @ 2013-03-07 1:07 UTC (permalink / raw)
To: Amos Kong; +Cc: seabios, qemu-devel
On Tue, Mar 05, 2013 at 05:52:21PM +0800, Amos Kong wrote:
> From: Kevin O'Connor <kevin@koconnor.net>
>
> Memory allocated with malloc_tmp() can't be used after the POST
> phase. The reboot-timeout inside romfile could not be loaded in
> boot_fail(). The patch saved reboot-timeout to a static variable,
> it fixed the regression bug introduced by commit 59d6ca52
FYI, this fix was committed.
-Kevin
^ permalink raw reply [flat|nested] 6+ messages in thread