[tools 1/3] testbot/LibvirtTool: Wait a bit between shutting down and reverting a VM.
Francois Gouget
fgouget at codeweavers.com
Mon Feb 14 22:03:17 CST 2022
Also rename ShutDown() to the more descriptive ShutDownIfOffSnapshot()
and document it.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
Without this delay reverting from a PCI-passthrough configuration to a
regular VGA live snapshot sometimes results in a black VM screen.
---
testbot/bin/LibvirtTool.pl | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index ef94a2be09..1fc7dc1d4c 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -280,7 +280,20 @@ sub GetPrivilegedTA($)
return $TA->SetTime() ? $TA : $VM->GetAgent(1);
}
-sub ShutDown()
+=pod
+=over 12
+
+=item C<ShutDownIfOffSnapshot()>
+
+Attempt a clean shutdown of the VM if it is running a snapshot that requests
+them (snapshot name containing '-off').
+
+Returns 0 if the shutdown failed, 2 if it was successful and 1 if the VM was
+already powered off or a shutdown was not needed.
+=back
+=cut
+
+sub ShutDownIfOffSnapshot()
{
my $Domain = $VM->GetDomain();
my $CurrentSnapshot = $Domain->GetSnapshotName();
@@ -311,7 +324,7 @@ sub ShutDown()
{
Debug(Elapsed($Start), " Successfully shut down $VMKey\n");
LogMsg "Successfully shut down $VMKey\n";
- return 1;
+ return 2;
}
sleep(1);
}
@@ -365,7 +378,7 @@ sub Monitor()
if ($IsReady and $VM->GetDomain()->IsPoweredOn())
{
# Try to perform a clean shutdown if requested
- ShutDown();
+ ShutDownIfOffSnapshot();
my $ErrMessage = $VM->GetDomain()->PowerOff();
if (defined $ErrMessage)
@@ -391,7 +404,7 @@ sub Monitor()
sub PowerOff()
{
# Try to perform a clean shutdown if requested
- ShutDown();
+ ShutDownIfOffSnapshot();
# Power off the VM no matter what its initial status is
$CurrentStatus = $VM->Status;
@@ -431,7 +444,7 @@ sub CheckOff()
if ($SnapshotName eq $VM->IdleSnapshot)
{
# Try to perform a clean shutdown if requested
- ShutDown();
+ ShutDownIfOffSnapshot();
my $ErrMessage = $VM->GetDomain()->PowerOff();
FatalError("$ErrMessage\n") if (defined $ErrMessage);
@@ -612,8 +625,10 @@ sub Revert()
$VM->Save();
}
- # Before reverting, try to perform a clean shutdown if requested
- ShutDown();
+ # Before reverting, try to perform a clean shutdown if requested.
+ # After a shutdown a small wait is also sometimes required, at least when
+ # switching from a PCI-passthrough configuration to a regular one.
+ sleep(1) if (ShutDownIfOffSnapshot() == 2);
# Revert the VM (and power it on if necessary)
Debug(Elapsed($Start), " Reverting $VMKey to $DomainSnapshot\n");
--
2.30.2
More information about the wine-devel
mailing list