]> git.ozlabs.org Git - petitboot/log
petitboot
9 years agoui/ncurses: Add device hierarchy
Samuel Mendoza-Jonas [Wed, 16 Jul 2014 06:23:59 +0000 (16:23 +1000)]
ui/ncurses: Add device hierarchy

Boot options are now listed under their matching boot device in the
ncurses UI to help differentitate similar boot option names

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoui/ncurses: Add safe mode indicator
Jeremy Kerr [Mon, 21 Jul 2014 10:28:04 +0000 (18:28 +0800)]
ui/ncurses: Add safe mode indicator

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover/platform-powerpc: Configure safe mode from IPMI bootdev setting
Jeremy Kerr [Mon, 21 Jul 2014 10:30:33 +0000 (18:30 +0800)]
discover/platform-powerpc: Configure safe mode from IPMI bootdev setting

An IPMI bootflags of 0x3 indicates a safe-mode boot. Use this to trigger
petitboot's safe mode.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover: Add safe mode
Jeremy Kerr [Mon, 21 Jul 2014 10:18:35 +0000 (18:18 +0800)]
discover: Add safe mode

Safe mode configures the discover server to not start any device
parsing; this can be used to diagnose any problems with early device
handing.

In safe mode, we don't initialise any of the device sources - udev,
network and user events are disabled.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoversion.sh: Ensure we're using petitboot's git directory
Jeremy Kerr [Fri, 18 Jul 2014 05:23:42 +0000 (13:23 +0800)]
version.sh: Ensure we're using petitboot's git directory

We don't want the version to be extracted from a higher-level git
directory.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoui/ncurses: allow tab/backtab to skip through a widget's fields
Jeremy Kerr [Fri, 18 Jul 2014 04:28:43 +0000 (12:28 +0800)]
ui/ncurses: allow tab/backtab to skip through a widget's fields

Since we may have a long list of devices on the configuration screen,
we'd like a way to jump between widgets. This change repeats the
PREV_FIELD/NEXT_FIELD driver request on these events.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoui/ncurses: Make Network: heading consistent with other labels
Jeremy Kerr [Fri, 18 Jul 2014 02:49:32 +0000 (10:49 +0800)]
ui/ncurses: Make Network: heading consistent with other labels

The 'Network' label was originally intended as a header, but we should
keep it consistent with other field labels.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoui/ncurses: Expose boot_device configuration through UI
Jeremy Kerr [Wed, 30 Apr 2014 04:14:41 +0000 (12:14 +0800)]
ui/ncurses: Expose boot_device configuration through UI

Add a configuration setting for the default boot device.

We change the autoboot option to a select, as we have three possible
behaviours for autoboot:

 ( ) Don't autoboot
 ( ) Autoboot from any disk/network device
 ( ) Only autoboot from a specific disk/network device

The latter option will show a list of possible devices to seelct for
autoboot behaviour.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover/powerpc: Parse & save default boot device parameter
Jeremy Kerr [Wed, 30 Apr 2014 03:25:42 +0000 (11:25 +0800)]
discover/powerpc: Parse & save default boot device parameter

This change implement load & save support for the default boot device
configuration parameter.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover: check config.boot_device before setting a default
Jeremy Kerr [Wed, 30 Apr 2014 02:58:43 +0000 (10:58 +0800)]
discover: check config.boot_device before setting a default

If a default device is set, we only allow booting from that device.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoconfig: Add boot_device member to config
Jeremy Kerr [Wed, 30 Apr 2014 02:17:20 +0000 (10:17 +0800)]
config: Add boot_device member to config

We'd like to specify a way to only boot from a specific block device;
this adds a field to the configuration to hold the value.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover: allow separate lifetimes for network interfaces and discover devices
Jeremy Kerr [Mon, 21 Jul 2014 07:51:58 +0000 (15:51 +0800)]
discover: allow separate lifetimes for network interfaces and discover devices

We want the network code's network interfaces to (potentially) persist
remove events. For example, discover devices may be removed by a user
event (this happens during a udhcpc deconfig). In this case, we want the
boot options to be removed, but the struct interface needs to stay
present.

This change adds network_(un)_register_device functions, to allow the
device handler to detach from and attach to interfaces.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover: Set UUID for network interface devices
Jeremy Kerr [Thu, 17 Jul 2014 01:13:58 +0000 (09:13 +0800)]
discover: Set UUID for network interface devices

We want to lookup network (as well as block) devices by UUID, so set one
based on the MAC address.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoui/ncurses: Remove net_conf parameter from sconfig_screen_layout_widgets
Jeremy Kerr [Thu, 17 Jul 2014 03:08:09 +0000 (11:08 +0800)]
ui/ncurses: Remove net_conf parameter from sconfig_screen_layout_widgets

We always pass screen->net_conf_type as this parameter, so we may as
weel grab it from screen directly.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoui/ncurses: specify a fixed length for status messages
Jeremy Kerr [Mon, 5 May 2014 03:45:16 +0000 (11:45 +0800)]
ui/ncurses: specify a fixed length for status messages

Incoming status messages can be an arbitrary length; if so, the status
line may be corrupt.

This change uses the 'n' variant of mvwaddnstr(), so we only write one
line of characters.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover: place countdown earlier in boot status messages
Jeremy Kerr [Mon, 5 May 2014 03:43:13 +0000 (11:43 +0800)]
discover: place countdown earlier in boot status messages

The boot status messages may be trimmed on the right-hand side; In this
case, we'll lose the boot countdown.

This change moves the boot countdown time to before the arbitrary-length
label string.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover/pxe-parser: Remove unnecessary semicolon
Jeremy Kerr [Wed, 4 Jun 2014 04:35:25 +0000 (12:35 +0800)]
discover/pxe-parser: Remove unnecessary semicolon

We have an unnecessary semicolon on an empty for-loop, which causes a
clang warning.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agom4: Add ncurses autoconf macros
Jeremy Kerr [Fri, 13 Jun 2014 03:42:03 +0000 (13:42 +1000)]
m4: Add ncurses autoconf macros

Currently, we depend on host autoconf-archive for the AX_WITH_CURSES
macros. Insead, include this in the source tree under m4/

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoversion.sh: Use git tags in versions
Jeremy Kerr [Fri, 14 Mar 2014 03:06:10 +0000 (11:06 +0800)]
version.sh: Use git tags in versions

If the current HEAD is tagged, we'd like to use that tag as the version.

We remove a 'v' prefix, so that v1.0 -> 1.0

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoversion.sh: Unify version generation
Jeremy Kerr [Fri, 14 Mar 2014 02:53:04 +0000 (10:53 +0800)]
version.sh: Unify version generation

This change includes a few fixes to the version.sh script, in order to
unify the versions generated from git vs. dev- versions. We unify on a
simple YYYYMMDD format, and drop the time specifier (if you're relying
on time info, you probably have the git SHAs to lookup from instead).

We also clean up the date-generation code, by using printf's %T
formatter, on git's %ct time specification, rather than trying to
transform a %ci date.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoautotools: Make petitboot autoreconfable
Jeff Bailey [Fri, 14 Mar 2014 00:49:10 +0000 (08:49 +0800)]
autotools: Make petitboot autoreconfable

The standard way to regenerate the autotools bits is with 'autoreconf',
but that doesn't work with our custom bootstrap script. We only need the
bootstrap script to generate the version in configure.ac, which we can
easily do with m4_esyscmd_s instead.

This change allows autoreconfiguration with `autoreconf -f -i`.

Includes changes proposed by Yann E. Morin <yann.morin.1998@free.fr>,
and modifications from the original patch from
Jeremy Kerr <jk@ozlabs.org>

Signed-off-by: Jeff Bailey <jeffbailey@google.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoautotools: Don't require custom automake options
Jeff Bailey [Fri, 14 Mar 2014 01:04:00 +0000 (09:04 +0800)]
autotools: Don't require custom automake options

We need a couple of automake options to prevent errors when regenerating
Makefile.ins during source preparation.

Some makefiles assume GNU make, so add 'foreign' where necessary. Also,
we are building objects in subdirectories, so we need 'subdir-objects'.

Modified to suit recent petitboot by Jeremy Kerr <jk@ozlabs.org>

Signed-off-by: Jeff Bailey <jeffbailey@google.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover/network: leave udhcpc processes running
Jeremy Kerr [Thu, 5 Jun 2014 07:38:07 +0000 (15:38 +0800)]
discover/network: leave udhcpc processes running

Currently, we start udhcpc with the '-n' argument, which means they'll
exit if no lease is obtained.

We'd prefer to leave the DHCP client running, so that any
slow-to-initialise links are not left deconfigured.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover/platform-powerpc: Don't rely on NVRAM working
Jeremy Kerr [Thu, 22 May 2014 10:31:16 +0000 (18:31 +0800)]
discover/platform-powerpc: Don't rely on NVRAM working

Although we need nvram to save settings, we may be running on a
nvram-less machine, but still need to detect as powerpc.

This change removes the nvram check.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover/network: Fix incorrect udhcpc command if we have no platform definition
Jeremy Kerr [Thu, 22 May 2014 08:03:19 +0000 (16:03 +0800)]
discover/network: Fix incorrect udhcpc command if we have no platform definition

If we don't have a platform defined, we generate an invalid uchdpc
command, as we've NULL-ed out the interface name.

This change fixes the no-platform case to terminate *after* the
interface name.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agogrub2: fix empty file handling
Jeremy Kerr [Wed, 4 Jun 2014 07:45:53 +0000 (15:45 +0800)]
grub2: fix empty file handling

Currently, we have a bug when parsing zero-length files: we subtract one
from the length to exclude the trailing NUL (added by read_file), but a
zero-length file will result in a length of -1.

This change adds an explicit exit if we're attempting to parse an empty
file.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover/paths: Fix wget command with https and !DEBUG
Jeremy Kerr [Wed, 4 Jun 2014 07:22:11 +0000 (15:22 +0800)]
discover/paths: Fix wget command with https and !DEBUG

When DEBUG is undefed, we run out of wget arguments for loading https
URLs. We need an extra element in the argv array to handle all possible
arguments.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover: don't free cancelled load tasks
Jeremy Kerr [Thu, 22 May 2014 10:42:33 +0000 (18:42 +0800)]
discover: don't free cancelled load tasks

Currently, we have a bug when a boot task with more than one load tasks
is cancelled:

1) boot_cancel calls cleanup_cancellations, which performs a
load_url_async_cancel on all load tasks. This sets the load tasks'
states to LOAD_CANCELLED, and signals associated processes.

2) The first load task process completes, we get a load_url_process_exit
callback. This then invokes cleanup_cancellations.

3) cleanup_cancellations then (incorrectly) frees the boot task (and
hence freeing all pending load tasks) as no load tasks are in LOAD_ASYNC
state (we set them all to LOAD_CANCELLED in step 1)

4) The actual completion for the second load task attempts to reference
the now-freed task structure.

This change fixes the issue by handing the LOAD_CANCELLED state properly
- if we find a load task in this state, we consider the boot task still
pending, and delay the free until all loads are complete.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoutils/pb-console: use a linux termcap entry for local consoles
Jeremy Kerr [Mon, 19 May 2014 05:16:51 +0000 (13:16 +0800)]
utils/pb-console: use a linux termcap entry for local consoles

For local consoles, we always want a TERM=linux.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover,ui: fix checks for debug option
Jeremy Kerr [Thu, 1 May 2014 12:53:43 +0000 (20:53 +0800)]
discover,ui: fix checks for debug option

We need to check for equality with opt_yes, not just check for non-zero.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agodiscover/yaboot: support lilo & silo for x86 and Sparc.
Jeff Bailey [Sun, 26 Jan 2014 00:48:24 +0000 (00:48 +0000)]
discover/yaboot: support lilo & silo for x86 and Sparc.

The yaboot.conf format is essentially the same format as silo.conf and
lilo.conf, especially if the author isn't using OF paths. This is a
cheap way of getting support for silo and lilo.

Signed-off-by: Jeff Bailey <jeffbailey@google.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
9 years agoui/ncurses: only cancel default boot on valid key events
Jeremy Kerr [Tue, 22 Apr 2014 02:41:59 +0000 (10:41 +0800)]
ui/ncurses: only cancel default boot on valid key events

We're seeing occasionaly failures to autoboot due to supirious key
events (getch() returing -1) on an IPMI console.

This change modifies the process_key logic to only abort the default if
we see a valid key event.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/udev: NULL return from udev_enumerate_get_list_entry isn't an error
Jeremy Kerr [Thu, 17 Apr 2014 03:47:39 +0000 (11:47 +0800)]
discover/udev: NULL return from udev_enumerate_get_list_entry isn't an error

A NULL return can mean the list is empty; don't return a failure from
this case.

udev_list_entry_foreach does a check for a NULL entry, so we'll do the
correct thing in the following loop.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/udev: fix double free on udev_init failures
Jeremy Kerr [Thu, 17 Apr 2014 03:40:09 +0000 (11:40 +0800)]
discover/udev: fix double free on udev_init failures

If the udev monitor or enumerate functions fail, we'll call the
udev_unref and udev_monitor_unref functions twice: once in the cleanup
path and once in the talloc destructor.

This change moves all cleanup to the talloc destructor, so we only do
the unrefs once.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Always provide a key definition for backtab
Jeremy Kerr [Tue, 15 Apr 2014 03:48:00 +0000 (11:48 +0800)]
ui/ncurses: Always provide a key definition for backtab

Petitboot environments will probably want a basic terminfo defintion
(eg, vt220) rather than a full linux or xterm, but vt220 and friends
don't define a backtab key. Backtab can be useful for proper form
navigation, and without a key definition, we just get an escape, which
exits the current screen.

This change provides a static definition for KEY_BTAB, so we should
always have one available.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Use a fixed-sized for small, known-length fields
Jeremy Kerr [Tue, 15 Apr 2014 03:08:39 +0000 (11:08 +0800)]
ui/ncurses: Use a fixed-sized for small, known-length fields

Fields without O_STATIC can "scroll" horizontally, and we may miss a
left-hand section of text from the current display. This can mean that
the user can't leave a validated field with no indication why, if the
off-to-the-left data is not a valid entry.

This change adds a widgetset function to mark a field as fixed-size, so
we don't have this scrolling behaviour. This means that the entire field
contents will always be visible, and any validation errors can be seen.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Fix uninitialised var warnings
Jeremy Kerr [Fri, 11 Apr 2014 08:11:51 +0000 (16:11 +0800)]
discover: Fix uninitialised var warnings

We get a couple of uninitialised var warning when compiling with certain
CFLAGS (-fprofile-arcs -ftest-coverage at this stage).

In statement_if_execute: We'll never actually use this uninitialised (as
there must be at least one conditional in the parsed statement), but we
should address the warning nonetheless.

As passed to strtok_r: strtok will initialise this, but it isn't obvious
to the compiler.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Ensure boot option labels are displayable as menu items
Jeremy Kerr [Thu, 13 Mar 2014 07:18:04 +0000 (15:18 +0800)]
ui/ncurses: Ensure boot option labels are displayable as menu items

ncurses' new_item() expects the name parameter to be a "printable
string", by converting it to a wchar *, and checking that each character
is printable with iswprint(). If it fails, we won't see a boot option at
all.

This change introduces a function to convert the label into something we
know is printable, and valid UTF-8. If mbstowcs fails, we replace it
with a generic 'Invalid option' label. If we encounter a valid multibyte
string with unprintable characters, we replace those with U+fffd
REPLACEMENT CHARACTER.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Fix discover_client leak
Jeremy Kerr [Thu, 13 Mar 2014 05:28:00 +0000 (13:28 +0800)]
ui/ncurses: Fix discover_client leak

We're not freeing the discover_client on exit, as it's not attached to
any existing talloc context.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: unpost ncurses menu in pmenu cleanup path
Jeremy Kerr [Thu, 13 Mar 2014 05:23:37 +0000 (13:23 +0800)]
ui/ncurses: unpost ncurses menu in pmenu cleanup path

We need to unpost the menu so that free_item can actually free the item.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Use pmenu_item destrutor to free ncurses ITEMs
Jeremy Kerr [Thu, 13 Mar 2014 02:37:20 +0000 (10:37 +0800)]
ui/ncurses: Use pmenu_item destrutor to free ncurses ITEMs

Currently, pemnu_destroy is used to free items. This means that the menu
code needs to iterate over items, and we have no way to free the ITEM *
of items that aren't in a menu.

Instead, free the ITEM in the pmenu_item destructor.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Separate menu item creation & initialisation from insertion
Jeremy Kerr [Wed, 12 Mar 2014 06:59:03 +0000 (14:59 +0800)]
ui/ncurses: Separate menu item creation & initialisation from insertion

Currently, the menu item creation is has two main functions:
pmenu_item_alloc and pmenu_item_setup. The latter does initialisation
(it sets item->name), and inserts the item into the menu. We have
pmenu_item_init to combine this into one, but that means we need to do
further initialisation (eg, to set on_execute) after the item has been
added to the menu.

Instead, this change use a more direct _create and _insert interface.
Create does the allocation and initialisation, while _insert does the
actual insertion.

This means new_item failures will be detected at creation time, rather
than during pmenu_insert. Also, we're now insert a completely-populated
item into the menu, rather than populating on_edit, on_execute and data
after insertion.

Because we can detect errors from creation (ie, from new_item failing),
we add handling code to cui_boot_option_add and cui_boot_editor_on_exit.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Don't use menu offsets for user item numbers
Jeremy Kerr [Thu, 10 Apr 2014 03:16:23 +0000 (11:16 +0800)]
ui/ncurses: Don't use menu offsets for user item numbers

The menu offsets are arbitrary, use a separate numbering scheme for user
items.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Remove pmenu_item_replace
Jeremy Kerr [Wed, 12 Mar 2014 06:34:13 +0000 (14:34 +0800)]
ui/ncurses: Remove pmenu_item_replace

... as nothing uses it.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Don't free item in pmenu_item_setup
Jeremy Kerr [Wed, 12 Mar 2014 06:22:47 +0000 (14:22 +0800)]
ui/ncurses: Don't free item in pmenu_item_setup

Currently pmenu_item_setup may free its item parameter on error.

This makes it non-obvious whether the item is still allocated on exit to
the caller.

Instead, this change removes the talloc_free, and requires that the
caller do this on error. This makes the potential use-after-free in
cui_boot_editor_on_exit obvious, so we fix that too.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/pb-protocol: fix deserialise of boot option priorities
Jeremy Kerr [Mon, 7 Apr 2014 07:22:46 +0000 (15:22 +0800)]
lib/pb-protocol: fix deserialise of boot option priorities

Commit aa530148 introduced a priority member to struct boot_priority,
but didn't update the protocol deserialise function to properly decode
config messages. This meant we were leaving half of the struct
uninitialised, and getting invalid values in the initialised part.

This change updates the config deserialise function to do proper
handling for boot priority data.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: clear DNS server setting before appending new servers
Jeremy Kerr [Mon, 7 Apr 2014 00:58:57 +0000 (08:58 +0800)]
ui/ncurses: clear DNS server setting before appending new servers

Currently, we have a bug where newly-configured DNS servers are appended
to the existing set of servers, rather than replacing them.

This change clears the existing servers out before adding the
newly-configured ones.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolog: Allow runtime selection of 'debug' log level
Jeremy Kerr [Fri, 4 Apr 2014 05:05:18 +0000 (13:05 +0800)]
log: Allow runtime selection of 'debug' log level

Currently, we need to compile with -DDEBUG to implement debug-level
logging in the UIs and discover server.

Since we may not be able to easily replace a system's petitboot
binaries, this change introduces a -v|--verbose option to the discver
server and ncurses UI, which enables debug at runtime. We also move some
of the udev debug code out of an #ifdef DEBUG block.

Since petitboot is generally started on boot, we also add a little
infrastructure to pass -v to petitboot on certain system contitions:
either petitboot.debug on the kernel command line, or a petitboot,debug?
NVRAM property containing the value 'true'.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/network: run udhcpc process in foreground mode
Jeremy Kerr [Thu, 3 Apr 2014 07:48:20 +0000 (15:48 +0800)]
discover/network: run udhcpc process in foreground mode

We don't want udhcpc processes to detach, otherwise we aren't able to
stop the spawned background process, which we need to do on reinit.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Use tty name in default log filename
Jeremy Kerr [Thu, 3 Apr 2014 07:17:27 +0000 (15:17 +0800)]
ui/ncurses: Use tty name in default log filename

When we have multiple ncurses UIs running, we'd like to log to separate
files. Currenly, all UIs log to the same file, which makes it diffifult
to determine which UI is logging each message.

This change uses the output of ttyname() (sanitised appropriately) as a
component of the default log filename.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/process: Add debug on process kill
Jeremy Kerr [Thu, 3 Apr 2014 06:25:48 +0000 (14:25 +0800)]
lib/process: Add debug on process kill

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/network: flush addresses when bringing an interface down
Jeremy Kerr [Wed, 2 Apr 2014 07:44:44 +0000 (15:44 +0800)]
discover/network: flush addresses when bringing an interface down

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add menu option to restart discovery
Jeremy Kerr [Wed, 2 Apr 2014 07:16:26 +0000 (15:16 +0800)]
ui/ncurses: Add menu option to restart discovery

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/common: associate boot options with devices
Jeremy Kerr [Wed, 2 Apr 2014 07:15:22 +0000 (15:15 +0800)]
ui/common: associate boot options with devices

The discover client isn't currently associating boot options with their
devices. This change adds appropriate device list management.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoprotocol: expose discovery reinit over client/server protocol
Jeremy Kerr [Wed, 2 Apr 2014 06:53:07 +0000 (14:53 +0800)]
protocol: expose discovery reinit over client/server protocol

Now that we can re-initialise the device handler, allow this to be
triggered from UIs over the petitboot protocol.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: add reinit path
Jeremy Kerr [Wed, 2 Apr 2014 06:33:38 +0000 (14:33 +0800)]
discover: add reinit path

Currently, changes to settings doesn't take effect while the discover
server is running. This means we need to reboot for any changes (eg, to
network settings) to take effect.

This change introduces a reinit path. Triggered by a configuration
update, this will cause the device handler to drop all of its devices
(and boot options), and restart the discovery process from the device
sources.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: move device sources to the device handler
Jeremy Kerr [Wed, 2 Apr 2014 06:08:26 +0000 (14:08 +0800)]
discover: move device sources to the device handler

Currently, the pb-discover main() function initialises the device
handler and the device sources.

We want to eventually be able to re-init the device sources, which will
be initiated by the handler. In this case, the handler will need
references to the sources.

This change moves the creation of the device sources to be internal to
the handler. This way, the device handler gets a reference to
everything, without having to pass pointers around in main().

We also remove the _destroy functions, as we handle everything through
talloc destructors, as all sources are parented to the handler. We also
change user_event_init and udev_init to take the handler as the first
('context') argument, to make them consistent with network_init.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/udev: duplicate devices aren't an error
Jeremy Kerr [Tue, 1 Apr 2014 08:33:43 +0000 (16:33 +0800)]
discover/udev: duplicate devices aren't an error

We don't need to error out of udev_handle_block_add if this is a
duplicate UUID.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/udev: don't propagate non-fatal errors from udev_process
Jeremy Kerr [Tue, 1 Apr 2014 08:30:27 +0000 (16:30 +0800)]
discover/udev: don't propagate non-fatal errors from udev_process

Currently, we have a bug where non-zero return codes from
udev_handle_dev_* cause the udev worker from deregistering from the
waiter poll loop. This is becasue udev_process is propagating these
errors, causing the deregistration.

This change stops propagation of non-fatal errors, so we don't
deregister.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Increase udev monitor buffer size
Jeremy Kerr [Tue, 18 Mar 2014 03:34:16 +0000 (14:34 +1100)]
discover: Increase udev monitor buffer size

Since we may be enumerating devices after enabling the udev monitor, we
may miss udev events that occur during this process.

This change increases the default udev buffer size.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoudev: use pb_log for device SKIP messages
Jeremy Kerr [Fri, 14 Mar 2014 07:17:08 +0000 (15:17 +0800)]
udev: use pb_log for device SKIP messages

We often want to find out why a device has been skipped, so include the
SKIP messages at pb_log, which doesn't require a -DDEBUG build.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Call mount syscall directly
Jeremy Kerr [Thu, 13 Mar 2014 02:24:32 +0000 (10:24 +0800)]
discover: Call mount syscall directly

We used to use the mount binary to do filesystem autodetection. Since we
now know the fstype, we may as well call the mount syscall directly.

We add a log messages too, as we'll no longer get the 'running process:'
output from the process code, which is helpful is debugging discovery
issues.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Use ID_FS_TYPE property for filesystem type detection
Jeremy Kerr [Thu, 13 Mar 2014 02:07:12 +0000 (10:07 +0800)]
discover: Use ID_FS_TYPE property for filesystem type detection

Currently, we don't hand any -t option to mount, as we expect the mount
binary to do autodetection of the filesystem type for us.

Turns out this isn't great with busybox mount, (which we're likely to be
using in petitboot builds), which implements "autodetection" by trying
the mount() syscall with every fs type in /proc/filesystems, until one
succeeds.

We expect a lot of the mount calls to fail, as we currently try to mount
everything (and abort discovery on devices that don't mount), including
non-filesystem partitions. On a test machine with 560 block devices, and
37 entries in /proc/partitions, this results in around 20,000 calls to
mount().

A better way would be to pass a -t option to mount. It turns out that
udev uses libblkid to probe the filesystem type, which is available in
the ID_FS_TYPE property. This change only attempts to mount filesystems
with this property, and passes an explicit fstype to the mount binary.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/powerpc: Invalidate next bootdev after reading
Jeremy Kerr [Mon, 10 Mar 2014 04:11:00 +0000 (12:11 +0800)]
discover/powerpc: Invalidate next bootdev after reading

The next-bootdev sysparam should only apply for the next boot, so
invalidate it after reading.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/powerpc: Fix sysparams base path
Jeremy Kerr [Mon, 10 Mar 2014 03:17:54 +0000 (11:17 +0800)]
discover/powerpc: Fix sysparams base path

We are appending the sysparam filename onto sysparams_dir, so we need a
trailing slash.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Add debug output to sysparams parsing
Jeremy Kerr [Mon, 10 Mar 2014 02:40:46 +0000 (10:40 +0800)]
discover: Add debug output to sysparams parsing

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Include boot priorities in configuration dump
Jeremy Kerr [Mon, 10 Mar 2014 02:39:52 +0000 (10:39 +0800)]
discover: Include boot priorities in configuration dump

To help debug boot priority issues, it'd be useful to include the
priority data in the configuration dump.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/udev: Register udev monitor before enumerating devices
Jeremy Kerr [Fri, 7 Mar 2014 05:46:49 +0000 (13:46 +0800)]
discover/udev: Register udev monitor before enumerating devices

Currently, we enumerate udev devices before setting up our monitor. This
means that we may lose devices that udev discovers after we start the
enumeration, but before the monitor is registered.

This change enables the monitor before enumeration, so we don't lose
devices. We add a filter to the enumeration code to only parse
completely initialised devices.

This means we may need to handle change events as the main source of
device notifications. We keep the existing CDROM event handler, but
check for new devices and handle those as an add.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Print error message on mount failure
Jeremy Kerr [Fri, 7 Mar 2014 01:10:16 +0000 (09:10 +0800)]
discover: Print error message on mount failure

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: don't retry mount without ro option
Jeremy Kerr [Fri, 7 Mar 2014 01:05:00 +0000 (09:05 +0800)]
discover: don't retry mount without ro option

Currently, if the read-only mount fails during device discovery, we
retry without the '-o ro' option. This was originally due to the
read-only mount failing when a device was already mounted elsewhere.

Since we check for exsiting mounts now, we can drop this retry.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: fix return value for discover_device_get_param
Jeremy Kerr [Thu, 6 Mar 2014 10:14:00 +0000 (18:14 +0800)]
discover: fix return value for discover_device_get_param

We're incorrectly returning the name, we need the value.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/udev: Separate block-specific udev discovery
Jeremy Kerr [Wed, 5 Mar 2014 02:19:55 +0000 (10:19 +0800)]
discover/udev: Separate block-specific udev discovery

We'd like to trigger network device discovery from udev code, but most
of the device_add code path assumes block devices.

This change adds a subsystem check, and moves the block-specific code to
udev_handle_block_add.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Ensure that the selected menu item is visible
Jeremy Kerr [Mon, 3 Mar 2014 10:15:31 +0000 (18:15 +0800)]
ui/ncurses: Ensure that the selected menu item is visible

When adding new items to the petitboot menu, we need to ensure that the
scroll position of the menu includes the currently-selected item.

This change adds a call to set_top_row, calculated from the selected
item index, and the number of rows in the menu.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add pxe discovery tests
Jeremy Kerr [Thu, 27 Feb 2014 08:52:20 +0000 (16:52 +0800)]
test/parser: Add pxe discovery tests

Add tests to cover pxlinux-style configuration autodiscovery.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/pxe: pxe parser should only treat "::" paths as absolute
Jeremy Kerr [Thu, 27 Feb 2014 05:54:32 +0000 (13:54 +0800)]
discover/pxe: pxe parser should only treat "::" paths as absolute

PXELinux treats all paths as relative, requiring a "::/path" syntax for
truly absolute URLs.

This change implements the same behaviour in petitboot, and updates the
testcases to suit.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/pxe: Fix prefix autodetection when bootfile is in the root dir
Jeremy Kerr [Thu, 27 Feb 2014 03:39:41 +0000 (11:39 +0800)]
discover/pxe: Fix prefix autodetection when bootfile is in the root dir

Currently, if the bootfile doesn't contain a directory, the path we use
for config file resolution will use the bootfile as the first component
of path.

For example, if bootfile is:

  pxelinux.0

the config files requested will be:

  pxelinux.0/<mac>
  pxelinux.0/<ips>
  pxelinux.0/default

For cases where bootfile is a single file, we need to use a blank
prefix.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/pxe: Add pxelinux.cfg/ directory to autodiscovered pxe paths
Jeremy Kerr [Thu, 27 Feb 2014 02:33:13 +0000 (10:33 +0800)]
discover/pxe: Add pxelinux.cfg/ directory to autodiscovered pxe paths

The pxelinux project will perform autodiscovery by looking for files
under the pxelinux.cfg/ prefix (in addition to any pxepathprefix from
DHCP option 210)

This change unifies petitboot's behaviour with pxelinux.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/network: Fix incorrect static DNS servers in resolv.conf
Jeremy Kerr [Tue, 25 Feb 2014 09:04:17 +0000 (17:04 +0800)]
discover/network: Fix incorrect static DNS servers in resolv.conf

We currently have a bug where we write NUL characters into
/etc/resolv.conf, when using static DNS server configurations:

With a network setting of: dns,9.0.6.11,9.0.7.1

We generate a resolv.conf containing:

 nameserver 9.0.6.11^@nameserver 9.0.7.1^@

This is due to an off-by-one bug when terminating the nameserver
entries.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/process: Don't abort stdout reads on EINTR
Jeremy Kerr [Thu, 20 Feb 2014 01:22:58 +0000 (09:22 +0800)]
lib/process: Don't abort stdout reads on EINTR

If our read() of the process stdout pipe fails with EINTR (eg, if we
receive a SIGCHLD because the process exited), then
process_read_stdout_once will return a non-zero exit code, and we'll
abort any further stdout collection.

Instead, we should check for EINTR, and allow the reads to continue.

This change normalises the return value from process_read_stdout_once to
return positive on success, negative on failure, and zero on competion.
We use a positive return value for the non-error EINTR case.

Also, add a pb_log if the read fails for non-EINTR reasons.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoutils: Add all hooks to Makefile
Jeremy Kerr [Fri, 14 Feb 2014 09:45:53 +0000 (17:45 +0800)]
utils: Add all hooks to Makefile

We were missing a couple of the later hooks from the Makefile.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Unify key bindings & key help text
Jeremy Kerr [Fri, 31 Jan 2014 02:53:57 +0000 (10:53 +0800)]
ui/ncurses: Unify key bindings & key help text

This change is a small cleanup of the key bindings; we ensure that the
general key bindings are available (and documented) on all screens.

In order to keep things consistent, this change adds an initial UI
guidelines text file, which documents the general key bindings.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add help to boot editor screen
Jeremy Kerr [Fri, 13 Dec 2013 08:02:12 +0000 (16:02 +0800)]
ui/ncurses: Add help to boot editor screen

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add help to system configuration screen
Jeremy Kerr [Fri, 13 Dec 2013 07:20:22 +0000 (15:20 +0800)]
ui/ncurses: Add help to system configuration screen

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add help to sysinfo screen
Jeremy Kerr [Fri, 13 Dec 2013 07:18:07 +0000 (15:18 +0800)]
ui/ncurses: Add help to sysinfo screen

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add help facility to text screens
Jeremy Kerr [Fri, 13 Dec 2013 07:15:06 +0000 (15:15 +0800)]
ui/ncurses: Add help facility to text screens

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add help text to nc-menu & generic-main
Jeremy Kerr [Tue, 10 Dec 2013 07:08:47 +0000 (15:08 +0800)]
ui/ncurses: Add help text to nc-menu & generic-main

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add support for help screens
Jeremy Kerr [Tue, 10 Dec 2013 03:48:25 +0000 (11:48 +0800)]
ui/ncurses: Add support for help screens

Add a textscreen-based help screen system, triggered from the cui
module's cui_show_help()

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add text_screen_set_text()
Jeremy Kerr [Mon, 9 Dec 2013 03:52:57 +0000 (11:52 +0800)]
ui/ncurses: Add text_screen_set_text()

When we have a large chunk of text, we'll want to add it all in one go.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Abstract text-screen code from sysinfo screen
Jeremy Kerr [Mon, 9 Dec 2013 03:30:19 +0000 (11:30 +0800)]
ui/ncurses: Abstract text-screen code from sysinfo screen

We want to implement help screens, which are very similar to the sysinfo
screen - show a set of lines, and allow scrolling.

This change splits the text-screen rendering code into a new nc-textinfo
module.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: do all config screen updates in config_screen_post
Jeremy Kerr [Fri, 13 Dec 2013 02:09:06 +0000 (10:09 +0800)]
ui/ncurses: do all config screen updates in config_screen_post

We call _post when the config screen is to be displayed, so do all
drawing here. This means we get the same drawing code on both init and
update.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/fold: Add text fold utility
Jeremy Kerr [Tue, 10 Dec 2013 06:12:48 +0000 (14:12 +0800)]
lib/fold: Add text fold utility

We want to fold help text into the ncurses UI, so add a little module to
split text into lines.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Use descriptive field labels for boot editor
Jeremy Kerr [Thu, 30 Jan 2014 13:53:30 +0000 (21:53 +0800)]
ui/ncurses: Use descriptive field labels for boot editor

Rather than the brief names for the boot editor field label, expand (and
capitalise) for a more-friendly form.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoplatforms/powerpc: Add support for OPAL sysparams
Jeremy Kerr [Thu, 30 Jan 2014 08:59:56 +0000 (16:59 +0800)]
platforms/powerpc: Add support for OPAL sysparams

PowerPC OPAL firmware's sysparam interface allows us to read the boot
device set over IPMI. This change implements support for IPMI bootdev
selection over the sysparams interface, using the new boot_priority
infrastructure.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Add DEVICE_TYPE_ANY for matching any device
Jeremy Kerr [Thu, 30 Jan 2014 08:32:21 +0000 (16:32 +0800)]
discover: Add DEVICE_TYPE_ANY for matching any device

Currently, If we want disable all but a specific device type from
default boot, we need to add a negative priority for all other devices.

This change adds a DEVICE_TYPE_ANY definition, to allow a simpler way to
express "only boot a specific type" by default behaviour.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Make boot_priorities more flexible
Jeremy Kerr [Thu, 30 Jan 2014 08:19:20 +0000 (16:19 +0800)]
discover: Make boot_priorities more flexible

Rather than rely on the ordering of the boot_priorities array to define
which device types have a higher "default boot" priority, this change
introduces a slightly more flexible way of priority lookups, by adding a
separate priority field to struct boot_priority.

This means we can have an unordered array, change priorities without
re-writing the array, and implementing a disable mechanism.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/network: Use platform definition for DHCP architecture ID
Jeremy Kerr [Fri, 17 Jan 2014 08:12:42 +0000 (16:12 +0800)]
discover/network: Use platform definition for DHCP architecture ID

Allow a platform to specify a DHCP architecture ID, as this is
platform-specific.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoplatforms/powerpc: Check for a powerpc platform in the probe function
Jeremy Kerr [Wed, 29 Jan 2014 09:41:04 +0000 (17:41 +0800)]
platforms/powerpc: Check for a powerpc platform in the probe function

Currently, we're always assuming a powerpc platform, as the powerpc
probe() function always returns true.

This change adds a check for some bits we need to work on a powerpc
platform.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agopb-config: Move config storage modules to "platform" modules in discover code
Jeremy Kerr [Wed, 29 Jan 2014 05:28:06 +0000 (13:28 +0800)]
pb-config: Move config storage modules to "platform" modules in discover code

There's no need to include the config storage code in lib/ as only the
discover server should be using it.

This change moves the config-storage code to discover/, with the
platform-specific parts moved to a 'struct platform'. Each platform has
a probe function, which is called during init. The first probe function
to return a platform is used.

At present we only have the one platform, but it's now non-intrusive to
add others.

We keep an array of platform pointers in a separate ("platforms")
section, to allow the test module to drop-in its own test "platform".

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/pb-config: Add config_copy
Jeremy Kerr [Tue, 28 Jan 2014 05:01:19 +0000 (13:01 +0800)]
lib/pb-config: Add config_copy

At the moment, UIs have the config_set_defaults function to estabilish
an initial configuration when performing an update.

Rather than using the defaults, this change provides a config_copy()
function, so that the updated configuration can be initialised from the
current config.

With this in place, the UI/server-common pb-config module can be reduced
to just the one function.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add Fedora 20 ppc64 parser testcase
Jeremy Kerr [Tue, 28 Jan 2014 01:42:28 +0000 (09:42 +0800)]
test/parser: Add Fedora 20 ppc64 parser testcase

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>