Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1ol36w-0003QS-82 for mharc-grub-devel@gnu.org; Wed, 19 Oct 2022 03:03:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol36W-0003Oi-AH for grub-devel@gnu.org; Wed, 19 Oct 2022 03:03:08 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:36744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ol36S-0005Qz-4T for grub-devel@gnu.org; Wed, 19 Oct 2022 03:03:04 -0400 Received: by mail-wr1-x434.google.com with SMTP id j7so27520259wrr.3 for ; Wed, 19 Oct 2022 00:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=OYVOS9HTiWqeK/XE9PFzW2uSq2pd5clvXfNYK7yWBsI=; b=gz9R97aBbHVB0xEf3Coa9aZyTH35JDhEWY4DnLDoiAsPj6co+soMgAr5GHjaF+VyCR KNhfp9dLP9FlQgv2wUl/qi5q5+mNDfnYsWIZeVqAAVk7gNDgrc2eU1rJV/6mT0eBNar3 QBrB63o3ktIC1PjoedkF5s3C6EXwcOm/T3A/v0eVRRIIxbmStk038AHSC3k5jGoCwEyI zXGXmXdmrXMxozivRNTTPDHJtClwirKHoneylcEI3J+21DloAl3LIIkhnSNP24krd0lv VAp7L+G7yN1Fen6jPxNkSsyyZTx2KH64WFnk9nU+VoECHjUpxZJRpwEWKbOnJrWlDXfq SVsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=OYVOS9HTiWqeK/XE9PFzW2uSq2pd5clvXfNYK7yWBsI=; b=ZFizacqu/SYnslpX1QA1Lx82Ay7GSJAeXvrskUoyYaYfdbG8RTPurScGuVvrFqTGUf cHddVA401jBffvfprXTIF5FUXofnxglSeFW6Ff93bjH7IaxlU4xmpiRtVEmR534My6HT iZe/O3N8ouvKD1j13d46OXte4WLgotS1qlUlm0h7tJ4Ce/xbVf53wJEBZVEy62y1ldvl cLUErONFYyRCpRAcNF/BOd0aHGyDhvLQ4pr/xahM2BUxONYHfn34C1yAo6iIAH1lVNl/ Xaor3Z/t29MnkQCepO2a8T+LaNdoKH5OEo/8l24MpGQeEbu2WgAPamfEmk1vrLPly1XW y0OA== X-Gm-Message-State: ACrzQf2YpSjcve08VYzHQRqlFUHrgrX5S1Mb+uzttHoieqRc+kvolTFc yM23Y8yoEz89NRuUi5gTp/k= X-Google-Smtp-Source: AMsMyM5bl7wEbz7zhbXomsjgRdCRI8LTWsDFBOpcFA0LxPccQ6qnCHE31bSzYbrF9B0wBMhArzYK7w== X-Received: by 2002:a5d:4dd0:0:b0:22e:33dc:3bf3 with SMTP id f16-20020a5d4dd0000000b0022e33dc3bf3mr4123079wru.214.1666162975724; Wed, 19 Oct 2022 00:02:55 -0700 (PDT) Received: from dj3ntoo (171.sub-72-110-15.myvzw.com. [72.110.15.171]) by smtp.gmail.com with ESMTPSA id z6-20020a1cf406000000b003c6deb5c1edsm15454341wma.45.2022.10.19.00.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 00:02:55 -0700 (PDT) Date: Wed, 19 Oct 2022 02:02:48 -0500 From: Oskari Pirhonen To: Robbie Harwood , The development of GNU GRUB Cc: Raymund Will , dkiper@net-space.pl, rw@suse.de, John Jolly , Javier Martinez Canillas , base-system@gentoo.org Subject: Re: [PATCH v4 1/1] Add support for grub-emu to kexec Linux menu entries Message-ID: Mail-Followup-To: Robbie Harwood , The development of GNU GRUB , Raymund Will , dkiper@net-space.pl, rw@suse.de, John Jolly , Javier Martinez Canillas , base-system@gentoo.org References: <20221004191648.77723-1-rharwood@redhat.com> <20221004191648.77723-2-rharwood@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dABg/5rVk3gj1aNt" Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=xxc3ncoredxx@gmail.com; helo=mail-wr1-x434.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 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: , X-List-Received-Date: Wed, 19 Oct 2022 07:03:18 -0000 --dABg/5rVk3gj1aNt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 18, 2022 at 15:26:45 -0400, Robbie Harwood wrote: > Oskari Pirhonen writes: >=20 > > On Tue, Oct 04, 2022 at 15:16:48 -0400, Robbie Harwood wrote: > >> From: Raymund Will > >>=20 > >> The GRUB emulator is used as a debugging utility but it could also be > >> used as a user-space bootloader if there is support to boot an operati= ng > >> system. > >>=20 > >> The Linux kernel is already able to (re)boot another kernel via the > >> kexec boot mechanism. So the grub-emu tool could rely on this feature > >> and have linux and initrd commands that are used to pass a kernel, > >> initramfs image and command line parameters to kexec for booting a > >> selected menu entry. > >>=20 > >> By default the systemctl kexec option is used so systemd can shutdown > >> all of the running services before doing a reboot using kexec. But if > >> this is not present, it can fall back to executing the kexec user-space > >> tool directly. The ability to force a kexec-reboot when systemctl kex= ec > >> fails must only be used in controlled environments to avoid possible > >> filesystem corruption and data loss. > >>=20 > > > > Can the existence of systemd/systemctl be checked at configure-time? >=20 > No - think about how binary distros work. Only on locally built > environments like gentoo is configure time guaranteed to look like > runtime. Consider Debian, for instance, which can run with multiple > init systems (including openrc, if memory serves): for them, a > configure-time check could make things worse. >=20 My idea was something along the lines of --with-kexec=3Dfoo in order to allow for automatic detection as well as manually specifying the method used. I believe that should cover building for binary distros as well as locally. > > I run OpenRC where systemctl is unavailable, so it looks like it would > > always hit the error case unless I pass the arg twice. It could also > > cause confusion to users if they notice it fails to call systemctl > > when on non-systemd systems. >=20 > I don't think this has the impact you're suggesting. This is new code - > you can't kexec from grub2-emu today. It's also working as documented > ("use kexec to boot Linux kernels via systemctl (pass twice to enable > dangerous fallback to non-systemctl)."). I don't think a user reading > that documentation would expect a system without systemctl functionality > to support this feature. (Whether users expect their system to have > systemctl functionality is better asked of initsystem developers than of > me.) >=20 These are valid points for the current (and possibly final) state of this patch. > I want to be clear here that I support people working on other init > systems, but if there's not an equivalent for this functionality, > there's very little I can do here. >=20 The most that I would be requesting be added is basic scaffolding to make future additions easier. But if no one comes forward before the patch is accepted as ready, saying there's an equally easy method to `systemctl kexec` for some other init system, then it wouldn't make sense to add it until said method can be added too. > > The simplest/safest solution would be to just disable this if the > > configure check fails until `systemctl kexec`-equivalent code paths are > > added. >=20 > Careful with langauge, please. There is nothing unsafe about attempting > to exec systemctl when it doesn't exist. And I don't think adding > configuration checks makes code simpler. >=20 I meant "safe" in the sense that it's a controlled kexec reboot, not that running a non-existent systemctl is unsafe. Apologies if that was unclear. > > I've CC-ed the Gentoo Base System project [1] in case some of them can > > provide additional input, such as how to get the safe path working > > with other init systems. >=20 > Okay. Any input here is fine, but I think it will be easier for > everyone if it's in the form of separate, follow-up patches. (I'm happy > to review them once posted, if that's helpful; just CC me.) >=20 You are probably right on that, which is why I wanted to get the idea out there at least. I will do some more digging myself too. - Oskari --dABg/5rVk3gj1aNt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQfOU+JeXjo4uxN6vCp8he9GGIfEQUCY0+hEwAKCRCp8he9GGIf Ea9hAQCUFlrqQICxq10sOr+etUftVJDrBZfj2IzcuShQwf6CYAEAw32xjcThigOd Jjse81JN+t5orcYyc6BTgJn0X/tPhgk= =QQKh -----END PGP SIGNATURE----- --dABg/5rVk3gj1aNt--