From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C405CC54798 for ; Sat, 2 Mar 2024 03:23:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rgFy0-0005Wh-1Y; Fri, 01 Mar 2024 22:23:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rgFwL-0004Ur-DA for grub-devel@gnu.org; Fri, 01 Mar 2024 22:21:33 -0500 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgFwJ-0002Ze-Cu for grub-devel@gnu.org; Fri, 01 Mar 2024 22:21:33 -0500 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a44cdb2d3a6so35160366b.2 for ; Fri, 01 Mar 2024 19:21:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709349689; x=1709954489; darn=gnu.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=6pm13XnBQABMaLmdUkAoENotGFDLtuKQrTxhJLolnXo=; b=QMCAvyQ7YM0tSdM5tjBzRn2L0gfS5RWG6xQKoke3amv2CJ/RpnSdSZSR37hKLMhs7m RSqMdl/zR9ONIXc+5O/mxwDJ3l/2FUIal6RKjHrdq9Z7LE2uF1IPeFTj1LDAKyDyxZTI 4URhJ+rWuyGF0JyPjB7PMXzKLQDUpukJ6A3eqAK1WhMJFAHnLKvJLb+vKZ8fxvQEs0Zc me9bX/rQlgMNYlIhV7aPRsUQ9PEi7c31ceFhvRPSrajpil7akcdLgeEIN9z8O3Uvf8MU 5eG4sQeA0oM8kFL6moIBXNncmkB1roQdNN+ev4Xr4pwxg+gVtMwhgEuMgB8dFtJm63UP 2kwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709349689; x=1709954489; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6pm13XnBQABMaLmdUkAoENotGFDLtuKQrTxhJLolnXo=; b=MgNF1i1Ci/QZujMnNrjC+gr46Cf1fqUNx157FlPpxffbXlvsYgpr5FDzcxQKW41cMW zRVzzjaTsA/2/Nfse1IQn3KZFLuxk0etXLeEAV6IbsrPw/wZNlOkuy+9NILCDu7o08kd FzbXUpLAI3NHY+sVO0JQvs+8lJyFiZdMhg17X1wMI02VLTx1cnCCzx9+eKaVzH9JwAQn gX7qUrKHQoVuQuuxO2Zwp8GFGLCkRad+cWwD0ISDDD7qCoKZ0p7hJYbM+QCbbnaJh3XM gWQdGM3xIYcg/zssFQdhCH9OtPKLrA+A1mBiLl2izdv93vxCoIHmRUbK2Qq7/Yd0kWS5 j/ZA== X-Gm-Message-State: AOJu0Yx6SkYepmoqzBCVlMZRTgvNbi6iPykDwhlJZaEz9t0pCjhEvGZ+ zSu7Or8CDZiB/84Ra6RBG9zpEfSowj25uISiGE0DrqF/iP3/X1TfFEDU0Tgr X-Google-Smtp-Source: AGHT+IFgHsa21OzV6O/wjF3Y9UnjEydusP9jL2zZ7zKDhIiXaRf05VpX7geGgcgfNk1khpqBlwO5GQ== X-Received: by 2002:a17:906:70b:b0:a44:125:58f6 with SMTP id y11-20020a170906070b00b00a44012558f6mr2610433ejb.32.1709349689061; Fri, 01 Mar 2024 19:21:29 -0800 (PST) Received: from dj3ntoo (30.sub-97-147-14.myvzw.com. [97.147.14.30]) by smtp.gmail.com with ESMTPSA id ag3-20020a1709069a8300b00a44790d06d3sm1380384ejc.71.2024.03.01.19.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 19:21:28 -0800 (PST) Date: Fri, 1 Mar 2024 21:21:21 -0600 From: Oskari Pirhonen To: Simon Rowe Cc: grub-devel@gnu.org Subject: Re: [PATCH] Support dropin files for Linux kernel parameters Message-ID: Mail-Followup-To: Simon Rowe , grub-devel@gnu.org References: <20240301154350.149056-1-simon.rowe@nutanix.com> MIME-Version: 1.0 In-Reply-To: <20240301154350.149056-1-simon.rowe@nutanix.com> Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=xxc3ncoredxx@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Content-Type: multipart/mixed; boundary="===============0904144489225413349==" Errors-To: grub-devel-bounces+grub-devel=archiver.kernel.org@gnu.org Sender: grub-devel-bounces+grub-devel=archiver.kernel.org@gnu.org --===============0904144489225413349== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FFpE1V285Oh6tXzN" Content-Disposition: inline --FFpE1V285Oh6tXzN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 01, 2024 at 15:43:50 +0000, Simon Rowe wrote: > Kernel parameters actually cover a range of purposes, including > userspace like systemd. They also need setting for a variety of > reasons: >=20 > * as distro defaults > * to provide configuration for a package > * for an admin to set desired behaviour >=20 > Having these all combined in a single line (like GRUB_CMDLINE_LINUX) > is unwieldy, it is hard to make changes without impacting another > usecase. >=20 > Add optional support for dropin files in the directories: >=20 > * /usr/lib/kernel.d/ > * /etc/kernel.d/ >=20 > where the contents of each file with the '.conf' suffix is evaluated > (excluding comments) and appended to any other kernel parameters > defined via GRUB_CMDLINE_LINUX etc. Files in /etc/kernel.d/ completely > replace those of the same name in /usr/lib/kernel.d/. This allows a > distro or installer to set parameters but then for an admin to > override them. >=20 Would it be better to have the kernel command line args in GRUB config override the ones in any drop-ins? At least for me it would be surprising behavior if my distro set something in /usr/lib/kernel.d/ and changing that value in my GRUB config didn't have an effect. > Signed-off-by: Simon Rowe > --- > util/grub-mkconfig_lib.in | 18 ++++++++++++++++++ > util/grub.d/10_linux.in | 8 +++++--- > util/grub.d/20_linux_xen.in | 8 +++++--- > 3 files changed, 28 insertions(+), 6 deletions(-) >=20 > diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in > index 08953287c..7aaa747f1 100644 > --- a/util/grub-mkconfig_lib.in > +++ b/util/grub-mkconfig_lib.in > @@ -348,3 +348,21 @@ grub_add_tab () { > sed -e "s/^/$grub_tab/" > } > =20 > +kernel_params_from_files () { > + # Read Linux kernel parameters from dropin files. > + > + file_bases=3D"" > + > + for f in /etc/kernel.d/*.conf /usr/lib/kernel.d/*.conf; do > + [ -r $f ] || continue > + file_bases=3D"$file_bases $(basename $f)" > + done > + > + for b in $(echo $file_bases | tr ' ' '\n' | sort -u); do > + if [ -r /etc/kernel.d/$b ]; then > + grep -v '^#' /etc/kernel.d/$b | tr '\n' ' ' > + elif [ -r /usr/lib/kernel.d/$b ]; then > + grep -v '^#' /usr/lib/kernel.d/$b | tr '\n' ' ' > + fi > + done > +} > diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in > index cc393be7e..fba3775f9 100644 > --- a/util/grub.d/10_linux.in > +++ b/util/grub.d/10_linux.in > @@ -275,6 +275,8 @@ for linux in ${reverse_sorted_list}; do > fi > fi > =20 > + extra_kernel_params=3D$(kernel_params_from_files) > + > # The GRUB_DISABLE_SUBMENU option used to be different than others sin= ce it was > # mentioned in the documentation that has to be set to 'y' instead of = 'true' to > # enable it. This caused a lot of confusion to users that set the opti= on to 'y', > @@ -285,7 +287,7 @@ for linux in ${reverse_sorted_list}; do > =20 > if [ "x$is_top_level" =3D xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" !=3D= xtrue ]; then > linux_entry "${OS}" "${version}" simple \ > - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" > + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${extra_kernel_= params}" > =20 In other words, should this instead be: "${extra_kernel_params} ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFA= ULT}" Similarly for the other instances below. - Oskari > submenu_indentation=3D"$grub_tab" > =20 > @@ -298,10 +300,10 @@ for linux in ${reverse_sorted_list}; do > fi > =20 > linux_entry "${OS}" "${version}" advanced \ > - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" > + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${ext= ra_kernel_params}" > if [ "x${GRUB_DISABLE_RECOVERY}" !=3D "xtrue" ]; then > linux_entry "${OS}" "${version}" recovery \ > - "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" > + "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX} ${= extra_kernel_params}" > fi > done > =20 > diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in > index 94dd8be13..089f6de43 100644 > --- a/util/grub.d/20_linux_xen.in > +++ b/util/grub.d/20_linux_xen.in > @@ -336,6 +336,8 @@ for current_xen in ${reverse_sorted_xen_list}; do > fi > fi > =20 > + extra_kernel_params=3D$(kernel_params_from_files) > + > # The GRUB_DISABLE_SUBMENU option used to be different than others sinc= e it was > # mentioned in the documentation that has to be set to 'y' instead of '= true' to > # enable it. This caused a lot of confusion to users that set the optio= n to 'y', > @@ -346,7 +348,7 @@ for current_xen in ${reverse_sorted_xen_list}; do > =20 > if [ "x$is_top_level" =3D xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" !=3D = xtrue ]; then > linux_entry "${OS}" "${version}" "${xen_version}" simple \ > - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_= XEN} ${GRUB_CMDLINE_XEN_DEFAULT}" > + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_= XEN} ${GRUB_CMDLINE_XEN_DEFAULT} ${extra_kernel_params}" > =20 > submenu_indentation=3D"$grub_tab$grub_tab" > =20 > @@ -360,10 +362,10 @@ for current_xen in ${reverse_sorted_xen_list}; do > fi > =20 > linux_entry "${OS}" "${version}" "${xen_version}" advanced \ > - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLI= NE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}" > + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLI= NE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT} ${extra_kernel_params}" > if [ "x${GRUB_DISABLE_RECOVERY}" !=3D "xtrue" ]; then > linux_entry "${OS}" "${version}" "${xen_version}" recovery \ > - "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE= _XEN}" > + "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE= _XEN} ${extra_kernel_params}" > fi > done > if [ x"$is_top_level" !=3D xtrue ]; then > --=20 > 2.22.3 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel --FFpE1V285Oh6tXzN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQfOU+JeXjo4uxN6vCp8he9GGIfEQUCZeKbKwAKCRCp8he9GGIf EeUmAP9N+1ZGzI4Ya5vDNkw5G+lk4SFBNEVvL5DA+PT6Fj251gEA7FOBd8Xafiyk 5UwwUWHVo6FSuq0Fwp9D3wuoulB87g0= =0W2B -----END PGP SIGNATURE----- --FFpE1V285Oh6tXzN-- --===============0904144489225413349== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KR3J1Yi1kZXZl bCBtYWlsaW5nIGxpc3QKR3J1Yi1kZXZlbEBnbnUub3JnCmh0dHBzOi8vbGlzdHMuZ251Lm9yZy9t YWlsbWFuL2xpc3RpbmZvL2dydWItZGV2ZWwK --===============0904144489225413349==--