summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--discover/device-handler.c18
-rw-r--r--discover/platform.c3
-rw-r--r--lib/pb-config/pb-config.c5
-rw-r--r--lib/pb-protocol/pb-protocol.c8
-rw-r--r--lib/types/types.h5
5 files changed, 30 insertions, 9 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index c57b7b6..a271390 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -386,28 +386,36 @@ static int default_option_priority(struct discover_boot_option *opt)
for (i = 0; i < config->n_boot_priorities; i++) {
prio = &config->boot_priorities[i];
if (priority_match(prio, opt))
- break;
+ return prio->priority;
}
- return i;
+ return 0;
}
static void set_default(struct device_handler *handler,
struct discover_boot_option *opt)
{
+ int new_prio;
+
if (!handler->autoboot_enabled)
return;
+ new_prio = default_option_priority(opt);
+
+ /* A negative priority indicates that we don't want to boot this device
+ * by default */
+ if (new_prio < 0)
+ return;
+
/* Resolve any conflicts: if we have a new default option, it only
* replaces the current if it has a higher priority. */
if (handler->default_boot_option) {
- int new_prio, cur_prio;
+ int cur_prio;
- new_prio = default_option_priority(opt);
cur_prio = default_option_priority(
handler->default_boot_option);
- if (new_prio < cur_prio) {
+ if (new_prio > cur_prio) {
handler->default_boot_option = opt;
/* extend the timeout a little, so the user sees some
* indication of the change */
diff --git a/discover/platform.c b/discover/platform.c
index d52c9f6..db0ea61 100644
--- a/discover/platform.c
+++ b/discover/platform.c
@@ -67,8 +67,9 @@ void config_set_defaults(struct config *config)
config->boot_priorities = talloc_array(config, struct boot_priority,
config->n_boot_priorities);
config->boot_priorities[0].type = DEVICE_TYPE_NETWORK;
+ config->boot_priorities[0].priority = 2;
config->boot_priorities[1].type = DEVICE_TYPE_DISK;
-
+ config->boot_priorities[1].priority = 1;
}
int platform_init(void *ctx)
diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c
index 35008cc..ed84fec 100644
--- a/lib/pb-config/pb-config.c
+++ b/lib/pb-config/pb-config.c
@@ -62,8 +62,11 @@ struct config *config_copy(void *ctx, const struct config *src)
dest->boot_priorities = talloc_array(dest, struct boot_priority,
src->n_boot_priorities);
- for (i = 0; i < src->n_boot_priorities; i++)
+ for (i = 0; i < src->n_boot_priorities; i++) {
+ dest->boot_priorities[i].priority =
+ src->boot_priorities[i].priority;
dest->boot_priorities[i].type = src->boot_priorities[i].type;
+ }
return dest;
}
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index 5a1cee7..3c472fe 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -279,7 +279,7 @@ int pb_protocol_config_len(const struct config *config)
len += 4 + optional_strlen(config->network.dns_servers[i]);
len += 4;
- len += config->n_boot_priorities * 4;
+ len += config->n_boot_priorities * 8;
return len;
}
@@ -464,7 +464,11 @@ int pb_protocol_serialise_config(const struct config *config,
*(uint32_t *)pos = __cpu_to_be32(config->n_boot_priorities);
pos += 4;
for (i = 0; i < config->n_boot_priorities; i++) {
- *(uint32_t *)pos = __cpu_to_be32(config->boot_priorities[i].type);
+ *(uint32_t *)pos =
+ __cpu_to_be32(config->boot_priorities[i].type);
+ pos += 4;
+ *(uint32_t *)pos =
+ __cpu_to_be32(config->boot_priorities[i].priority);
pos += 4;
}
diff --git a/lib/types/types.h b/lib/types/types.h
index 3a76cda..a1065ee 100644
--- a/lib/types/types.h
+++ b/lib/types/types.h
@@ -109,6 +109,11 @@ struct network_config {
};
struct boot_priority {
+ /* Boot options with higher priority values will take precedence over
+ * lower values. Negative priorities signify "don't boot this by
+ * default".
+ */
+ int priority;
enum device_type type;
};
OpenPOWER on IntegriCloud