config: Add boot_device member to config
authorJeremy Kerr <jk@ozlabs.org>
Wed, 30 Apr 2014 02:17:20 +0000 (10:17 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 21 Jul 2014 09:20:08 +0000 (17:20 +0800)
We'd like to specify a way to only boot from a specific block device;
this adds a field to the configuration to hold the value.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/pb-config/pb-config.c
lib/pb-protocol/pb-protocol.c
lib/types/types.h

index ed84fec9e76d8dc4fc21859eebdeed8fa9cd3f8f..2adc7b248d8b956569ff971464cf6e2bc74092e4 100644 (file)
@@ -68,5 +68,10 @@ struct config *config_copy(void *ctx, const struct config *src)
                dest->boot_priorities[i].type = src->boot_priorities[i].type;
        }
 
                dest->boot_priorities[i].type = src->boot_priorities[i].type;
        }
 
+       if (src->boot_device && strlen(src->boot_device))
+               dest->boot_device = talloc_strdup(dest, src->boot_device);
+       else
+               dest->boot_device = NULL;
+
        return dest;
 }
        return dest;
 }
index cf27b8ec49c35ff47bfdfff00cc43f36e9f06015..4a5c75a32437b1e4bd201eba7d5a760288ad55ad 100644 (file)
@@ -472,6 +472,8 @@ int pb_protocol_serialise_config(const struct config *config,
                pos += 4;
        }
 
                pos += 4;
        }
 
+       pos += pb_protocol_serialise_string(pos, config->boot_device);
+
        assert(pos <= buf + buf_len);
        (void)buf_len;
 
        assert(pos <= buf + buf_len);
        (void)buf_len;
 
@@ -846,6 +848,7 @@ int pb_protocol_deserialise_config(struct config *config,
        unsigned int len, i, tmp;
        const char *pos;
        int rc = -1;
        unsigned int len, i, tmp;
        const char *pos;
        int rc = -1;
+       char *str;
 
        len = message->payload_len;
        pos = message->payload;
 
        len = message->payload_len;
        pos = message->payload;
@@ -878,10 +881,9 @@ int pb_protocol_deserialise_config(struct config *config,
                        config->network.n_dns_servers);
 
        for (i = 0; i < config->network.n_dns_servers; i++) {
                        config->network.n_dns_servers);
 
        for (i = 0; i < config->network.n_dns_servers; i++) {
-               char *tmp;
-               if (read_string(config->network.dns_servers, &pos, &len, &tmp))
+               if (read_string(config->network.dns_servers, &pos, &len, &str))
                        goto out;
                        goto out;
-               config->network.dns_servers[i] = tmp;
+               config->network.dns_servers[i] = str;
        }
 
        if (read_u32(&pos, &len, &config->n_boot_priorities))
        }
 
        if (read_u32(&pos, &len, &config->n_boot_priorities))
@@ -898,6 +900,11 @@ int pb_protocol_deserialise_config(struct config *config,
                config->boot_priorities[i].type = tmp;
        }
 
                config->boot_priorities[i].type = tmp;
        }
 
+       if (read_string(config, &pos, &len, &str))
+               goto out;
+
+       config->boot_device = str;
+
        rc = 0;
 
 out:
        rc = 0;
 
 out:
index 129319309cc0882ee36f3c7775fe56e780e1afd1..762530a36d46467d3770e3411d8f1460fabdab5c 100644 (file)
@@ -124,6 +124,7 @@ struct config {
        struct network_config   network;
        struct boot_priority    *boot_priorities;
        unsigned int            n_boot_priorities;
        struct network_config   network;
        struct boot_priority    *boot_priorities;
        unsigned int            n_boot_priorities;
+       char                    *boot_device;
 };
 
 #endif /* _TYPES_H */
 };
 
 #endif /* _TYPES_H */