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.
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).
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.
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.
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.
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.
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.
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]
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.
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.
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.
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.
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.
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.
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.
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:19:13 +0000 (12:19 +1000)]
waiter: Don't rely on global variables to keep waiter state
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>
Jeremy Kerr [Wed, 10 Apr 2013 02:19:13 +0000 (12:19 +1000)]
lib/types: Create common file for type definitions
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>
Jeremy Kerr [Wed, 6 Mar 2013 05:42:15 +0000 (13:42 +0800)]
test: Add URL parser test infrastructure
This change adds some simple testing infrastrcture to the URL parser.
We use a small C binary (parse-url) to run the url parser on its
argument, and compare the output with an expected datafile.
An initial test is included, to check the behaviour of URLs with
multiple slashes between host and pathname. This test currently fails.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
Jeremy Kerr [Tue, 5 Mar 2013 05:49:15 +0000 (13:49 +0800)]
ui/ncurses: Fix warning from unnecessary if statement
ui/ncurses/nc-menu.c: In function 'pmenu_process_key':
ui/ncurses/nc-menu.c:207:33: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
Geoff Levand [Mon, 19 Mar 2012 05:19:49 +0000 (22:19 -0700)]
Parser test cleanup
Major cleanup of parser tests.
* Change test data directory layout to ease test automation.
* Remove some unneeded files.
* Re-write test wraper script, rename to run-parser-tests.
* Rework for autotools.
Geoff Levand [Sun, 18 Mar 2012 23:20:38 +0000 (16:20 -0700)]
Add new member get_pair to conf parser context
To allow parsers more control over finding paramerter pairs
add a new member get_pair to the parser struct conf_context.
Initialize get_pair=conf_get_pair_equal for existing parsers.
Geoff Levand [Sat, 17 Mar 2012 05:06:03 +0000 (22:06 -0700)]
Use static array for parsers
Change the parser structure array implementation from using an
array in a seperate parsers section to a static array of pointers
in parser.c. Parser priority is now set by the position in the
new parsers array.