summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* ui/ncurses: Make server connect message more clearv1.2.7petitboot-1.2.xSamuel Mendoza-Jonas2016-11-241-3/+5
| | | | | | | | | | The current message mentions a "server" which can give the misleading impression that the UI is waiting for a remote network server. The delay is actually in waiting for the pb-discover process to be ready, so update the message to reflect that. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (cherry picked from commit ea8bd5f424a9b01c71e1694bb5b6ffc13e3da4f5)
* ui/ncurses: Spin child to ensure autoboot cancelled on exitSamuel Mendoza-Jonas2016-11-241-0/+43
| | | | | | | | | | | If the client is not connected to the server instance when exiting, fork and have the child process spin until the server is available and can be told to cancel autoboot. This prevents the scenario of a user exiting the UI and having the server continue to autoboot while they are using the command line. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (cherry picked from commit 1dd51e986202e5e111c1042f148867bd08c2bedc)
* discover/platform-powerpc: Reject bootdevs with empty UUIDsSamuel Mendoza-Jonas2016-11-241-8/+11
| | | | | | | | | | If a "uuid:" label is set in the petitboot,bootdevs or petitboot,bootdev parameters without a matching UUID, the UUID is unintentionally accepted and set to NULL. This can cause a segfault in nc-config when device UUIDs are compared against the autoboot option. Instead treat options like this as malformed. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/pxe-parser: Parse only the first configv1.2.6Samuel Mendoza-Jonas2016-10-111-34/+59
| | | | | | | | | | | | | | | | | | | | Commit 2163af5 "discover/pxe-parser: Retrieve configs asynchronously" added asynchronous loading of remote pxe filenames, but made an unintended change in behaviour to the PXE parser. Previously the parser would try a list of possible filenames, and parse the first one it found. However the above commit spawns an asynchronous job for every filename, and parses any that can be retrieved. It is a common configuration to have a machine-specific config and a 'fallback' default config, and the change means we could erroneously retrieve and parse both configs. Update the PXE parser so that asynchronous jobs are spawned sequentially. That is, spawn a job for the first filename and if not successful spawn another job for the next filename, and so on. Once a remote config is successfully retrieved, parse it and stop. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (cherry picked from commit f64638f5a4f159297a74df9329afc6e73acf6d6b)
* discover/network: Add find_interface_by_uuidv1.2.5Samuel Mendoza-Jonas2016-09-081-21/+40
| | | | | | | | | | | Currently in network_register_device() and network_unregister_device() the appropriate interface is searched for by name. However it is possible in some scenarios for multiple interfaces to have the same name, so instead search by UUID to be sure that the correct interface is being selected. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (cherry picked from commit 82b4c9d7ecbfada62295620a6082caf1b9860ff6)
* discover: Pass UUID to discover_device_create()Samuel Mendoza-Jonas2016-09-086-14/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently discover_device_create() will search for existing discover devices by id to determine if a new device is required. However it is possible under some circumstances for distinct devices to have the same name. This is especially troublesome if the following network events are seen in network_handle_nlmsg(): - New interface, 'foo' with uuid x:x:x:x:x:x -> new discover device created with dev->device->id = 'foo' dev->uuid = x:x:x:x:x:x - New interface, 'foo' with uuid y:y:y:y:y:y -> existing device 'foo' found dev->uuid = y:y:y:y:y:y This can occur if an interface rename event arrives *after* an old name is reused, where temporarily Petitboot will see two distinct network interfaces with the same name. Now the two interfaces point to the same discover device, which can quickly result in a segfault if a 'remove' event occurs for one of the interfaces and the discover device is freed. To generally avoid this a 'uuid' parameter is added to discover_device_create(), which if present allows existing devices to be looked up by UUID rather than just their name. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (cherry picked from commit 1def8f21aecc41ac22652e7b8bd1f5bf7a4dae98)
* utils: Always pass MAC address in pb-udhcpcSamuel Mendoza-Jonas2016-09-081-2/+3
| | | | | | | | | pb-udhcpc currently only passes the interface's MAC address for an 'add' event, however it is useful to know it for any user event concerning a network interface. Pass it to pb-event in all cases. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (cherry picked from commit 4da0965a861bedd4332217c131abf399bc2b5a18)
* discover: Deprecate 'conf' user eventSamuel Mendoza-Jonas2016-09-085-61/+1
| | | | | | | | | | | | | The 'conf' user event is functionally very similar to the 'url' event, in that both events result in downloading a specified configuration file and passing it to iterate_parsers(). The 'url' event additionally allows downloading files from a directory path and is also accessed by the UI via pb-protocol, so remove the 'conf' event and associated functions in favour of 'url' and device_handler_process_url(). Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (cherry picked from commit e2c92865481a5fb043c03c0cde625a96ca608699)
* discover/event: Ensure event struct exists for async callersv1.2.4Samuel Mendoza-Jonas2016-09-022-3/+7
| | | | | | | | | | | | | | | | | When handling an event, user_event_handle_message() creates an event struct with relevant parameters. Once user_event_handle_message() is finished it frees the struct. However in the case of a dhcp or add_url event, asynchronous jobs may be spawned that will later reference the event struct. In particular this becomes a problem when pxe_process_pair() handles an IPAPPEND name/value pair and tries to access event->device. In the case of dhcp and add_url events, we avoid this by changing the event struct's talloc parent to the discover_context struct which persists until all async pxe jobs have completed. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (cherry picked from commit a50d5fe279db71cf85fabeb675c99b167ec63dcb)
* discover/network: Ignore tun devicesv1.2.3Samuel Mendoza-Jonas2016-08-231-0/+3
| | | | | | | | In some environments a default 'tun' device is created. Petitboot doesn't use this and it clutters up the list of network devices, so ignore it if it is encountered. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Treat left/right arrow keys properlySamuel Mendoza-Jonas2016-08-231-2/+6
| | | | | | | | | It turns out ncurses helpfully provides REQ_LEFT_FIELD and REQ_RIGHT_FIELD to navigate between visually horizontal fields. Update widgetset_process_key() to use these for KEY_LEFT and KEY_RIGHT respectively. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/boot: Always pass --append to kexecSamuel Mendoza-Jonas2016-08-191-6/+4
| | | | | | | | | If we don't specify command line arguments for the next kernel, kexec will add the contents of /chosen/bootargs if present. This is unintended and not obvious to the user, so explicitly add append="" to the kexec arguments if we have none to add instead. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* hooks/set-stdout: move hook to after automatic stdout settingsv1.2.2Jeremy Kerr2016-08-082-2/+2
| | | | | | | | | | If a console is defined in NVRAM, we want it to take precedence over anything that 30-add-offb calculates automatically. This change shifts the 20-set-stdout script to later in the hook processing, so that it will override any automatic settings. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* hooks/add-offb: Add leading slash to HVC node pathsJeremy Kerr2016-08-081-1/+1
| | | | | | | | | | We need an absolute path to the serial@N device. It looks like some kernels aren't reading the current path correctly, leading to no console output. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Acked-by: Stewart Smith <stewart@linux.vnet.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* README.md: Add README fileSamuel Mendoza-Jonas2016-08-081-0/+22
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Add 'sync' user eventSamuel Mendoza-Jonas2016-08-086-1/+63
| | | | | | | | | | | | | | | | | | | | Add a user event named 'sync' that causes the discover server to merge the devicemapper snapshots of mounted devices. This is particularly useful as a debug aid (for example, when copying logs to a USB device), as the server will otherwise only sync changes to mounted devices in response to parser actions. The command can be called as pb-event sync@device to sync a particular device, or as pb-event sync@all to sync all devices with snapshots. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Call widget process_key handlers firstSamuel Mendoza-Jonas2016-07-211-5/+15
| | | | | | | | | | | | | | | Adding KEY_LEFT and KEY_RIGHT brought to light the problem that widgetset_process_keys() may handle keystrokes that would have also been handled by a widget's process_keys function. In particular the cursor in a textbox widget could no longer be moved with the left/right keys. This updates widgetset_process_keys() to call the focussed widget's process_keys function before handling the key in any other way. All of the widget process_keys functions correctly return false if the key is not relevant to the widget except for textbox_process_key() which is updated to ignore the main navigational keys. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/device-handler: Remove default option if device removedv1.2.1Samuel Mendoza-Jonas2016-07-141-0/+9
| | | | | | | If one of a device's boot options is the current default boot option, make sure the default boot is cancelled before the device is removed. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/network: Mark interfaces configured once configuredSamuel Mendoza-Jonas2016-07-141-1/+6
| | | | | | | | | | In some cases additional netlink messages can be received for an already-configured interface without any relevant changes. This can result in multiple DHCP requests for the same interface. Once an interface has been configured mark it as IFSTATE_CONFIGURED to avoid configuring it again. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/platform-powerpc: Use IPMI on BMC-based machines onlySamuel Mendoza-Jonas2016-07-141-3/+5
| | | | | | | | With a kernel that has IPMI support Petitboot will try to use direct IPMI, however on FSP machines this is not fully functional. Use direct IPMI only on BMC-based machines, and use sysparams otherwise. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/device-handler: Ignore options without kernelSamuel Mendoza-Jonas2016-07-141-0/+8
| | | | | | | All boot options must at least have a boot image; ignore any options that do not before trying to resolve them. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Properly set focus when updating subsetSamuel Mendoza-Jonas2016-07-132-2/+7
| | | | | | | | | | | When a subset widget is made empty focus is switched to the first visible field. It should actually be set to the first visible and active field, otherwise we can try to focus an un-selectable label. While we're here, also properly set the visibility for the autoboot enable/disable widget. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Update keybindings for subsetsSamuel Mendoza-Jonas2016-07-132-21/+8
| | | | | | | | | | We now use KEY_LEFT and KEY_RIGHT for general navigation; update subset_process_key() to use the following keybindings: Reorder items up/down: Minus/Plus keys (-/+) Delete item: Delete or Backspace Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: define KEY_DC (delete key)Samuel Mendoza-Jonas2016-07-121-0/+1
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* utils/hooks: Set linux,stdout-path for primary consolev1.2.0Samuel Mendoza-Jonas2016-06-291-0/+120
| | | | | | | | If the boot_tty environment variable is set, determine which device path to set in the linux,stdout-path property, which will instruct the next kernel to use it as the primary console. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: List available consoles in nc-configSamuel Mendoza-Jonas2016-06-291-3/+53
| | | | | | | | | Include a list of available consoles as specified by the discover server in nc-config from which the user can select a default. The selected console specifies the which console to be set as the primary console when a kernel is kexec'd. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/common: Set current console on boot commandSamuel Mendoza-Jonas2016-06-291-0/+1
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/boot: Set boot_tty variable before kexecSamuel Mendoza-Jonas2016-06-291-0/+13
| | | | | | | | If boot_tty is set or a boot command is sent manually from a certain console, set the boot_tty environment variable to be used by a boot hook before kexec. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Add petitboot,tty and track available consolesSamuel Mendoza-Jonas2016-06-292-0/+53
| | | | | | | | | | Add the NVRAM parameter petitboot,tty which sets the default console to use when booting a kernel. In load_config() construct a list of available consoles depending on the current platform. A future patch depending on firmware changes will allow this list to be constructed dynamically. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib: Add support for tracking boot consolesSamuel Mendoza-Jonas2016-06-283-2/+49
| | | | | | | | | | Add tty_list and boot_tty to the config struct to keep track of available console interfaces and the default console to set as primary respectively. Also add a tty field to the boot_command struct so that the current console can be sent to the discover server during a manual boot command. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/pxe-parser: Retrieve configs asynchronouslySamuel Mendoza-Jonas2016-06-286-45/+130
| | | | | | | | | | | | | | | | | | Depending on the configuration of the DHCP server and the network, tftp requests made by the pxe parser can timeout. The pxe parser makes these requests synchronously so several timeouts can block the server completely for several minutes, leaving the server unresponsive to UI requests. Rework the pxe parser such that it handles the result of each tftp request in a callback, which can complete after iterate_parsers() has returned. Each callback is allocated its own conf_context which takes a talloc reference on the discover_context so that each callback can commit new boot options after the initial iterate loop has completed. This also means talloc_unlink must be used instead by the original parent of the discover_context. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Update tests to support changes to pxe_parserSamuel Mendoza-Jonas2016-06-283-45/+139
| | | | | | | | | | | Substitute load_url_async() when running tests to support direct callers of load_url_async() who will expect to read a file in a callback. Stub out device_handler_discover_context_commit() since it will remove discover_options from the given discover_context, but the tests will check the discover_context to count boot_options. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/device-handler: Make boot_status() publicSamuel Mendoza-Jonas2016-06-282-10/+14
| | | | | | | | | Rename boot_status() to device_handler_boot_status() and make it accessible by files that include device-handler.h. This enables the boot status to be updated from additional callers, in particular within parser functions. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib/pb-config: Properly initialise interface_configSamuel Mendoza-Jonas2016-06-271-1/+4
| | | | | | | | | | | The addition of the "url" field is not reflected in config_copy_interface() which leaves the pointer uninitialised, causing a potential segfault later on. Copy the field from the source config, and use talloc_zero() for the interface_config struct to prevent this more generally. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/platform-powerpc: Return bootdev error correctlyv1.1.1Samuel Mendoza-Jonas2016-06-161-2/+2
| | | | | | | | | | | | | In one case get_ipmi_bootdev_ipmi() can return 0 on an error, which leads to bootdev being treated as a valid bootdev despite being uninitialised. If the planets line up correctly and bootdev is less than or equal to IPMI_BOOTDEV_SETUP, Petitboot will incorrectly apply an IPMI override. Update the error return value in get_ipmi_bootdev_ipmi(), and properly initialise bootdev. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Remember to abort boot on server connectSamuel Mendoza-Jonas2016-05-261-4/+14
| | | | | | | | | The UI can now come up before the server, but in order for a key press to cancel autoboot a key has to be pressed once the server connects. Instead remember to cancel autoboot if a key has been pressed at any point. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* utils: Add diagnostic scriptv1.1.0Samuel Mendoza-Jonas2016-05-243-1/+78
| | | | | | | | | | | | | | | | Add a simple script to gather up useful information in the unlikely event a user runs into trouble. Usage: pb-sos [-v] [-f file] [-d user@host:/path] Options -v verbose output -f file Supply filename for tar archive (default pb-sos.tar) -d host Supply user, hostname, and path to transfer archive to a remote host Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Extend the "add url" function to allow file:// URLsSamuel Mendoza-Jonas2016-05-242-2/+14
| | | | | | | | | | | | | | This allows URLs of the form file:///path/to/local/file.conf to be used in nc-add-url, in order to access configuration files relative to the root directory. This is primarily a debugging tool aimed at developers rather than an expected use case. The DEVICE_TYPE_ANY enum is used in this case to represent that a resulting boot option is not associated with any device in the traditional sense, and in the UI is represented as a "Custom Local Option". Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Interpret left/right keys as up/downSamuel Mendoza-Jonas2016-05-241-0/+2
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* pb-discover: add dtb support for PXE configOliver O'Halloran2016-05-242-0/+7
| | | | | | | | | | | | | | Currently there is no way to manually specify a DTB file when with a PXE network boot configuration file. This makes it difficult when you need to work with or emulate a special snowflake machines with special snowflake hardware. Some ARM systems provide this feature with the "fdt" option so this patch adds support for using the ftd or dtb configuration options to the PXE config parser. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib/flash: fix resource leak in flash_setup_buffer() error pathsAndrew Donnellan2016-05-061-5/+8
| | | | | | | | | | | Some error paths in flash_setup_buffer() fail to free the flash_info struct or close the open ffs before they return. Change them to goto the cleanup code at the end. Separate the cleanup code into separate labels depending on whether we need to call ffs_close(), arch_flash_close() and talloc_free(). Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* pb-event: Add 'boot' user eventSamuel Mendoza-Jonas2016-05-064-1/+27
| | | | | | | | | | | Add a user event to send a boot command to the discover server. The format of the boot command is similar to the add command, eg: pb-event boot@eth0 image="http://host/image" initrd="http://host/initrd" and also recognises "id", "dtb", and "args" arguments. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* pb-console: Reduce kernel log output before starting UISamuel Mendoza-Jonas2016-05-061-0/+4
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Start UI before connected to serverSamuel Mendoza-Jonas2016-05-063-11/+59
| | | | | | | | | | | | | | | | If petitboot-nc starts before the discover server it will try to connect for a short while waiting for the server to appear. However in some scenarios the server can take longer than expected to come up, for example if the kernel is compiled with modules and the system has many disks, and the process will timeout and exit before the server is ready. The UI does not appear during this time so it can appear as if Petitboot failed to start at all. Change the default behaviour to start the UI first, and then wait for the server to appear. The UI will not timeout in this mode. The "--timeout" option is added to start with the old behaviour. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui: Fix typo: 'deamon' -> 'daemon'Samuel Mendoza-Jonas2016-05-064-10/+10
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/platform-powerpc: Zero-pad BMC aux-versionv1.0.1Samuel Mendoza-Jonas2016-04-261-1/+1
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub2: Do not set $0 in functionsAlan Dunn2016-04-261-1/+1
| | | | | | | | | | | | | | | GRUB2 does not set $0 in functions, so don't set it in our GRUB2 script parser. (As it doesn't have a value in GRUB2 scripts, probably no GRUB2 script depends on the value of $0.) Additionally, dash and bash set environment variable 0 to the name of the script (even in functions), so the current behavior of $0 doesn't really match shell scripts either. Tested: Existing tests pass. Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Allow evaluation of arbitrarily-positioned arguments in GRUB2 parserAlan Dunn2016-04-262-4/+5
| | | | | | | | | | | | | | | GRUB2 allows essentially arbitrary numbers of positional arguments, so ensure that they can be evaluated within scripts. GRUB2 also appears to support arbitrary numbers of leading 0's in positional parameters (i.e., $01 should evalute the same as $1), but this doesn't seem like a particularly important case to support. Tested: Modified test-grub2-pos-param to cover higher-numbered positional arguments. Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Fix sparse warningsAndrew Donnellan2016-04-204-5/+5
| | | | | | | | Fix some sparse warnings by using NULL instead of 0 and static-ifying a variable not used outside its file. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Increase timeout when waiting for pb-discoverSamuel Mendoza-Jonas2016-04-201-1/+1
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
OpenPOWER on IntegriCloud