summaryrefslogtreecommitdiffstats
path: root/discover/user-event.c
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 /discover/user-event.c
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>
Diffstat (limited to 'discover/user-event.c')
-rw-r--r--discover/user-event.c23
1 files changed, 23 insertions, 0 deletions
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;
}
OpenPOWER on IntegriCloud