summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-10-14 13:29:31 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-10-15 11:19:55 +0800
commit2312c424d516862877c45a9566816acfe2da0f06 (patch)
tree7d6e62f8392c613c0ccd34a997c6af671f412c74 /discover/device-handler.c
parente983d818be18a975c519bd76294519a01ce7a1c3 (diff)
downloadtalos-petitboot-2312c424d516862877c45a9566816acfe2da0f06.tar.gz
talos-petitboot-2312c424d516862877c45a9566816acfe2da0f06.zip
discover: Allow an in-progress boot to be cancelled
Currently, once the boot() function is called, the boot process will ignore any cancellations. This change allows boot() to be cancelled, via boot_cancel(). Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 142f6a4..af9fbba 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -40,6 +40,9 @@ struct device_handler {
struct discover_boot_option *default_boot_option;
struct list unresolved_boot_options;
+
+ struct boot_task *pending_boot;
+ bool pending_boot_is_default;
};
static int mount_device(struct discover_device *dev);
@@ -331,6 +334,9 @@ static int default_timeout(void *arg)
if (!handler->default_boot_option)
return 0;
+ if (handler->pending_boot)
+ return 0;
+
opt = handler->default_boot_option;
if (handler->sec_to_boot) {
@@ -346,8 +352,9 @@ static int default_timeout(void *arg)
pb_log("Timeout expired, booting default option %s\n", opt->option->id);
- boot(handler, handler->default_boot_option, NULL,
- handler->dry_run, boot_status, handler);
+ handler->pending_boot = boot(handler, handler->default_boot_option,
+ NULL, handler->dry_run, boot_status, handler);
+ handler->pending_boot_is_default = true;
return 0;
}
@@ -655,7 +662,11 @@ void device_handler_boot(struct device_handler *handler,
if (cmd->option_id && strlen(cmd->option_id))
opt = find_boot_option_by_id(handler, cmd->option_id);
- boot(handler, opt, cmd, handler->dry_run, boot_status, handler);
+ if (handler->pending_boot)
+ boot_cancel(handler->pending_boot);
+ handler->pending_boot = boot(handler, opt, cmd, handler->dry_run,
+ boot_status, handler);
+ handler->pending_boot_is_default = false;
}
void device_handler_cancel_default(struct device_handler *handler)
@@ -674,6 +685,12 @@ void device_handler_cancel_default(struct device_handler *handler)
pb_log("Cancelling default boot option\n");
+ if (handler->pending_boot && handler->pending_boot_is_default) {
+ boot_cancel(handler->pending_boot);
+ handler->pending_boot = NULL;
+ handler->pending_boot_is_default = false;
+ }
+
handler->default_boot_option = NULL;
status.type = BOOT_STATUS_INFO;
OpenPOWER on IntegriCloud