summaryrefslogtreecommitdiffstats
path: root/discover
Commit message (Collapse)AuthorAgeFilesLines
* udev: use pb_log for device SKIP messagesJeremy Kerr2014-03-141-5/+5
| | | | | | | 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>
* discover: Call mount syscall directlyJeremy Kerr2014-03-141-14/+17
| | | | | | | | | | | 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>
* discover: Use ID_FS_TYPE property for filesystem type detectionJeremy Kerr2014-03-142-1/+12
| | | | | | | | | | | | | | | | | | | | | | | 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>
* discover/powerpc: Invalidate next bootdev after readingJeremy Kerr2014-03-141-3/+46
| | | | | | | The next-bootdev sysparam should only apply for the next boot, so invalidate it after reading. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/powerpc: Fix sysparams base pathJeremy Kerr2014-03-141-1/+1
| | | | | | | We are appending the sysparam filename onto sysparams_dir, so we need a trailing slash. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add debug output to sysparams parsingJeremy Kerr2014-03-141-2/+10
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Include boot priorities in configuration dumpJeremy Kerr2014-03-141-0/+26
| | | | | | | 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>
* discover/udev: Register udev monitor before enumerating devicesJeremy Kerr2014-03-071-20/+47
| | | | | | | | | | | | | | | | 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>
* discover: Print error message on mount failureJeremy Kerr2014-03-071-0/+3
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: don't retry mount without ro optionJeremy Kerr2014-03-071-11/+0
| | | | | | | | | | 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>
* discover: fix return value for discover_device_get_paramJeremy Kerr2014-03-061-1/+1
| | | | | | We're incorrectly returning the name, we need the value. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/udev: Separate block-specific udev discoveryJeremy Kerr2014-03-051-14/+33
| | | | | | | | | | 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>
* discover/pxe: pxe parser should only treat "::" paths as absoluteJeremy Kerr2014-02-271-3/+41
| | | | | | | | | | 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>
* discover/pxe: Fix prefix autodetection when bootfile is in the root dirJeremy Kerr2014-02-271-2/+3
| | | | | | | | | | | | | | | | | | | | | 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>
* discover/pxe: Add pxelinux.cfg/ directory to autodiscovered pxe pathsJeremy Kerr2014-02-271-9/+13
| | | | | | | | | | 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>
* discover/network: Fix incorrect static DNS servers in resolv.confJeremy Kerr2014-02-251-1/+1
| | | | | | | | | | | | | | | | 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>
* platforms/powerpc: Add support for OPAL sysparamsJeremy Kerr2014-01-301-0/+102
| | | | | | | | | 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>
* discover: Add DEVICE_TYPE_ANY for matching any deviceJeremy Kerr2014-01-301-1/+2
| | | | | | | | | | 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>
* discover: Make boot_priorities more flexibleJeremy Kerr2014-01-302-6/+15
| | | | | | | | | | | | 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>
* discover/network: Use platform definition for DHCP architecture IDJeremy Kerr2014-01-304-2/+18
| | | | | | | Allow a platform to specify a DHCP architecture ID, as this is platform-specific. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* platforms/powerpc: Check for a powerpc platform in the probe functionJeremy Kerr2014-01-301-0/+15
| | | | | | | | | | 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>
* pb-config: Move config storage modules to "platform" modules in discover codeJeremy Kerr2014-01-308-5/+753
| | | | | | | | | | | | | | | | | | 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>
* discover/grub2: Add support for for-loopsJeremy Kerr2014-01-303-0/+55
| | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Perform word-expansion non-destructivelyJeremy Kerr2014-01-301-99/+83
| | | | | | | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add support for checking directories in parser APIJeremy Kerr2014-01-303-0/+35
| | | | | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: skip menuentries that don't define a boot optionJeremy Kerr2014-01-301-0/+3
| | | | | | | | | | menuentries may perform arbitrary commands; we only want ones that define a boot option. This change doesn't add a boot option if we haven't seen at least a boot image defined in the menuentry. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub: Add feature variable for --id support.Jeremy Kerr2014-01-301-0/+3
| | | | | | | Since we support --id arguments on menuentries, add the corresponding feature variable. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Use script_env_set when initialising the environmentJeremy Kerr2014-01-301-6/+2
| | | | | | | | | | No need to duplicate the environment-adding code in init_env, as we can just use script_env_set. Since script_env_set does its own talloc, we don't need to talloc our strings here either. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Use lowercase hex chars for MAC-address-based conf requestsJeremy Kerr2014-01-221-1/+1
| | | | | | | The de-facto PXELINUX standard specifies lowercase characters for the MAC addresses, so change our reuqests to suit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: Add helper for check process clean exitJeremy Kerr2014-01-211-2/+2
| | | | | | | We have a few incorrect checks for the exit status of a process; this change adds a helper with the correct WIFEXITED && WEXITSTATUS==0 logic. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/paths: Check process exit status when loading URLsJeremy Kerr2014-01-211-1/+4
| | | | | | | | | | 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. This fix adds a check to the synchronous load. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* utils/pb-udhcpc: Unify references to DHCP bootfile parameterJeremy Kerr2014-01-211-2/+2
| | | | | | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Send DHCP client architecture typeJeremy Kerr2014-01-171-0/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Support DHCP "pathprefix" configuration optionJeremy Kerr2014-01-172-36/+58
| | | | | | | | | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't rely on ctx->conf_url side-effect in user_event_parse_conf_urlJeremy Kerr2014-01-173-5/+11
| | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub: Use --id values for default option detectionBen Stoltz2014-01-171-7/+24
| | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Bring down configured interfaces on discover server exit.Jeremy Kerr2014-01-172-1/+7
| | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: we need stderr for the BusyBox TFTP type checkJeremy Kerr2014-01-141-0/+1
| | | | | | | Busybox tftp doesn't support -V, so prints an error to stderr. We'll only see the Busybox identifier if we capture stderr too. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/yaboot: Remove known_names listJeremy Kerr2014-01-141-26/+2
| | | | | | | | | | | The known_names list only duplicates the arg matching we do in the body of the parser, and so introduces a problem when the array becomes out of sync. We drop the priority of the "unknown name" messages to pb_debug, as this isn't really imporant unless we're debugging. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/yaboot: Clear globals_done when we see an image definitionJeremy Kerr2014-01-141-3/+2
| | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/udev: Set device type for optical media correctlyJeremy Kerr2014-01-131-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* configure: Use AC_GNU_SOURCEJeremy Kerr2013-12-1810-10/+24
| | | | | | | Rather than #defining _GNU_SOURCE in our .c files, we can define this from config.h instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* sysinfo: Add interface link status to sysinfo dataJeremy Kerr2013-12-183-13/+29
| | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/yaboot: Fix assertion failure on empty yaboot filesJeremy Kerr2013-12-101-1/+2
| | | | | | | | | | yaboot configuration files with no option will cause an assertion failure (or segfault), as we unconditionally call yaboot_finish(). Check for the presence of an option in yaboot_finish() instead of asserting. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/boot: Copy local paths before running boot hooksJeremy Kerr2013-12-051-13/+22
| | | | | | | | | | | We're seeing a crash when boot hooks are specifying new resources, as boot_hook_update_param will write to a NULL struct load_url_result. Instead of writing the updated values to the struct, copy the local parts of the result to a separate string, which the boot hooks are free to update. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/boot: Fix condition for updating boot paramsJeremy Kerr2013-12-051-5/+3
| | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/udev: Use UUIDs for multipath checkJeremy Kerr2013-12-051-9/+14
| | | | | | Partitions will share a serial number. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Fixes for bison 3.xJeremy Kerr2013-12-032-7/+7
| | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Fix CDROM handlingJeremy Kerr2013-12-024-1/+172
| | | | | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/device-handler: Ensure we free unresolved boot options on removeJeremy Kerr2013-12-021-0/+11
| | | | | | | | | | When we remove a device, some options may still be unresolved, and so won't be deallocated through freeing the device. This chagne explicitly removes & frees any currently-unresolved options for this device. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud