From nobody Thu Apr 25 11:49:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=fail (BodyHash is different from the expected one) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1572044009094869.9188722809703; Fri, 25 Oct 2019 15:53:29 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iO8RS-0004E8-0G; Fri, 25 Oct 2019 22:52:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iO8RR-0004Dy-7k for xen-devel@lists.xenproject.org; Fri, 25 Oct 2019 22:52:21 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (unknown [40.107.6.130]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1916ed44-f77a-11e9-94cd-12813bfff9fa; Fri, 25 Oct 2019 22:52:19 +0000 (UTC) Received: from VI1PR06MB4720.eurprd06.prod.outlook.com (20.177.200.18) by VI1PR06MB5583.eurprd06.prod.outlook.com (20.177.202.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Fri, 25 Oct 2019 22:52:17 +0000 Received: from VI1PR06MB4720.eurprd06.prod.outlook.com ([fe80::d067:c8d1:e873:5632]) by VI1PR06MB4720.eurprd06.prod.outlook.com ([fe80::d067:c8d1:e873:5632%5]) with mapi id 15.20.2387.021; Fri, 25 Oct 2019 22:52:17 +0000 X-Inumbo-ID: 1916ed44-f77a-11e9-94cd-12813bfff9fa ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ckMrotn2uZ8SmceBwdIfloeui/Dq/j9zBQaKB8iaWhIKJ/FVH81EfrKhHBBvCShiQgcOFVWAwyohwqattFDDjM9fRM0Oo3Etw+IAmPnw3LYJVHl/C8tvuga+C5vmR0Vun6jlkJE6gUtIu5CYcoYQiFWm7wtyiiVEbFVSlN8bFoWolSAQzMMgqwmIhovTtX5OS4yMT4QWLK+y1BUr3ob8BgJ4Ze8/wkOpRjGjjntT50mcfRNNAoSKKWvUGFiY6NoGD9xO8YesNhtutFa8PLbzI90RzFw8gxoYAIBdiJp9Kp4SMTB1++W+FezEc5papd86A8ZpnHcRRWtLDgswb+SVcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cqQssvL0QFp0PYbissrRB7wzp7O6AgiJU0bpAsVoq18=; b=oFXFkqCRJYt3ttE7wQQa0p5wBzji9ktFPTT08U0QMIdyVIk5Gl8Ue65Dna6ZYtoQRqwYGORX4Wg+2byhQzWOt3ztcG/xVh4dENoLskUajWsJhqSbR4+qrmaDArzr+LQBWXWDcuUDcCK/+/fFE5/A8mzjdBEB9nMwzVSHg4LghGOC+ZXflSQnYXVBleGtztstqUbUOn/4tE43E6pn9V46ocqcKd8L9baNwabYt/dz3kVCn76QAaUlm/mu4u3v9RYS34CFN5rEkcJdcxxOUBJOWxjNAV629Kt41HyHGbfb34z/GIKVAgeCGuMcKeSnO4tJX3nmOVBhb2s7l5xB4U+jgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=durham.ac.uk; dmarc=pass action=none header.from=durham.ac.uk; dkim=pass header.d=durham.ac.uk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=durhamuniversity.onmicrosoft.com; s=selector2-durhamuniversity-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cqQssvL0QFp0PYbissrRB7wzp7O6AgiJU0bpAsVoq18=; b=N3XIF6m10e7O0PKECg3vYqdC6zoRwRReNllE/T/gIQoOcZSd5rne02Re0KA7sVoG0tgCbpbU/eeOcrUCu7rQa+diaScN9fOFmWN3uuRw+11wXF0aQm8dz+VLkRXkSMUrasKC8zhynGqx5S1GDr63Zu0fuC/EEKrmxV4ZkoAqqWY= From: "YOUNG, MICHAEL A." To: "xen-devel@lists.xenproject.org" Thread-Topic: [XEN PATCH 1/3] set default kernel from grubenv next_entry or saved_entry Thread-Index: AQHVi4bZp6Rlls8E60iiZZ95hwr4Gg== Date: Fri, 25 Oct 2019 22:52:17 +0000 Message-ID: <30a4fb6bb023348af867a253f6ff1e80efc7e232.1572038720.git.m.a.young@durham.ac.uk> References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2a00:23c4:921a:2100:1097:224c:243b:f186] x-mailer: git-send-email 2.21.0 x-clientproxiedby: LNXP123CA0016.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:d2::28) To VI1PR06MB4720.eurprd06.prod.outlook.com (2603:10a6:803:90::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=m.a.young@durham.ac.uk; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6c9b051d-2318-411c-3c2b-08d7599dfc03 x-ms-traffictypediagnostic: VI1PR06MB5583: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1051; x-forefront-prvs: 02015246A9 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(136003)(366004)(346002)(376002)(396003)(199004)(189003)(66476007)(66946007)(256004)(8676002)(8936002)(81156014)(50226002)(66556008)(305945005)(7736002)(2501003)(54906003)(36756003)(66446008)(186003)(5660300002)(14454004)(86362001)(76176011)(786003)(316002)(52116002)(102836004)(386003)(6506007)(6436002)(2616005)(6512007)(71200400001)(71190400001)(446003)(64756008)(99286004)(6486002)(11346002)(25786009)(486006)(5640700003)(478600001)(4326008)(476003)(2906002)(118296001)(46003)(6116002)(6916009)(2351001)(81166006)(14444005); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR06MB5583; H:VI1PR06MB4720.eurprd06.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; received-spf: None (protection.outlook.com: durham.ac.uk does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: zMJe54zRgfoNoS/SEAxRJZ3PMcXMIn+Uf8/jrterrvxLAdyy7rSkT5VPk0x5OWuEuNmqc9WnYoXsXMkz0TDXoYYH1NVQdOOKPIKWFWoCVUpOXT390N91i6oiVc5bFu+IuHdxUJRbEVYacoF8CktwOHQxQz5llKlNePDB+wrZgHtNOelsElgxt9JR3GIYsGJM58nBk0eFJ/LH7BCOY+1+iZ/VqCnQ3c7bxtY0GKbkj3W5PmTe8aMDVT5fP6gzn/FiPtpCcdtLyryK7BRtR73JdoViR/rHqRPtUc0hLtfD5UfPKjV3E19K0rZ+k/RUejY9PHJ9SoOaOIgI/JfJY+vig9xzkR6nLDq44PB3nZCMJoyhiJ47kkCZfkefKCzK5uDGHAKW53y3SOhB/tAwI1DUiHKgi0ed15ke5dtleZGOUxsGl0ygStsNYA0/2YIg3sq8 MIME-Version: 1.0 X-OriginatorOrg: durham.ac.uk X-MS-Exchange-CrossTenant-Network-Message-Id: 6c9b051d-2318-411c-3c2b-08d7599dfc03 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2019 22:52:17.0791 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7250d88b-4b68-4529-be44-d59a2d8a6f94 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: yuFjdmEKyMrCQak5fkv3Hg6BAFYBb+M0bb+mBYukr99St9Hf0Jh+vW+N+8egzO+eYHzkcTTFtQ3OUgWWBO9bfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR06MB5583 Subject: [Xen-devel] [XEN PATCH 1/3] set default kernel from grubenv next_entry or saved_entry X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Wei Liu , "YOUNG, MICHAEL A." Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This patch reads the contents of a grubenv file if available, and uses the value of next_entry (in preference) or of saved_entry to set the default kernel if there is a matching title or if it is a number. If either next_entry or saved_entry is set and neither is used then the default is set to 0. Signed-off-by: Michael Young Tested-by: Steven Haigh --- tools/pygrub/src/GrubConf.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py index 73f1bbed2f..1fc68cadb2 100644 --- a/tools/pygrub/src/GrubConf.py +++ b/tools/pygrub/src/GrubConf.py @@ -368,7 +368,7 @@ class Grub2ConfigFile(_GrubConfigFile): def new_image(self, title, lines): return Grub2Image(title, lines) =20 - def parse(self, buf =3D None): + def parse(self, buf =3D None, grubenv =3D None): if buf is None: if self.filename is None: raise ValueError("No config file defined to parse!") @@ -379,10 +379,17 @@ class Grub2ConfigFile(_GrubConfigFile): else: lines =3D buf.split("\n") =20 + if grubenv is not None: + lines =3D grubenv.split("\n") + lines + in_function =3D False img =3D None title =3D "" menu_level=3D0 + img_count=3D0 + saved_entry =3D "" + next_entry =3D "" + entry_matched =3D False for l in lines: l =3D l.strip() # skip blank lines @@ -408,6 +415,13 @@ class Grub2ConfigFile(_GrubConfigFile): raise RuntimeError("syntax error: cannot nest menuentr= y (%d %s)" % (len(img),img)) img =3D [] title =3D title_match.group(1) + if title =3D=3D next_entry: + setattr(self, 'default', img_count) + entry_matched =3D True + if title =3D=3D saved_entry and not entry_matched: + setattr(self, 'default', img_count) + entry_matched =3D True + img_count +=3D 1 continue =20 if l.startswith("submenu"): @@ -432,6 +446,14 @@ class Grub2ConfigFile(_GrubConfigFile): =20 (com, arg) =3D grub_exact_split(l, 2) =20 + if com =3D=3D "next_entry": + next_entry =3D arg + continue + + if com =3D=3D "saved_entry": + saved_entry =3D arg + continue + if com =3D=3D "set": (com,arg) =3D grub2_handle_set(arg) =20 @@ -448,6 +470,13 @@ class Grub2ConfigFile(_GrubConfigFile): pass else: logging.warning("Unknown directive %s" %(com,)) + + if next_entry.isdigit(): + setattr(self, 'default', next_entry) + elif saved_entry.isdigit() and not entry_matched: + setattr(self, 'default', saved_entry) + elif (next_entry !=3D "" or saved_entry !=3D "") and not entry_mat= ched: + setattr(self, 'default', 0) =20 if img is not None: raise RuntimeError("syntax error: end of file with open menuen= try(%d %s)" % (len(img),img)) --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 11:49:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=fail (BodyHash is different from the expected one) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1572044010446339.9358769370135; Fri, 25 Oct 2019 15:53:30 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iO8RX-0004FB-A9; Fri, 25 Oct 2019 22:52:27 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iO8RW-0004F2-5t for xen-devel@lists.xenproject.org; Fri, 25 Oct 2019 22:52:26 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (unknown [40.107.6.97]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1aee5bfc-f77a-11e9-94cd-12813bfff9fa; Fri, 25 Oct 2019 22:52:22 +0000 (UTC) Received: from VI1PR06MB4720.eurprd06.prod.outlook.com (20.177.200.18) by VI1PR06MB5583.eurprd06.prod.outlook.com (20.177.202.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Fri, 25 Oct 2019 22:52:21 +0000 Received: from VI1PR06MB4720.eurprd06.prod.outlook.com ([fe80::d067:c8d1:e873:5632]) by VI1PR06MB4720.eurprd06.prod.outlook.com ([fe80::d067:c8d1:e873:5632%5]) with mapi id 15.20.2387.021; Fri, 25 Oct 2019 22:52:21 +0000 X-Inumbo-ID: 1aee5bfc-f77a-11e9-94cd-12813bfff9fa ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XCmHEVol8SfXRVCPZ1zaFUQwK8iltlTA/2mJ2wxZ/gv6NL/ux6RNeg+Gk2dHZ2FaaSh8ZvNWLpHXPh1dqnzDvbuAx8TcA86F/BeAfzwRE68LvTmRbbX4Wwx5WubM5SGw01NOou2sIxdB6SDqxsngblVYyMQu665xZWG/IT+/2uv6zBfEN9z/4+3hEhcRs3gYKaEfPufmOIbC5I6Xt/iB4HtDid5UdYl8tToV+xl+M8ZUu//fTzgAJn2M9aPtdtIakJN2Wuex+fDwlAt7TaXuhNUGD++DSKRxJDmdzDnldwEMPsJoIk5x3+bibjqDXopBfYYJhBfLSRsDB8jyq9TBtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j7TaoTyM0pJll+A8glmDyS4mzp9+V71BAb5vP2iXglA=; b=WREPHqwU2O5LOVmxhiE22rcACpS6mz5PB4mjC1/Fku5jTO0bdsS2inePD65UZu2RCxBJlPvepcGKsRNlT10M9d4vJYSpqEx4aZuNlXgK+r/I49XOptDJaQhXYSBDKCggHi5GydKDJ+6rP4hbRth2Q0pz2J43cfXKAYSEB3GE5nZXDJegXEKfmJe9jbxMAcwsQYdEyPvwT7JetLPhOiurc5faVM8IA1e7919Indn4QHkqDR5+gxe9nAfW9mQA+pRxuL6hDcQ2GzMOMZgje4Rn8Vs/i2gesOVk3XYBCz0CB80NLJYTTIu1jX+sfvwjj26DWFq5LnBfmHyNY0m1ZIkUvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=durham.ac.uk; dmarc=pass action=none header.from=durham.ac.uk; dkim=pass header.d=durham.ac.uk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=durhamuniversity.onmicrosoft.com; s=selector2-durhamuniversity-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j7TaoTyM0pJll+A8glmDyS4mzp9+V71BAb5vP2iXglA=; b=nhTacVqbzVS5eqhnppdGzUikVqw7KNtLM0/xm/ali8Jj0KuEAYajE5qnfVAw984bdc8SXhrXrEu0z+LoTqy4shiGF8TRKgtPlIFrL1agq438RBMqDw/493q/rip6mcONtqXP/w2MnQvk+fgljLaPyVp7crPWR5tPbpFlulzLZ6g= From: "YOUNG, MICHAEL A." To: "xen-devel@lists.xenproject.org" Thread-Topic: [XEN PATCH 2/3] read a grubenv file if it is next to the grub.cfg file Thread-Index: AQHVi4bcsVc5X9HnfkOVxxCiimkx9Q== Date: Fri, 25 Oct 2019 22:52:21 +0000 Message-ID: <2491e384fae5399baf8639e07882f8ee687b6370.1572038720.git.m.a.young@durham.ac.uk> References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2a00:23c4:921a:2100:1097:224c:243b:f186] x-mailer: git-send-email 2.21.0 x-clientproxiedby: LNXP123CA0016.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:d2::28) To VI1PR06MB4720.eurprd06.prod.outlook.com (2603:10a6:803:90::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=m.a.young@durham.ac.uk; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 97f7528c-86d6-4662-7643-08d7599dfeac x-ms-traffictypediagnostic: VI1PR06MB5583: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 02015246A9 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(136003)(366004)(346002)(376002)(396003)(199004)(189003)(66476007)(66946007)(256004)(8676002)(8936002)(81156014)(50226002)(66556008)(305945005)(7736002)(2501003)(54906003)(36756003)(66446008)(186003)(5660300002)(14454004)(86362001)(76176011)(786003)(316002)(52116002)(102836004)(386003)(6506007)(6436002)(2616005)(6512007)(71200400001)(71190400001)(446003)(64756008)(99286004)(6486002)(11346002)(25786009)(486006)(5640700003)(478600001)(4326008)(476003)(2906002)(118296001)(46003)(6116002)(6916009)(2351001)(81166006)(14444005); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR06MB5583; H:VI1PR06MB4720.eurprd06.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; received-spf: None (protection.outlook.com: durham.ac.uk does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: mIGl+HEXn+erTnOy1hSC14DVP9J1d9RT7cJk0uCXDqdqd6BwAwlRQr2auMfZvRO6q8vo7J0jR/AsyzGBgnGumBnroW6zJtmF6+TMDCSSpq5ZtvL/BCfH1t5d968eIIsduAH7ghdOZ/O48M64IwEl+TzFICNZ37njXCudmYdzzEazVQPEMfxmuwB6hBdFIppAVHItllIeZgkDkJuNQwxRYBLgai4xK8h+JnNuUmx3rgwhI2QcP72CeND9X5iAdV+MSaSwEw79FNk1jJHvsllvIM5qUmyDp8QoV+/7QAqVF/1fz2Qcbadiq0xX2slnuivJymKqWCCr9gHoSwTU1qlZ/t1VSQM/3vefzFU9ZeS6qbntgb9ypsSw5A2zDR1YsAEtSMT0ymPDaNcikxxRFZ/Ok4E7tgaFle9mvXbtGIxIHOsXC+52ZJB/LPdtcG4z6f7G MIME-Version: 1.0 X-OriginatorOrg: durham.ac.uk X-MS-Exchange-CrossTenant-Network-Message-Id: 97f7528c-86d6-4662-7643-08d7599dfeac X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2019 22:52:21.5406 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7250d88b-4b68-4529-be44-d59a2d8a6f94 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 86AkGu7O8b+MxnAtOI607XHeQAfgNu8MgL6ALFkmK/Y3zb4aDfI9T8FJSJT1/6ISJeZ13PAmLwBpHuryZCzUOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR06MB5583 Subject: [Xen-devel] [XEN PATCH 2/3] read a grubenv file if it is next to the grub.cfg file X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Wei Liu , "YOUNG, MICHAEL A." Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) When a grub.cfg file is found this patch checks if there is grubenv file in the same directory as the grub.cfg file. If there is it passes the contents to parse(). Signed-off-by: Michael Young Tested-by: Steven Haigh --- tools/pygrub/src/pygrub | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub index ce7ab0eb8c..53a0803817 100755 --- a/tools/pygrub/src/pygrub +++ b/tools/pygrub/src/pygrub @@ -457,10 +457,25 @@ class Grub: # limit read size to avoid pathological cases buf =3D f.read(FS_READ_MAX) del f - if sys.version_info[0] < 3: - self.cf.parse(buf) + # check for a grubenv file next to the grub.cfg file + (fdir, fsep, ffile) =3D self.cf.filename.rpartition("/") + if fdir !=3D "" and ffile =3D=3D "grub.cfg": + fenv =3D fdir + "/grubenv" else: - self.cf.parse(buf.decode()) + fenv =3D "" + if fenv !=3D "" and fs.file_exists(fenv): + fenvf =3D fs.open_file(fenv) + grubenv =3D fenvf.read(FS_READ_MAX) + del fenvf + if sys.version_info[0] < 3: + self.cf.parse(buf, grubenv) + else: + self.cf.parse(buf.decode(), grubenv.decode()) + else: + if sys.version_info[0] < 3: + self.cf.parse(buf) + else: + self.cf.parse(buf.decode()) =20 def image_index(self): if isinstance(self.cf.default, int): --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 11:49:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=fail (BodyHash is different from the expected one) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1572044013373299.77836671687623; Fri, 25 Oct 2019 15:53:33 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iO8Rb-0004Gx-Ns; Fri, 25 Oct 2019 22:52:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iO8RZ-0004GM-VH for xen-devel@lists.xenproject.org; Fri, 25 Oct 2019 22:52:30 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:fe0c::705]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1de5c84a-f77a-11e9-beca-bc764e2007e4; Fri, 25 Oct 2019 22:52:27 +0000 (UTC) Received: from VI1PR06MB4720.eurprd06.prod.outlook.com (20.177.200.18) by VI1PR06MB5583.eurprd06.prod.outlook.com (20.177.202.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.22; Fri, 25 Oct 2019 22:52:26 +0000 Received: from VI1PR06MB4720.eurprd06.prod.outlook.com ([fe80::d067:c8d1:e873:5632]) by VI1PR06MB4720.eurprd06.prod.outlook.com ([fe80::d067:c8d1:e873:5632%5]) with mapi id 15.20.2387.021; Fri, 25 Oct 2019 22:52:26 +0000 X-Inumbo-ID: 1de5c84a-f77a-11e9-beca-bc764e2007e4 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JjLIMAccINYyvtotAC3NyEnqa+3rwt/VLoywfJaVP7zHx7wVTI9WlvynsfbjFKo1gjkYzQr30kOvZFhTcmO1t3g7DAp0hYVGjTdqKo3ytKUs0TIulaaQhXs2r+Vh+982BbMgOo5eGOwm2BBqZvXyePeri8723TlkYr5B3vRqVg8O/uYJipopseD2aNuO0QvfXyyS07y7GuZwf/PbuwzahOKIPZ6RrIbOhfB/CF1keCgnedcsRiAg8SPwQ+uMqqobTcqnfxIiqPxcFmBeKCvtolZ0pveBygbZuQQTySCUBo6ZA+/TlS1l4Qe8FyHBSK7p/fOqkLtflbxuDdhMUxJVew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YQa5TNw39xOZhAw+gE5ZdAbNzr33LofTBkSvtZJrImE=; b=eRlOJQrnU40sAl1HTyVYW99yq7GQ1Gh+IJHvrUIkT2HQLZot2xSrzsdGElECpNc4GP0CgW87gTBB6d1MGf7wHiua/WGkby+CBeP5tAmAWDwDUEsKaq9Axti5+InnByOEGERvY7vwt07pLI8Bn8MS5OzVRCi3j/ApsFHkugsQVQMdECta+Po2IOHkUc5I9DbRQtbQIBroF40ZuBqzlbBzp9OlWuaLAWLKxCz9kHOOpMUpn0Hgc7MVGkdNpuHj7bENbW9ySqBgcL52T+rd+urT/UoFF4HcqjvBaubJlvJbIghfbEOX4wb+rUxFWBdLz1Rb4KXaAiAqVfSDMGljukyqQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=durham.ac.uk; dmarc=pass action=none header.from=durham.ac.uk; dkim=pass header.d=durham.ac.uk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=durhamuniversity.onmicrosoft.com; s=selector2-durhamuniversity-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YQa5TNw39xOZhAw+gE5ZdAbNzr33LofTBkSvtZJrImE=; b=UuJ+hlwx4Oxn05F2QP7agEYTwPu2UkfR1HMhHNsoIb8qwnTsE3y+uiU903aWO5O8eGBqGxIB9/diVb0suVgJfIXhFiACK8aixAkh05ikjZi2gn2rFAddCs3EkBue5JKGSf//1Hish6xyl6HbTdEe6Fb7MiMXHMc3OOBnrbg+f14= From: "YOUNG, MICHAEL A." To: "xen-devel@lists.xenproject.org" Thread-Topic: [XEN PATCH 3/3] Example Fedora 31 grub.cfg and grubenv files Thread-Index: AQHVi4beohHi3efWhU+ktcm1z/wr3w== Date: Fri, 25 Oct 2019 22:52:26 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2a00:23c4:921a:2100:1097:224c:243b:f186] x-mailer: git-send-email 2.21.0 x-clientproxiedby: LNXP123CA0016.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:d2::28) To VI1PR06MB4720.eurprd06.prod.outlook.com (2603:10a6:803:90::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=m.a.young@durham.ac.uk; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 940bf95e-e65a-4e68-5d30-08d7599e0160 x-ms-traffictypediagnostic: VI1PR06MB5583: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 02015246A9 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(39860400002)(136003)(366004)(346002)(376002)(396003)(199004)(189003)(66476007)(66946007)(256004)(8676002)(8936002)(81156014)(50226002)(66556008)(305945005)(7736002)(2501003)(54906003)(36756003)(66446008)(186003)(5660300002)(14454004)(86362001)(76176011)(786003)(316002)(52116002)(102836004)(386003)(6506007)(6436002)(2616005)(6512007)(71200400001)(71190400001)(446003)(64756008)(99286004)(6486002)(11346002)(25786009)(486006)(5640700003)(478600001)(4326008)(476003)(2906002)(118296001)(46003)(6116002)(6916009)(2351001)(81166006)(14444005); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR06MB5583; H:VI1PR06MB4720.eurprd06.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; received-spf: None (protection.outlook.com: durham.ac.uk does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ZFcg+qEh1WwjHka2eSwt10t2ARe9U9nJbvJE08/hDaZWM5xmeRaO0oemybJfkJJnlh6K9VBYpkJQfXakwaeag1bv5XSXXZTNWwOHDwfcmqO9MGr/SNTX3j+QRUbwEPV0ii+nFj/Go5IC1AuOouYHo1ZwwwJdCFw+V9MP7do07FO26Otb4JHONZhQ6VPovU7TgQOvbZD9+5jDWRJkVpv36pymaAocbK0s1TuITixHckIHLSxyXG8GG8DDLJWS7fmZeUmo+K6fBPMuLyq2g11lbslkk/U4inRFRbEiyU2QexBY7XrS3s0GVC6EjktXFVuBFbyu22kaEMV5q5Dk4EF8QmJ9EXTCOAZZbkermxoOqPxH3mCWi3GypXMls3hjifn8m02arD9fqzH8/GM2KxserXVd7ZjTx54QLZn+Bb1B9c73KvfZiDHpmHMAvx7WsNrf MIME-Version: 1.0 X-OriginatorOrg: durham.ac.uk X-MS-Exchange-CrossTenant-Network-Message-Id: 940bf95e-e65a-4e68-5d30-08d7599e0160 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2019 22:52:26.0720 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7250d88b-4b68-4529-be44-d59a2d8a6f94 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: xygb52muMeNaCPOUiyeVYd1fD+4AZZXfGlBoitmbpEEfFpdkh44pKbyI/pTS9qe8C7hu42/+XQ051dBKbo+nDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR06MB5583 Subject: [Xen-devel] [XEN PATCH 3/3] Example Fedora 31 grub.cfg and grubenv files X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Wei Liu , "YOUNG, MICHAEL A." Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This patch adds an example grub.cfg and grubenv file for reference Signed-off-by: Michael Young Acked-by: Ian Jackson Tested-by: Steven Haigh --- tools/pygrub/examples/fedora-31.grub.cfg | 200 +++++++++++++++++++++++ tools/pygrub/examples/fedora-31.grubenv | 5 + 2 files changed, 205 insertions(+) create mode 100644 tools/pygrub/examples/fedora-31.grub.cfg create mode 100644 tools/pygrub/examples/fedora-31.grubenv diff --git a/tools/pygrub/examples/fedora-31.grub.cfg b/tools/pygrub/exampl= es/fedora-31.grub.cfg new file mode 100644 index 0000000000..9ce38d43b7 --- /dev/null +++ b/tools/pygrub/examples/fedora-31.grub.cfg @@ -0,0 +1,200 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +set pager=3D1 + +if [ -f ${config_directory}/grubenv ]; then + load_env -f ${config_directory}/grubenv +elif [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default=3D"${next_entry}" + set next_entry=3D + save_env next_entry + set boot_once=3Dtrue +else + set default=3D"${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" =3D xy ]; then + menuentry_id_option=3D"--id" +else + menuentry_id_option=3D"" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry=3D"${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry=3D + save_env prev_saved_entry + set boot_once=3Dtrue +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry=3D"${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module =3D xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +terminal_output console +if [ x$feature_timeout_style =3D xy ] ; then + set timeout_style=3Dmenu + set timeout=3D5 +# Fallback normal timeout code in case the timeout_style feature is +# unavailable. +else + set timeout=3D5 +fi +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/01_users ### +if [ -f ${prefix}/user.cfg ]; then + source ${prefix}/user.cfg + if [ -n "${GRUB2_PASSWORD}" ]; then + set superusers=3D"root" + export superusers + password_pbkdf2 root ${GRUB2_PASSWORD} + fi +fi +### END /etc/grub.d/01_users ### + +### BEGIN /etc/grub.d/08_fallback_counting ### +insmod increment +# Check if boot_counter exists and boot_success=3D0 to activate this behav= iour. +if [ -n "${boot_counter}" -a "${boot_success}" =3D "0" ]; then + # if countdown has ended, choose to boot rollback deployment, + # i.e. default=3D1 on OSTree-based systems. + if [ "${boot_counter}" =3D "0" -o "${boot_counter}" =3D "-1" ]; then + set default=3D1 + set boot_counter=3D-1 + # otherwise decrement boot_counter + else + decrement boot_counter + fi + save_env boot_counter +fi +### END /etc/grub.d/08_fallback_counting ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Fedora (5.3.6-300.fc31.x86_64) 31 (Thirty One)' --class fedora = --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_optio= n 'gnulinux-5.3.6-300.fc31.x86_64-advanced-1dec723d-4bdf-461a-a09b-e71ba597= 4892' { + load_video + set gfxpayload=3Dkeep + insmod gzio + insmod part_msdos + insmod ext2 + set root=3D'hd0,msdos1' + if [ x$feature_platform_search_hint =3D xy ]; then + search --no-floppy --fs-uuid --set=3Droot --hint=3D'hd0,msdos1' 00c6a4= 4a-1624-4c8f-bd08-bc66ea59edbe + else + search --no-floppy --fs-uuid --set=3Droot 00c6a44a-1624-4c8f-bd08-bc66e= a59edbe + fi + linux /vmlinuz-5.3.6-300.fc31.x86_64 root=3D/dev/mapper/fedora_localhost-= -live-root ro resume=3D/dev/mapper/fedora_localhost--live-swap rd.lvm.lv=3D= fedora_localhost-live/root rd.lvm.lv=3Dfedora_localhost-live/swap rhgb quie= t=20 + initrd /initramfs-5.3.6-300.fc31.x86_64.img +} +menuentry 'Fedora (0-rescue-fbc80dcce05d4a1a9b9a7951232a4eeb) 31 (Thirty O= ne)' --class fedora --class gnu-linux --class gnu --class os --unrestricted= $menuentry_id_option 'gnulinux-0-rescue-fbc80dcce05d4a1a9b9a7951232a4eeb-a= dvanced-1dec723d-4bdf-461a-a09b-e71ba5974892' { + load_video + insmod gzio + insmod part_msdos + insmod ext2 + set root=3D'hd0,msdos1' + if [ x$feature_platform_search_hint =3D xy ]; then + search --no-floppy --fs-uuid --set=3Droot --hint=3D'hd0,msdos1' 00c6a4= 4a-1624-4c8f-bd08-bc66ea59edbe + else + search --no-floppy --fs-uuid --set=3Droot 00c6a44a-1624-4c8f-bd08-bc66e= a59edbe + fi + linux /vmlinuz-0-rescue-fbc80dcce05d4a1a9b9a7951232a4eeb root=3D/dev/mapp= er/fedora_localhost--live-root ro resume=3D/dev/mapper/fedora_localhost--li= ve-swap rd.lvm.lv=3Dfedora_localhost-live/root rd.lvm.lv=3Dfedora_localhost= -live/swap rhgb quiet=20 + initrd /initramfs-0-rescue-fbc80dcce05d4a1a9b9a7951232a4eeb.img +} + +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/10_reset_boot_success ### +insmod increment +# Hiding the menu is ok if last boot was ok or if this is a first boot att= empt to boot the entry +if [ "${boot_success}" =3D "1" -o "${boot_indeterminate}" =3D "1" ]; then + set menu_hide_ok=3D1 +else + set menu_hide_ok=3D0=20 +fi +# Reset boot_indeterminate after a successful boot, increment otherwise +if [ "${boot_success}" =3D "1" ] ; then + set boot_indeterminate=3D0 +else + increment boot_indeterminate +fi +# Reset boot_success for current boot=20 +set boot_success=3D0 +save_env boot_success boot_indeterminate +### END /etc/grub.d/10_reset_boot_success ### + +### BEGIN /etc/grub.d/12_menu_auto_hide ### +if [ x$feature_timeout_style =3D xy ] ; then + if [ "${menu_show_once}" ]; then + unset menu_show_once + save_env menu_show_once + set timeout_style=3Dmenu + set timeout=3D60 + elif [ "${menu_auto_hide}" -a "${menu_hide_ok}" =3D "1" ]; then + set orig_timeout_style=3D${timeout_style} + set orig_timeout=3D${timeout} + if [ "${fastboot}" =3D "1" ]; then + # timeout_style=3Dmenu + timeout=3D0 avoids the countdown code keypr= ess check + set timeout_style=3Dmenu + set timeout=3D0 + else + set timeout_style=3Dhidden + set timeout=3D1 + fi + fi +fi +### END /etc/grub.d/12_menu_auto_hide ### + +### BEGIN /etc/grub.d/20_linux_xen ### + +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/20_ppc_terminfo ### +### END /etc/grub.d/20_ppc_terminfo ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/30_uefi-firmware ### +### END /etc/grub.d/30_uefi-firmware ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type = the +# menu entries you want to add after this comment. Be careful not to chan= ge +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f ${config_directory}/custom.cfg ]; then + source ${config_directory}/custom.cfg +elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### diff --git a/tools/pygrub/examples/fedora-31.grubenv b/tools/pygrub/example= s/fedora-31.grubenv new file mode 100644 index 0000000000..6df61b0fe5 --- /dev/null +++ b/tools/pygrub/examples/fedora-31.grubenv @@ -0,0 +1,5 @@ +# GRUB Environment Block +saved_entry=3Dfbc80dcce05d4a1a9b9a7951232a4eeb-5.3.6-300.fc31.x86_64 +kernelopts=3Droot=3D/dev/mapper/fedora_localhost--live-root ro resume=3D/d= ev/mapper/fedora_localhost--live-swap rd.lvm.lv=3Dfedora_localhost-live/roo= t rd.lvm.lv=3Dfedora_localhost-live/swap rhgb quiet +boot_success=3D1 +##########################################################################= ###########################################################################= ###########################################################################= ###########################################################################= ###########################################################################= ###########################################################################= ###########################################################################= ###########################################################################= ###########################################################################= #################################################### \ No newline at end of file --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel