petitboot
6 years agolib/process: replace pb_run_cmd
Jeremy Kerr [Tue, 13 Aug 2013 05:03:53 +0000 (13:03 +0800)]
lib/process: replace pb_run_cmd

This change replaces the pb_run_cmd() function with proper usage of the
process API.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/process: replace pb_run_cmd_pipe
Jeremy Kerr [Mon, 12 Aug 2013 08:39:36 +0000 (16:39 +0800)]
lib/process: replace pb_run_cmd_pipe

Replace pb_run_cmd_pipe with process_create / process_run_sync.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agotest/lib: add process tests
Jeremy Kerr [Wed, 14 Aug 2013 07:05:56 +0000 (15:05 +0800)]
test/lib: add process tests

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/waiter: handle -EINTR
Jeremy Kerr [Mon, 19 Aug 2013 03:58:23 +0000 (11:58 +0800)]
lib/waiter: handle -EINTR

Now that we're handing non-fatal signals (i.e., SIGCHLD in the process
lib), we need to gracefully handle -EINTR from poll().

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/process: Add process helpers
Jeremy Kerr [Mon, 12 Aug 2013 07:57:41 +0000 (15:57 +0800)]
lib/process: Add process helpers

We've grown-out of pb_run_cmd a little, as we have a number of different
process types:

   boot():
    - kexec: short-running process, run synchronously
    - boot hooks: short-running, run sync, need exit code & stdout

   network init:
    - interface configuration: short running, run sync
    - udhcp processes are long running, we may want completion, but
      doesn't block other actions

   downloads:
    - potentially long-running, block parse progress

   config nvram:
    - read: short running, can block, need stdout
    - write: short running, can block

We'd like to introduce proper asynchronous processes, to allow config &
boot-option downloads without blocking the discover server.

This change introduces a new type for processes, 'struct process'. These
structures are created with process_create, and run with
process_run_sync or process_run_async. The latter reports completion
through a callback member of struct process.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agotest: Add --enable-test-valgrind
Jeremy Kerr [Mon, 19 Aug 2013 03:08:56 +0000 (11:08 +0800)]
test: Add --enable-test-valgrind

Add an --enable-test-valgrind argument to configure, to run all tests
under valgrind, configured to fail on leaked memory

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agotest/lib: Use talloc in list test
Jeremy Kerr [Mon, 19 Aug 2013 03:08:36 +0000 (11:08 +0800)]
test/lib: Use talloc in list test

.. so we can free at exit

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agotest/lib: build with -DEBUG
Jeremy Kerr [Fri, 12 Jul 2013 06:25:07 +0000 (14:25 +0800)]
test/lib: build with -DEBUG

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/boot: talloc struct boot_task
Jeremy Kerr [Tue, 13 Aug 2013 03:23:57 +0000 (11:23 +0800)]
discover/boot: talloc struct boot_task

Rather than using the stack for struct boot_task, talloc one instead.
This gives us a short-lived context (active for the boot() process
only), and we don't need to use the externally-provided context
directly.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: remove unused user_event_trigger
Jeremy Kerr [Fri, 12 Jul 2013 06:31:49 +0000 (14:31 +0800)]
discover: remove unused user_event_trigger

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/waiter: remove waitset_destroy
Jeremy Kerr [Mon, 19 Aug 2013 01:58:58 +0000 (09:58 +0800)]
lib/waiter: remove waitset_destroy

We can rely on the ctx free to destroy the waitset.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/waiter: talloc waiters from waitset context
Jeremy Kerr [Wed, 14 Aug 2013 06:55:46 +0000 (14:55 +0800)]
lib/waiter: talloc waiters from waitset context

We can lose a reference to the first waiter allocated, as set->waiters
may be NULL.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/waiter: fix talloc_realloc context
Jeremy Kerr [Wed, 14 Aug 2013 06:17:02 +0000 (14:17 +0800)]
lib/waiter: fix talloc_realloc context

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/waiter: merge time & io waiter init loops
Jeremy Kerr [Sat, 1 Jun 2013 10:07:40 +0000 (20:07 +1000)]
lib/waiter: merge time & io waiter init loops

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/waiter: move type-specific members to a union
Jeremy Kerr [Sat, 1 Jun 2013 09:56:15 +0000 (19:56 +1000)]
lib/waiter: move type-specific members to a union

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/file: Add sensible perms when using replace_file
Jeremy Kerr [Thu, 15 Aug 2013 07:28:06 +0000 (15:28 +0800)]
discover/file: Add sensible perms when using replace_file

Rather than no access at all, use a default of 0644.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/network: free buffers from resolv.conf update
Jeremy Kerr [Thu, 15 Aug 2013 07:27:39 +0000 (15:27 +0800)]
discover/network: free buffers from resolv.conf update

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/network: fix incorrect nameserver directive in resolv.conf
Jeremy Kerr [Thu, 15 Aug 2013 07:25:14 +0000 (15:25 +0800)]
discover/network: fix incorrect nameserver directive in resolv.conf

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agonetwork: handle DNS config
Jeremy Kerr [Thu, 8 Aug 2013 07:41:39 +0000 (15:41 +0800)]
network: handle DNS config

If we have a dns config option, update resolv.conf

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/file: Add replace_file()
Jeremy Kerr [Thu, 8 Aug 2013 07:25:24 +0000 (15:25 +0800)]
discover/file: Add replace_file()

Add a function to atomically replace a file.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: separate file-reading code into file.c
Jeremy Kerr [Thu, 8 Aug 2013 06:40:59 +0000 (14:40 +0800)]
discover: separate file-reading code into file.c

We'll need to read files in the network config code, so add a 'file'
object, containing the read_file function.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: remove libparser object
Jeremy Kerr [Thu, 8 Aug 2013 06:33:19 +0000 (14:33 +0800)]
discover: remove libparser object

There's no real need for a separate libparser object. Our tests pull-in
the parsers directly, and the discover server is the only thing that
actually links to libparser.ro.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoconfig: DNS configuration isn't interface-specific
Jeremy Kerr [Thu, 8 Aug 2013 06:21:00 +0000 (14:21 +0800)]
config: DNS configuration isn't interface-specific

Rather than attaching DNS configuration to an interface, separate it out
into general network config.

The powerpc-nvram storage exepects dns as a "dns,server,..." string.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoconfig: Split interface configuration from network configuration
Jeremy Kerr [Thu, 8 Aug 2013 05:54:19 +0000 (13:54 +0800)]
config: Split interface configuration from network configuration

This change moves the interface configuration into its own 'struct
interface_config'. We also remove the _config suffix from the network
and interface members.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/yaboot: implement default options
Jeremy Kerr [Wed, 7 Aug 2013 06:39:40 +0000 (14:39 +0800)]
discover/yaboot: implement default options

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/yaboot: fix device parsing
Jeremy Kerr [Wed, 7 Aug 2013 06:00:16 +0000 (14:00 +0800)]
discover/yaboot: fix device parsing

A couple of fixes for yaboot's device-handling code. Firstly, we need to
use 'device=' rather than 'root=', as the latter is purely for ybin, to
define where the yaboot binary goes.

Secondly, we need to respect global and option-specific device=
parameters. To do this, we keep all boot_image and initrd strings in the
state, and create the actual resources in yaboot_finish.

Add a test for all override cases, and fix the incorrect boot= parsing
in the rh8 test.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/yaboot: Allow all image options to be overridden by global options
Jeremy Kerr [Wed, 7 Aug 2013 02:31:05 +0000 (10:31 +0800)]
discover/yaboot: Allow all image options to be overridden by global options

All of the image options should be overridable by global options.

Instead of building the boot_args during yaboot_process_pair, we add
discovered data into the state struct, then create the boot args from
this data during yaboot_finish

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: fix segfault on failed boot image load
Jeremy Kerr [Thu, 1 Aug 2013 07:25:53 +0000 (15:25 +0800)]
discover: fix segfault on failed boot image load

If the boot image fails to load, we end up calling talloc_free on an
unitialised are of stack (boot_task.local_initrd).

Move the initialisers a little earlier, so we always NULL pointers
before potentially freeing.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoparser/yaboot: Fix check for image presence
Jeremy Kerr [Wed, 31 Jul 2013 00:44:11 +0000 (08:44 +0800)]
parser/yaboot: Fix check for image presence

In the cleanup of yaboot option state, 3fb8fb6fb, we change from
checking opt->boot_image to opt, to indicate that we're parsing an image
section.

We missed one check, which is causing a segfault due to the null opt.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: Hookup --no-autoboot to config
Geoff Levand [Tue, 23 Jul 2013 20:30:19 +0000 (13:30 -0700)]
discover: Hookup --no-autoboot to config

Add new routine config_set_autoboot(), and use it to set
the --no-autoboot option.

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agodiscover: Add --no-autoboot option
Geoff Levand [Tue, 23 Jul 2013 19:09:18 +0000 (12:09 -0700)]
discover: Add --no-autoboot option

Add the command line option --no-autoboot to pb-discover
and update the pb-discover manpage.

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agodiscover: Log autoboot timeout
Geoff Levand [Tue, 23 Jul 2013 17:59:23 +0000 (10:59 -0700)]
discover: Log autoboot timeout

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agodiscover: Rename default_enabled
Geoff Levand [Mon, 22 Jul 2013 21:38:52 +0000 (14:38 -0700)]
discover: Rename default_enabled

Rename default_enabled to autoboot_enabled for consistency
with pb-config.

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agodiscover: Add grub.cfg path for openSUSE
Geoff Levand [Sat, 20 Jul 2013 00:11:09 +0000 (17:11 -0700)]
discover: Add grub.cfg path for openSUSE

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agoconfigure: Update to use AX_WITH_CURSES
Geoff Levand [Sat, 20 Jul 2013 00:07:31 +0000 (17:07 -0700)]
configure: Update to use AX_WITH_CURSES

For a more portable build system convert to using the
autoconf-archive AX_WITH_CURSES macros.  Allows building
on openSUSE, which has a different header file layout than
other distros, and fixes menu entries with UTF-8 characters;
this causes fedora installs (codename "Schrödinger´s cat")
to break the UI.

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agoautomake: Add $(EXEEXT) to .ro objects
Geoff Levand [Fri, 19 Jul 2013 00:23:41 +0000 (17:23 -0700)]
automake: Add $(EXEEXT) to .ro objects

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agoui/ncurses: Add setlocale call
Jeremy Kerr [Tue, 9 Jul 2013 06:03:35 +0000 (14:03 +0800)]
ui/ncurses: Add setlocale call

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agodiscover: Don't free URL in load_url
Jeremy Kerr [Thu, 18 Jul 2013 05:21:37 +0000 (13:21 +0800)]
discover: Don't free URL in load_url

Previously, load_url took a char * argument, from which it parsed a
newly allocated URL, and freed the URL before returning.

Commit 5be946c changed load_url (then load_file) to accept a parsed URL
instead of a char *, but didn't remove the free. Any URLs passed to
load_url are currently being unintionally free()ed.

This change removes the invalid free.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agopb-udhcp: Fix MAC-address-based configuration file location
Jeremy Kerr [Mon, 15 Jul 2013 08:09:09 +0000 (16:09 +0800)]
pb-udhcp: Fix MAC-address-based configuration file location

We're currently requesting a colon-separated MAC address. Instead, we
need it to be hypen-separated, and prefixed with the ethernet type
("01-").

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agopb-udhcp: PXE fixes
Jeremy Kerr [Mon, 15 Jul 2013 05:11:13 +0000 (13:11 +0800)]
pb-udhcp: PXE fixes

Fix a couple of bugs in the udhcp script.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/waiter: Defer free of removed waiters
Jeremy Kerr [Wed, 10 Jul 2013 07:50:43 +0000 (15:50 +0800)]
lib/waiter: Defer free of removed waiters

We may end up calling remove()-d time waiters if the timeout expires as
we're processing an IO waiter. Instead of freeing the waiter in
waiter_remove, mark the waiter as inactive, and defer the free until the
end of waiter_poll().

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/pxe: remove debug statement
Jeremy Kerr [Tue, 9 Jul 2013 08:16:48 +0000 (16:16 +0800)]
discover/pxe: remove debug statement

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agotest/parser: Add pxe tests
Jeremy Kerr [Tue, 9 Jul 2013 08:14:41 +0000 (16:14 +0800)]
test/parser: Add pxe tests

Add a couple of tests to verify the pxe parser, particularly the
different styles of initrd handling.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agotest/parser: Add check_resolved_url_resource
Jeremy Kerr [Tue, 9 Jul 2013 08:14:00 +0000 (16:14 +0800)]
test/parser: Add check_resolved_url_resource

Add a check for external URL resources.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/pxe: Handle initrds
Jeremy Kerr [Tue, 9 Jul 2013 08:12:51 +0000 (16:12 +0800)]
discover/pxe: Handle initrds

We may see initrds specified on the kernel argument line, or as their
own configuration directive.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agopb-console: Read /etc/environment and /etc/locale
Jeremy Kerr [Tue, 9 Jul 2013 07:24:38 +0000 (15:24 +0800)]
pb-console: Read /etc/environment and /etc/locale

Since we're starting from no environment on the consoles, allow
specifying an initial environment.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agotest/parser: Add test_set_conf_source()
Jeremy Kerr [Thu, 4 Jul 2013 07:27:01 +0000 (15:27 +0800)]
test/parser: Add test_set_conf_source()

For non-local parsers (ie, PXE), we need to have the conf_url set. This
change adds a function to provide the originating URL.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/pxe-parser: All options are name <space> value pairs
Jeremy Kerr [Thu, 4 Jul 2013 07:25:51 +0000 (15:25 +0800)]
discover/pxe-parser: All options are name <space> value pairs

Abort the pair parse if we don't have both a name and a value.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/device-handler: hook up autoboot_enabled config var
Jeremy Kerr [Tue, 2 Jul 2013 03:24:10 +0000 (11:24 +0800)]
discover/device-handler: hook up autoboot_enabled config var

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoconfig/powerpc-nvram: Fix nvram line parsing
Jeremy Kerr [Tue, 2 Jul 2013 02:47:35 +0000 (10:47 +0800)]
config/powerpc-nvram: Fix nvram line parsing

We have a couple of issues with the nvram output parser; lines aren't
being broken up correctly.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoconfig/powerpc-nvram: Don't require petitboot, prefix on all params
Jeremy Kerr [Tue, 2 Jul 2013 02:36:47 +0000 (10:36 +0800)]
config/powerpc-nvram: Don't require petitboot, prefix on all params

Currently, we only store nvram params with a "petitboot," prefix, so
that we don't grow the config list to an unbound size. However,
the "auto-boot?" param has no prefix.

Instead, remove the requirement for the "petitboot," prefix, and use an
array of known parameters instead.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: Fix automake warnings
Geoff Levand [Sun, 30 Jun 2013 20:45:58 +0000 (13:45 -0700)]
discover: Fix automake warnings

Change the Makfile.am relocatable output files from automake _LIBRARIES
to automake _PROGRAMS.  Also, change the output file name extension
from .o to .ro to better show these are relocatable files.

Fixes automake warnings like these:

  discover/Makefile.am: `libparser.o' is not a standard library name
  discover/Makefile.am: did you mean `libparser.a'?

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agotest/parser: Cleanup Makefile.am
Geoff Levand [Sun, 30 Jun 2013 20:31:32 +0000 (13:31 -0700)]
test/parser: Cleanup Makefile.am

General cleanup of Makefile.am.  This cleanup should retain the same
makefile behavior.

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agoui/ncurses: Remove unused 'cod' variable
Jeremy Kerr [Mon, 24 Jun 2013 05:03:14 +0000 (13:03 +0800)]
ui/ncurses: Remove unused 'cod' variable

When configured with --disable-debug, we get an unused variable warning:

  ui/ncurses/nc-cui.c: In function 'cui_device_remove':
  ui/ncurses/nc-cui.c:439:24: error: unused variable 'cod'
  cc1: all warnings being treated as errors

This change just removes the temporary variable.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoutils/hooks: Add sample update-dtb hook.
Jeremy Kerr [Fri, 21 Jun 2013 02:43:49 +0000 (10:43 +0800)]
utils/hooks: Add sample update-dtb hook.

Provide an example for writing a pre-boot hook to update the dtb.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/boot: Allow boot hooks to alter boot data
Jeremy Kerr [Thu, 20 Jun 2013 06:04:29 +0000 (14:04 +0800)]
discover/boot: Allow boot hooks to alter boot data

By exiting with status == 2, boot hooks can update boot data by
printing name=value to stdout.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoutils/hooks: Add create-dtb hook
Jeremy Kerr [Thu, 20 Jun 2013 06:19:24 +0000 (14:19 +0800)]
utils/hooks: Add create-dtb hook

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/system: Add pb_run_cmd_pipe
Jeremy Kerr [Thu, 20 Jun 2013 05:27:16 +0000 (13:27 +0800)]
lib/system: Add pb_run_cmd_pipe

Add a function to run a command and capture the output into a buffer.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/event: Fix incorrect calculation of param data length
Jeremy Kerr [Thu, 20 Jun 2013 04:00:26 +0000 (12:00 +0800)]
discover/event: Fix incorrect calculation of param data length

We're not accounting for the action in the event header (only the device
string) when we pass the length of param data to event_parse_params.
This means we walk past the end of the event data while parsing params.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoutils: Add busybox reboot script
Jeremy Kerr [Thu, 20 Jun 2013 02:56:04 +0000 (10:56 +0800)]
utils: Add busybox reboot script

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/boot: Add boot hooks
Jeremy Kerr [Thu, 20 Jun 2013 02:33:29 +0000 (10:33 +0800)]
discover/boot: Add boot hooks

Add a method of running pre-boot hooks. Executable files in
/etc/petitboot/boot.d/ are run (in order) before we start the boot
process.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/boot: Put all boot params into a struct boot_task
Jeremy Kerr [Thu, 20 Jun 2013 01:31:40 +0000 (09:31 +0800)]
discover/boot: Put all boot params into a struct boot_task

This keeps all the boot-specific details in one place.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoAdd pkgsysconfdir
Jeremy Kerr [Wed, 19 Jun 2013 07:28:22 +0000 (15:28 +0800)]
Add pkgsysconfdir

We'll need a sysconf dir to store the boot hooks.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoAdd initial dtb support
Geoff Levand [Mon, 15 Apr 2013 22:23:05 +0000 (15:23 -0700)]
Add initial dtb support

Updates & fixes by Jeremy Kerr <jk@ozlabs.org>.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: bring network interfaces down in network_shutdown
Jeremy Kerr [Sat, 1 Jun 2013 09:50:00 +0000 (19:50 +1000)]
discover: bring network interfaces down in network_shutdown

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: Add network handling
Jeremy Kerr [Thu, 30 May 2013 06:25:26 +0000 (16:25 +1000)]
discover: Add network handling

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib: Add pb-config module
Jeremy Kerr [Wed, 29 May 2013 07:24:42 +0000 (17:24 +1000)]
lib: Add pb-config module

Add a library for (name, value) configuration.

Different storage backends are allowed (although currently hardcoded to
powerpc nvram), and config is read-only at present.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: Add logging for default boot option behaviour
Jeremy Kerr [Tue, 21 May 2013 06:39:32 +0000 (14:39 +0800)]
discover: Add logging for default boot option behaviour

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/event: Allow empty param values
Jeremy Kerr [Tue, 21 May 2013 06:33:15 +0000 (14:33 +0800)]
discover/event: Allow empty param values

Useful for specifying defaults:

 pb-event add@defaults name='Netboot' \
   image=http://192.168.0.1/vmlinuz \
  default

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoui/ncurses: Add cancel-default reporting
Jeremy Kerr [Tue, 21 May 2013 06:26:12 +0000 (14:26 +0800)]
ui/ncurses: Add cancel-default reporting

When we first see key input, we can tell the discover server to cancel
the default boot.

Untested on ps3.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoui/common: Add code to send cancel-default messages
Jeremy Kerr [Tue, 21 May 2013 06:20:51 +0000 (14:20 +0800)]
ui/common: Add code to send cancel-default messages

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoui: implement timers with waitsets
Jeremy Kerr [Tue, 21 May 2013 04:43:36 +0000 (12:43 +0800)]
ui: implement timers with waitsets

A temporary change to the timers; we'll eventually remove these from the
ui code.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: Add "cancel default boot" messages
Jeremy Kerr [Tue, 21 May 2013 06:16:35 +0000 (14:16 +0800)]
discover: Add "cancel default boot" messages

Allow the default boot process to be cancelled, via a message with
action PB_PROTOCOL_ACTION_CANCEL_DEFAULT.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/event: Allow user events to be defaults
Jeremy Kerr [Tue, 21 May 2013 06:14:23 +0000 (14:14 +0800)]
discover/event: Allow user events to be defaults

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: Add countdown before default boot
Jeremy Kerr [Tue, 21 May 2013 05:57:56 +0000 (13:57 +0800)]
discover: Add countdown before default boot

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover: implement default booting
Jeremy Kerr [Tue, 21 May 2013 05:33:46 +0000 (13:33 +0800)]
discover: implement default booting

When we see a boot option with is_default set, store it in the handler
and register a timeout waiter.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/boot: Allow null boot command
Jeremy Kerr [Tue, 21 May 2013 05:32:11 +0000 (13:32 +0800)]
discover/boot: Allow null boot command

If we're booting from a default option, we don't have a boot command.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agolib/waiter: Add timeout waiters
Jeremy Kerr [Tue, 21 May 2013 03:52:00 +0000 (11:52 +0800)]
lib/waiter: Add timeout waiters

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agodiscover/grub2: Add default option parsing
Jeremy Kerr [Tue, 21 May 2013 02:13:28 +0000 (10:13 +0800)]
discover/grub2: Add default option parsing

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoui/test: print default status of boot options
Jeremy Kerr [Tue, 21 May 2013 07:23:55 +0000 (15:23 +0800)]
ui/test: print default status of boot options

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agotypes: Add is_default to struct boot_option
Jeremy Kerr [Fri, 17 May 2013 03:41:04 +0000 (11:41 +0800)]
types: Add is_default to struct boot_option

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
6 years agoautotools: Fix make maintainer-clean
Geoff Levand [Wed, 29 May 2013 21:00:25 +0000 (14:00 -0700)]
autotools: Fix make maintainer-clean

Fixes to make maintainer-clean work properly.

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 years agotest/parser: Remove gawk specifics
Geoff Levand [Wed, 29 May 2013 20:42:16 +0000 (13:42 -0700)]
test/parser: Remove gawk specifics

Remove the GNU awk specifics to allow the use of a standard
awk program.  Fixes build errors on older distros.

Signed-off-by: Geoff Levand <geoff@infradead.org>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>