From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 C30E799D38 for ; Thu, 16 Nov 2023 17:38:43 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AA9BC17E21 for ; Thu, 16 Nov 2023 17:38:13 +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 for ; Thu, 16 Nov 2023 17:38:12 +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 A28B2433A2 for ; Thu, 16 Nov 2023 17:38:12 +0100 (CET) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Date: Thu, 16 Nov 2023 17:37:56 +0100 Message-Id: <20231116163759.1203156-2-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231116163759.1203156-1-s.ivanov@proxmox.com> References: <20231116163759.1203156-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.089 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 - Subject: [pve-devel] [PATCH installer v2 1/4] fix #4747: pass kernel cmdline parameters to target system X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Nov 2023 16:38:43 -0000 Parameters needed for booting during installation are best preserved in the target cmdline as well - e.g. if you need a particular cmdline switch for your system to boot at all - not having to add it for the first boot of the installed system and manually adding it to the bootloader config is an improvement. This additionally enables us to drop the console parameter handling for serial consoles (it is just one of the parameters to pass along). Finally it fixes the regular expressions for the installer settings we read from the cmdline (swapsize, maxroot,...) which were broken if added as last entry. Signed-off-by: Stoiko Ivanov --- Proxmox/Install.pm | 11 +++++------ Proxmox/Install/Config.pm | 25 +++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Proxmox/Install.pm b/Proxmox/Install.pm index 66adb2d..c868992 100644 --- a/Proxmox/Install.pm +++ b/Proxmox/Install.pm @@ -1152,11 +1152,10 @@ _EOD } update_progress(0.8, 0.95, 1, "make system bootable"); - my $console_param=''; - if (my $console = Proxmox::Install::Config::get_console()) { - $console_param="console=$console"; - my $console_snippet = "GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX $console_param\""; - file_write_all("$targetdir/etc/default/grub.d/console.cfg", $console_snippet); + my $target_cmdline=''; + if ($target_cmdline = Proxmox::Install::Config::get_target_cmdline()) { + my $target_cmdline_snippet = "GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX $target_cmdline\""; + file_write_all("$targetdir/etc/default/grub.d/installer.cfg", $target_cmdline_snippet); } if ($use_zfs) { @@ -1164,7 +1163,7 @@ _EOD my $zfs_snippet = "GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX root=ZFS=$zfs_pool_name/ROOT/$zfs_root_volume_name boot=zfs\""; file_write_all("$targetdir/etc/default/grub.d/zfs.cfg", $zfs_snippet); - file_write_all("$targetdir/etc/kernel/cmdline", "root=ZFS=$zfs_pool_name/ROOT/$zfs_root_volume_name boot=zfs $console_param\n"); + file_write_all("$targetdir/etc/kernel/cmdline", "root=ZFS=$zfs_pool_name/ROOT/$zfs_root_volume_name boot=zfs $target_cmdline\n"); zfs_setup_module_conf($targetdir); } diff --git a/Proxmox/Install/Config.pm b/Proxmox/Install/Config.pm index 5e80255..b1acebc 100644 --- a/Proxmox/Install/Config.pm +++ b/Proxmox/Install/Config.pm @@ -16,36 +16,37 @@ my sub parse_kernel_cmdline { my $cmdline = Proxmox::Install::RunEnv::get('kernel_cmdline'); - if ($cmdline =~ m/\s(ext4|xfs)(\s.*)?$/) { + if ($cmdline =~ s/\b(ext4|xfs)\s?//i) { $cfg->{filesys} = $1; } - if ($cmdline =~ m/hdsize=(\d+(\.\d+)?)[\s\n]/i) { + if ($cmdline =~ s/\bhdsize=(\d+(\.\d+)?)\s?//i) { $cfg->{hdsize} = $1; } - if ($cmdline =~ m/swapsize=(\d+(\.\d+)?)[\s\n]/i) { + if ($cmdline =~ s/\bswapsize=(\d+(\.\d+)?)\s?//i) { $cfg->{swapsize} = $1; } - if ($cmdline =~ m/maxroot=(\d+(\.\d+)?)[\s\n]/i) { + if ($cmdline =~ s/\bmaxroot=(\d+(\.\d+)?)\s?//i) { $cfg->{maxroot} = $1; } - if ($cmdline =~ m/minfree=(\d+(\.\d+)?)[\s\n]/i) { + if ($cmdline =~ s/\bminfree=(\d+(\.\d+)?)\s?//i) { $cfg->{minfree} = $1; } my $iso_env = Proxmox::Install::ISOEnv::get(); if ($iso_env->{product} eq 'pve') { - if ($cmdline =~ m/maxvz=(\d+(\.\d+)?)[\s\n]/i) { + if ($cmdline =~ s/\bmaxvz=(\d+(\.\d+)?)\s?//i) { $cfg->{maxvz} = $1; } } - if ($cmdline =~ m/console=(\S+)[\s\n]?/i) { - $cfg->{console} = $1; - } + $cmdline =~ s/(?:BOOT_IMAGE|root|ramdisk_size|splash|vga)=\S+\s?//gi; + $cmdline =~ s/ro|rw|quiet|proxdebug|proxtui|nomodeset//gi; + + $cfg->{target_cmdline}= $cmdline; return $cfg; } @@ -101,7 +102,7 @@ my sub init_cfg { cidr => undef, gateway => undef, dns => undef, - console => undef, + target_cmdline => undef, }; $initial = parse_kernel_cmdline($initial); @@ -235,8 +236,8 @@ sub get_gateway { return get('gateway'); } sub set_dns { set_key('dns', $_[0]); } sub get_dns { return get('dns'); } -sub set_console { set_key('console', $_[0]); } -sub get_console { return get('console'); } +sub set_target_cmdline { set_key('target_cmdline', $_[0]); } +sub get_target_cmdline { return get('target_cmdline'); } 1; -- 2.39.2