summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
Commit message (Collapse)AuthorAgeFilesLines
* protocol: expose discovery reinit over client/server protocolJeremy Kerr2014-04-021-1/+1
| | | | | | | 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>
* discover: add reinit pathJeremy Kerr2014-04-021-0/+41
| | | | | | | | | | | | | 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>
* discover: move device sources to the device handlerJeremy Kerr2014-04-021-0/+42
| | | | | | | | | | | | | | | | | | | | 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>
* 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-141-1/+6
| | | | | | | | | | | | | | | | | | | | | | | 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: 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: 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-301-5/+13
| | | | | | | | | | | | 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>
* pb-config: Move config storage modules to "platform" modules in discover codeJeremy Kerr2014-01-301-1/+1
| | | | | | | | | | | | | | | | | | 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/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>
* discover: populate sysinfo with block devicesJeremy Kerr2013-11-221-0/+5
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Handle incoming configuration messagesJeremy Kerr2013-11-131-1/+7
| | | | | | | When the client sends us a PB_PROTOCOL_ACTION_CONFIG message, we want to update the current config. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/types: use unsigned int for interface, dns and prio countsJeremy Kerr2013-11-131-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Change parsers to explicitly request configuration filesNeelesh Gupta2013-11-061-8/+26
| | | | | | | | | | | | | | | | | | | Add a new function parser_request_url() to read the data from configuration files present remotely. We deprecate iterate_parser_files() and download_config() functions along with the 'filenames' and 'method' members of the 'parser' structure so that individual parsers would now require to request the configuration files data from the parser code and doesn't necessarily export the list of configuration files. Add the support to handle incoming DHCP event, done by passing all the relevant environment variables of the udhcpc to the discover code. Also, update the pxe parser code to populate the list of configuration file names as per PXELINUX convention of fallback names using mac and ip addresses of the booting machine. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allocate contexts with talloc_zeroJeremy Kerr2013-11-061-3/+1
| | | | | | Ensure all pointers from the context are NULL. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* logging: Clean up debug logsJeremy Kerr2013-11-011-3/+3
| | | | | | | We have quite a few pb_logs which should be pb_debug. This change moves developer-specific info to pb_debug. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow an in-progress boot to be cancelledJeremy Kerr2013-10-151-3/+20
| | | | | | | | | Currently, once the boot() function is called, the boot process will ignore any cancellations. This change allows boot() to be cancelled, via boot_cancel(). Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow device_handler_boot with no optionJeremy Kerr2013-10-101-2/+3
| | | | | | Only call find_boot_option_by_id if we have an ID. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/device-handler: Fix use-after-free when unmountingJeremy Kerr2013-10-091-2/+3
| | | | | | We need to do the rmdir after clearing mount_path. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add device_{request,release}_writeJeremy Kerr2013-10-011-3/+53
| | | | | | | | Add a pair of functions to the parser API to allow write access to the underlying device. We'll use this in the GRUB2 parser to implement environment persistence. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add test_data member to struct discover_contextJeremy Kerr2013-10-011-0/+1
| | | | | | | | We have parsers passing discover_contexts around, which we want to hook into the test framework. Add a void * member, which the test code can use to reference the test. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't continue discovery if mount failsJeremy Kerr2013-10-011-1/+5
| | | | | | | Check the return value from mount_device and abort the discover on failure. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow for already-mounted devicesJeremy Kerr2013-10-011-8/+81
| | | | | | | | | | | When we start the discover server, we may find that devices are already mounted. In this case, mount_device will fail, and we'll abort the parse. This change uses /proc/self/mounts to check if new devices are already mounted, and uses the existing mount point. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Check for devices with duplicate serial propertiesJeremy Kerr2013-09-241-0/+13
| | | | | | | | | If we have multipath devices present in the system, we'll end up with duplicate mounts, parse results and boot options. This change adds a check to see if we've encountered a device with this serial number previously. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: clear default_timeout waiter on timeoutJeremy Kerr2013-09-231-0/+2
| | | | | | We don't want cancel_default to try to remove an already-removed waiter. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't register multiple boot_timeout waitersJeremy Kerr2013-09-231-2/+8
| | | | | | | Rather than adding another timeout waiter, just override handler->default_boot_option and extend the timeout a little. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Implement device prioritiesJeremy Kerr2013-09-191-4/+37
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Remove unnecessary event passingJeremy Kerr2013-09-191-328/+195
| | | | | | | | | | | | | | | Currently, we pass "events" between the udev, user-event and device-handler layers. These events all get sent through device_handler_event, then de-multiplexed to an appropriate handler, depending on their source. Instead, just export relevant device_handler functions, and have the (old) event sources call these functions directly. This also means we can include a lot more of the device hander code in the parser tests. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Consolidate device path, name and ID.Jeremy Kerr2013-09-191-28/+7
| | | | | | | | | | | | This change cleans up our usage of device path, names and IDs. Device ID is the kernel name for the device. We also expose this through lookup_by_name. Device path is the path to the dev node (ie, always starts with /dev/), and is only used for mounting. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: populate udev device typesJeremy Kerr2013-09-181-0/+22
| | | | | | Now that we have device types, populate from the udev info. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-config: Add autoboot timeout to configuration varsJeremy Kerr2013-09-181-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: replace pb_run_cmdJeremy Kerr2013-08-191-38/+14
| | | | | | | This change replaces the pb_run_cmd() function with proper usage of the process API. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Log autoboot timeoutGeoff Levand2013-07-231-3/+5
| | | | Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Rename default_enabledGeoff Levand2013-07-231-4/+4
| | | | | | | Rename default_enabled to autoboot_enabled for consistency with pb-config. Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover/device-handler: hook up autoboot_enabled config varJeremy Kerr2013-07-021-1/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Add initial dtb supportGeoff Levand2013-06-241-0/+5
| | | | | | | Updates & fixes by Jeremy Kerr <jk@ozlabs.org>. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add logging for default boot option behaviourJeremy Kerr2013-06-241-0/+6
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add "cancel default boot" messagesJeremy Kerr2013-06-241-0/+29
| | | | | | | Allow the default boot process to be cancelled, via a message with action PB_PROTOCOL_ACTION_CANCEL_DEFAULT. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add countdown before default bootJeremy Kerr2013-06-241-3/+31
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: implement default bootingJeremy Kerr2013-06-241-11/+46
| | | | | | | When we see a boot option with is_default set, store it in the handler and register a timeout waiter. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Send options to client in orderGeoff Levand2013-05-211-2/+2
| | | | | | | | Send the boot options to the client in the order discovered. This change is in follow up to inverting the order that the server saves the options internally. Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: log cleanupJeremy Kerr2013-05-161-4/+18
| | | | | | | Remove some of the more noisy log messages, and add some information pertinent to device resolution events. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Make device handler a little more testableJeremy Kerr2013-05-151-280/+307
| | | | | | | | | | | This change moves some of the device-handler code into an #ifdef-ed section, so we can easily drop the stuff that's not required for testing. Although the change is quite large, most of it is moving entire functions around. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow devices with no device_pathJeremy Kerr2013-05-151-1/+4
| | | | | | | | Devices that have been added via the user path may not have a device path. In this case, don't segfault in device_match_path, and break out of mount_device early. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: handle boot_option->device_id entirely within handlerJeremy Kerr2013-05-091-0/+3
| | | | | | | No need for parsers to populate (or forget to populate, in the case of most parsers) opt->device_id, as we should do it on finalise. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't invert option discovery orderJeremy Kerr2013-05-081-1/+1
| | | | | | | | Keep options in the order that we discovered them in; this makes testing a little easier, as the options appear in the list in the same order as the config file. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: log unresolved boot optionsJeremy Kerr2013-05-061-0/+3
| | | | | | | These are a bit of a special-case ("why isn't my boot option appearing?"), so add a log message. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: detect unresolvable resourcesJeremy Kerr2013-05-061-2/+11
| | | | | | We don't want to call NULL resolve_resource callbacks. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud