From 8265560336297522704704068eff0bc8205e264c Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 16 Jan 2025 17:20:02 +0800 Subject: [PATCH] Add option for additional kernel parameters bsc#1231522 makes one point clear that we are looking into feature request to have some point before reboot to collect logs for further analysis and using something that already exists created exactly for this purpose which has the timeout value configurable on the linuxrc command line: - https://github.com/yast/yast-yast2/pull/977 - https://github.com/yast/yast-installation/pull/823 - https://github.com/openSUSE/installation-images/pull/344 It's even briefly documented at https://en.opensuse.org/SDB:Linuxrc. In order to generalize this change and also make things much easier, using "extra kernel params" can help pass any desired parameters to kernel instead of just reboot_timeout. --- lib/virt_autotest/utils.pm | 34 +++++++++++++++++++ tests/virt_autotest/guest_installation_run.pm | 3 +- .../host_upgrade_generate_run_file.pm | 4 +++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/virt_autotest/utils.pm b/lib/virt_autotest/utils.pm index ced7abb95227..79e206dd5fce 100644 --- a/lib/virt_autotest/utils.pm +++ b/lib/virt_autotest/utils.pm @@ -95,6 +95,7 @@ our @EXPORT = qw( get_guest_regcode execute_over_ssh reboot_virtual_machine + get_guest_settings ); my %log_cursors; @@ -1435,4 +1436,37 @@ sub reboot_virtual_machine { } } +=head2 get_guest_settings + + get_guest_settings(separator => 'string separator') + +Settings for guests can be provided just only once and then it should be replicated +to all guests specified by GUEST_PATTERN, GUEST_LIST or GUEST. This subroutine has +two arguments list of names of settings and separator. Multiple settings are seperated +by comma. The generated value of settings joined together by specified separator. +Multiple settings and their values are put in a hash object and returns its reference. + +=cut + +sub get_guest_settings { + my (%args) = @_; + $args{settings} //= ""; + $args{separator} //= ","; + + my $guest = (get_var("GUEST_PATTERN") ? get_var("GUEST_PATTERN") : (get_var("GUEST_LIST") ? get_var("GUEST_LIST") : get_var("GUEST", ""))); + croak("Settings and guests (GUEST_PATTERN, GUEST_LIST or GUEST exclusively) to be involved must be given") if (!$args{settings} or !$guest); + + my %settings_matrix = (); + my $guest_count = ($args{separator} eq '|' ? scalar(split("\\$args{separator}", $guest)) : scalar(split("$args{separator}", $guest))); + foreach (split(/,/, $args{settings})) { + my $value = get_var($_, ""); + my $setting_count = ($args{separator} eq '|' ? scalar(split("\\$args{separator}", $value)) : scalar(split("$args{separator}", $value))); + $value = join("$args{separator}", ($value) x $guest_count) if ($guest_count != $setting_count); + my $setting_pointer = \%settings_matrix; + $setting_pointer->{$_} = $value; + } + + return \%settings_matrix; +} + 1; diff --git a/tests/virt_autotest/guest_installation_run.pm b/tests/virt_autotest/guest_installation_run.pm index 3fe713bbd276..c8f7a2f362d9 100644 --- a/tests/virt_autotest/guest_installation_run.pm +++ b/tests/virt_autotest/guest_installation_run.pm @@ -37,7 +37,8 @@ sub get_script_run { my $guest_pattern = get_var('GUEST_PATTERN', 'sles-12-sp2-64-[p|f]v-def-net'); my $parallel_num = get_var("PARALLEL_NUM", "2"); my ($regcode, $regcode_ltss) = get_guest_regcode(separator => '|'); - $pre_test_cmd .= " -f \"" . $guest_pattern . "\" -n " . $parallel_num . " -r " . " -e \"" . $regcode . "\" -E \"" . $regcode_ltss . "\""; + my $kernel_params = get_guest_settings(settings => 'GUEST_EXT_KERNEL_PARAMS', separator => '|'); + $pre_test_cmd .= " -f \"" . $guest_pattern . "\" -n " . $parallel_num . " -r " . " -e \"" . $regcode . "\" -E \"" . $regcode_ltss . "\" -k \"" . $kernel_params->{'GUEST_EXT_KERNEL_PARAMS'} . "\""; $pre_test_cmd .= " 2>&1 | tee /tmp/s390x_guest_install_test.log" if (is_s390x); return $pre_test_cmd; diff --git a/tests/virt_autotest/host_upgrade_generate_run_file.pm b/tests/virt_autotest/host_upgrade_generate_run_file.pm index 519c98db9a3c..6064971d9bb9 100644 --- a/tests/virt_autotest/host_upgrade_generate_run_file.pm +++ b/tests/virt_autotest/host_upgrade_generate_run_file.pm @@ -33,6 +33,8 @@ sub get_script_run { my $do_registration = (check_var('SCC_REGISTER', 'installation') || check_var('REGISTER', 'installation') || get_var('AUTOYAST', '')) ? "true" : "false"; my $registration_server = get_var('SCC_URL', 'https://scc.suse.com'); my $registration_code = get_var('SCC_REGCODE', 'INVALID_REGCODE'); + my $host_kernel_params = get_var('HOST_EXT_KERNEL_PARAMS', 'NA'); + my $guest_kernel_params = get_guest_settings(settings => 'GUEST_EXT_KERNEL_PARAMS', separator => '|'); $pre_test_cmd = "/usr/share/qa/tools/_generate_vh-update_tests.sh"; $pre_test_cmd .= " -m $mode"; @@ -46,6 +48,8 @@ sub get_script_run { $pre_test_cmd .= " -e $do_registration"; $pre_test_cmd .= " -s $registration_server"; $pre_test_cmd .= " -c $registration_code"; + $pre_test_cmd .= " -K $host_ext_kernel_params"; + $pre_test_cmd .= " -k $guest_ext_kernel_params"; return "$pre_test_cmd"; }