Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for additional kernel parameters #20971

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_kernel_params";
$pre_test_cmd .= " -k $guest_kernel_params";

return "$pre_test_cmd";
}
Expand Down
Loading