Skip to content

Commit

Permalink
Regenrate EFI secret key before power management
Browse files Browse the repository at this point in the history
According to information about changes made by Jira feature PED-87
Do NOT auto-generate EFI secret-key for hibernation verification,
it is necessary to regenerate key by:
echo 1 > /sys/firmware/efi/secret-key/regen before power management.
  • Loading branch information
waynechen55 committed Jan 3, 2025
1 parent f8cbef8 commit 7e362d0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
25 changes: 24 additions & 1 deletion lib/virt_autotest/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ our @EXPORT = qw(
remove_additional_nic
start_guests
is_guest_online
ensure_online wait_guest_online
ensure_online
wait_guest_online
restore_downloaded_guests
save_original_guest_xmls
restore_original_guests
Expand All @@ -92,6 +93,7 @@ our @EXPORT = qw(
recreate_guests
download_vm_import_disks
get_guest_regcode
run_command_over_ssh
);

my %log_cursors;
Expand Down Expand Up @@ -1373,4 +1375,25 @@ sub wait_for_host_reboot {
select_console('root-ssh');
}

=head2 run_command_over_ssh
run_command_over_ssh(address => $address, timeout => $timeout)
Run command over passwordless ssh session. Arguments include address, which can take
the form of FQDN or IP, and timeout, which sets amount of time to wait before return.
=cut

sub run_command_over_ssh {
my %args = @_;
$args{username} //= 'root';
$args{address} //= '';
$args{command} //= '';
$args{timeout} //= 90;
croak('Argument address must be given to run command over ssh') if (!$args{address} or !$args{command});

my $command = "ssh $args{username}\@$args{address} $args{command}";
script_retry($command, timeout => $args{timeout}, delay => 15, retry => 3, die => 1);
}

1;
14 changes: 14 additions & 0 deletions tests/virt_autotest/uefi_guest_verification.pm
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ sub check_guest_secure_boot {
return $self;
}

# PED-87 Do NOT auto-generate EFI secret-key for hibernation verification leads
# to bsc#1230977 Fail to dompmsuspend 15SP7 FV UEFI guest system. In order to
# continue to perform power management, regenerating efi secret key and reboot
# for uefi guest is needed.
sub regen_efi_secret_key {
my ($self, $guest) = @_;

run_command_over_ssh(address => $guest, command => 'echo 1 > /sys/firmware/efi/secret-key/regen');
run_command_over_ssh(address => $guest, command => 'reboot');
wait_guest_online($guest);
}

sub check_guest_pmsuspend_enabled {
my $self = shift;

Expand All @@ -108,13 +120,15 @@ sub check_guest_pmsuspend_enabled {
record_info("PMSUSPEND to hyrbrid is not supported here", "Guest $_ on kvm sles 15+ host");
next;
}
$self->regen_efi_secret_key($_);
$self->do_guest_pmsuspend($_, 'hybrid');
}
foreach (keys %virt_autotest::common::guests) {
if (is_sle('>=15') and ($_ =~ /12-sp5/img)) {
record_info("PMSUSPEND to disk is not supported here", "Guest $_ on kvm sles 15+ host");
next;
}
$self->regen_efi_secret_key($_);
$self->do_guest_pmsuspend($_, 'disk');
}
}
Expand Down

0 comments on commit 7e362d0

Please sign in to comment.