]> git.ozlabs.org Git - petitboot/log
petitboot
10 years agodiscover: Send options to client in order
Geoff Levand [Tue, 21 May 2013 13:27:24 +0000 (21:27 +0800)]
discover: Send options to client in order

Send the boot options to the client in the order discovered.  This
change  is in follow up to inverting the order that the server
saves the options internally.

Signed-off-by: Geoff Levand <geoff@infradead.org>
10 years agodiscover/grub2: remove uuid log message
Jeremy Kerr [Tue, 21 May 2013 02:14:35 +0000 (10:14 +0800)]
discover/grub2: remove uuid log message

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/test: Add boot status messages to test client
Jeremy Kerr [Tue, 21 May 2013 07:14:15 +0000 (15:14 +0800)]
ui/test: Add boot status messages to test client

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: implement global keys
Jeremy Kerr [Fri, 17 May 2013 02:26:05 +0000 (10:26 +0800)]
ui/ncurses: implement global keys

Add process_global_keys to handle global key events. Using this,
implement ctrl+l to refresh.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: move getch() out of process_key callbacks
Jeremy Kerr [Fri, 17 May 2013 02:02:41 +0000 (10:02 +0800)]
ui/ncurses: move getch() out of process_key callbacks

All process_key callbacks will want to query the key that was pressed,
so do the getch() once in cui_process_key, and pass the result to the
callback.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/waiter: Ensure waiters are consistent during waiter_poll
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.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/waiter: allocate waiters separately from set->waiters
Jeremy Kerr [Thu, 16 May 2013 12:39:27 +0000 (20:39 +0800)]
lib/waiter: allocate waiters separately from set->waiters

Since we reallocate set->waiters, we can't hand out pointers to within
that array.

Instead, this change allocates the 'struct waiter's separately from the
set->waiters array.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: fix error handling from failed client writes
Jeremy Kerr [Thu, 16 May 2013 08:40:39 +0000 (16:40 +0800)]
discover: fix error handling from failed client writes

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Fix accept() return value check
Jeremy Kerr [Thu, 16 May 2013 08:23:19 +0000 (16:23 +0800)]
discover: Fix accept() return value check

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: destroy client if message read failed
Jeremy Kerr [Thu, 16 May 2013 08:09:37 +0000 (16:09 +0800)]
discover: destroy client if message read failed

When a client disconnects, the read from the client's fd will return
EOF. We should destroy the client in this situation.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoutils/pb-console: use getty rather than exec
Jeremy Kerr [Thu, 16 May 2013 05:55:03 +0000 (13:55 +0800)]
utils/pb-console: use getty rather than exec

exec is a bit flaky for starting on consoles, so use getty instead.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoutils/pbconsole: Use here-document for usage text
Jeremy Kerr [Mon, 20 May 2013 02:42:08 +0000 (10:42 +0800)]
utils/pbconsole: Use here-document for usage text

Allows for cleaner usage message in the source.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: cleanup parser allocations on exit
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

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoutil/pb-console: Packaging updates
Geoff Levand [Sun, 19 May 2013 13:07:02 +0000 (21:07 +0800)]
util/pb-console: Packaging updates

In preparation for packaging add a man page, a help option, and some
comments to the script.

Signed-off-by: Geoff Levand <geoff@infradead.org>
10 years agotest/parser: Add check_not_present_resource
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.

Signed-off-by: Geoff Levand <geoff@infradead.org>
10 years agoparser: Use list to hold parsers
Geoff Levand [Fri, 17 May 2013 05:55:18 +0000 (13:55 +0800)]
parser: Use list to hold parsers

Now that we dynamically add parsers, we can use a list to
hold them.  Also simplifies the test_run_parser() routine.

Signed-off-by: Geoff Levand <geoff@infradead.org>
10 years agotest/parser: Add ubuntu grub tests
Geoff Levand [Fri, 17 May 2013 09:09:01 +0000 (17:09 +0800)]
test/parser: Add ubuntu grub tests

Signed-off-by: Geoff Levand <geoff@infradead.org>
10 years agotest/parser: Better message output
Geoff Levand [Fri, 17 May 2013 09:07:43 +0000 (17:07 +0800)]
test/parser: Better message output

Signed-off-by: Geoff Levand <geoff@infradead.org>
10 years agoparser/grub2: Add parse for linux16
Geoff Levand [Fri, 17 May 2013 07:11:10 +0000 (15:11 +0800)]
parser/grub2: Add parse for linux16

Ubuntu uses the linux16 symbol in thier conf files for memory test entries.

Signed-off-by: Geoff Levand <geoff@infradead.org>
10 years agoparser/grub2: Better menuentry parsing
Geoff Levand [Fri, 17 May 2013 06:28:45 +0000 (14:28 +0800)]
parser/grub2: Better menuentry parsing

Grub2 menuentry entry text can use double or single quotes.

Signed-off-by: Geoff Levand <geoff@infradead.org>
10 years agoconfigure: Add check for libncurses
Geoff Levand [Sun, 12 May 2013 14:16:51 +0000 (22:16 +0800)]
configure: Add check for libncurses

Signed-off-by: Geoff Levand <geoff@infradead.org>
10 years agotest/parser: Add grub2 multiple resolution test
Jeremy Kerr [Fri, 10 May 2013 04:00:23 +0000 (12:00 +0800)]
test/parser: Add grub2 multiple resolution test

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/grub2: handle search commands to specify root filesystems
Jeremy Kerr [Wed, 8 May 2013 08:46:26 +0000 (16:46 +0800)]
discover/grub2: handle search commands to specify root filesystems

Add a resource type for grub, allowing us to parse search parameters.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/resource: Provide resolve_resource_against_device
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.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: log cleanup
Jeremy Kerr [Thu, 9 May 2013 08:12:24 +0000 (16:12 +0800)]
discover: log cleanup

Remove some of the more noisy log messages, and add some information
pertinent to device resolution events.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add yaboot test from a ppc64 RH8 machine
Jeremy Kerr [Thu, 9 May 2013 08:08:32 +0000 (16:08 +0800)]
test/parser: Add yaboot test from a ppc64 RH8 machine

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add f18 grub config test
Jeremy Kerr [Wed, 8 May 2013 04:45:58 +0000 (12:45 +0800)]
test/parser: Add f18 grub config test

Add a real-world config file from a f18 ppc64 machine.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add simple GRUB2 parser test
Jeremy Kerr [Wed, 8 May 2013 03:26:46 +0000 (11:26 +0800)]
test/parser: Add simple GRUB2 parser test

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add simple kboot test
Jeremy Kerr [Mon, 6 May 2013 03:11:37 +0000 (11:11 +0800)]
test/parser: Add simple kboot test

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add yaboot test for external devices
Jeremy Kerr [Wed, 15 May 2013 08:58:38 +0000 (16:58 +0800)]
test/parser: Add yaboot test for external devices

Add a yaboot test to add boot options for an external device, then
hotplug that device.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add simple yaboot test
Jeremy Kerr [Wed, 15 May 2013 08:52:34 +0000 (16:52 +0800)]
test/parser: Add simple yaboot test

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add test device hotplug functions
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.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add resource check helpers
Jeremy Kerr [Wed, 15 May 2013 08:36:34 +0000 (16:36 +0800)]
test/parser: Add resource check helpers

Add check_resolved_local_resource and check_unresolved_resource to
check the resources returned from parsers.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add check_name helper
Jeremy Kerr [Wed, 8 May 2013 04:52:47 +0000 (12:52 +0800)]
test/parser: Add check_name helper

Simple function to check a boot_option's name.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add check_args helper
Jeremy Kerr [Mon, 6 May 2013 03:10:36 +0000 (11:10 +0800)]
test/parser: Add check_args helper

Add a small helper to check boot option arguments.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add check_boot_option_count helper & get_boot_option
Jeremy Kerr [Thu, 9 May 2013 08:49:59 +0000 (16:49 +0800)]
test/parser: Add check_boot_option_count helper & get_boot_option

Add a helper function to check the expected boot option counts, and
print the boot option details if the check fails.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Error on invalid parser name
Jeremy Kerr [Mon, 6 May 2013 03:09:31 +0000 (11:09 +0800)]
test/parser: Error on invalid parser name

We should error-out if we didn't find a valid parser, so it doesn't look
like we found no boot options.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Allow raw config data in test .c files
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.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Allow tests to provide pre-loaded config data
Jeremy Kerr [Wed, 15 May 2013 08:01:14 +0000 (16:01 +0800)]
test/parser: Allow tests to provide pre-loaded config data

Some tests may want to use an existing buffer as config data, so add
test_read_config_data() to allow this.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest: Replace parser tests with empty framework
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.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Make device handler a little more testable
Jeremy Kerr [Fri, 3 May 2013 06:31:55 +0000 (14:31 +0800)]
discover: Make device handler a little more testable

This change moves some of the device-handler code into an #ifdef-ed
section, so we can easily drop the stuff that's not required for
testing.

Although the change is quite large, most of it is moving entire
functions around.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/url: Add pb_url_to_string
Jeremy Kerr [Thu, 2 May 2013 09:46:56 +0000 (17:46 +0800)]
lib/url: Add pb_url_to_string

Add a function to unparse a URL, to make comparisons in tests easy.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Allow devices with no device_path
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>
10 years agodiscover: Always associate resources with a boot option
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>
10 years agodiscover: Don't access bytes before the start of empty strings
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>
10 years agodiscover: Always add a NUL byte to config data
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>
10 years agodiscover/yaboot: Fix boot option state
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>
10 years agodiscover/udev: use devname (not devpath) for device IDs
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>
10 years agodiscover/grub2: Add grub2/grub.cfg config file
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>
10 years agoutils/Makefile: pb-console is dist_
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>
10 years agoui/nc: Don't segfault if we can't open log_file
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>
10 years agoui/nc: Handle cui_opt_data with no boot option more gracefully
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>
10 years agoui/ncurses: Simplify menu item names
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>
10 years agoutils: Add pb-console util
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>
10 years agopb-udhcpc: Look for more boot options
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>
10 years agoutils/pb-udhcpc: Use command-line format of pb-event
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>
10 years agopb-event: move send code to a separate function
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>
10 years agoutils/pb-event: handle event data on command line
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>
10 years agodiscover: handle boot_option->device_id entirely within handler
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>
10 years agodiscover/udev: Setup event params from udev properties
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>
10 years agodiscover/event: Add event_set_param
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>
10 years agodiscover/udev: Don't print properties of skipped devices
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>
10 years agodiscover/grub2: Rework config state
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>
10 years agodiscover: Don't invert option discovery order
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>
10 years agodiscover: Don't resend all options to all clients
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>
10 years agodiscover/event-parser: correctly populate boot option resources
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>
10 years agodiscover/resource.h: Add forward declarations
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>
10 years agoMakefiles: remove -I$(includedir)
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>
10 years agoconfigure: Remove -Winline
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>
10 years agodiscover/user-event: better event debugging output
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>
10 years agodiscover/kboot: Fix boot_option initialisation
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>
10 years agolib/url: fix no-scheme URL parsing
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>
10 years agodiscover: log unresolved boot options
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>
10 years agodiscover: kexec harder
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>
10 years agodiscover/user-event: handle initrds
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>
10 years agoparsers: populate resolve_resource members
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>
10 years agodiscover: detect unresolvable resources
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>
10 years agocui: Show incoming status messages
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>
10 years agodiscover: Send boot status messages during boot()
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>
10 years agodiscover: Add discover_server_notify_boot_status
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>
10 years agoui: Receive boot status messages
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>
10 years agoprotocol: Add boot_status (de-)serialisation functions
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>
10 years agolib: Add boot_status type & protocol definitions
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>
10 years agodiscover/udev: remove unnecessary udevadm references
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>
10 years agotest/url: Add uncommitted data files
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>
10 years agoconfigure: More helpful missing libudev message
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>
10 years agoudev: Revove use of udev_get_sys_path
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>
10 years agodiscover: Remove unused 99-petitboot.rules file
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>
10 years agodiscover: Remove empty routine udev_trigger
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>
10 years agodiscover: Update udev routines to use libudev
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>
10 years agodiscover: Rename struct udev to struct pb_udev
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>
10 years agotest/lib: Add empty list test
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>
10 years agolib/list: Fix handling of empty lists
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>
10 years agodiscover: Add PXE parser
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>
10 years agodiscover: Add configuration events & DHCP handler
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>
10 years agodiscover: Add configuration methods
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>
10 years agoparsers: dynamically register parsers
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>
10 years agodiscover: Handle unresolved resources
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>
10 years agodiscover: Finalise boot options during commit
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>
10 years agodiscover/device-handler: Initialise existing_device variable
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>