summaryrefslogtreecommitdiffstats
path: root/discover/pxe-parser.c
diff options
context:
space:
mode:
authorNeelesh Gupta <neelegup@linux.vnet.ibm.com>2013-10-28 12:45:21 +0530
committerJeremy Kerr <jk@ozlabs.org>2013-11-06 16:34:26 +0800
commitb8e53cb4b96eb17dc7fa0ffc505dfebae37e6cbf (patch)
tree2049ee274a9a7872366da8b95dbecaffc215df3a /discover/pxe-parser.c
parentf385e8cacbc574e213b0805a8d383373f29a8058 (diff)
downloadtalos-petitboot-b8e53cb4b96eb17dc7fa0ffc505dfebae37e6cbf.tar.gz
talos-petitboot-b8e53cb4b96eb17dc7fa0ffc505dfebae37e6cbf.zip
discover: Change parsers to explicitly request configuration files
Add a new function parser_request_url() to read the data from configuration files present remotely. We deprecate iterate_parser_files() and download_config() functions along with the 'filenames' and 'method' members of the 'parser' structure so that individual parsers would now require to request the configuration files data from the parser code and doesn't necessarily export the list of configuration files. Add the support to handle incoming DHCP event, done by passing all the relevant environment variables of the udhcpc to the discover code. Also, update the pxe parser code to populate the list of configuration file names as per PXELINUX convention of fallback names using mac and ip addresses of the booting machine. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/pxe-parser.c')
-rw-r--r--discover/pxe-parser.c62
1 files changed, 58 insertions, 4 deletions
diff --git a/discover/pxe-parser.c b/discover/pxe-parser.c
index 368d5c7..bc07a13 100644
--- a/discover/pxe-parser.c
+++ b/discover/pxe-parser.c
@@ -9,6 +9,8 @@
#include "parser-conf.h"
#include "parser-utils.h"
#include "resource.h"
+#include "paths.h"
+#include "user-event.h"
struct pxe_parser_info {
struct discover_boot_option *opt;
@@ -91,15 +93,23 @@ static void pxe_process_pair(struct conf_context *ctx,
}
-static int pxe_parse(struct discover_context *dc, char *buf, int len)
+static int pxe_parse(struct discover_context *dc)
{
struct pxe_parser_info *parser_info;
+ char **pxe_conf_files, **filename;
+ struct pb_url *conf_url, *url;
struct conf_context *conf;
+ int len, rc;
+ char *buf;
+
+ /* Expects dhcp event parameters to support network boot */
+ if (!dc->event)
+ return -1;
conf = talloc_zero(dc, struct conf_context);
if (!conf)
- return 0;
+ goto out;
conf->dc = dc;
conf->get_pair = conf_get_pair_space;
@@ -109,16 +119,60 @@ static int pxe_parse(struct discover_context *dc, char *buf, int len)
parser_info = talloc_zero(conf, struct pxe_parser_info);
conf->parser_info = parser_info;
+ conf_url = user_event_parse_conf_url(dc, dc->event);
+ if (!conf_url)
+ goto out_conf;
+
+ if (dc->conf_url) {
+ rc = parser_request_url(dc, dc->conf_url, &buf, &len);
+ if (rc)
+ goto out_conf;
+ } else {
+ pxe_conf_files = user_event_parse_conf_filenames(dc, dc->event);
+ if (!pxe_conf_files)
+ goto out_conf;
+
+ for (filename = pxe_conf_files; *filename; filename++) {
+ url = pb_url_join(dc, conf_url, *filename);
+ if (!url)
+ goto out_pxe_conf;
+
+ rc = parser_request_url(dc, url, &buf, &len);
+ if (!rc) /* found one, just break */
+ break;
+
+ talloc_free(url);
+ }
+
+ /* No configuration file found on the boot server */
+ if (rc)
+ goto out_pxe_conf;
+
+ dc->conf_url = url;
+
+ talloc_free(conf_url);
+ talloc_free(pxe_conf_files);
+ }
+
+ /* Call the config file parser with the data read from the file */
conf_parse_buf(conf, buf, len);
+ talloc_free(buf);
+ talloc_free(conf);
+
+ return 0;
+
+out_pxe_conf:
+ talloc_free(pxe_conf_files);
+out_conf:
talloc_free(conf);
- return 1;
+out:
+ return -1;
}
static struct parser pxe_parser = {
.name = "pxe",
.parse = pxe_parse,
- .method = CONF_METHOD_DHCP,
};
register_parser(pxe_parser);
OpenPOWER on IntegriCloud