summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-09-24 10:58:16 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-09-25 14:56:56 +0800
commit43b0a412efc1dfd8f2484a8b1e8aae11a855763c (patch)
tree02a1605202888afb349a119c8d553e0070815794
parentb3d241164a7e34eed56159f4e0a8a2821b7ebf4d (diff)
downloadtalos-petitboot-43b0a412efc1dfd8f2484a8b1e8aae11a855763c.tar.gz
talos-petitboot-43b0a412efc1dfd8f2484a8b1e8aae11a855763c.zip
discover/boot: Check for failed loads in boot()
Use the status argument to the URL load callback to check for load failures. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--discover/boot.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/discover/boot.c b/discover/boot.c
index 18bca58..313bd2a 100644
--- a/discover/boot.c
+++ b/discover/boot.c
@@ -31,6 +31,7 @@ enum boot_process_state {
BOOT_STATE_INITIAL,
BOOT_STATE_IMAGE_LOADING,
BOOT_STATE_INITRD_LOADING,
+ BOOT_STATE_DTB_LOADING,
BOOT_STATE_FINISH,
BOOT_STATE_UNKNOWN,
};
@@ -287,7 +288,7 @@ static void run_boot_hooks(struct boot_task *task)
free(hooks);
}
-static void boot_process(void *ctx, int status __attribute__((unused)))
+static void boot_process(void *ctx, int status)
{
struct boot_task *task = ctx;
unsigned int clean_image = 0;
@@ -305,13 +306,20 @@ static void boot_process(void *ctx, int status __attribute__((unused)))
BOOT_STATUS_ERROR,
"Couldn't load kernel image");
goto no_load;
- } else {
- task->state = BOOT_STATE_IMAGE_LOADING;
- return;
}
+ task->state = BOOT_STATE_IMAGE_LOADING;
+ return;
}
if (task->state == BOOT_STATE_IMAGE_LOADING) {
+ if (status) {
+ update_status(task->status_fn, task->status_arg,
+ BOOT_STATUS_ERROR,
+ "Error loading kernel image");
+ goto no_load;
+ }
+ task->state = BOOT_STATE_INITRD_LOADING;
+
if (task->initrd) {
update_status(task->status_fn, task->status_arg,
BOOT_STATUS_INFO, "loading initrd");
@@ -322,16 +330,20 @@ static void boot_process(void *ctx, int status __attribute__((unused)))
BOOT_STATUS_ERROR,
"Couldn't load initrd image");
goto no_load;
- } else {
- task->state = BOOT_STATE_INITRD_LOADING;
- return;
}
- } else {
- task->state = BOOT_STATE_INITRD_LOADING;
+ return;
}
}
if (task->state == BOOT_STATE_INITRD_LOADING) {
+ if (status) {
+ update_status(task->status_fn, task->status_arg,
+ BOOT_STATUS_ERROR,
+ "Error loading initrd");
+ goto no_load;
+ }
+ task->state = BOOT_STATE_DTB_LOADING;
+
if (task->dtb) {
update_status(task->status_fn, task->status_arg,
BOOT_STATUS_INFO,
@@ -343,15 +355,22 @@ static void boot_process(void *ctx, int status __attribute__((unused)))
BOOT_STATUS_ERROR,
"Couldn't load device tree");
goto no_load;
- } else {
- task->state = BOOT_STATE_FINISH;
- return;
}
- } else {
- task->state = BOOT_STATE_FINISH;
+ return;
+ }
+ }
+
+ if (task->state == BOOT_STATE_DTB_LOADING) {
+ if (status) {
+ update_status(task->status_fn, task->status_arg,
+ BOOT_STATUS_ERROR,
+ "Error loading dtb");
+ goto no_load;
}
+ task->state = BOOT_STATE_FINISH;
}
+
if (task->state != BOOT_STATE_FINISH) {
task->state = BOOT_STATE_UNKNOWN;
return;
OpenPOWER on IntegriCloud