[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 5/4] pc-bios/s390-ccw/net: Try to load pxelinux.c
From: |
Thomas Huth |
Subject: |
[Qemu-devel] [PATCH v2 5/4] pc-bios/s390-ccw/net: Try to load pxelinux.cfg file accoring to the UUID |
Date: |
Mon, 23 Apr 2018 16:55:48 +0200 |
With the STSI instruction, we can get the UUID of the current VM instance,
so we can support loading pxelinux config files via UUID in the file name,
too.
Signed-off-by: Thomas Huth <address@hidden>
---
Sorry, just found out how to get the VM UUID after sending out the v2
series, so this is now patch 5 of 4 ;-)
pc-bios/s390-ccw/netmain.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
index fdf115e..f75bd7e 100644
--- a/pc-bios/s390-ccw/netmain.c
+++ b/pc-bios/s390-ccw/netmain.c
@@ -286,6 +286,37 @@ static void net_release(filename_ip_t *fn_ip)
}
}
+static int get_uuid(uint8_t *uuid)
+{
+ register int r0 asm("0");
+ register int r1 asm("1");
+ uint8_t *mem, *buf;
+ int i, chk = 0;
+
+ mem = malloc(2 * PAGE_SIZE);
+ if (!mem) {
+ puts("Out of memory ... can not get UUID.");
+ return -12;
+ }
+ buf = (uint8_t *)(((uint64_t)mem + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1));
+ memset(buf, 0, PAGE_SIZE);
+
+ /* Get SYSIB 3.2.2 */
+ r0 = (3 << 28) | 2;
+ r1 = 2;
+ asm volatile(" stsi 0(%2)\n" : : "d" (r0), "d" (r1), "a" (buf)
+ : "cc", "memory");
+
+ for (i = 0; i < 16; i++) {
+ uuid[i] = buf[8 * 4 + 12 * 4 + i];
+ chk |= uuid[i];
+ }
+
+ free(mem);
+
+ return chk ? 0 : -1;
+}
+
/* This structure holds the data from one pxelinux.cfg file entry */
struct lkia {
const char *label;
@@ -403,6 +434,7 @@ static int net_try_pxelinux_cfgs(filename_ip_t *fn_ip)
int rc, idx;
char basedir[256];
int has_basedir;
+ uint8_t uuid[16];
cfgbuf[sizeof(cfgbuf) - 1] = 0; /* Make sure that it is NUL-terminated */
@@ -419,6 +451,19 @@ static int net_try_pxelinux_cfgs(filename_ip_t *fn_ip)
printf("Trying pxelinux.cfg files...\n");
+ /* Try to load config file with name based on the VM UUID */
+ if (get_uuid(uuid) == 0) {
+ sprintf((char *)fn_ip->filename, "%s%02x%02x%02x%02x-%02x%02x-"
+ "%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", basedir,
+ uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5],
+ uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11],
+ uuid[12], uuid[13], uuid[14], uuid[15]);
+ rc = tftp_load(fn_ip, cfgbuf, sizeof(cfgbuf) - 1);
+ if (rc > 0) {
+ return handle_pxelinux_cfg(fn_ip, cfgbuf, sizeof(cfgbuf));
+ }
+ }
+
/* Look for config file with MAC address in its name */
sprintf((char *)fn_ip->filename, "%s%02x-%02x-%02x-%02x-%02x-%02x",
basedir, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
--
1.8.3.1
- [Qemu-devel] [PATCH v2 0/4] pc-bios/s390-ccw: Network boot improvements, Thomas Huth, 2018/04/23
- [Qemu-devel] [PATCH v2 3/4] pc-bios/s390-ccw/net: Add support for .INS config files, Thomas Huth, 2018/04/23
- [Qemu-devel] [PATCH v2 1/4] pc-bios/s390-ccw/net: Split up net_load() into init, load and uninit parts, Thomas Huth, 2018/04/23
- [Qemu-devel] [PATCH v2 4/4] pc-bios/s390-ccw/net: Use diag308 to reset machine before jumping to the OS, Thomas Huth, 2018/04/23
- [Qemu-devel] [PATCH v2 2/4] pc-bios/s390-ccw/net: Add support for pxelinux-style config files, Thomas Huth, 2018/04/23
- Re: [Qemu-devel] [PATCH v2 2/4] pc-bios/s390-ccw/net: Add support for pxelinux-style config files, Viktor VM Mihajlovski, 2018/04/24
- [Qemu-devel] [PATCH v2 5/4] pc-bios/s390-ccw/net: Try to load pxelinux.cfg file accoring to the UUID,
Thomas Huth <=