Skip to content

Commit

Permalink
Add option for additional kernel parameters
Browse files Browse the repository at this point in the history
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:
- yast/yast-yast2#977
- yast/yast-installation#823
- openSUSE/installation-images#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.
  • Loading branch information
waynechen55 committed Jan 16, 2025
1 parent 1f5d460 commit 8265560
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
34 changes: 34 additions & 0 deletions lib/virt_autotest/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ our @EXPORT = qw(
get_guest_regcode
execute_over_ssh
reboot_virtual_machine
get_guest_settings
);

my %log_cursors;
Expand Down Expand Up @@ -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;
3 changes: 2 additions & 1 deletion tests/virt_autotest/guest_installation_run.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions tests/virt_autotest/host_upgrade_generate_run_file.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
}
Expand Down

0 comments on commit 8265560

Please sign in to comment.