summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--discover/device-handler.c10
-rw-r--r--discover/platform.c3
-rw-r--r--lib/pb-config/pb-config.c1
-rw-r--r--lib/pb-protocol/pb-protocol.c10
-rw-r--r--lib/types/types.h1
5 files changed, 24 insertions, 1 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];
diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c
index 2adc7b2..d43a5ab 100644
--- a/lib/pb-config/pb-config.c
+++ b/lib/pb-config/pb-config.c
@@ -42,6 +42,7 @@ struct config *config_copy(void *ctx, const struct config *src)
dest = talloc(ctx, struct config);
dest->autoboot_enabled = src->autoboot_enabled;
dest->autoboot_timeout_sec = src->autoboot_timeout_sec;
+ dest->safe_mode = src->safe_mode;
dest->network.n_interfaces = src->network.n_interfaces;
dest->network.interfaces = talloc_array(dest, struct interface_config *,
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index 67e1f9e..d39c1c4 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -267,7 +267,8 @@ int pb_protocol_config_len(const struct config *config)
unsigned int i, len;
len = 4 /* config->autoboot_enabled */ +
- 4 /* config->autoboot_timeout_sec */;
+ 4 /* config->autoboot_timeout_sec */ +
+ 4 /* config->safe_mode */;
len += 4;
for (i = 0; i < config->network.n_interfaces; i++)
@@ -448,6 +449,9 @@ int pb_protocol_serialise_config(const struct config *config,
*(uint32_t *)pos = __cpu_to_be32(config->autoboot_timeout_sec);
pos += 4;
+ *(uint32_t *)pos = config->safe_mode;
+ pos += 4;
+
*(uint32_t *)pos = __cpu_to_be32(config->network.n_interfaces);
pos += 4;
for (i = 0; i < config->network.n_interfaces; i++) {
@@ -862,6 +866,10 @@ int pb_protocol_deserialise_config(struct config *config,
if (read_u32(&pos, &len, &config->autoboot_timeout_sec))
goto out;
+ if (read_u32(&pos, &len, &tmp))
+ goto out;
+ config->safe_mode = !!tmp;
+
if (read_u32(&pos, &len, &config->network.n_interfaces))
goto out;
diff --git a/lib/types/types.h b/lib/types/types.h
index 762530a..0333a02 100644
--- a/lib/types/types.h
+++ b/lib/types/types.h
@@ -121,6 +121,7 @@ struct boot_priority {
struct config {
bool autoboot_enabled;
unsigned int autoboot_timeout_sec;
+ bool safe_mode;
struct network_config network;
struct boot_priority *boot_priorities;
unsigned int n_boot_priorities;
OpenPOWER on IntegriCloud