summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-05-07 10:43:21 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-05-07 14:08:40 +0800
commit1920721aa011923555d95fc3b6a4378064a991ca (patch)
treee00b010d02303cddc3235ee97531e14e9f78d13a
parent069a838172150a062fb29531ab2af3234c98ee39 (diff)
downloadtalos-petitboot-1920721aa011923555d95fc3b6a4378064a991ca.tar.gz
talos-petitboot-1920721aa011923555d95fc3b6a4378064a991ca.zip
discover/event-parser: correctly populate boot option resources
The user event parser should be populating the discover_boot_option's resources, not the strings in struct boot_option. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--discover/event-parser.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/discover/event-parser.c b/discover/event-parser.c
index 714f75c..45d7b3a 100644
--- a/discover/event-parser.c
+++ b/discover/event-parser.c
@@ -4,10 +4,37 @@
#include "log/log.h"
#include "talloc/talloc.h"
+#include "url/url.h"
+
+#include "resource.h"
#include "event.h"
#include "parser-utils.h"
#include "device-handler.h"
+static struct resource *user_event_resource(struct discover_boot_option *opt,
+ struct event *event, const char *param_name)
+{
+ struct resource *res;
+ struct pb_url *url;
+ const char *val;
+
+ val = event_get_param(event, param_name);
+ if (!val)
+ return NULL;
+
+ url = pb_url_parse(opt, val);
+ if (!url)
+ return NULL;
+
+ res = create_url_resource(opt, url);
+ if (!res) {
+ talloc_free(url);
+ return NULL;
+ }
+
+ return res;
+}
+
/**
* parse_user_event - Parse a user event.
*
@@ -40,27 +67,22 @@ int parse_user_event(struct discover_context *ctx, struct event *event)
opt->device_id = talloc_strdup(opt, dev->id);
opt->name = talloc_strdup(opt, p);
- p = event_get_param(event, "image");
- assert(p);
-
- if (!p) {
- pb_log("%s: no image found\n", __func__);
+ d_opt->boot_image = user_event_resource(d_opt, event, "image");
+ if (!d_opt->boot_image) {
+ pb_log("%s: no boot image found for %s!\n", __func__,
+ opt->name);
goto fail;
}
- opt->boot_image_file = talloc_strdup(opt, p);
-
- p = event_get_param(event, "initrd");
- if (p)
- opt->initrd_file = talloc_strdup(opt, p);
+ d_opt->initrd = user_event_resource(d_opt, event, "initrd");
p = event_get_param(event, "args");
- assert(p);
- opt->boot_args = talloc_strdup(opt, p);
+ if (p)
+ opt->boot_args = talloc_strdup(opt, p);
opt->description = talloc_asprintf(opt, "%s %s", opt->boot_image_file,
- opt->boot_args);
+ opt->boot_args ? : "");
discover_context_add_boot_option(ctx, d_opt);
OpenPOWER on IntegriCloud