Jeremy Kerr [Fri, 17 May 2013 01:38:07 +0000 (09:38 +0800)]
lib/waiter: Ensure waiters are consistent during waiter_poll
We have a bug at the moment: if the waitset's->waiters array is updated
duing waiter_poll() (eg, a client connection is closed, and the client's
callback performs a waiter_remove()), then we may invoke callbacks for
incorrect waiters.
This change uses a consistent waiters array duing execution of
waiter_poll, so that any pollfds returned from poll() will result in
correct callback invocations.
This assumes that a waiter will only ever remove *itself* from the
waitset; otherwise, we may call a free()ed waiter.
Jeremy Kerr [Mon, 20 May 2013 02:28:23 +0000 (10:28 +0800)]
test/parser: cleanup parser allocations on exit
We should talloc_free the parser list once we're done, enabling
valgrind's leak check. Before:
[jk@pablo parser]$ valgrind ./test-null
...
==9330== HEAP SUMMARY:
==9330== in use at exit: 288 bytes in 3 blocks
==9330== total heap usage: 11 allocs, 8 frees, 1,177 bytes allocated
After:
[jk@pablo parser]$ valgrind ./test-null
...
==9940== HEAP SUMMARY:
==9940== in use at exit: 0 bytes in 0 blocks
==9940== total heap usage: 11 allocs, 11 frees, 1,177 bytes allocated
==9940==
==9940== All heap blocks were freed -- no leaks are possible
Geoff Levand [Sat, 18 May 2013 01:57:07 +0000 (09:57 +0800)]
test/parser: Add check_not_present_resource
Add a new routine check_not_present_resource() to check
that a resource is not present. This is typically used
to check that an initrd entry has not been found.
Also add any needed checks for no initrd to the existing
tests.
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.