Alan Dunn [Tue, 15 Mar 2016 00:40:47 +0000 (17:40 -0700)]
In GRUB2 parser save_env, treat unset variable value as empty
It seems better to treat unset variable values as empty rather than
crashing in save_env. While GRUB's behavior is actually to delete the
variable from the environment block, it seems useful to at least not
crash while later on someone can do further work to improve GRUB
compatibility if desired.
Tested:
Modified test-grub2-save-env to cover this case.
Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
po: Update help string and add untranslated strings
Update the nc-lang help string translation to reflect the change
introduced in the previous commit, "Remove "h=help" hint in language page".
Also update each .po file with any new strings lacking a translation.
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
Use 'Primary' instead of 'Current' for flash sides
When queried libflash will return the 'first' flash side (ie. the one
with the lowest TOC address), however we label this the 'Current' side
which is incorrect if the machine has booted from the alternate side.
A future fix will inlcude additional platform logic to determine which
flash side is current; in the interim label the first flash side as
'Primary' instead of 'Current'.
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
On BMC platforms the 'Get System Boot Options' command can also be used
to check for a temporary network interface config override. This is
implemented via the optional 'OEM Parameters' field defined in the IPMI
v2 spec. We define the actual format of the field as:
- 4 byte cookie value
- 2 byte version value
- 1 byte hardware address size
- 1 byte IP address size
- Hardware address
- 1 byte flags for 'ignore' and 'method'
And for static configs:
- IP Address
- 1 byte subnet value
- Gateway address
If set the config override replaces any other interface config, forcing
the use of the specified configuration.
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
utils/hooks: Write offb device address to device tree
On OpenPOWER machines, kernels missing the AST video driver can use the
existing 'Open Firmware' framebuffer device code to inherit an existing
framebuffer from Petitboot. This requires us to translate the 64-bit
address of the framebuffer 'back' into a PCI address and write it into
an assigned-addresses property in the device tree.
Bootstrapped-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
On BMC machines the "Get Device ID" and "Get BMC Golden Side Version"
IPMI commands are available. If possible retrieve some interesting
version numbers and display them in the System Information screen.
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
Add basic libflash support to read the VERSION partition on BMC
machines. This adds a dependency on the libflash shared library from
Skiboot.
The MTD partition is accessed through the libflash helper functions.
Once read into a buffer, the VERSION partition is a simple list of
newline-terminated version strings. Some BMC platforms may have two
'sides' to flash - these are interpreted as the "current" and "other"
sides depending on which one the current Petitboot is running from.
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
If "" or '' are used in a statement to omit a word, we must still
return a TOKEN_WORD for an empty string.
In particular this fixes an issue where Petitboot would fail to parse
the grub.cfg included in the Debian 8.2 install image, which includes a
menuentry statement with an empty name.
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
During install some distributions[0] will create subvolumes when formatting
the root filesystem with BTRFS. In particular this can mean that
bootloader config files will appear (in the case of GRUB) under
/var/petitboot/mnt/dev/$device/@/boot/grub/
rather than the expected
/var/petitboot/mnt/dev/$device/boot/grub/
If this is the case, perform all file operations from the parser
relative to this subvolume rather than the mount point. At the moment
this only supports the trivial case where the subvolume name for root is
blank (ie. '@').
[0] In particular, Ubuntu from at least 14.04
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
Alan Dunn [Tue, 12 Jan 2016 23:43:02 +0000 (15:43 -0800)]
discover/grub2: Fix behavior of save_env -f
Currently, "save_env -f" in the GRUB2 parser only works with three
arguments, which means only commands of the form "save_env -f <path>"
that save *no* environment variables are allowed.
Allow "save_env -f <path> [<var>]*", making "save_env -f" useful.
Tested:
Unit test test-grub2-save-env-dash-f tests this change, and the
remaining unit tests still pass.
Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
lib/pb-protocol: Fix NULL dereference on non-powerpc
If not running on a powerpc platform the bmc_mac pointer remains NULL.
If this is the case set an address of zero when serialising rather
than dereferencing the pointer.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
discover: extend URL in UI to support auto-discovery
The URL field currently only supports loading a particular file for
static network configurations. But it makes sense in certain static
network configurations to 'auto-discover' a file like petitboot does
with DHCP -- based off the MAC address and IP. Extend
device_handler_process_url to take those as parameters, and toggle off
the URL ending in a '/' to indicate whether to 'auto-discover' or
directly load the specified URL.
Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
ui: add URL for static configurations to load a specified file
In certain configurations, e.g. automation, we want to use static
networking but load a particular file, automatically and parse it as a
pxelinux config file. Currently, we support something like this for DHCP
based booting, but not static. Add a URL field to the UI for static
configurations and reuse the logic from device_handler_process_url() to
load the specified file.
Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
discover: Fix dead code in udev_handle_cdrom_events()
The check against ddev->mounted to cause an eject action is logically
impossible. Change it so a cdrom_eject() is called properly.
Change the return value to 'true' for any action caused by
DISK_EJECT_REQUEST - no further action is appropriate in this case
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
- Abbreviate several translations of "Disk R/W".
- Do not expand 'DHCP' in pt_BR.
- Remove several extra space characters in French translations.
- Shorten some translations of "Boot Order", "DNS Servers".
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Jeremy Kerr [Wed, 30 Sep 2015 00:38:36 +0000 (08:38 +0800)]
discover/ipmi: Increase IPMI timeout to a reasonable value
We've seen some IPMI timeouts during testing - meaning that an IPMI
bootdev setting will be ignored. This can result in a machine booting
from an incorrect boot device, or missing a 'safe mode' indication, or
incorrectly proceeding past petitboot.
The firmware & kernel has its own timeout & retry mechanism, so we
already have a little error-recovery there; the timeout in petitboot is
to prevent an indefinite block if the kernel interface isn't behaving
correctly.
So, this change bumps the timeout to a value that suits BMCs we've seen
in the field (specifying a 2 second timeout, with one retry).
Jeremy Kerr [Tue, 29 Sep 2015 04:14:16 +0000 (12:14 +0800)]
discover/ipmi: Use advisory locking on ipmi device
The ipmi module is shared between pb-config and pb-discover. During
system initilisation, we're likely to have a few invocations of
pb-config running, as well as pb-discover starting.
We may have multiple potential concurrent accesses to the ipmi device
node. To avoid problems, this change introduces a fcntl lock on the
device node.
The nc-config screen now includes several select options with a FIELD
height greater than one, but config_screen_widget_focus() will only
scroll down enough to see the first line of text.
Update config_screen_widget_focus() to try and make as much of the
focussed widget visible as possible.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Several string translations used in select widgets are longer than the
maximum possible width of the widget. Rather than associating several
FIELDs with a select option, use a fold_text callback to pad out
substrings of the original string such that the ncurses O_WRAP option
properly wraps strings within the field.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
If we have a device-mapper snapshot available we can now guarantee
filesystem recovery will not write back to a read-only mounted disk.
Allow recovery on those devices with the notable exception of XFS which
may fail to mount if the filesystem is the opposite endian of Petitboot.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
ui/ncurses: Improve update handling in nested screens
Several screens in petitboot-nc require an update if a config or sysinfo
update is received. However if those screens exist but are not the
current screen they will incorrectly try to draw to the screen.
Where the currently active screen is a textscreen (eg. a help screen)
the update is delayed until after the screen is exited.
In the particular case of nc-config where the current screen can be an
nc-subset screen, the nc-subset screen is exited immediately so the
update can be performed, since the nc-subset screen depends on the
information in the previous screen.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
ui/ncurses: Change arrangement of boot order buttons
The buttons 'Add Device', 'Clear', and 'Clear & Boot Any' are short
enough to be positioned horizontally, but several localisations have
strings as long as all three buttons combined.
Instead arrange the buttons vertically and allow longer strings to
resize the width of the button to fit the whole string.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Jeremy Kerr [Wed, 2 Sep 2015 09:13:27 +0000 (17:13 +0800)]
pb-plugin: Implement plugin ABI versioning
If a future update to plugins is not compatbile with the installed
plugin infrastructure, we want to abort the scan / install process.
This change adds an ABI version to the script, as well as version (and
minimum-supported version) to the plugin metadata. This means we can
check before plugin execution.
Jeremy Kerr [Wed, 2 Sep 2015 07:41:38 +0000 (15:41 +0800)]
pb-plugin: Only require a fixed plugin extension, instead of full name
Currently, the `pb-plugin scan` code requires a fixed archive name at
the root of distributed media. This means that vendors need to have a
fixed name, and can only ship one plugin per device.
This change shifts the requirement to just a filename extension
(.pb-plugin) instead.
To handle this, we now look for any plugin with a .pb-plugin extension,
and so may find multiple plugins on a device.
Users may want to prioritise USB-attached storage devices differently to
other devices. Detect if a device is USB-attached and add a new device
type to identify it.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Commit 9781a370 ("Handle mblen return code when n is zero.") in glibc
changes the return value for when the number of bytes ('n') is zero.
Add an extra condition to detect if we've reached the end of the buffer.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Jeremy Kerr [Fri, 21 Aug 2015 05:12:19 +0000 (13:12 +0800)]
pb-plugin: Keep chroot persistent, and create wrapper scripts
Rather than having to 'pb-plugin run' multiple times, we want users to
be able to execute multiple plugin binaries with more accessible
command-line statements.
This change reverts to the previous 'install' (rather than 'run')
behaviour, and creates wrapper scripts to call into the chroot.
discover/udev: Additional checks in udev_handle_block_add
- Several filesystem types can appear that we won't be able to mount.
Instead of waiting to fail mounting them in device_handler_discover(),
skip processing them at all.
- Do not create dm-snapshots on top of raid arrays until we have a
reliable way of determining the sector count for a md raid device.
- Turn down the verbosity on skipping dm-devices.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
discover/devmapper: Disable libdm udev sync support
Certain userspace environments that Petitboot is packaged with include
a libdm built with udev sync support which hung with the previous approach.
Relying on udev to properly process dm device creation makes some
assumptions about the flavour of udev available - until that is certain
disable udev sync support and have device-mapper control device creation
itself.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Jeremy Kerr [Fri, 7 Aug 2015 04:14:42 +0000 (12:14 +0800)]
pb-plugin: Update to chroot-style plugins
This change uses a chroot for all plugins, so that plugins have complete
flexibility with their libraries, dependencies and configuration.
We remove the 'install' action, as we simply run the plugin once.
Running involves extracting the archive, setting up a root filesystem,
and running a chroot.
To simplify plugin discovery behaviour, we standardise the plugin file
to be at pb-plugin.conf of attached devices, and read the metadatafile
straight out of the archive.
Create a new Petitboot option 'petitboot,write?' that specifies whether
the system is allowed to mount devices read-write. The option can be
toggled by the user in the nc-config screen.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
discover: Mount snapshots for all eligible disk devices
Device-mapper snapshots are created for all disk devices prior to
being mounted. If explicit writes are made to the snapshot they are
merged back to the disk once write access is released.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
discover: Support creation of device-mapper devices
Add discover/dm-snapshot that allows the creation of device-mapper
snapshots that support merging changes back to disk.
Device-mapper snapshots are a CoW device backed by a ramdisk, mirroring
the contents of a source device. No changes are made to the original
disk unless an explicit merge action is performed. This guarantees
read-only mounting of host disks even when writes could implicitly
occur, eg. when performing recovering a journaled filesystem.
In the event that writing back to the disk is desired, such as when
updating grubenv, the changes made to the snapshot can be merged back to
the source disk.
This patch adds support but does not change functionality.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Jeremy Kerr [Fri, 26 Jun 2015 03:41:46 +0000 (11:41 +0800)]
discover: Fix raw string argument to talloc_asprintf_append
Current builds give a warning:
../discover/platform-powerpc.c: In function ‘update_bootdev_config’:
../discover/platform-powerpc.c:667:4: warning: format not a string
literal and no format arguments [-Wformat-security]
tmp = val = talloc_asprintf_append(val, boot_str);
^
ui/ncurses: Properly reposition cursor after menu update
The currently selected item in the main menu can be set to an item off
the visible portion of the menu after the additional or removal of a
boot option. Update the currently selected item and/or the current view
such that the item remains in the visible area.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Send a short message to the UI to inform the user a device is being
parsed for boot options. This helps slightly in environments when the UI
appears well before devices are available for parsing, giving the user
an indication that work is still being done.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
discover: Clear default-boot-device when invalidated
Update the clear_ipmi_bootdev functions to optionally invalidate the
next- or default-boot-device for their respective machines.
If a client invalidates the ipmi_bootdev in the config, invalidate the
respective bootdev.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Move petitboot to a more familiar 'boot-order' based autoboot system.
The discover server now reads multiple values from the petitboot,bootdev
parameter and adds them in order to config->autoboot_opts. Boot priority
is determined by the options' position in the list.
On the client, nc-config now recognises the new boot order, and allows
the user to add, remove, and reorder the devices in the list.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Changing the visual order of widgets will cause their associated fields to be
out of order relative to the widgetset field array. Rather than manually
resorting the array, use sorted navigation to move according to a field's
visual positon
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
The nc-subset screen is intended to be used as a sub-screen from the
current screen (eg. nc-config) which passes a pointer to a
nc_widget_subset struct. The nc-subset screen allows the user to select
an option from a list of 'inactive' options, before returning control
back to the current screen.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
The new nc_widget_subset is similar to nc_widget_select, but hides added
options until they are made active. This allows the widget to have
multiple options selected and ordered without cluttering the screen.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
discover: Add support for multiple bootdev arguments
To support multiple autoboot options while retaining backwards
compatability, interpret the petitboot,bootdev parameter as
optionally having several space-separated values.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>