summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-07-21 18:18:35 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-07-22 09:04:59 +0800
commitd2b12ddb905a74fa6b2e454142b0b9f71fd99398 (patch)
treeef6ab12a56aa0dc9fc0f6b35795ed2b9f01c0411 /discover
parent3c49b3fa6e6038fd226253e71cb082e09b4ff7a5 (diff)
downloadtalos-petitboot-d2b12ddb905a74fa6b2e454142b0b9f71fd99398.tar.gz
talos-petitboot-d2b12ddb905a74fa6b2e454142b0b9f71fd99398.zip
discover: Add safe mode
Safe mode configures the discover server to not start any device parsing; this can be used to diagnose any problems with early device handing. In safe mode, we don't initialise any of the device sources - udev, network and user events are disabled. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover')
-rw-r--r--discover/device-handler.c10
-rw-r--r--discover/platform.c3
2 files changed, 13 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index b93cdfa..e4978fa 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -285,6 +285,9 @@ struct device_handler *device_handler_init(struct discover_server *server,
parser_init();
+ if (config_get()->safe_mode)
+ return handler;
+
rc = device_handler_init_sources(handler);
if (rc) {
talloc_free(handler);
@@ -842,6 +845,13 @@ static int device_handler_init_sources(struct device_handler *handler)
static void device_handler_reinit_sources(struct device_handler *handler)
{
+ /* if we haven't initialised sources previously (becuase we started in
+ * safe mode), then init once here. */
+ if (!(handler->udev || handler->network || handler->user_event)) {
+ device_handler_init_sources(handler);
+ return;
+ }
+
udev_reinit(handler->udev);
network_shutdown(handler->network);
diff --git a/discover/platform.c b/discover/platform.c
index 3ab6b7b..be60f00 100644
--- a/discover/platform.c
+++ b/discover/platform.c
@@ -43,6 +43,9 @@ static void dump_config(struct config *config)
if (config->network.n_interfaces || config->network.n_dns_servers)
pb_log(" network configuration:\n");
+ if (config->safe_mode)
+ pb_log(" safe mode: active\n");
+
for (i = 0; i < config->network.n_interfaces; i++) {
struct interface_config *ifconf =
config->network.interfaces[i];
OpenPOWER on IntegriCloud