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.
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.
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.
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.
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".
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.
Jeremy Kerr [Fri, 24 Jan 2014 06:40:46 +0000 (14:40 +0800)]
discover/grub2: Add support for for-loops
GRUB2 syntax allows for for-loops; this change adds supoprt in the
parser grammar and script execution code to implement them. In the
execution code, we simply update the for-loop variable and re-execute
the body statements.
In order to implement for-loops, we may need to evaluate the same chunk
of script more than once, and perform that evaluation in a different
context (particularly, with different environment variables).
Currently, the process_expansion code destroys the result of the
parse-tree (ie, the token list) when performing expansions. This means
that we can only perform the expansions once.
This change preserves the token list while creating the argv array. This
means that we can expand the list multiple times.
Jeremy Kerr [Fri, 24 Jan 2014 06:39:37 +0000 (14:39 +0800)]
discover: Add support for checking directories in parser API
This change adds a function to the parser API:
int parser_check_dir(struct discover_context *ctx,
struct discover_device *dev, const char *dirname)
- which allows parsers to check for the presence of a directory (path of
'dirname') on the device ('dev'). We use this in the GRUB2 parser to
implement the `test -d` check.
Jeremy Kerr [Tue, 21 Jan 2014 00:27:48 +0000 (08:27 +0800)]
discover/paths: Check process exit status when loading URLs
Currently, we may report incorrect success when loading a URL, as we
only check the return value of process_run_sync() (and not the process
exit status itself) in load_process_to_local_file.
Jeremy Kerr [Mon, 20 Jan 2014 00:58:49 +0000 (08:58 +0800)]
utils/pb-udhcpc: Unify references to DHCP bootfile parameter
udhcpc may pass the bootfile parameter as either $bootfile or
$boot_file, depending on whether the option is present in the BOOTP
header, or as a DHCP vendor option. We have code in pb-udhcpc to unify
this to $bootfile, but we only use the unified value in one of the user
events.
This change uses the correct value of bootfile, and fixes the check to
conditionally generate the explicit add event. We also need to update
the user-event code to use the right event parameter name.
Jeremy Kerr [Mon, 20 Jan 2014 00:51:11 +0000 (08:51 +0800)]
utils/pb-udhcpc: Fix incorrect reference to $interface
We have a typo in the udhcpc hook, where we're not referncing the
interface variable correctly. This means we'll get the same device
identifier for all netboot options.
Jeremy Kerr [Fri, 17 Jan 2014 07:51:54 +0000 (15:51 +0800)]
discover: Support DHCP "pathprefix" configuration option
This change implements support for the DHCP "pathprefix" option. We use
the following logic:
- If pathprefix is present and a full URL, we base the config file
location on pathprefix + conffile
- If pathprefix is present but not a full URL, we use it as the path
component of the URL, and pick up the host from other parameters in
the DHCP response
- If no pathprefix is present, we determine the configuration prefix
from the DHCP bootfile parameter.
Jeremy Kerr [Fri, 17 Jan 2014 08:36:41 +0000 (16:36 +0800)]
test/parser: Check for full URLs in parser tests
At present, we only match the 'file' portion of a URL in the parser
tests, so we "serve" a file if just the filename (but not the scheme,
hostname or path) matches the file we set with test_read_conf_embedded.
This change introduces test_read_conf_embedded_url, which we can use to
specify a full URL. In this case, the fake parser_request_file matches
the entire URL before returning the file data.
Jeremy Kerr [Fri, 17 Jan 2014 06:50:54 +0000 (14:50 +0800)]
discover: Don't rely on ctx->conf_url side-effect in user_event_parse_conf_url
Currently, user_event_parse_conf_url sets dc->conf_url if it detects we
have a full URL (rather than a base URL). This is a little too subtle,
so replace it with an explicit output parameter.
Ben Stoltz [Wed, 15 Jan 2014 23:10:25 +0000 (15:10 -0800)]
discover/grub: Use --id values for default option detection
Fix Petitboot's grub.cfg parser to handle --id=label argument to
menuentry, and use it (in preference to the option name) when looking
for a default option.
Jeremy Kerr [Thu, 16 Jan 2014 01:13:20 +0000 (09:13 +0800)]
discover: Bring down configured interfaces on discover server exit.
We want to down the interfaces that we brought up, so hook up the
network_shutdown function to the discover exit path. Also, we only want
to down interfaces that we've configured, and exclude lo.
Jeremy Kerr [Tue, 14 Jan 2014 07:44:10 +0000 (15:44 +0800)]
lib/process: Add add_stderr flag to process module
For some process execution functions, we'd like to capture stderr as
well as stdout. Currently, we unconditionally redirect subprocess stderr
to the petitboot log file.
This change adds an add_stderr flag to struct process, which indicates
to the process library that we want stderr as well as stdout. If this is
specified, the subprocess' stderr is captured to stdout_buf.
Jeremy Kerr [Tue, 14 Jan 2014 02:56:41 +0000 (10:56 +0800)]
discover/yaboot: Clear globals_done when we see an image definition
Currently, we have a bug where a 'known_name' that appears before an
image section will cause globals_done to be set, and we don't see any
further global variables.
This change sets globals_done only once we see an image section.
Jeremy Kerr [Mon, 23 Dec 2013 08:42:21 +0000 (16:42 +0800)]
config/powerpc: Always call update_network_config
Currently, we have a bug when setting the default network configuration
(ie, no devices have any specific config), as we won't call
update_network_config to clear out the value of the petitboot,network
parameter.
This change always invokes update_network_config, regardless of the
number of interfaces configured. This ensures we clear out the
petitboot,network param, which is then synced to nvram if the param has
changed.
We'd like to do some validation of the system configuration parameters,
so add a few validation types to the widget code. We currently need
integer, ipv4 address and multiple ipv4 address types. These are
implemented as small wrappers around the ncurses form validator code.
Jeremy Kerr [Mon, 16 Dec 2013 02:49:29 +0000 (10:49 +0800)]
sysinfo: Add interface link status to sysinfo data
This changes adds a 'link' parameter to the interface information sent
in sysinfo messages. The discover network code populates this from the
incoming netlink messages.
Jeremy Kerr [Thu, 5 Dec 2013 06:32:28 +0000 (14:32 +0800)]
discover/boot: Fix condition for updating boot params
In commit 823958fb, we change to use struct process, but left in the
check for rc == BOOT_HOOK_EXIT_UPDATE. We actually want to check
process->exit_status here, not rc.
Jeremy Kerr [Tue, 3 Dec 2013 07:14:53 +0000 (15:14 +0800)]
discover/grub2: Fixes for bison 3.x
YYLEX_PARAM is removed in bison 3.0, so we need to pass the scanner
param directly through yyparse (rather than referencing
parser->scanner). Unfortunately, we don't have the lexer header
available at the time we declare yyparse, so we need to pass a void *
here.
Jeremy Kerr [Fri, 29 Nov 2013 02:47:10 +0000 (10:47 +0800)]
discover: Fix CDROM handling
Currently, we don't handle CDROM devices well; we'll try to mount on
boot, and not detect any media changes. Also, the default rules shipping
with udev will put the CDROM tray into a locked state, blocking eject
from working.
This change adds a set of cdrom utility functions, which the udev code
can use to properly initialise cdrom devices and handle eject and media
change requests.
In an upcoming change, we'll populate $prefix (which is used to locate
the environment file) based on the location of the config file, so these
paths will need to be consistent.
Jeremy Kerr [Fri, 22 Nov 2013 06:12:59 +0000 (14:12 +0800)]
ui/ncurses/nc-widgets: Unify select key
We have a few instances where we check for a 'select' action (enter or
space key event), and some are inconsistent. Unify these with a
key_is_select() function.
Jeremy Kerr [Tue, 19 Nov 2013 06:39:41 +0000 (17:39 +1100)]
ui/ncurses: Fix use-after-free when exiting boot option editor
After we've called on_exit, we can no longer use the boot editor. This
change moves individual button callbacks into process_key, which returns
to the main loop.
Jeremy Kerr [Tue, 19 Nov 2013 00:52:49 +0000 (11:52 +1100)]
ui/ncurses: Draw boot editor into a scrollable pad
Like the config editor, draw the boot editor into a pad instead of
directly into the sub window. This means that long device lists will be
handled correctly.
Jeremy Kerr [Sun, 17 Nov 2013 08:36:55 +0000 (19:36 +1100)]
ui/ncurses: Add device selector to boot editor
Rather than expecting users to enter full (prefixed) mount paths, add a
select widget to pick a device, and we automatically add the prefix when
the form is submitted.
Jeremy Kerr [Sun, 17 Nov 2013 03:04:08 +0000 (14:04 +1100)]
ui/ncurses: Make boot editor API consistent with config & sysinfo screens
The boot-editor API is a little more exposed than it needs to be: the
boot_editor struct does not need to be available to other files, and the
init function and on_exit functions differ from those provided for the
config and sysinfo screens.
This change unifies the boot_editor API with those for the other
screens.
Jeremy Kerr [Tue, 19 Nov 2013 04:25:43 +0000 (15:25 +1100)]
discover: Use pxeconffile for udhcpc option name
The patch that went upstream for udhcpc's option 209 handling uses the
option name 'pxeconffile' rather than 'conffile', and it was added as a
non-default option: