From patchwork Fri Oct 25 22:52:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Young X-Patchwork-Id: 11213157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 819231709 for ; Fri, 25 Oct 2019 22:53:51 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5AB5A21D81 for ; Fri, 25 Oct 2019 22:53:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=durhamuniversity.onmicrosoft.com header.i=@durhamuniversity.onmicrosoft.com header.b="nhTacVqb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AB5A21D81 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=durham.ac.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org 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 X-Inumbo-ID: 1aee5bfc-f77a-11e9-94cd-12813bfff9fa 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) 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= 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 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 (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." Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 --- 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 = 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) = self.cf.filename.rpartition("/") + if fdir != "" and ffile == "grub.cfg": + fenv = fdir + "/grubenv" else: - self.cf.parse(buf.decode()) + fenv = "" + if fenv != "" and fs.file_exists(fenv): + fenvf = fs.open_file(fenv) + grubenv = 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()) def image_index(self): if isinstance(self.cf.default, int):