From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.gruenbichler@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 3732B6522E
 for <pve-devel@lists.proxmox.com>; Tue,  1 Feb 2022 12:35:07 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 280892DE94
 for <pve-devel@lists.proxmox.com>; Tue,  1 Feb 2022 12:35:07 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 310352DE89
 for <pve-devel@lists.proxmox.com>; Tue,  1 Feb 2022 12:35:05 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id EA5DF43D95
 for <pve-devel@lists.proxmox.com>; Tue,  1 Feb 2022 12:35:04 +0100 (CET)
Date: Tue, 01 Feb 2022 12:34:56 +0100
From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
References: <20220131175918.2099575-1-s.ivanov@proxmox.com>
 <20220131175918.2099575-5-s.ivanov@proxmox.com>
In-Reply-To: <<20220131175918.2099575-5-s.ivanov@proxmox.com>
MIME-Version: 1.0
User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid)
Message-Id: <1643711016.jhlin58wfo.astroid@nora.none>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.218 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [multi-user.target, proxmox.com]
Subject: Re: [pve-devel] [PATCH pve-kernel-meta 4/5] proxmox-boot: add
 kernel next-boot command
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Tue, 01 Feb 2022 11:35:07 -0000

On January 31, 2022 6:59 pm, Stoiko Ivanov wrote:
> by pinning the desired version and touching a flag file, which is used
> by the systemd service as condition for unpinning and refreshing upon
> reboot
>=20
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>  bin/proxmox-boot-tool                     |  9 +++++++--
>  debian/pve-kernel-helper.install          |  1 +
>  debian/rules                              |  3 +++
>  proxmox-boot/Makefile                     |  4 ++++
>  proxmox-boot/functions                    |  1 +
>  proxmox-boot/proxmox-boot-cleanup.service | 15 +++++++++++++++
>  6 files changed, 31 insertions(+), 2 deletions(-)
>  create mode 100644 proxmox-boot/proxmox-boot-cleanup.service
>=20
> diff --git a/bin/proxmox-boot-tool b/bin/proxmox-boot-tool
> index 75eea0e..005109a 100755
> --- a/bin/proxmox-boot-tool
> +++ b/bin/proxmox-boot-tool
> @@ -302,7 +302,7 @@ usage() {
>  	warn "       $0 init <partition>"
>  	warn "       $0 clean [--dry-run]"
>  	warn "       $0 refresh [--hook <name>]"
> -	warn "       $0 kernel <add|remove|pin> <kernel-version>"
> +	warn "       $0 kernel <add|remove|pin|next-boot> <kernel-version>"
>  	warn "       $0 kernel <list|unpin>"
>  	warn "       $0 status [--quiet]"
>  	warn "       $0 help"
> @@ -325,7 +325,7 @@ help() {
>  	echo ""
>  	echo "    refresh all configured EFI system partitions. Use --hook to o=
nly run the specified hook, omit to run all."
>  	echo ""
> -	echo "USAGE: $0 kernel <add|remove|pin> <kernel-version>"
> +	echo "USAGE: $0 kernel <add|remove|pin|next-boot> <kernel-version>"
>  	echo ""
>  	echo "    add/remove pve-kernel with ABI <kernel-version> to list of sy=
nced kernels, in addition to automatically selected ones."
>  	echo "    NOTE: you need to manually run 'refresh' once you're finished=
 with adding/removing kernels from the list"

this doesn't really make it clear (to me) that 'next-boot' removes an=20
existing pinning. I'd either add an explicit note about this (here and=20
in *-docs ;)), or dis-entangle it:
- next-boot-active becomes next-boot and contains the temp. pinned=20
  kernel version
- grub gets a second snippet file (see other mail) for temp=20
  pinning/next-boot with higher priority than regular pinning
- systemd-boot checks for next-boot before pinned-kernel when refreshing
- systemd service removes 'next-boot' and extra grub snippet, then does=20
  refresh

> @@ -499,6 +499,11 @@ case "$1" in
>  				unpin_kernel "$2"
>  				exit 0
>  			;;
> +			'next-boot')
> +				pin_kernel "$2"
> +				touch "${PMX_NEXT_BOOT_FILE}"
> +				exit 0
> +			;;
>  			*)
>  				warn "E: invalid 'kernel' subcommand '$cmd'."
>  				warn ""
> diff --git a/debian/pve-kernel-helper.install b/debian/pve-kernel-helper.=
install
> index 5f264aa..33170fb 100644
> --- a/debian/pve-kernel-helper.install
> +++ b/debian/pve-kernel-helper.install
> @@ -2,6 +2,7 @@ etc/grub.d/000_proxmox_boot_header
>  etc/kernel/postinst.d/*
>  etc/kernel/postrm.d/*
>  etc/initramfs/post-update.d/proxmox-boot-sync
> +lib/systemd/system/proxmox-boot-cleanup.service
>  usr/sbin/proxmox-boot-tool
>  usr/sbin/grub-install
>  usr/share/pve-kernel-helper/scripts/functions
> diff --git a/debian/rules b/debian/rules
> index 58f7f7d..3dd1bc8 100755
> --- a/debian/rules
> +++ b/debian/rules
> @@ -12,5 +12,8 @@ debian/control: $(wildcard debian/*.in)
>  %:
>  	dh $@
> =20
> +override_dh_installsystemd:
> +	dh_installsystemd --no-start
> +
>  .PHONY: build clean
>  build clean:
> diff --git a/proxmox-boot/Makefile b/proxmox-boot/Makefile
> index effd726..2b0685d 100644
> --- a/proxmox-boot/Makefile
> +++ b/proxmox-boot/Makefile
> @@ -2,12 +2,14 @@ KERNEL_HOOKSCRIPTS =3D proxmox-auto-removal zz-proxmox-=
boot
>  INITRAMFS_HOOKSCRIPTS =3D proxmox-boot-sync
>  SHARE_FILES =3D functions
>  GRUB_CFG_SNIPPET =3D 000_proxmox_boot_header
> +SYSTEMD_SERVICES =3D proxmox-boot-cleanup.service
> =20
>  POSTINSTHOOKDIR =3D ${DESTDIR}/etc/kernel/postinst.d
>  POSTRMHOOKDIR =3D ${DESTDIR}/etc/kernel/postrm.d
>  POSTINITRAMFSHOOKDIR =3D ${DESTDIR}/etc/initramfs/post-update.d
>  SHARE_SCRIPTDIR =3D ${DESTDIR}/usr/share/pve-kernel-helper/scripts
>  GRUB_CFG_DIR =3D ${DESTDIR}/etc/grub.d
> +SERVICE_DIR =3D ${DESTDIR}/lib/systemd/system
> =20
>  .PHONY: all
>  all:
> @@ -23,6 +25,8 @@ install:
>  	install -m 0755 ${SHARE_FILES} ${SHARE_SCRIPTDIR}
>  	install -d ${GRUB_CFG_DIR}
>  	install -m 0755 ${GRUB_CFG_SNIPPET} ${GRUB_CFG_DIR}
> +	install -d ${SERVICE_DIR}
> +	install -m 0644 ${SYSTEMD_SERVICES} ${SERVICE_DIR}
> =20
>  .PHONY: clean distclean
>  distclean:
> diff --git a/proxmox-boot/functions b/proxmox-boot/functions
> index 9fa29ca..3bea421 100755
> --- a/proxmox-boot/functions
> +++ b/proxmox-boot/functions
> @@ -6,6 +6,7 @@ ESPTYPE=3D'c12a7328-f81f-11d2-ba4b-00a0c93ec93b'
> =20
>  MANUAL_KERNEL_LIST=3D"/etc/kernel/pve-efiboot-manual-kernels"
>  PINNED_KERNEL_CONF=3D"/etc/kernel/proxmox-boot-pin"
> +PMX_NEXT_BOOT_FILE=3D"/etc/kernel/next-boot-active"
> =20
>  MOUNTROOT=3D"${TMPDIR:-/var/tmp}/espmounts"
>  # relative to the ESP mountpoint
> diff --git a/proxmox-boot/proxmox-boot-cleanup.service b/proxmox-boot/pro=
xmox-boot-cleanup.service
> new file mode 100644
> index 0000000..3c390de
> --- /dev/null
> +++ b/proxmox-boot/proxmox-boot-cleanup.service
> @@ -0,0 +1,15 @@
> +[Unit]
> +Description=3DClean up bootloader next-boot setting
> +After=3Dsystemd-remount-fs.service
> +ConditionPathExists=3D/etc/kernel/next-boot-active
> +
> +[Service]
> +Type=3Doneshot
> +RemainAfterExit=3Dyes
> +ExecStart=3D/usr/sbin/proxmox-boot-tool kernel unpin
> +ExecStart=3D/usr/sbin/proxmox-boot-tool refresh
> +ExecStart=3D/bin/rm -f /etc/kernel/next-boot-active
> +
> +[Install]
> +WantedBy=3Dmulti-user.target
> +
> --=20
> 2.30.2
>=20
>=20
>=20
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>=20
>=20
>=20