Commit
ce54f86 "Add petitboot,tty and track available consoles" added
the petitboot,tty parameter, but the petitboot,console parameter is also
recognised by Petitboot. These are ultimately handled by the 30-add-offb
and 80-set-stdout hooks respectively, but exist for mostly the same
purpose.
We consolidate these down to just the original petitboot,console
parameter. If the contents of petitboot,console have been configured by
Petitboot (ie. it is of the form /dev/dev# [ Description ]) we behave as
normal, otherwise we assume that petitboot,console contains a full
OF path to the intended console device and do not allow it to be
modified. This follows petitboot,console's original intent to be a debug
aid, and takes precedence over any other use.
The 80-set-stdout hook is removed as 30-add-offb now accounts for both
use cases.
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
struct pb_url *image = NULL, *initrd = NULL, *dtb = NULL;
struct pb_url *image_sig = NULL, *initrd_sig = NULL, *dtb_sig = NULL,
*cmdline_sig = NULL;
- const struct config *config;
+ const struct config *config = config_get();
struct boot_task *boot_task;
const char *boot_desc;
int rc;
boot_task->args = NULL;
}
- if (cmd && cmd->console)
+ if (cmd && cmd->console && !config->manual_console)
boot_task->boot_console = talloc_strdup(boot_task, cmd->console);
- else {
- config = config_get();
+ else
boot_task->boot_console = config ? config->boot_console : NULL;
- }
if (boot_task->verify_signature || boot_task->decrypt_files) {
if (cmd && cmd->args_sig_file) {
"petitboot,debug?",
"petitboot,write?",
"petitboot,snapshots?",
- "petitboot,tty",
+ "petitboot,console",
NULL,
};
if (val)
config->disable_snapshots = !strcmp(val, "false");
- val = get_param(platform, "petitboot,tty");
+ val = get_param(platform, "petitboot,console");
if (val)
config->boot_console = talloc_strdup(config, val);
+ /* If a full path is already set we don't want to override it */
+ config->manual_console = config->boot_console &&
+ !strchr(config->boot_console, '[');
}
static char *iface_config_str(void *ctx, struct interface_config *config)
val = config->allow_writes ? "true" : "false";
update_string_config(platform, "petitboot,write?", val);
- val = config->boot_console ?: "";
- update_string_config(platform, "petitboot,tty", val);
+ if (!config->manual_console) {
+ val = config->boot_console ?: "";
+ update_string_config(platform, "petitboot,console", val);
+ }
update_network_config(platform, config);
pb_log(" Default UI to boot on: %s\n",
config->boot_console ?: "none set");
+ if (config->manual_console)
+ pb_log(" (Manually set)\n");
pb_log(" language: %s\n", config->lang ?: "");
if (src->boot_console)
dest->boot_console = talloc_strdup(dest, src->boot_console);
+ dest->manual_console = src->manual_console;
if (src->lang && strlen(src->lang))
dest->lang = talloc_strdup(dest, src->lang);
len += 4 + optional_strlen(config->consoles[i]);
len += 4 + optional_strlen(config->boot_console);
+ len += 4; /* manual_console */
len += 4 + optional_strlen(config->lang);
pos += pb_protocol_serialise_string(pos, config->consoles[i]);
pos += pb_protocol_serialise_string(pos, config->boot_console);
+ *(uint32_t *)pos = config->manual_console;
+ pos += 4;
pos += pb_protocol_serialise_string(pos, config->lang);
config->boot_console = str;
+ if (read_u32(&pos, &len, &tmp))
+ goto out;
+ config->manual_console = !!tmp;
+
if (read_string(config, &pos, &len, &str))
goto out;
bool allow_writes;
char *boot_console;
+ bool manual_console;
char *lang;
/* not user-settable */
struct nc_widget_select *allow_write_f;
struct nc_widget_label *boot_console_l;
struct nc_widget_select *boot_console_f;
+ struct nc_widget_label *manual_console_l;
struct nc_widget_label *current_console_l;
struct nc_widget_label *net_override_l;
if (allow_write != config->allow_writes)
config->allow_writes = allow_write;
- if (config->n_consoles) {
+ if (config->n_consoles && !config->manual_console) {
idx = widget_select_get_value(screen->widgets.boot_console_f);
if (!config->boot_console) {
config->boot_console = talloc_strdup(config,
y += 1;
- if (widget_height(widget_select_base(screen->widgets.boot_console_f))) {
+ if (screen->widgets.manual_console_l) {
+ layout_pair(screen, y++, screen->widgets.boot_console_l,
+ widget_label_base(screen->widgets.manual_console_l));
+ widget_move(widget_label_base(screen->widgets.current_console_l),
+ y, screen->field_x);
+ widget_set_visible(widget_select_base(
+ screen->widgets.boot_console_f), false);
+ y += 2;
+ } else if (widget_height(widget_select_base(screen->widgets.boot_console_f))) {
layout_pair(screen, y, screen->widgets.boot_console_l,
widget_select_base(screen->widgets.boot_console_f));
y += widget_height(widget_select_base(screen->widgets.boot_console_f));
{
struct nc_widgetset *set = screen->widgetset;
struct interface_config *ifcfg;
- char *str, *ip, *mask, *gw, *url, *tty;
+ char *str, *ip, *mask, *gw, *url, *tty, *label;
enum net_conf_type type;
unsigned int i;
int add_len, clear_len, any_len, min_len = 20;
for (i = 0; i < sysinfo->n_blockdevs; i++) {
struct blockdev_info *bd = sysinfo->blockdevs[i];
- char *label;
label = talloc_asprintf(screen, _("disk: %s [uuid: %s]"),
bd->name, bd->uuid);
for (i = 0; i < sysinfo->n_interfaces; i++) {
struct interface_info *info = sysinfo->interfaces[i];
- char *label, mac[20];
+ char mac[20];
mac_str(info->hwaddr, info->hwaddr_size, mac, sizeof(mac));
}
for (i = DEVICE_TYPE_NETWORK; i < DEVICE_TYPE_UNKNOWN; i++) {
- char *label;
if (i == DEVICE_TYPE_ANY)
label = talloc_asprintf(screen, _("Any Device"));
widget_textbox_set_validator_integer(screen->widgets.timeout_f, 0, 999);
if (config->ipmi_bootdev) {
- char *label = talloc_asprintf(screen,
+ label = talloc_asprintf(screen,
_("%s IPMI boot option: %s"),
config->ipmi_bootdev_persistent ?
"Persistent" : "Temporary",
config->consoles[i], found);
}
+ if (config->manual_console) {
+ label = talloc_asprintf(screen, _("Manually set: '%s'"),
+ config->boot_console);
+ screen->widgets.manual_console_l = widget_new_label(set, 0, 0, label);
+ }
+
tty = talloc_asprintf(screen, _("Current interface: %s"),
ttyname(STDIN_FILENO));
screen->widgets.current_console_l = widget_new_label(set, 0 , 0, tty);
utils/logrotate.conf \
utils/hooks/01-create-default-dtb \
utils/hooks/20-update-dtb-sample \
- utils/hooks/90-sort-dtb \
- utils/hooks/80-set-stdout
+ utils/hooks/90-sort-dtb
return 0;
}
- if (strstr(boot_console, "tty") != NULL) {
+ if (strncmp(boot_console, "/dev/", strlen("/dev/")) != 0) {
+ /* We already have the full path */
+ stdout_path = talloc_strdup(ctx, boot_console);
+ } else if (strstr(boot_console, "tty") != NULL) {
fprintf(stderr, "TTY recognised: %s\n", boot_console);
stdout_path = get_vga_path(ctx);
} else {
+++ /dev/null
-#!/bin/sh
-
-# Hook to set the linux,stdout-path property from an nvram property
-# (named $nvram_prop).
-
-nvram_prop=petitboot,console
-
-# we need to be using a dtb
-[ -n "$boot_dtb" ] || exit
-
-console=$(nvram --print-config="$nvram_prop")
-
-[ $? = 0 -a -n "$console" ] || exit
-
-dtb_in=$boot_dtb
-dtb_out=$(mktemp)
-
-(
- dtc -I dtb -O dts $dtb_in
- echo '/ { chosen { linux,stdout-path = "'$console'"; }; }; '
-) | dtc -I dts -O dtb -o $dtb_out
-
-[ $? = 0 ] && mv $dtb_out $dtb_in