+ if (cmd && cmd->initrd_file) {
+ initrd = pb_url_parse(opt, cmd->initrd_file);
+ } else if (opt && opt->initrd) {
+ initrd = opt->initrd->url;
+ }
+
+ if (cmd && cmd->dtb_file) {
+ dtb = pb_url_parse(opt, cmd->dtb_file);
+ } else if (opt && opt->dtb) {
+ dtb = opt->dtb->url;
+ }
+
+ boot_task = talloc_zero(ctx, struct boot_task);
+ boot_task->dry_run = dry_run;
+ boot_task->status_fn = status_fn;
+ boot_task->status_arg = status_arg;
+
+ if (cmd && cmd->boot_args) {
+ boot_task->args = talloc_strdup(boot_task, cmd->boot_args);
+ } else if (opt && opt->option->boot_args) {
+ boot_task->args = talloc_strdup(boot_task,
+ opt->option->boot_args);
+ } else {
+ boot_task->args = NULL;
+ }
+
+ /* start async loads for boot resources */
+ rc = start_url_load(boot_task, "kernel image", image, &boot_task->image)
+ || start_url_load(boot_task, "initrd", initrd, &boot_task->initrd)
+ || start_url_load(boot_task, "dtb", dtb, &boot_task->dtb);
+
+ /* If all URLs are local, we may be done. */
+ if (rc) {
+ talloc_free(boot_task);
+ return NULL;
+ }
+
+ boot_process(NULL, boot_task);
+
+ return boot_task;
+}
+
+void boot_cancel(struct boot_task *task)
+{
+ task->cancelled = true;
+
+ update_status(task->status_fn, task->status_arg, BOOT_STATUS_INFO,
+ "Boot cancelled");
+
+ cleanup_cancellations(task, NULL);