* [pve-devel] [PATCH installer v3 0/3] properly filter out all installer-related kernel arguments
@ 2024-11-11 11:05 Christoph Heiss
2024-11-11 11:05 ` [pve-devel] [PATCH installer v3 1/3] low level: config: filter out kernel cmdline on word boundaries Christoph Heiss
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Christoph Heiss @ 2024-11-11 11:05 UTC (permalink / raw)
To: pve-devel
Friedrich reported that when installing using the auto-installer, the
kernel commandline does not get cleaned up properly.
History
=======
v2: https://lore.proxmox.com/pve-devel/20240821132307.1352643-1-c.heiss@proxmox.com/
v1: https://lists.proxmox.com/pipermail/pve-devel/2024-August/065070.html
Notable changes v2 -> v3:
* rebased on latest master
* added explicit test for preservation of `nomodeset` parameter
Notable changes v1 -> v2:
* parse whole line by splitting and then filtering out individually
* add some tests
Diffstat
========
Christoph Heiss (3):
low level: config: filter out kernel cmdline on word boundaries
low level: config: filter out all installer-related kernel arguments
test: add test for kernel commandline parsing
Proxmox/Install/Config.pm | 11 ++++---
test/Makefile | 7 +++-
test/parse-kernel-cmdline.pl | 62 ++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 5 deletions(-)
create mode 100755 test/parse-kernel-cmdline.pl
--
2.45.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH installer v3 1/3] low level: config: filter out kernel cmdline on word boundaries
2024-11-11 11:05 [pve-devel] [PATCH installer v3 0/3] properly filter out all installer-related kernel arguments Christoph Heiss
@ 2024-11-11 11:05 ` Christoph Heiss
2024-11-11 11:05 ` [pve-devel] [PATCH installer v3 2/3] low level: config: filter out all installer-related kernel arguments Christoph Heiss
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Heiss @ 2024-11-11 11:05 UTC (permalink / raw)
To: pve-devel
Otherwise, substrings might get replaced, e.g. the replacement
`proxmox-start-auto-installer` -> `pxmox-start-auto-installer` would be
done.
Fixes: a02a78a ("fix #4747: pass kernel cmdline parameters to target system")
Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v2 -> v3:
* rebased on latest master
Changes v1 -> v2:
* split commandline along whitespace and filter individually, to avoid
problems with regexes and word boundaries
Proxmox/Install/Config.pm | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/Proxmox/Install/Config.pm b/Proxmox/Install/Config.pm
index d604676..4152a77 100644
--- a/Proxmox/Install/Config.pm
+++ b/Proxmox/Install/Config.pm
@@ -43,10 +43,12 @@ my sub parse_kernel_cmdline {
}
}
- $cmdline =~ s/(?:BOOT_IMAGE|root|ramdisk_size|splash|vga)=\S+\s?//gi;
- $cmdline =~ s/ro|rw|quiet|proxdebug|proxtui//gi;
+ my @filtered = grep {
+ $_ !~ m/^(BOOT_IMAGE|root|ramdisk_size|splash|vga)=\S+$/ &&
+ $_ !~ m/^(ro|rw|quiet|proxdebug|proxtui)$/
+ } split(/\s+/, $cmdline);
- $cfg->{target_cmdline}= $cmdline;
+ $cfg->{target_cmdline} = join(' ', @filtered);
return $cfg;
}
--
2.47.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH installer v3 2/3] low level: config: filter out all installer-related kernel arguments
2024-11-11 11:05 [pve-devel] [PATCH installer v3 0/3] properly filter out all installer-related kernel arguments Christoph Heiss
2024-11-11 11:05 ` [pve-devel] [PATCH installer v3 1/3] low level: config: filter out kernel cmdline on word boundaries Christoph Heiss
@ 2024-11-11 11:05 ` Christoph Heiss
2024-11-11 11:05 ` [pve-devel] [PATCH installer v3 3/3] test: add test for kernel commandline parsing Christoph Heiss
2024-11-11 12:30 ` [pve-devel] applied: [PATCH installer v3 0/3] properly filter out all installer-related kernel arguments Thomas Lamprecht
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Heiss @ 2024-11-11 11:05 UTC (permalink / raw)
To: pve-devel
For one, include the auto-installer arguments, which weren't filtered
out before. Secondly, include the aliases as introduced in [0].
[0] de7f779 ("unconfigured: accept more telling boot cmdline option names")
Reported-by: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v2 -> v3:
* rebased on latest master
Changes v1 -> v2:
* added parentheses around 'or'-expression
* adapted to new filtering
Proxmox/Install/Config.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Proxmox/Install/Config.pm b/Proxmox/Install/Config.pm
index 4152a77..6260ade 100644
--- a/Proxmox/Install/Config.pm
+++ b/Proxmox/Install/Config.pm
@@ -45,7 +45,8 @@ my sub parse_kernel_cmdline {
my @filtered = grep {
$_ !~ m/^(BOOT_IMAGE|root|ramdisk_size|splash|vga)=\S+$/ &&
- $_ !~ m/^(ro|rw|quiet|proxdebug|proxtui)$/
+ $_ !~ m/^(ro|rw|quiet)$/ &&
+ $_ !~ m/^(prox(debug|tui|auto)|proxmox-\S+)$/
} split(/\s+/, $cmdline);
$cfg->{target_cmdline} = join(' ', @filtered);
--
2.47.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] [PATCH installer v3 3/3] test: add test for kernel commandline parsing
2024-11-11 11:05 [pve-devel] [PATCH installer v3 0/3] properly filter out all installer-related kernel arguments Christoph Heiss
2024-11-11 11:05 ` [pve-devel] [PATCH installer v3 1/3] low level: config: filter out kernel cmdline on word boundaries Christoph Heiss
2024-11-11 11:05 ` [pve-devel] [PATCH installer v3 2/3] low level: config: filter out all installer-related kernel arguments Christoph Heiss
@ 2024-11-11 11:05 ` Christoph Heiss
2024-11-11 12:30 ` [pve-devel] applied: [PATCH installer v3 0/3] properly filter out all installer-related kernel arguments Thomas Lamprecht
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Heiss @ 2024-11-11 11:05 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v2 -> v3:
* fixed typo in test message
* added explicit test for nomodeset preservation
Changes v1 -> v2:
* new patch
Proxmox/Install/Config.pm | 2 +-
test/Makefile | 7 +++-
test/parse-kernel-cmdline.pl | 62 ++++++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 2 deletions(-)
create mode 100755 test/parse-kernel-cmdline.pl
diff --git a/Proxmox/Install/Config.pm b/Proxmox/Install/Config.pm
index 6260ade..6d47b75 100644
--- a/Proxmox/Install/Config.pm
+++ b/Proxmox/Install/Config.pm
@@ -11,7 +11,7 @@ use Proxmox::Log;
use Proxmox::Install::ISOEnv;
use Proxmox::Sys::Net;
-my sub parse_kernel_cmdline {
+sub parse_kernel_cmdline {
my ($cfg) = @_;
my $cmdline = Proxmox::Install::RunEnv::get('kernel_cmdline');
diff --git a/test/Makefile b/test/Makefile
index c473af8..70a05be 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -3,7 +3,8 @@ all:
export PERLLIB=..
.PHONY: check
-check: test-zfs-arc-max test-run-command test-parse-fqdn test-ui2-stdio test-zfs-get-pool-list
+check: test-zfs-arc-max test-run-command test-parse-fqdn test-ui2-stdio \
+ test-zfs-get-pool-list test-parse-kernel-cmdline
.PHONY: test-zfs-arc-max
test-zfs-arc-max:
@@ -24,3 +25,7 @@ test-ui2-stdio:
.PHONY: test-zfs-get-pool-list
test-zfs-get-pool-list:
./zfs-get-pool-list.pl
+
+.PHONY: test-parse-kernel-cmdline
+test-parse-kernel-cmdline:
+ ./parse-kernel-cmdline.pl
diff --git a/test/parse-kernel-cmdline.pl b/test/parse-kernel-cmdline.pl
new file mode 100755
index 0000000..0c6ce82
--- /dev/null
+++ b/test/parse-kernel-cmdline.pl
@@ -0,0 +1,62 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::MockModule qw(strict);
+
+use Proxmox::Install::RunEnv;
+use Proxmox::Install::Config qw(parse_kernel_cmdline);
+
+my $proxmox_install_runenv = Test::MockModule->new('Proxmox::Install::RunEnv');
+my $proxmox_install_isoenv = Test::MockModule->new('Proxmox::Install::ISOEnv');
+
+$proxmox_install_isoenv->redefine(
+ get => sub {
+ my ($k) = @_;
+ return { product => 'pve' } if !defined($k);
+ die "iso environment key $k not mocked!\n";
+ },
+);
+
+my sub mock_kernel_cmdline {
+ my ($cmdline) = @_;
+
+ $proxmox_install_runenv->redefine(
+ get => sub {
+ my ($k) = @_;
+ return $cmdline if $k eq 'kernel_cmdline';
+ die "iso environment key $k not mocked!\n";
+ },
+ );
+}
+
+sub is_parsed {
+ my ($cmdline, $expected) = @_;
+
+ mock_kernel_cmdline($cmdline);
+ my $cfg = Proxmox::Install::Config::parse_kernel_cmdline({});
+
+ is($cfg->{target_cmdline}, $expected, "filtered kernel commandline matched expected: ${expected}");
+}
+
+is_parsed(
+ 'BOOT_IMAGE=/vmlinuz-6.8.12-1-pve root=/dev/mapper/pve-root ro quiet',
+ ''
+);
+
+is_parsed(
+ 'BOOT_IMAGE=/vmlinuz-6.8.12-1-pve root=/dev/mapper/pve-root ro= quiet',
+ 'ro='
+);
+
+is_parsed(
+ 'a BOOT_IMAGE=/vmlinuz-6.8.12-1-pve b root=/dev/mapper/pve-root c ro d quiet e',
+ 'a b c d e'
+);
+
+is_parsed('proxmox-foo foo=bar proxtui', 'foo=bar');
+is_parsed('proxmox-foo nomodeset quiet', 'nomodeset');
+
+done_testing();
--
2.47.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] applied: [PATCH installer v3 0/3] properly filter out all installer-related kernel arguments
2024-11-11 11:05 [pve-devel] [PATCH installer v3 0/3] properly filter out all installer-related kernel arguments Christoph Heiss
` (2 preceding siblings ...)
2024-11-11 11:05 ` [pve-devel] [PATCH installer v3 3/3] test: add test for kernel commandline parsing Christoph Heiss
@ 2024-11-11 12:30 ` Thomas Lamprecht
3 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2024-11-11 12:30 UTC (permalink / raw)
To: Proxmox VE development discussion, Christoph Heiss
Am 11.11.24 um 12:05 schrieb Christoph Heiss:
> Friedrich reported that when installing using the auto-installer, the
> kernel commandline does not get cleaned up properly.
>
> History
> =======
>
> v2: https://lore.proxmox.com/pve-devel/20240821132307.1352643-1-c.heiss@proxmox.com/
> v1: https://lists.proxmox.com/pipermail/pve-devel/2024-August/065070.html
>
> Notable changes v2 -> v3:
> * rebased on latest master
> * added explicit test for preservation of `nomodeset` parameter
>
> Notable changes v1 -> v2:
> * parse whole line by splitting and then filtering out individually
> * add some tests
>
> Diffstat
> ========
>
> Christoph Heiss (3):
> low level: config: filter out kernel cmdline on word boundaries
> low level: config: filter out all installer-related kernel arguments
> test: add test for kernel commandline parsing
>
> Proxmox/Install/Config.pm | 11 ++++---
> test/Makefile | 7 +++-
> test/parse-kernel-cmdline.pl | 62 ++++++++++++++++++++++++++++++++++++
> 3 files changed, 75 insertions(+), 5 deletions(-)
> create mode 100755 test/parse-kernel-cmdline.pl
>
applied series, thanks!
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-11-11 12:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-11 11:05 [pve-devel] [PATCH installer v3 0/3] properly filter out all installer-related kernel arguments Christoph Heiss
2024-11-11 11:05 ` [pve-devel] [PATCH installer v3 1/3] low level: config: filter out kernel cmdline on word boundaries Christoph Heiss
2024-11-11 11:05 ` [pve-devel] [PATCH installer v3 2/3] low level: config: filter out all installer-related kernel arguments Christoph Heiss
2024-11-11 11:05 ` [pve-devel] [PATCH installer v3 3/3] test: add test for kernel commandline parsing Christoph Heiss
2024-11-11 12:30 ` [pve-devel] applied: [PATCH installer v3 0/3] properly filter out all installer-related kernel arguments Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox