From nobody Tue Feb 10 12:58:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524495422813503.62793135576317; Mon, 23 Apr 2018 07:57:02 -0700 (PDT) Received: from localhost ([::1]:53329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fActp-0007w8-Qd for importer@patchew.org; Mon, 23 Apr 2018 10:57:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAcss-0007XX-OY for qemu-devel@nongnu.org; Mon, 23 Apr 2018 10:56:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fAcsp-0008WR-NL for qemu-devel@nongnu.org; Mon, 23 Apr 2018 10:56:02 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45102 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fAcsp-0008Vt-Ho; Mon, 23 Apr 2018 10:55:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0ED92EC010; Mon, 23 Apr 2018 14:55:55 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3110B215CDC8; Mon, 23 Apr 2018 14:55:48 +0000 (UTC) From: Thomas Huth To: Christian Borntraeger , qemu-s390x@nongnu.org, Viktor Mihajlovski Date: Mon, 23 Apr 2018 16:55:48 +0200 Message-Id: <1524495348-435-1-git-send-email-thuth@redhat.com> In-Reply-To: <1524470305-26484-1-git-send-email-thuth@redhat.com> References: <1524470305-26484-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 23 Apr 2018 14:55:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 23 Apr 2018 14:55:55 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 5/4] pc-bios/s390-ccw/net: Try to load pxelinux.cfg file accoring to the UUID X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Farhan Ali , Collin Walling , Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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) } } =20 +static int get_uuid(uint8_t *uuid) +{ + register int r0 asm("0"); + register int r1 asm("1"); + uint8_t *mem, *buf; + int i, chk =3D 0; + + mem =3D malloc(2 * PAGE_SIZE); + if (!mem) { + puts("Out of memory ... can not get UUID."); + return -12; + } + buf =3D (uint8_t *)(((uint64_t)mem + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)= ); + memset(buf, 0, PAGE_SIZE); + + /* Get SYSIB 3.2.2 */ + r0 =3D (3 << 28) | 2; + r1 =3D 2; + asm volatile(" stsi 0(%2)\n" : : "d" (r0), "d" (r1), "a" (buf) + : "cc", "memory"); + + for (i =3D 0; i < 16; i++) { + uuid[i] =3D buf[8 * 4 + 12 * 4 + i]; + chk |=3D 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]; =20 cfgbuf[sizeof(cfgbuf) - 1] =3D 0; /* Make sure that it is NUL-termin= ated */ =20 @@ -419,6 +451,19 @@ static int net_try_pxelinux_cfgs(filename_ip_t *fn_ip) =20 printf("Trying pxelinux.cfg files...\n"); =20 + /* Try to load config file with name based on the VM UUID */ + if (get_uuid(uuid) =3D=3D 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 =3D 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]); --=20 1.8.3.1