aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2018-05-26 08:06:08 +0200
committerAlexey Kardashevskiy <aik@ozlabs.ru>2018-05-29 19:08:14 +1000
commit64c526a6020c3042e3b2a505d5f5f11478d5f2cb (patch)
tree34065f6fe2f961fe004614b3e60c717fdd9b27ed /lib
parent5092c97eda8900070bc0be084526c89de5eed3a8 (diff)
downloadSLOF-64c526a6020c3042e3b2a505d5f5f11478d5f2cb.zip
SLOF-64c526a6020c3042e3b2a505d5f5f11478d5f2cb.tar.gz
SLOF-64c526a6020c3042e3b2a505d5f5f11478d5f2cb.tar.bz2
libnet: Support UUID-based pxelinux.cfg file names
Retrieve the UUID from the device tree and pass it to the pxelinux.cfg function, so that we can look there for UUID-based file names, too. Signed-off-by: Thomas Huth <thuth@redhat.com> [aik: removed trailing space] Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'lib')
-rw-r--r--lib/libnet/netload.c18
-rw-r--r--lib/libnet/pxelinux.c16
-rw-r--r--lib/libnet/pxelinux.h2
3 files changed, 31 insertions, 5 deletions
diff --git a/lib/libnet/netload.c b/lib/libnet/netload.c
index 4c7ac37..f7ec341 100644
--- a/lib/libnet/netload.c
+++ b/lib/libnet/netload.c
@@ -427,6 +427,21 @@ static int tftp_load(filename_ip_t *fnip, void *buffer, int len,
return rc;
}
+static const char *get_uuid(void)
+{
+ char *addr;
+ int len;
+
+ if (SLOF_get_property("/", "system-id", &addr, &len))
+ return NULL;
+ if (len < 37) { /* This should never happen... */
+ puts("Warning: UUID property is too short.");
+ return NULL;
+ }
+
+ return addr;
+}
+
#define CFG_BUF_SIZE 2048
#define MAX_PL_CFG_ENTRIES 16
static int net_pxelinux_load(filename_ip_t *fnip, char *loadbase,
@@ -442,7 +457,8 @@ static int net_pxelinux_load(filename_ip_t *fnip, char *loadbase,
return -1;
}
- rc = pxelinux_load_parse_cfg(fnip, mac, retries, cfgbuf, CFG_BUF_SIZE,
+ rc = pxelinux_load_parse_cfg(fnip, mac, get_uuid(), retries,
+ cfgbuf, CFG_BUF_SIZE,
entries, MAX_PL_CFG_ENTRIES, &def);
if (rc < 0)
goto out_free;
diff --git a/lib/libnet/pxelinux.c b/lib/libnet/pxelinux.c
index 91b3c13..718ceca 100644
--- a/lib/libnet/pxelinux.c
+++ b/lib/libnet/pxelinux.c
@@ -51,7 +51,7 @@ static int pxelinux_tftp_load(filename_ip_t *fnip, void *buffer, int len,
* Try to load a pxelinux.cfg file by probing the possible file names.
* Note that this function will overwrite filename_ip_t->filename.
*/
-static int pxelinux_load_cfg(filename_ip_t *fn_ip, uint8_t *mac,
+static int pxelinux_load_cfg(filename_ip_t *fn_ip, uint8_t *mac, const char *uuid,
int retries, char *cfgbuf, int cfgbufsize)
{
int rc, idx;
@@ -101,6 +101,15 @@ static int pxelinux_load_cfg(filename_ip_t *fn_ip, uint8_t *mac,
}
}
+ /* Try to load config file with name based on the VM UUID */
+ if (uuid) {
+ strcpy(baseptr, uuid);
+ rc = pxelinux_tftp_load(fn_ip, cfgbuf, cfgbufsize - 1, retries);
+ if (rc > 0) {
+ return rc;
+ }
+ }
+
/* Look for config file with MAC address in its name */
sprintf(baseptr, "01-%02x-%02x-%02x-%02x-%02x-%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
@@ -215,6 +224,7 @@ nextline:
* Try to load and parse a pxelinux-style configuration file.
* @param fn_ip must contain server and client IP information
* @param mac MAC address which should be used for probing
+ * @param uuid UUID which should be used for probing (can be NULL)
* @param retries Amount of TFTP retries before giving up
* @param cfgbuf Pointer to the buffer where config file should be loaded
* @param cfgsize Size of the cfgbuf buffer
@@ -223,14 +233,14 @@ nextline:
* @param def_ent Used to return the index of the default entry
* @return Number of valid entries
*/
-int pxelinux_load_parse_cfg(filename_ip_t *fn_ip, uint8_t *mac,
+int pxelinux_load_parse_cfg(filename_ip_t *fn_ip, uint8_t *mac, const char *uuid,
int retries, char *cfgbuf, int cfgsize,
struct pl_cfg_entry *entries, int max_entries,
int *def_ent)
{
int rc;
- rc = pxelinux_load_cfg(fn_ip, mac, retries, cfgbuf, cfgsize);
+ rc = pxelinux_load_cfg(fn_ip, mac, uuid, retries, cfgbuf, cfgsize);
if (rc < 0)
return rc;
diff --git a/lib/libnet/pxelinux.h b/lib/libnet/pxelinux.h
index 98b3925..0514d0d 100644
--- a/lib/libnet/pxelinux.h
+++ b/lib/libnet/pxelinux.h
@@ -25,7 +25,7 @@ struct pl_cfg_entry {
int pxelinux_parse_cfg(char *cfg, int cfgsize, struct pl_cfg_entry *entries,
int max_entries, int *def_ent);
-int pxelinux_load_parse_cfg(filename_ip_t *fn_ip, uint8_t *mac,
+int pxelinux_load_parse_cfg(filename_ip_t *fn_ip, uint8_t *mac, const char *uuid,
int retries, char *cfgbuf, int cfgsize,
struct pl_cfg_entry *entries,
int max_entries, int *def_ent);