summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-04-22 14:20:49 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-05-06 13:57:30 +1000
commit81f28af2bd94cc552aef1a7b959e4c6b84457ce7 (patch)
tree2addc5a78c0f094a2f3080e95fc657ccdfdbc1f0
parente544283809454252c2c2d3148492362ad10643ba (diff)
downloadtalos-petitboot-81f28af2bd94cc552aef1a7b959e4c6b84457ce7.tar.gz
talos-petitboot-81f28af2bd94cc552aef1a7b959e4c6b84457ce7.zip
pb-event: Add 'boot' user event
Add a user event to send a boot command to the discover server. The format of the boot command is similar to the add command, eg: pb-event boot@eth0 image="http://host/image" initrd="http://host/initrd" and also recognises "id", "dtb", and "args" arguments. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
-rw-r--r--discover/event.c2
-rw-r--r--discover/event.h1
-rw-r--r--discover/user-event.c23
-rw-r--r--utils/pb-event.c2
4 files changed, 27 insertions, 1 deletions
diff --git a/discover/event.c b/discover/event.c
index 7932378..8b3a1ab 100644
--- a/discover/event.c
+++ b/discover/event.c
@@ -53,6 +53,8 @@ static int event_parse_ad_header(char *buf, int len, enum event_action *action,
*action = EVENT_ACTION_CONF;
else if (streq(buf, "dhcp"))
*action = EVENT_ACTION_DHCP;
+ else if (streq(buf, "boot"))
+ *action = EVENT_ACTION_BOOT;
else {
pb_log("%s: unknown action: %s\n", __func__, buf);
return -1;
diff --git a/discover/event.h b/discover/event.h
index 8dee13b..35c0767 100644
--- a/discover/event.h
+++ b/discover/event.h
@@ -13,6 +13,7 @@ enum event_action {
EVENT_ACTION_URL,
EVENT_ACTION_CONF,
EVENT_ACTION_DHCP,
+ EVENT_ACTION_BOOT,
EVENT_ACTION_MAX,
};
diff --git a/discover/user-event.c b/discover/user-event.c
index 8926458..15d9c87 100644
--- a/discover/user-event.c
+++ b/discover/user-event.c
@@ -58,6 +58,8 @@ static const char *event_action_name(enum event_action action)
return "url";
case EVENT_ACTION_DHCP:
return "dhcp";
+ case EVENT_ACTION_BOOT:
+ return "boot";
default:
break;
}
@@ -444,6 +446,24 @@ static int user_event_url(struct user_event *uev, struct event *event)
return 0;
}
+static int user_event_boot(struct user_event *uev, struct event *event)
+{
+ struct device_handler *handler = uev->handler;
+ struct boot_command *cmd = talloc(handler, struct boot_command);
+
+ cmd->option_id = talloc_strdup(cmd, event_get_param(event, "id"));
+ cmd->boot_image_file = talloc_strdup(cmd, event_get_param(event, "image"));
+ cmd->initrd_file = talloc_strdup(cmd, event_get_param(event, "initrd"));
+ cmd->dtb_file = talloc_strdup(cmd, event_get_param(event, "dtb"));
+ cmd->boot_args = talloc_strdup(cmd, event_get_param(event, "args"));
+
+ device_handler_boot(handler, cmd);
+
+ talloc_free(cmd);
+
+ return 0;
+}
+
static void user_event_handle_message(struct user_event *uev, char *buf,
int len)
{
@@ -476,6 +496,9 @@ static void user_event_handle_message(struct user_event *uev, char *buf,
case EVENT_ACTION_DHCP:
result = user_event_dhcp(uev, event);
break;
+ case EVENT_ACTION_BOOT:
+ result = user_event_boot(uev, event);
+ break;
default:
break;
}
diff --git a/utils/pb-event.c b/utils/pb-event.c
index a1affe5..572eb16 100644
--- a/utils/pb-event.c
+++ b/utils/pb-event.c
@@ -55,7 +55,7 @@ static void print_usage(void)
" Events can be read from stdin, or provided on the command line.\n"
" User events must have the following format:\n"
"\n"
-" (add|remove)@device-id [name=value] [image=value] [args=value]\n"
+" (add|remove|boot)@device-id [name=value] [image=value] [args=value]\n"
"\n"
" When read from stdin, components are separated by NUL chars\n"
"\n"
OpenPOWER on IntegriCloud