Jeremy Kerr [Wed, 8 May 2013 08:39:58 +0000 (16:39 +0800)]
discover/resource: Provide resolve_resource_against_device
Any other implementation of resources will need to resolve againsst
particular devices, so make resolve_devpath_against_device
publically-accessible, and rename to not be devpath-specific.
Jeremy Kerr [Wed, 15 May 2013 08:41:56 +0000 (16:41 +0800)]
test/parser: Add test device hotplug functions
Add a function, test_hotplug_device(), to simulate the addition of
devices during tests. This should make it possible to observe boot
options' resources changing from unresolved state to resolved.
Jeremy Kerr [Wed, 15 May 2013 05:11:43 +0000 (13:11 +0800)]
test/parser: Allow raw config data in test .c files
Add a little post-processing script (extract-config.awk) to allow us to
put the config data directly into the test .c files, without having to
quote the C string.
Jeremy Kerr [Wed, 15 May 2013 07:28:57 +0000 (15:28 +0800)]
test: Replace parser tests with empty framework
This change is a major rework of the parser tests. Currently, the parser
tests just run the parsers on each subdir of data/, but we don't
actually check the results.
Rather than just running parsers and expecting a certain fixed output,
the new tests are arbitraty (short!) C programs. This allows us to set
up the device configuration / discover context etc in whatever manner
necessary, and check that the boot options that the parsers emit are
correct.
This change removes all of the old tests, and adds a new "null" test.
Actual tests will be added in subsequent changes.
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.
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.
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.
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.
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.
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.
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.