summaryrefslogtreecommitdiffstats
path: root/lib/pb-config/storage-test.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-01-29 13:28:06 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-01-30 21:59:10 +0800
commitc14b12980885edd035322cd3bc87efff444c39b1 (patch)
tree138bac8bfacd9d1a36d04421d91e0eedf4164da2 /lib/pb-config/storage-test.c
parentdea7842fb28ff055b4e0f43a6a1fdaf3c4b5ba89 (diff)
downloadtalos-petitboot-c14b12980885edd035322cd3bc87efff444c39b1.tar.gz
talos-petitboot-c14b12980885edd035322cd3bc87efff444c39b1.zip
pb-config: Move config storage modules to "platform" modules in discover code
There's no need to include the config storage code in lib/ as only the discover server should be using it. This change moves the config-storage code to discover/, with the platform-specific parts moved to a 'struct platform'. Each platform has a probe function, which is called during init. The first probe function to return a platform is used. At present we only have the one platform, but it's now non-intrusive to add others. We keep an array of platform pointers in a separate ("platforms") section, to allow the test module to drop-in its own test "platform". Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'lib/pb-config/storage-test.c')
-rw-r--r--lib/pb-config/storage-test.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/lib/pb-config/storage-test.c b/lib/pb-config/storage-test.c
deleted file mode 100644
index 48cb238..0000000
--- a/lib/pb-config/storage-test.c
+++ /dev/null
@@ -1,73 +0,0 @@
-
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include <util/util.h>
-
-#include "pb-config.h"
-#include "storage.h"
-
-struct interface_config net1 = {
- .hwaddr = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 },
- .method = CONFIG_METHOD_DHCP,
-};
-
-struct interface_config net2 = {
- .hwaddr = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x56 },
- .method = CONFIG_METHOD_STATIC,
- .static_config = {
- .address = "192.168.0.2/24",
- .gateway = "192.168.0.1",
- },
-};
-
-struct interface_config *interface_configs[] = { &net1, &net2 };
-const char *dns_servers[] = { "192.168.1.1", "192.168.1.2" };
-
-struct config test_config = {
- .autoboot_enabled = true,
- .network = {
- .interfaces = interface_configs,
- .n_interfaces = ARRAY_SIZE(interface_configs),
- .dns_servers = dns_servers,
- .n_dns_servers = ARRAY_SIZE(dns_servers),
- }
-};
-
-struct test_storage {
- struct config_storage storage;
- struct param *params;
- int n_params;
- struct config *config;
-};
-
-#define to_test_storage(st) container_of(st, struct test_storage, storage)
-
-static int load(struct config_storage *st, struct config *config)
-{
- struct test_storage *ts = to_test_storage(st);
- memcpy(config, ts->config, sizeof(test_config));
- return 0;
-}
-
-static int save(struct config_storage *st, struct config *newconfig)
-{
- struct test_storage *ts = to_test_storage(st);
- ts->config = newconfig;
- return 0;
-}
-
-static struct test_storage st = {
- .storage = {
- .load = load,
- .save = save,
- },
-};
-
-struct config_storage *create_test_storage(void *ctx __attribute__((unused)))
-{
- st.config = &test_config;
- return &st.storage;
-}
OpenPOWER on IntegriCloud