]> git.ozlabs.org Git - petitboot/blobdiff - discover/event-parser.c
discover: log unresolved boot options
[petitboot] / discover / event-parser.c
index c09c5babc27a1e44d642c31f523688b55b652ff4..714f75cda436f337364b8c69eb19469f7bb0a5ee 100644 (file)
@@ -6,6 +6,7 @@
 #include "talloc/talloc.h"
 #include "event.h"
 #include "parser-utils.h"
+#include "device-handler.h"
 
 /**
  * parse_user_event - Parse a user event.
  * Understands params: name, image, args.
  */
 
-struct boot_option *parse_user_event(struct device *device, struct event *event)
+int parse_user_event(struct discover_context *ctx, struct event *event)
 {
+       struct discover_boot_option *d_opt;
        struct boot_option *opt;
+       struct device *dev;
        const char *p;
 
-       opt = talloc_zero(device, struct boot_option);
+       dev = ctx->device->device;
 
-       if (!opt)
+       d_opt = discover_boot_option_create(ctx, ctx->device);
+       opt = d_opt->option;
+
+       if (!d_opt)
                goto fail;
 
        p = event_get_param(event, "name");
@@ -30,8 +36,8 @@ struct boot_option *parse_user_event(struct device *device, struct event *event)
                goto fail;
        }
 
-       opt->id = talloc_asprintf(opt, "%s#%s", device->id, p);
-       opt->device_id = talloc_strdup(opt, device->id);
+       opt->id = talloc_asprintf(opt, "%s#%s", dev->id, p);
+       opt->device_id = talloc_strdup(opt, dev->id);
        opt->name = talloc_strdup(opt, p);
 
        p = event_get_param(event, "image");
@@ -44,6 +50,10 @@ struct boot_option *parse_user_event(struct device *device, struct event *event)
 
        opt->boot_image_file = talloc_strdup(opt, p);
 
+       p = event_get_param(event, "initrd");
+       if (p)
+               opt->initrd_file = talloc_strdup(opt, p);
+
        p = event_get_param(event, "args");
        assert(p);
 
@@ -52,11 +62,11 @@ struct boot_option *parse_user_event(struct device *device, struct event *event)
        opt->description = talloc_asprintf(opt, "%s %s", opt->boot_image_file,
                opt->boot_args);
 
-       device_add_boot_option(device, opt);
+       discover_context_add_boot_option(ctx, d_opt);
 
-       return opt;
+       return 0;
 
 fail:
-       talloc_free(opt);
-       return NULL;
+       talloc_free(d_opt);
+       return -1;
 }