summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--discover/Makefile.am2
-rw-r--r--discover/boot.c14
-rw-r--r--discover/boot.h10
-rw-r--r--discover/device-handler.c28
-rw-r--r--discover/device-handler.h4
-rw-r--r--discover/discover-server.c2
6 files changed, 59 insertions, 1 deletions
diff --git a/discover/Makefile.am b/discover/Makefile.am
index 5f63442..0e20835 100644
--- a/discover/Makefile.am
+++ b/discover/Makefile.am
@@ -41,6 +41,8 @@ libparser_la_LIBADD = $(top_builddir)/lib/libpbcore.la
sbin_PROGRAMS = pb-discover
pb_discover_SOURCES = \
+ boot.c \
+ boot.h \
device-handler.c \
device-handler.h \
discover-server.c \
diff --git a/discover/boot.c b/discover/boot.c
new file mode 100644
index 0000000..ddb9e7d
--- /dev/null
+++ b/discover/boot.c
@@ -0,0 +1,14 @@
+
+#include "boot.h"
+
+int boot(void *ctx, struct boot_option *opt, struct boot_command *cmd,
+ int dry_run)
+{
+ /* todo: run kexec with options from opt & cmd */
+ (void)ctx;
+ (void)opt;
+ (void)cmd;
+ (void)dry_run;
+
+ return 0;
+}
diff --git a/discover/boot.h b/discover/boot.h
new file mode 100644
index 0000000..be2ca57
--- /dev/null
+++ b/discover/boot.h
@@ -0,0 +1,10 @@
+#ifndef _BOOT_H
+#define _BOOT_H
+
+struct boot_option;
+struct boot_command;
+
+int boot(void *ctx, struct boot_option *opt, struct boot_command *cmd,
+ int dry_run);
+
+#endif /* _BOOT_H */
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 0d43496..6a27f15 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -19,6 +19,7 @@
#include "parser.h"
#include "udev.h"
#include "paths.h"
+#include "boot.h"
struct device_handler {
struct discover_server *server;
@@ -429,3 +430,30 @@ void device_handler_destroy(struct device_handler *handler)
{
talloc_free(handler);
}
+
+static struct boot_option *find_boot_option_by_id(
+ struct device_handler *handler, const char *id)
+{
+ unsigned int i;
+
+ for (i = 0; i < handler->n_devices; i++) {
+ struct device *dev = handler->devices[i];
+ struct boot_option *opt;
+
+ list_for_each_entry(&dev->boot_options, opt, list)
+ if (!strcmp(opt->id, id))
+ return opt;
+ }
+
+ return NULL;
+}
+
+void device_handler_boot(struct device_handler *handler,
+ struct boot_command *cmd)
+{
+ struct boot_option *opt;
+
+ opt = find_boot_option_by_id(handler, cmd->option_id);
+
+ boot(handler, opt, cmd, 0);
+}
diff --git a/discover/device-handler.h b/discover/device-handler.h
index 796b328..7207f8d 100644
--- a/discover/device-handler.h
+++ b/discover/device-handler.h
@@ -5,6 +5,7 @@
struct device_handler;
struct discover_server;
+struct boot_command;
struct event;
struct device;
@@ -30,4 +31,7 @@ const struct device *device_handler_get_device(
int device_handler_event(struct device_handler *handler, struct event *event);
+void device_handler_boot(struct device_handler *handler,
+ struct boot_command *cmd);
+
#endif /* _DEVICE_HANDLER_H */
diff --git a/discover/discover-server.c b/discover/discover-server.c
index 76d03d1..6c80372 100644
--- a/discover/discover-server.c
+++ b/discover/discover-server.c
@@ -149,7 +149,7 @@ static int discover_server_process_message(void *arg)
return 0;
}
- /* todo: pass boot_command to client->server->device_handler */
+ device_handler_boot(client->server->device_handler, boot_command);
return 0;
}
OpenPOWER on IntegriCloud