summaryrefslogtreecommitdiffstats
path: root/discover
Commit message (Collapse)AuthorAgeFilesLines
* discover/user-event: better event debugging outputJeremy Kerr2013-05-072-10/+22
| | | | | | | | | | | | | | | We don't currently handle conf events very well: user_event remove event: device: /net/eth0 name => (null) image => (null) args => (null) This change prints the event action properly, and prints all event params. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/kboot: Fix boot_option initialisationJeremy Kerr2013-05-061-0/+1
| | | | | | | We're not populating d_opt->option, so are returning invalid boot options from the kboot parser. 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: kexec harderJeremy Kerr2013-05-061-0/+15
| | | | | | | | `kexec -e` will just call shutdown, which we've already tried, so it's likely to fail. Add a further fallback to force a kexec with -e -f options. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/user-event: handle initrdsJeremy Kerr2013-05-061-0/+4
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* parsers: populate resolve_resource membersJeremy Kerr2013-05-062-8/+10
| | | | | | We're only dealing with devpath resources at the moment. 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>
* discover: Send boot status messages during boot()Jeremy Kerr2013-05-063-6/+55
| | | | | | | Now what we have protocol support, send status updates during the boot process. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add discover_server_notify_boot_statusJeremy Kerr2013-05-062-0/+30
| | | | | | Add a function to the server to notify clients of boot status updates. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* udev: Revove use of udev_get_sys_pathGeoff Levand2013-05-051-1/+1
| | | | | | | libudev1 changed the symbol udev_get_sys_path to be private, so remove its use in petitboot. Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Remove empty routine udev_triggerGeoff Levand2013-05-033-7/+0
| | | | | | | | With the switch of the discover server to use the libudev enumeration support the udev_trigger() routine has becone empty and is no longer needed. Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Update udev routines to use libudevGeoff Levand2013-05-032-90/+240
| | | | | | | Support for 'RUN+="socket:' in udev rules files has been removed in udev version 183. Update the discover server to use libudev. Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Rename struct udev to struct pb_udevGeoff Levand2013-05-033-14/+15
| | | | | | | To avoid symbol clashes with libudev, rename struct udev to struct pb_udev. No functional changes. Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Add PXE parserJeremy Kerr2013-04-292-1/+80
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add configuration events & DHCP handlerJeremy Kerr2013-04-295-2/+111
| | | | | | | | | | This change adds a new event type, EVENT_ACTION_CONF. These events supply a new configuration URL that petitiboot should download and parse. With this in place, we can receive DHCP configuration events. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add configuration methodsJeremy Kerr2013-04-297-8/+25
| | | | | | | | | | | | We'd like to be able to download petitboot configurations from other sources (not just local files), but we'll need some way to indicate to the parsers that a chunk of config data is from a specific source. This change adds "configuration methods". At present, we have only one: CONF_METHOD_LOCAL_FILE. For any incoming configuration data, we only run parsers that have registered themselves with that configuration method. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* parsers: dynamically register parsersJeremy Kerr2013-04-296-29/+38
| | | | | | | | | | | | | | | Currently, we require all parsers to be defined in an array in parsers.c. This change removes this requirement, by introducting a register_parser() macro, which adds a constructor to register the parser with the core parser infrastructure. Because each parser no longer resolves an undefined symbol, we need to use a `ld -r` object for libparser, instead of using libtool, which creates a .a (and hence has no parsers included). Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Handle unresolved resourcesJeremy Kerr2013-04-293-6/+62
| | | | | | | | | | | | This change adds an unresolved resource queue - any unresolved resources discovered by parsers are added to this queue rather than being reported to the clients. When we discover a new device, we try to resolve any resources in the queue against the new device. If resolution succeeds, we can send the option to clients. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Finalise boot options during commitJeremy Kerr2013-04-291-0/+35
| | | | | | | | | | | Once the discover context is committed, we need to turn the resources in struct discover_boot_option into strings in struct boot_option, so that the parser can display & edit the boot option. This may cause assertions if any of the boot options contain unresolved resources, we'll fix this in the next patch. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/device-handler: Initialise existing_device variableJeremy Kerr2013-04-291-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Change parsers to emit resources rather than filenamesJeremy Kerr2013-04-2912-360/+154
| | | | | | | | | | | | | | | | | | | | | | | | This change switches the parsers over to populate the resources in discover_boot_option, rather than the string parameters in boot_option. To do this, we need a few things: * Add struct resources to discover_boot_option for the boot_image, initrd and icon data. * Have the parsers populate the resources, rather than the strings. Currently, parsers can all use the devpath resource type. * Add a resolve_resource callback to parsers; this is how the device handler will attempt to resolve resources. * Change load_file to load_url, as we should be only accessing (resolved) resources by URLs. This then allows us to remove the mount map, and associated lookup code, as well as the UUID and label links to devices. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add URL resourcesJeremy Kerr2013-04-292-0/+13
| | | | | | | URL resources are simple: the URLs are already resolved, so not much to do here. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add devpath resourcesJeremy Kerr2013-04-293-0/+138
| | | | | | | | | Add a generic resource type, to handle "dev:path"-style file references. This creates a duplicate of is_prefix_ignorecase, which we'll switch over to later. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add struct resourceJeremy Kerr2013-04-292-0/+24
| | | | | | | | | | | | Introduce a new type, struct resource, for handling resources such as kernels and initrds. This allows the parsers to better describe resources that are required for booting. Firstly, we enforce all resources to be URLs, rather than local paths. Also, resources allow us to describe files devices that have not-yet been hotplugged. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Introduce a container type for boot optionsJeremy Kerr2013-04-297-95/+137
| | | | | | | | | This change introduces a new type, struct discover_boot_option. Like struct discover_device adds discover-specific data to struct device, struct discover_boot_option allows the discover server to store more than just the boot option strings for a boot option. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add device lookup functionsJeremy Kerr2013-04-292-0/+98
| | | | | | | | | | | | Add a few functions to find devices by various attributes: * device_lookup_by_name * device_lookup_by_path * device_lookup_by_uuid * device_lookup_by_label * device_lookup_by_id Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add uuid and label parameters to persistent device dataJeremy Kerr2013-04-292-19/+28
| | | | | | | | | | | | | | | | Rather than depending on the event (which is only available during inital discovery) for UUID and label parameters, this change adds uuid and label members to struct discover_device. This means that the label and UUID are available during the device's lifetime, not just during initial discovery. We can also just pass the device to some of the device handling code, rather than the discover context. Also, fix an issue where we don't use the raw label/uuid (instead of the encoded one) in setup_device_links. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* parsers: change parser.parse to accept a bufferJeremy Kerr2013-04-297-104/+108
| | | | | | | Rather than having each of the parsers do their own open(), read(), etc, use the registered filenames array to find & open parser conf files. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* parsers: Add filenames to struct parserJeremy Kerr2013-04-294-5/+18
| | | | | | | In preparation of moving file handling to the discover core (rather than the parsers), include the conf file names in struct parser. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* device-handler: Don't unmount non-mounted devicesJeremy Kerr2013-04-291-0/+3
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Fix potentially-unused var warningJeremy Kerr2013-04-291-1/+1
| | | | | | | discover/boot.c: In function ‘boot’: discover/boot.c:153:13: error: ‘local_initrd’ may be used uninitialized in this function [-Werror=maybe-uninitialized] Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* event: Make strings constGeoff Levand2013-04-281-3/+3
| | | | | | | The processing of events does not modify the event strings, so change the strings in struct event to const (read-only). Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Add missing udev_destroy callGeoff Levand2013-04-211-0/+1
| | | | Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Separate temporary and permanent device dataJeremy Kerr2013-04-1610-192/+209
| | | | | | | | | | | At present, we keep both permanent (eg links/n_links) and temporary (event) data in struct discover_context. This change makes discover_context a temporary structure, just used during actual device discovery. Once discovery is complete, the permanent data (discover_device) is "committed" to the device handler. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Consolidate user events by device IDJeremy Kerr2013-04-163-15/+18
| | | | | | | | | | Currently, we assume all user events are for a new device. This means that we can never add boot options to an existing device. This change tries to find an existing (matching by ID) device before creating a new one in the user event add path. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* protocol: Separate device add from boot-option add messagesJeremy Kerr2013-04-164-15/+59
| | | | | | | | | | | | | | | | | | | | We want to cater for situations where boot options may be discovered some time after we get notificiation about devices. For instance, discovering boot options from DHCP configuration parameters. In this case, we'll need to notify UIs of boot options appear some time after the device (and/or other boot options on the same device) has appeared. This change adds a new protocol message type, PB_PROTOCOL_ACTION_BOOT_OPTION_ADD. We also rename PB_PROTOCOL_ACTION_ADD to make it clear that it is just for devices. The discover server is updated to send boot option add events at device discover time, but we are now able to decouple this later. We also update the clients to handle the boot option add events separately. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* pb-protocol: Don't allocate in deserialise functionsJeremy Kerr2013-04-161-2/+5
| | | | | | | | | | | | | Curently, the protocol deserialise functions are allocating device and boot_command structures. This (implicitly) makes them responsible for initialisation of these structures too. Rather that making the protocol responsible for initialising the devices and boot commands, this change gives the deserialise functions an argument to an already-instanciated structure. This means that the creation is no longer implied by the deserialise. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Fix boot with initrd errorGeoff Levand2013-04-151-2/+2
| | | | | | Fix typo in boot() routine. Signed-off-by: Geoff Levand <geoff@infradead.org>
* Move --dry-run option to discover serverJeremy Kerr2013-04-153-5/+15
| | | | | | | Now that the server does the booting, we should move the --dry-run argument to the server. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Move boot to discover serverJeremy Kerr2013-04-153-6/+431
| | | | | | | | | | | | | | | | | | | | | This change moves the boot-via-kexec functionality from the UIs to the discover server. On the UI side: rather than run kexec directly, we just send a message to the discover server. Because this is generic discover client functionality, we no longer need the boot callbacks in the twin- and ncurses-specific code. We also remove the kexec and URL-loading code from the UIs, and add it to the discover server code, in paths.c. We expose this to the server though a new function: load_path(void *, const char *, unsigned int *); On the server side, we simply move hook up the boot() function to use the load_file and kexec calls. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Implement device handler boot pathJeremy Kerr2013-04-156-1/+59
| | | | | | | | | | This change adds a funtion, device_handler_boot, which processes the boot command message from the discover server. We add a new file, discover/boot.c (and a corresponding header) with a skeleton for the final kexec code. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: parse boot message from incoming ACTION_BOOT messagesJeremy Kerr2013-04-151-1/+9
| | | | | | | Add a function in the protocol code to deserialise a boot message, and use it to extract a boot_command in the discover server. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover-server: Add reference to server in struct clientJeremy Kerr2013-04-151-0/+2
| | | | | | We'll need to reference the server when handling messages from clients. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow discover server to receive boot messagesJeremy Kerr2013-04-151-2/+24
| | | | | | | | | | | | | | | Currently, the petitboot socket is one way: messages are only sent from server to client. Beause we want the clients to trigger a boot, this change allows the server to receive messages on the petitboot socket. This is just a matter of adding a waiter to the client-specific socket, then handling incoming messages. At present we don't do anything with the messages, but we'll add a handler later. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* waiter: Don't rely on global variables to keep waiter stateJeremy Kerr2013-04-107-14/+26
| | | | | | | | | Rather than defining the set of waiters (and pollfds) in waiter.c, add a struct waitset to contain these. A waitset is created with waitset_create, which is passed to the waiter_* functions. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
* lib/types: Create common file for type definitionsJeremy Kerr2013-04-107-7/+7
| | | | | | | | | | | | The device and boot_option types are defined in pb-protocol.h, but aren't really specific to the procotol. This means a lot of non-messaging-related files are #including the protocol definitions unnecessarily. This change separates the types out into lib/types/types.h. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Remove {U,}MOUNT_BIN definesJeremy Kerr2013-03-051-7/+4
| | | | | | | Use pb_system_apps instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
* Add udevadm to pb_system_appsJeremy Kerr2013-03-051-1/+1
| | | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Use pb_run_cmd rather than calling system()Jeremy Kerr2013-03-051-1/+11
| | | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: remove (unused) duplicate struct mount_mapJeremy Kerr2013-03-051-5/+0
| | | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
OpenPOWER on IntegriCloud