summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-02-27 11:00:32 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-04-15 15:42:26 +0800
commit69c459db80abece18b5557d9b8a8098a88329c28 (patch)
treec4faa93f3039a20d79180cd99b43e35d0f80f3d2 /ui
parent01ed80939b8ed440390729c524ad875047dbd406 (diff)
downloadtalos-petitboot-69c459db80abece18b5557d9b8a8098a88329c28.tar.gz
talos-petitboot-69c459db80abece18b5557d9b8a8098a88329c28.zip
discover-client: Add discover_client_boot
This change implements the client side of the server-based boot interface. We add a funcion, discover_client_boot, which serialises a boot message, then sends it to the server. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/common/discover-client.c39
-rw-r--r--ui/common/discover-client.h15
-rw-r--r--ui/common/ui-system.h7
3 files changed, 55 insertions, 6 deletions
diff --git a/ui/common/discover-client.c b/ui/common/discover-client.c
index cd9f63a..9374dc5 100644
--- a/ui/common/discover-client.c
+++ b/ui/common/discover-client.c
@@ -172,3 +172,42 @@ struct device *discover_client_get_device(struct discover_client *client,
return client->devices[index];
}
+
+static void create_boot_command(struct boot_command *command,
+ const struct device *device __attribute__((unused)),
+ const struct boot_option *boot_option,
+ const struct pb_boot_data *data)
+{
+
+ command->option_id = boot_option->id;
+ command->boot_image_file = data->image;
+ command->initrd_file = data->initrd;
+ command->boot_args = data->args;
+}
+
+int discover_client_boot(struct discover_client *client,
+ const struct device *device,
+ const struct boot_option *boot_option,
+ const struct pb_boot_data *data)
+{
+ struct pb_protocol_message *message;
+ struct boot_command boot_command;
+ int len, rc;
+
+ create_boot_command(&boot_command, device, boot_option, data);
+
+ len = pb_protocol_boot_len(&boot_command);
+
+ message = pb_protocol_create_message(client,
+ PB_PROTOCOL_ACTION_BOOT, len);
+
+ if (!message)
+ return -1;
+
+ pb_protocol_serialise_boot_command(&boot_command,
+ message->payload, len);
+
+ rc = pb_protocol_write_message(client->fd, message);
+
+ return rc;
+}
diff --git a/ui/common/discover-client.h b/ui/common/discover-client.h
index 4af936c..6e768d9 100644
--- a/ui/common/discover-client.h
+++ b/ui/common/discover-client.h
@@ -5,6 +5,12 @@
struct discover_client;
+struct pb_boot_data {
+ char *image;
+ char *initrd;
+ char *args;
+};
+
/**
* struct discover_client_ops - Application supplied client info.
* @device_add: PB_PROTOCOL_ACTION_ADD event callback.
@@ -51,4 +57,13 @@ int discover_client_device_count(struct discover_client *client);
*/
struct device *discover_client_get_device(struct discover_client *client,
int index);
+
+/* Tell the discover server to boot an image
+ * @param client A pointer to the discover client
+ * @param boot_command The command to boot
+ */
+int discover_client_boot(struct discover_client *client,
+ const struct device *device,
+ const struct boot_option *boot_option,
+ const struct pb_boot_data *data);
#endif
diff --git a/ui/common/ui-system.h b/ui/common/ui-system.h
index bf4f4e9..b4372ee 100644
--- a/ui/common/ui-system.h
+++ b/ui/common/ui-system.h
@@ -24,15 +24,10 @@
#include "system/system.h"
#include "types/types.h"
#include "ui/common/timer.h"
+#include "ui/common/discover-client.h"
#include <signal.h>
-struct pb_boot_data {
- char *image;
- char *initrd;
- char *args;
-};
-
int pb_boot(const struct pb_boot_data *bd, int dry_run);
int pb_start_daemon(void);
OpenPOWER on IntegriCloud