Module: tools Branch: master Commit: 44456b4f96bc602827244416afe2dbbbb7600d10 URL: https://source.winehq.org/git/tools.git/?a=commit;h=44456b4f96bc602827244416...
Author: Francois Gouget fgouget@codeweavers.com Date: Wed Jul 11 11:35:42 2018 +0200
testbot/LibvirtTool: Only power off the VM if needed for the revert.
Reverting from a powered off state is sometimes ten times longer than reverting from the current state. But Libvirt/QEmu is buggy and fails to revert if the VM configuration changes. So try the revert first and, if it fails (which is fast), power off + re-revert the VM.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/bin/LibvirtTool.pl | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl index 39e8c55..e6742f4 100755 --- a/testbot/bin/LibvirtTool.pl +++ b/testbot/bin/LibvirtTool.pl @@ -411,19 +411,25 @@ sub Revert() } $CurrentStatus = "reverting";
- # Some QEmu/KVM versions are buggy and cannot revert a running VM - Debug(Elapsed($Start), " Powering off the VM\n"); + # Revert the VM (and power it on if necessary) my $Domain = $VM->GetDomain(); - my $ErrMessage = $Domain->PowerOff(); + Debug(Elapsed($Start), " Reverting $VMKey to ", $VM->IdleSnapshot, "\n"); + my $ErrMessage = $Domain->RevertToSnapshot(); if (defined $ErrMessage) { - LogMsg "Could not power off $VMKey: $ErrMessage\n"; - LogMsg "Trying the revert anyway...\n"; - } + # Libvirt/QEmu is buggy and cannot revert a running VM from one hardware + # configuration to another. So try again after powering off the VM, though + # this can be much slower. + Debug(Elapsed($Start), " Powering off the VM\n"); + $ErrMessage = $Domain->PowerOff(); + if (defined $ErrMessage) + { + FatalError("Could not power off $VMKey: $ErrMessage\n"); + }
- # Revert the VM (and power it on if necessary) - Debug(Elapsed($Start), " Reverting $VMKey to ", $VM->IdleSnapshot, "\n"); - $ErrMessage = $Domain->RevertToSnapshot(); + Debug(Elapsed($Start), " Reverting $VMKey to ", $VM->IdleSnapshot, "... again\n"); + $ErrMessage = $Domain->RevertToSnapshot(); + } if (defined $ErrMessage) { FatalError("Could not revert $VMKey to ". $VM->IdleSnapshot .": $ErrMessage\n");