summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2018-12-13 11:24:09 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2018-12-13 11:26:17 +1100
commit95ec722a057b3ebb44699af16ea68ca0dffef50e (patch)
tree39bf178ae40aba39f9b43bbc6cd68c09d4d0a648
parent35ec247ac2dc4611cd3c9e99e0fcea0cf0d97415 (diff)
downloadtalos-petitboot-95ec722a057b3ebb44699af16ea68ca0dffef50e.zip
talos-petitboot-95ec722a057b3ebb44699af16ea68ca0dffef50e.tar.gz
ui/ncurses: Add option to clear IPMI boot mailbox
If there is an IPMI boot mailbox configuration present display a message in the System Configuration screen and provide the option to clear the mailbox. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
-rw-r--r--lib/pb-config/pb-config.c1
-rw-r--r--lib/pb-protocol/pb-protocol.c6
-rw-r--r--ui/ncurses/nc-config.c49
3 files changed, 55 insertions, 1 deletions
diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c
index 7fa925c..a802c92 100644
--- a/lib/pb-config/pb-config.c
+++ b/lib/pb-config/pb-config.c
@@ -83,6 +83,7 @@ struct config *config_copy(void *ctx, const struct config *src)
dest->ipmi_bootdev = src->ipmi_bootdev;
dest->ipmi_bootdev_persistent = src->ipmi_bootdev_persistent;
+ dest->ipmi_bootdev_mailbox = src->ipmi_bootdev_mailbox;
dest->allow_writes = src->allow_writes;
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index d8771fc..b4138bb 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -324,6 +324,7 @@ int pb_protocol_config_len(const struct config *config)
}
len += 4 + 4; /* ipmi_bootdev, ipmi_bootdev_persistent */
+ len += 4; /* ipmi_bootdev_mailbox */
len += 4; /* allow_writes */
@@ -646,6 +647,8 @@ int pb_protocol_serialise_config(const struct config *config,
pos += 4;
*(uint32_t *)pos = config->ipmi_bootdev_persistent;
pos += 4;
+ *(uint32_t *)pos = config->ipmi_bootdev_mailbox;
+ pos += 4;
*(uint32_t *)pos = config->allow_writes;
pos += 4;
@@ -1277,6 +1280,9 @@ int pb_protocol_deserialise_config(struct config *config,
if (read_u32(&pos, &len, &tmp))
goto out;
config->ipmi_bootdev_persistent = !!tmp;
+ if (read_u32(&pos, &len, &tmp))
+ goto out;
+ config->ipmi_bootdev_mailbox = !!tmp;
if (read_u32(&pos, &len, &tmp))
goto out;
diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c
index 4685fa5..943ee8a 100644
--- a/ui/ncurses/nc-config.c
+++ b/ui/ncurses/nc-config.c
@@ -34,7 +34,7 @@
#include "nc-config.h"
#include "nc-widgets.h"
-#define N_FIELDS 49
+#define N_FIELDS 51
extern struct help_text config_help_text;
@@ -67,6 +67,7 @@ struct config_screen {
bool autoboot_enabled;
bool ipmi_override;
+ bool ipmi_mailbox;
bool net_override;
struct {
@@ -86,6 +87,9 @@ struct config_screen {
struct nc_widget_label *ipmi_clear_l;
struct nc_widget_button *ipmi_clear_b;
+ struct nc_widget_label *ipmi_mailbox_l;
+ struct nc_widget_button *ipmi_mailbox_b;
+
struct nc_widget_label *network_l;
struct nc_widget_select *network_f;
@@ -439,6 +443,27 @@ static void ipmi_clear_click(void *arg)
screen->exit = true;
}
+static void ipmi_clear_mailbox_click(void *arg)
+{
+ struct config_screen *screen = arg;
+ struct config *config;
+ int rc;
+
+ config = config_copy(screen, screen->cui->config);
+ config->ipmi_bootdev_mailbox = false;
+ config->safe_mode = false;
+
+ rc = cui_send_config(screen->cui, config);
+ talloc_free(config);
+
+ if (rc)
+ pb_log("cui_send_config failed!\n");
+ else
+ pb_debug("config sent!\n");
+ screen->exit = true;
+}
+
+
static int layout_pair(struct config_screen *screen, int y,
struct nc_widget_label *label,
struct nc_widget *field)
@@ -546,6 +571,18 @@ static void config_screen_layout_widgets(struct config_screen *screen)
y += 1;
}
+ if (screen->ipmi_mailbox) {
+ wl = widget_label_base(screen->widgets.ipmi_mailbox_l);
+ widget_set_visible(wl, true);
+ widget_move(wl, y, screen->label_x);
+ y += 1;
+
+ wf = widget_button_base(screen->widgets.ipmi_mailbox_b);
+ widget_set_visible(wf, true);
+ widget_move(wf, y, screen->field_x);
+ y += 1;
+ }
+
y += 1;
y += layout_pair(screen, y, screen->widgets.network_l,
@@ -990,6 +1027,16 @@ static void config_screen_setup_widgets(struct config_screen *screen,
screen->ipmi_override = true;
}
+ if (config->ipmi_bootdev_mailbox) {
+ screen->widgets.ipmi_mailbox_l = widget_new_label(set, 0, 0,
+ _("IPMI boot order mailbox config present"));
+ screen->widgets.ipmi_mailbox_b = widget_new_button(set, 0, 0,
+ strncols(_("Clear IPMI boot order mailbox now")) + 10,
+ _("Clear IPMI boot order mailbox now"),
+ ipmi_clear_mailbox_click, screen);
+ screen->ipmi_mailbox = true;
+ }
+
screen->widgets.network_l = widget_new_label(set, 0, 0, _("Network:"));
screen->widgets.network_f = widget_new_select(set, 0, 0,
COLS - screen->field_x - 1);
OpenPOWER on IntegriCloud