summaryrefslogtreecommitdiffstats
path: root/discover
Commit message (Collapse)AuthorAgeFilesLines
* automake: Fixups for maintainer-cleanGeoff Levand2013-11-181-1/+1
| | | | Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Use mkstemp rather than tempnamJeremy Kerr2013-11-141-4/+6
| | | | | | We're getting warnings from some compilers about tempnam being unsafe. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Handle incoming configuration messagesJeremy Kerr2013-11-133-1/+24
| | | | | | | When the client sends us a PB_PROTOCOL_ACTION_CONFIG message, we want to update the current config. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* config: Implement config messagesJeremy Kerr2013-11-132-0/+36
| | | | | | On client connect, send a PB_PROTOCOL_ACTION_CONFIG message. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/types: use unsigned int for interface, dns and prio countsJeremy Kerr2013-11-132-3/+4
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib: consolidate util macros in util/util.hJeremy Kerr2013-11-133-3/+3
| | | | | | | This change groups the offsetof, container_of and ARRAY_SIZE macros in a single header file util/util.h. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Fix potentially-uninitialised variablesJeremy Kerr2013-11-133-1/+4
| | | | | | | We've been compiling with --enable-debug; this change fixes some problems exposed by the optimiser. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Change parsers to explicitly request configuration filesNeelesh Gupta2013-11-0613-163/+402
| | | | | | | | | | | | | | | | | | | Add a new function parser_request_url() to read the data from configuration files present remotely. We deprecate iterate_parser_files() and download_config() functions along with the 'filenames' and 'method' members of the 'parser' structure so that individual parsers would now require to request the configuration files data from the parser code and doesn't necessarily export the list of configuration files. Add the support to handle incoming DHCP event, done by passing all the relevant environment variables of the udhcpc to the discover code. Also, update the pxe parser code to populate the list of configuration file names as per PXELINUX convention of fallback names using mac and ip addresses of the booting machine. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allocate contexts with talloc_zeroJeremy Kerr2013-11-061-3/+1
| | | | | | Ensure all pointers from the context are NULL. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* logging: Clean up debug logsJeremy Kerr2013-11-017-25/+16
| | | | | | | We have quite a few pb_logs which should be pb_debug. This change moves developer-specific info to pb_debug. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Allow for arbitrary-sized netlink messagesJeremy Kerr2013-11-011-5/+41
| | | | | | | | | | | Currently, we drop any netlink data beyond our 4096-byte buffer. This means that we can only parse a limited number of network interfaces. This change uses recvmsg with MSG_PEEK to determine the size of an incoming netlink message before doing the actual recvmsg. This way, we can realloc our buffer to suit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/file: Fix invalid free in replace_fileJeremy Kerr2013-10-241-1/+1
| | | | | | We talloced tempfile, we should be freeing with talloc_free. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: cleanup allocated dataJeremy Kerr2013-10-211-0/+7
| | | | | | | We have a few allocations hanging around at the end of pb-discover; free them. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/file: Fix invalid free vs talloc_freeJeremy Kerr2013-10-211-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Ensure dns config buffer contains a trailling nulJeremy Kerr2013-10-211-1/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/parser: free parsers on exitJeremy Kerr2013-10-211-1/+12
| | | | | | Allocate parsers against a context, and free that context on exit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/sysinfo: Fix talloc against uninitialised server varJeremy Kerr2013-10-211-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Clean lexer.[ch]Jeremy Kerr2013-10-211-1/+2
| | | | | | `make distcheck` fails with a couple of failes remaining after clean. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't free clients on write failureJeremy Kerr2013-10-151-5/+8
| | | | | | | | | | | | | | Currently, if we see an error when writing to a client, we free the client immediately. This means that any pending reads will be discarded. Additionally, if a client disconnects before we have finished the writes in discover_server_process_connection, we won't register the waiter to read from the socket. Instead of freeing the client on write failure, this change sets a flag (se we don't continue to write), and we rely on the read EOF to free the client. This means we don't drop incoming messages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow an in-progress boot to be cancelledJeremy Kerr2013-10-153-15/+87
| | | | | | | | | Currently, once the boot() function is called, the boot process will ignore any cancellations. This change allows boot() to be cancelled, via boot_cancel(). Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add load_url_cancelJeremy Kerr2013-10-142-4/+38
| | | | | | | We'd like a way to cancel pending loads, as part of aborting the boot process. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Allow URL resourcesJeremy Kerr2013-10-142-3/+10
| | | | | | Allow URL-format specifiers for GRUB2 resources. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow device_handler_boot with no optionJeremy Kerr2013-10-101-2/+3
| | | | | | Only call find_boot_option_by_id if we have an ID. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: remove register_parser printfJeremy Kerr2013-10-091-2/+0
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/sysinfo: Add helper script to populate sysinfo identifiersJeremy Kerr2013-10-092-3/+33
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Add system info messagesJeremy Kerr2013-10-097-0/+128
| | | | | | | | Add a little infrastructure for communicating information about the system to the petitboot UIs. We just send some identifying info (type and identifier), as well as the interfaces. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/udev: dup property values returned from udevJeremy Kerr2013-10-091-2/+7
| | | | | | The property strings are managed by the udev code, so we need to strdup. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/device-handler: Fix use-after-free when unmountingJeremy Kerr2013-10-091-2/+3
| | | | | | We need to do the rmdir after clearing mount_path. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't call config_set_autoboot before config_initJeremy Kerr2013-10-091-3/+2
| | | | | | | | Change f611bde3 shifted the config_init until after process_init, as we need to run processes during config init. We also needed to move the config_set_autoboot invocation too. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Fix uninitialised yylinenoJeremy Kerr2013-10-041-0/+1
| | | | | | | | | Valgrind reports an invalid usage of an uninitialised var in yyerror, causing testcase failures. Initialise lineno before we start parsing. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement save_env commandJeremy Kerr2013-10-042-5/+166
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement load_envJeremy Kerr2013-10-013-0/+116
| | | | | | | Use the new parser_request_file API to access the GRUB environment block. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: strdup strings used in the environmentJeremy Kerr2013-10-011-4/+6
| | | | | | | Use a copy of the name & value pairs that we pass to the environment, as the data loaded from load_env will be talloc_free-ed. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add default prefixJeremy Kerr2013-10-011-1/+3
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add device_{request,release}_writeJeremy Kerr2013-10-014-3/+95
| | | | | | | | Add a pair of functions to the parser API to allow write access to the underlying device. We'll use this in the GRUB2 parser to implement environment persistence. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add parser_request_fileJeremy Kerr2013-10-012-2/+28
| | | | | | Add a function to allow parsers to access files on a local device. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add test_data member to struct discover_contextJeremy Kerr2013-10-012-0/+2
| | | | | | | | We have parsers passing discover_contexts around, which we want to hook into the test framework. Add a void * member, which the test code can use to reference the test. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't continue discovery if mount failsJeremy Kerr2013-10-011-1/+5
| | | | | | | Check the return value from mount_device and abort the discover on failure. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow for already-mounted devicesJeremy Kerr2013-10-012-9/+84
| | | | | | | | | | | When we start the discover server, we may find that devices are already mounted. In this case, mount_device will fail, and we'll abort the parse. This change uses /proc/self/mounts to check if new devices are already mounted, and uses the existing mount point. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Clean up error-handling for grub2 parser & lexerJeremy Kerr2013-09-263-16/+19
| | | | | | | Rather than printf() & exit(), use the pb logging functions and abort the parse. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/resource: create_url_resource should take ownership of urlJeremy Kerr2013-09-261-0/+1
| | | | | | | The URL needs to share the lifetime of resource, so talloc_steal it in create_url_resource. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/paths: Check local file URLs in load_urlJeremy Kerr2013-09-261-3/+20
| | | | | | Make the error case for local files the same as for remotes. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/boot: Log boot status updatesJeremy Kerr2013-09-261-0/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/boot: Download resources in parallelJeremy Kerr2013-09-261-104/+64
| | | | | | | | Now that we can download asynchronously, we can download boot resources in parallel. This also means we don't need a state machine; we're either not done (loads are still pending) or done. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add struct load_url_result and load_taskJeremy Kerr2013-09-264-307/+287
| | | | | | | | | | | | | | | Currently, load_url and load_url_async return a filename parameter and a tempfile flag (indicating whether the file needs to be cleaned after use). Instead, encapsulate this data in a struct load_url_result, which the caller (and async callbacks) can read the status, filename and clean parameters. For internal use in load_url and helpers, we add a struct load_task to hold a pointer to the load_url_result and async data. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't depend on tftp failure for type detectionJeremy Kerr2013-09-261-40/+69
| | | | | | | | Rather than always trying both TFTP client types, do a runtime detection on first invocation. This can be fixed at build-time with --with-tftp=TYPE. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/boot: Store clean_* in the boot taskJeremy Kerr2013-09-261-9/+9
| | | | | | ... otherwise we won't clean up local files from earlier boot stages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/boot: Check for failed loads in boot()Jeremy Kerr2013-09-251-14/+33
| | | | | | | Use the status argument to the URL load callback to check for load failures. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: load_url_async callback should take an int statusJeremy Kerr2013-09-253-15/+5
| | | | | | We don't need a pointer here, just the status value. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/boot: Implement asynchronous boot() processNeelesh Gupta2013-09-251-82/+137
| | | | | | | | | | | | The current boot process handled by boot() function is implemented such that it blocks on the boot resources being downloaded which blocks the discover process until the download completes. This patch re-implements the boot() function using callback mechanism and asynchronous notifications so that boot() returns to continue the discover process while the download is in progress. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
OpenPOWER on IntegriCloud