From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cW2Sq-0003f0-0Q for mharc-grub-devel@gnu.org; Tue, 24 Jan 2017 09:52:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cW2Sl-0003Zf-6A for grub-devel@gnu.org; Tue, 24 Jan 2017 09:52:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cW2Sg-0002Oo-9a for grub-devel@gnu.org; Tue, 24 Jan 2017 09:52:47 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:31428) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cW2Sg-0002Nw-0H for grub-devel@gnu.org; Tue, 24 Jan 2017 09:52:42 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v0OEqbnH032559 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Jan 2017 14:52:38 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v0OEqbkw004005 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Jan 2017 14:52:37 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v0OEqaq8005692; Tue, 24 Jan 2017 14:52:37 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 24 Jan 2017 06:52:36 -0800 Received: by char.us.oracle.com (Postfix, from userid 1000) id B7FCB6A09E7; Tue, 24 Jan 2017 09:52:35 -0500 (EST) Date: Tue, 24 Jan 2017 09:52:35 -0500 From: Konrad Rzeszutek Wilk To: The development of GNU GRUB Cc: Matthew Garrett Subject: Re: [PATCH] Add fwconfig command Message-ID: <20170124145235.GE17957@char.us.oracle.com> References: <20170123234332.22379-1-mjg59@coreos.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170123234332.22379-1-mjg59@coreos.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 141.146.126.69 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jan 2017 14:52:51 -0000 On Mon, Jan 23, 2017 at 03:43:32PM -0800, Matthew Garrett wrote: > Add a command to read values from the qemu fwcfg store. This allows data > to be passed from the qemu command line to grub. > > Example use: > > echo '(hd0,1)' >rootdev > qemu -fw_cfg opt/rootdev,file=rootdev > > fwconfig opt/rootdev root > --- > docs/grub.texi | 6 +++ > grub-core/Makefile.core.def | 6 +++ > grub-core/commands/fwconfig.c | 121 ++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 133 insertions(+) > create mode 100644 grub-core/commands/fwconfig.c > > diff --git a/docs/grub.texi b/docs/grub.texi > index 4469638..4f8a378 100644 > --- a/docs/grub.texi > +++ b/docs/grub.texi > @@ -3818,6 +3818,7 @@ you forget a command, you can run the command @command{help} > * eval:: Evaluate agruments as GRUB commands > * export:: Export an environment variable > * false:: Do nothing, unsuccessfully > +* fwconfig:: Retrieves a value from the qemu fwcfg store > * getenv:: Retrieve an EFI firmware variable > * gettext:: Translate a string > * gptsync:: Fill an MBR based on GPT entries > @@ -4259,6 +4260,11 @@ Do nothing, unsuccessfully. This is mainly useful in control constructs > such as @code{if} and @code{while} (@pxref{Shell-like scripting}). > @end deffn > > +@node fwconfig > +@subsection fwconig > +@deffn Command fwconfig fwpath envvar > +Retrieves @var{fwpath} from the qemu fwcfg store and stores it in @var{envvar} > + > @node getenv > @subsection getenv > > diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def > index db77a7f..f6b6f38 100644 > --- a/grub-core/Makefile.core.def > +++ b/grub-core/Makefile.core.def > @@ -2362,3 +2362,9 @@ module = { > common = loader/i386/xen_file64.c; > extra_dist = loader/i386/xen_fileXX.c; > }; > + > +module = { > + name = fwconfig; > + common = commands/fwconfig.c; > + enable = x86; > +}; > diff --git a/grub-core/commands/fwconfig.c b/grub-core/commands/fwconfig.c > new file mode 100644 > index 0000000..289d167 > --- /dev/null > +++ b/grub-core/commands/fwconfig.c > @@ -0,0 +1,121 @@ > +/* fwconfig.c - command to read config from qemu fwconfig */ > +/* > + * GRUB -- GRand Unified Bootloader > + * Copyright (C) 2015 CoreOS, Inc. Hmm, See https://www.gnu.org/licenses/why-assign.html > + * > + * GRUB is free software: you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation, either version 3 of the License, or > + * (at your option) any later version. So what is your option here (see the 'at your option'). > + * > + * GRUB is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with GRUB. If not, see . > + */