6 #include "talloc/talloc.h"
11 #include "parser-utils.h"
12 #include "device-handler.h"
14 static struct resource *user_event_resource(struct discover_boot_option *opt,
15 struct event *event, const char *param_name)
21 val = event_get_param(event, param_name);
25 url = pb_url_parse(opt, val);
29 res = create_url_resource(opt, url);
39 * parse_user_event - Parse a user event.
41 * Understands params: name, image, args.
44 int parse_user_event(struct discover_context *ctx, struct event *event)
46 struct discover_boot_option *d_opt;
47 struct boot_option *opt;
51 dev = ctx->device->device;
53 d_opt = discover_boot_option_create(ctx, ctx->device);
59 p = event_get_param(event, "name");
62 pb_log("%s: no name found\n", __func__);
66 opt->id = talloc_asprintf(opt, "%s#%s", dev->id, p);
67 opt->name = talloc_strdup(opt, p);
69 d_opt->boot_image = user_event_resource(d_opt, event, "image");
70 if (!d_opt->boot_image) {
71 pb_log("%s: no boot image found for %s!\n", __func__,
76 d_opt->initrd = user_event_resource(d_opt, event, "initrd");
78 p = event_get_param(event, "args");
81 opt->boot_args = talloc_strdup(opt, p);
83 opt->description = talloc_asprintf(opt, "%s %s", opt->boot_image_file,
84 opt->boot_args ? : "");
86 discover_context_add_boot_option(ctx, d_opt);