Jeremy Kerr [Mon, 13 May 2013 02:08:47 +0000 (10:08 +0800)]
discover: Allow devices with no device_path
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>
Jeremy Kerr [Mon, 13 May 2013 01:16:00 +0000 (09:16 +0800)]
discover: Always associate resources with a boot option
We should always be tallocing resources to a boot option context;
anything else (for example, the discover context) may have a different
lifetime.
In order to enforce this, we change the void *ctx argument to the
context_create functions to a struct discover_boot_option.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Fri, 10 May 2013 04:01:06 +0000 (12:01 +0800)]
discover: Don't access bytes before the start of empty strings
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Fri, 10 May 2013 02:47:24 +0000 (10:47 +0800)]
discover: Always add a NUL byte to config data
conf_get_pair will read one-byte past the end of the conf buffer, so
always NUL-terminate.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Fri, 10 May 2013 02:16:48 +0000 (10:16 +0800)]
discover/yaboot: Fix boot option state
We're only picking up every second boot option.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Fri, 10 May 2013 01:42:36 +0000 (09:42 +0800)]
discover/udev: use devname (not devpath) for device IDs
devnames are unique, and much shorter.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 8 May 2013 09:01:13 +0000 (17:01 +0800)]
discover/grub2: Add grub2/grub.cfg config file
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 15 May 2013 06:35:01 +0000 (14:35 +0800)]
utils/Makefile: pb-console is dist_
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 7 May 2013 07:01:53 +0000 (15:01 +0800)]
ui/nc: Don't segfault if we can't open log_file
Fallback to logging to /dev/null.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 7 May 2013 06:36:51 +0000 (14:36 +0800)]
ui/nc: Handle cui_opt_data with no boot option more gracefully
We can currently segfault petitboot by escaping from the option editor
(before entering any details), then trying to boot the new, empty
option.
This change adds some sanity checks to prevent a segfault.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 7 May 2013 06:28:11 +0000 (14:28 +0800)]
ui/ncurses: Simplify menu item names
Just use the item name, rather than including boot option details.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 7 May 2013 07:39:53 +0000 (15:39 +0800)]
utils: Add pb-console util
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Mon, 6 May 2013 07:54:23 +0000 (15:54 +0800)]
pb-udhcpc: Look for more boot options
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Mon, 6 May 2013 06:55:36 +0000 (14:55 +0800)]
utils/pb-udhcpc: Use command-line format of pb-event
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Mon, 6 May 2013 06:23:17 +0000 (14:23 +0800)]
pb-event: move send code to a separate function
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Mon, 6 May 2013 02:15:36 +0000 (10:15 +0800)]
utils/pb-event: handle event data on command line
It'd be nice to avoid using printf just for the \0 characters, so allow
parsing events from the command line.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 8 May 2013 13:09:05 +0000 (21:09 +0800)]
discover: handle boot_option->device_id entirely within handler
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>
Jeremy Kerr [Wed, 8 May 2013 12:36:37 +0000 (20:36 +0800)]
discover/udev: Setup event params from udev properties
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 8 May 2013 12:36:14 +0000 (20:36 +0800)]
discover/event: Add event_set_param
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 8 May 2013 12:21:59 +0000 (20:21 +0800)]
discover/udev: Don't print properties of skipped devices
This cleans up the log output a little.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 8 May 2013 05:11:50 +0000 (13:11 +0800)]
discover/grub2: Rework config state
Rather than creating boot options pre-emptively, in two paths, just do
it once when we see the menuentry option.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 8 May 2013 05:04:28 +0000 (13:04 +0800)]
discover: Don't invert option discovery order
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>
Jeremy Kerr [Tue, 7 May 2013 08:48:41 +0000 (16:48 +0800)]
discover: Don't resend all options to all clients
Currently, when a new UI client connects, we send all boot options to
all clients. This results in existing clients getting duplicate add
events.
Instead, we only want to send existing boot options to the new client.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 7 May 2013 02:43:21 +0000 (10:43 +0800)]
discover/event-parser: correctly populate boot option resources
The user event parser should be populating the discover_boot_option's
resources, not the strings in struct boot_option.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 7 May 2013 02:42:44 +0000 (10:42 +0800)]
discover/resource.h: Add forward declarations
We need to define a few structs for the params of resource functions.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 7 May 2013 02:02:23 +0000 (10:02 +0800)]
Makefiles: remove -I$(includedir)
Currently, we include the system include dir in some of our makefiles;
this is causing build problems when cross-compiling, as the system
include dir may not contain files for the host.
The compiler should be searing in the proper system include dir, so just
remove the redundant -I.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 7 May 2013 01:41:23 +0000 (09:41 +0800)]
configure: Remove -Winline
I'm getting the following errors when compiling with --enable-werror:
kboot-parser.c: In function 'kboot_process_pair':
./parser-conf.h:50:21: error: inlining failed in call to 'conf_get_pair_equal':
call is unlikely and code size would grow [-Werror=inline]
kboot-parser.c:65:7: error: called from here [-Werror=inline]
Since this is a header function, the inline isn't there for optimisation
reasons; the warning is just informing us of a code optimisation
decision. Drop -Winline to allow -Werror builds.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Mon, 6 May 2013 09:02:25 +0000 (17:02 +0800)]
discover/user-event: better event debugging output
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>
Jeremy Kerr [Mon, 6 May 2013 03:12:42 +0000 (11:12 +0800)]
discover/kboot: Fix boot_option initialisation
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>
Jeremy Kerr [Thu, 2 May 2013 09:30:55 +0000 (17:30 +0800)]
lib/url: fix no-scheme URL parsing
We were incorrectly dropping the first strlen("file://") characters from
URLs with no scheme:
--- test/urls/data/localpath.test 2013-05-02 17:26:48.
826359036 +0800
+++ /tmp/tmp.gn4JsWLw5o 2013-05-02 17:26:50.
262364613 +0800
@@ -2,6 +2,6 @@
scheme file
host (null)
port (null)
-path /test/path/to/local/file
-dir /test/path/to/local/
+path ath/to/local/file
+dir ath/to/local/
file file
This change fixes the issue by indicating "no scheme found" by a NULL
return from pb_url_find_scheme, and hadling it appropriately. We add a
testcase too.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Thu, 2 May 2013 03:39:43 +0000 (11:39 +0800)]
discover: log unresolved boot options
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>
Jeremy Kerr [Wed, 1 May 2013 08:53:20 +0000 (16:53 +0800)]
discover: kexec harder
`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>
Jeremy Kerr [Wed, 1 May 2013 09:03:08 +0000 (17:03 +0800)]
discover/user-event: handle initrds
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Thu, 2 May 2013 02:23:09 +0000 (10:23 +0800)]
parsers: populate resolve_resource members
We're only dealing with devpath resources at the moment.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Thu, 2 May 2013 02:20:39 +0000 (10:20 +0800)]
discover: detect unresolvable resources
We don't want to call NULL resolve_resource callbacks.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 1 May 2013 02:03:31 +0000 (10:03 +0800)]
cui: Show incoming status messages
Add a callback to handle and display boot status messages from the
discover server.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 1 May 2013 01:56:54 +0000 (09:56 +0800)]
discover: Send boot status messages during boot()
Now what we have protocol support, send status updates during the boot
process.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 1 May 2013 01:29:51 +0000 (09:29 +0800)]
discover: Add discover_server_notify_boot_status
Add a function to the server to notify clients of boot status updates.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 1 May 2013 01:09:39 +0000 (09:09 +0800)]
ui: Receive boot status messages
Add support in the discover client code to handle boot status messages,
and pass them to the UI thorugh a new callback ("update_status") in the
client_ops.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 1 May 2013 01:18:44 +0000 (09:18 +0800)]
protocol: Add boot_status (de-)serialisation functions
Add code to the pb-protocol layer to serialise and deserialise
boot_status messages.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 1 May 2013 00:49:54 +0000 (08:49 +0800)]
lib: Add boot_status type & protocol definitions
Add an initial definition for boot status messages sent to clients
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Mon, 6 May 2013 01:00:50 +0000 (09:00 +0800)]
discover/udev: remove unnecessary udevadm references
Since we interact with libudev now, we no longer need to run udevadm.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Mon, 6 May 2013 00:55:56 +0000 (08:55 +0800)]
test/url: Add uncommitted data files
Add a couple of data files for test that'd I'd ommitted from an earlier
commit.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Geoff Levand [Sun, 5 May 2013 15:18:31 +0000 (08:18 -0700)]
configure: More helpful missing libudev message
Signed-off-by: Geoff Levand <geoff@infradead.org>
Geoff Levand [Sun, 5 May 2013 17:18:08 +0000 (10:18 -0700)]
udev: Revove use of udev_get_sys_path
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>
Geoff Levand [Sun, 28 Apr 2013 19:29:40 +0000 (12:29 -0700)]
discover: Remove unused 99-petitboot.rules file
With the switch of the discover server to use the libudev
monitor support a rules file is no longer needed.
Signed-off-by: Geoff Levand <geoff@infradead.org>
Geoff Levand [Sun, 28 Apr 2013 19:17:58 +0000 (12:17 -0700)]
discover: Remove empty routine udev_trigger
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>
Geoff Levand [Mon, 22 Apr 2013 05:20:14 +0000 (22:20 -0700)]
discover: Update udev routines to use libudev
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>
Geoff Levand [Sun, 21 Apr 2013 18:47:20 +0000 (11:47 -0700)]
discover: Rename struct udev to struct pb_udev
To avoid symbol clashes with libudev, rename struct udev to
struct pb_udev. No functional changes.
Signed-off-by: Geoff Levand <geoff@infradead.org>
Jeremy Kerr [Wed, 1 May 2013 05:11:17 +0000 (13:11 +0800)]
test/lib: Add empty list test
Check that the list iterators work on empty lists too.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Geoff Levand <geoff@infradead.org>
Jeremy Kerr [Wed, 1 May 2013 05:11:17 +0000 (13:11 +0800)]
lib/list: Fix handling of empty lists
The current list_for_each_entry_safe marco SEGVs on empty lists; the
list_entry will give us a NULL tmp on the first iteration.
This change removes the use of list_entry, as we're effectively
by-passing its NULL return semantics with our own.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Geoff Levand <geoff@infradead.org>
Jeremy Kerr [Tue, 19 Mar 2013 07:42:51 +0000 (15:42 +0800)]
discover: Add PXE parser
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 19 Mar 2013 06:24:57 +0000 (14:24 +0800)]
discover: Add configuration events & DHCP handler
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>
Jeremy Kerr [Tue, 19 Mar 2013 06:00:53 +0000 (14:00 +0800)]
discover: Add configuration methods
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>
Jeremy Kerr [Mon, 18 Mar 2013 06:23:23 +0000 (14:23 +0800)]
parsers: dynamically register parsers
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>
Jeremy Kerr [Fri, 15 Mar 2013 08:13:32 +0000 (16:13 +0800)]
discover: Handle unresolved resources
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>
Jeremy Kerr [Fri, 15 Mar 2013 07:33:39 +0000 (15:33 +0800)]
discover: Finalise boot options during commit
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>
Jeremy Kerr [Tue, 19 Mar 2013 07:38:57 +0000 (15:38 +0800)]
discover/device-handler: Initialise existing_device variable
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 16 Apr 2013 08:58:18 +0000 (16:58 +0800)]
discover: Change parsers to emit resources rather than filenames
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>
Jeremy Kerr [Tue, 16 Apr 2013 07:57:43 +0000 (15:57 +0800)]
discover: Add URL resources
URL resources are simple: the URLs are already resolved, so not much to
do here.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 16 Apr 2013 07:54:13 +0000 (15:54 +0800)]
discover: Add devpath resources
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>
Jeremy Kerr [Thu, 14 Mar 2013 07:55:55 +0000 (15:55 +0800)]
discover: Add struct resource
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>
Jeremy Kerr [Thu, 14 Mar 2013 06:18:54 +0000 (14:18 +0800)]
discover: Introduce a container type for boot options
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>
Jeremy Kerr [Thu, 28 Feb 2013 09:16:57 +0000 (17:16 +0800)]
discover: Add device lookup functions
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>
Jeremy Kerr [Thu, 28 Feb 2013 09:05:06 +0000 (17:05 +0800)]
discover: Add uuid and label parameters to persistent device data
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>
Jeremy Kerr [Tue, 12 Mar 2013 08:13:55 +0000 (16:13 +0800)]
parsers: change parser.parse to accept a buffer
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>
Jeremy Kerr [Tue, 12 Mar 2013 07:30:41 +0000 (15:30 +0800)]
parsers: Add filenames to struct parser
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>
Jeremy Kerr [Mon, 18 Mar 2013 08:48:19 +0000 (16:48 +0800)]
lib/url: Add pb_join_url
Add a a function to join a string to a base URL
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 12 Mar 2013 03:35:31 +0000 (11:35 +0800)]
device-handler: Don't unmount non-mounted devices
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Mon, 29 Apr 2013 02:44:53 +0000 (12:44 +1000)]
test/lib: Hook into `make check`
This change hooks the new list tests into 'make check'. To do this, we
need to fix the return code of the list-test program.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 16 Apr 2013 08:07:33 +0000 (16:07 +0800)]
discover: Fix potentially-unused var warning
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>
Geoff Levand [Mon, 22 Apr 2013 00:49:37 +0000 (17:49 -0700)]
event: Make strings const
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>
Geoff Levand [Sun, 28 Apr 2013 18:21:50 +0000 (11:21 -0700)]
test: Rename test/list to test/lib
Having a test/list directory is a little too specific, so rename
the test/list directory to test/lib as a place for any lib tests.
Signed-off-by: Geoff Levand <geoff@infradead.org>
Geoff Levand [Wed, 24 Apr 2013 03:41:07 +0000 (20:41 -0700)]
list: Fix seg fault with list_for_each_entry_safe
Signed-off-by: Geoff Levand <geoff@infradead.org>
Geoff Levand [Wed, 24 Apr 2013 03:18:00 +0000 (20:18 -0700)]
test: Add list test
Signed-off-by: Geoff Levand <geoff@infradead.org>
Geoff Levand [Sun, 21 Apr 2013 15:31:04 +0000 (08:31 -0700)]
discover: Add missing udev_destroy call
Signed-off-by: Geoff Levand <geoff@infradead.org>
Jeremy Kerr [Mon, 11 Mar 2013 09:08:57 +0000 (17:08 +0800)]
discover: Separate temporary and permanent device data
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>
Jeremy Kerr [Tue, 16 Apr 2013 03:39:59 +0000 (11:39 +0800)]
lib/list: Add list_for_each_entry_safe
Add a list iterator that is safe against deletion of the current
element.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Mon, 11 Mar 2013 06:07:36 +0000 (14:07 +0800)]
discover: Consolidate user events by device ID
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>
Jeremy Kerr [Mon, 11 Mar 2013 05:43:48 +0000 (13:43 +0800)]
protocol: Separate device add from boot-option add messages
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>
Jeremy Kerr [Fri, 8 Mar 2013 09:04:21 +0000 (17:04 +0800)]
pb-protocol: Don't allocate in deserialise functions
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>
Geoff Levand [Mon, 15 Apr 2013 20:41:55 +0000 (13:41 -0700)]
ncurses: Fix build warning
Add missing header include. Fixes this warning:
ui/ncurses/nc-cui.c: warning: implicit declaration of function 'pb_protocol_device_cmp'
Signed-off-by: Geoff Levand <geoff@infradead.org>
Geoff Levand [Mon, 15 Apr 2013 19:59:14 +0000 (12:59 -0700)]
discover: Fix boot with initrd error
Fix typo in boot() routine.
Signed-off-by: Geoff Levand <geoff@infradead.org>
Jeremy Kerr [Thu, 7 Mar 2013 02:22:42 +0000 (10:22 +0800)]
Move --dry-run option to discover server
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>
Jeremy Kerr [Wed, 27 Feb 2013 08:45:21 +0000 (16:45 +0800)]
Move boot to discover server
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>
Jeremy Kerr [Wed, 6 Mar 2013 09:14:58 +0000 (17:14 +0800)]
discover: Implement device handler boot path
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>
Jeremy Kerr [Wed, 6 Mar 2013 09:08:05 +0000 (17:08 +0800)]
discover: parse boot message from incoming ACTION_BOOT messages
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>
Jeremy Kerr [Wed, 6 Mar 2013 09:04:48 +0000 (17:04 +0800)]
discover-server: Add reference to server in struct client
We'll need to reference the server when handling messages from clients.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 5 Mar 2013 07:28:14 +0000 (15:28 +0800)]
lib/url: Move URL-handling code to lib
We'll need to use the URL handling code in the server, so move it to the
lib/ directory.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 27 Feb 2013 08:23:56 +0000 (16:23 +0800)]
ui/ncurses: Add discover client to struct cui
.. we'll need it later.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 27 Feb 2013 08:04:23 +0000 (16:04 +0800)]
discover-client: interact directly with waitset
Currently, clients need to mess with the discover client fd directly,
and manually register the waiter.
Instead, this change adds a waitset parameter to
discover_client_register, so that the discover client can register
itself, and call discover_client_process directly. This means no proxy
handlers, and no casts to waiter callbacks.
We can also get rid of discover_client_get_fd.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 27 Feb 2013 03:00:32 +0000 (11:00 +0800)]
discover-client: Add discover_client_boot
This change implements the client side of the server-based boot
interface. We add a funcion, discover_client_boot, which serialises a
boot message, then sends it to the server.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 27 Feb 2013 01:33:34 +0000 (09:33 +0800)]
discover: Allow discover server to receive boot messages
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>
Jeremy Kerr [Wed, 27 Feb 2013 01:09:47 +0000 (09:09 +0800)]
Add boot command structure to petitboot protocol description
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 27 Feb 2013 06:28:55 +0000 (14:28 +0800)]
ui: callback & boot actions: kexec -> boot
find ui/ -type f |
xargs sed -i -e s/kexec_cb/boot_cb/g \
-e s/on_kexec/on_boot/g \
-e s/run_kexec/boot/g
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 27 Feb 2013 06:22:01 +0000 (14:22 +0800)]
ui: pb_kexec_data -> pb_boot_data
find ui/ -type f |
xargs sed -i -e s/pb_kexec_data/pb_boot_data/g \
-e 's/\<kd\>/bd/g'
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 27 Feb 2013 06:15:34 +0000 (14:15 +0800)]
ui/ncurses: ked -> boot-editor
git mv ui/ncurses/nc-ked.c ui/ncurses/nc-boot-editor.c
git mv ui/ncurses/nc-ked.h ui/ncurses/nc-boot-editor.h
find ui/ncurses -type f |
xargs sed -i -e s/nc-ked\./nc-boot-editor./g \
-e s/ked/boot_editor/g
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 10 Apr 2013 02:02:20 +0000 (12:02 +1000)]
pb-udhcpc: Fix generation of TFTP URLs
DHCP boot-file parameters may not contain a preceeding slash. In this
case, the current udhcp script will not form a correct URL.
This change adds the slash unconditionally; in the case that the
pathname already has a preceeding slash, the URL parser will handle this
correctly.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Geoff Levand <geoff@infradead.org>
Jeremy Kerr [Wed, 10 Apr 2013 02:13:35 +0000 (12:13 +1000)]
ui/common: Remove unused artwork
A few of the oxygen icons are no longer used, so remove them from the
artwork tree.
Coincidentally, this fixes and issue with `make dist`, as the
drive-removable-media-usb-pendrive.png file is too long (when used with
an autogenerated git version string) to be tar-ed up.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Geoff Levand <geoff@infradead.org>
Jeremy Kerr [Wed, 10 Apr 2013 02:13:35 +0000 (12:13 +1000)]
test/urls: Fix distcheck breakages
We need a couple of extra automake variables to get `make distcheck`
working.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Geoff Levand <geoff@infradead.org>