Module: tools
Branch: master
Commit: d19b0f740497ffce9a1780ccd75cc9eff417e537
URL: https://source.winehq.org/git/tools.git/?a=commit;h=d19b0f740497ffce9a1780c…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Sep 25 08:51:57 2019 +0200
testbot/LibvirtTool: Create the locale snapshots as needed.
A VM may have a lot of locale live snapshots. This removes the need for
manually creating them (or recreating them after restoring the VM from
backup or after a QEmu upgrade).
Sadly the locales must still be manually installed beforehand.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/bin/LibvirtTool.pl | 73 ++++++++++++++++++++++++++++----
testbot/{scripts => bin}/SetWinLocale | 0
testbot/bin/WineRunReconfig.pl | 2 +-
testbot/lib/WineTestBot/LibvirtDomain.pm | 5 +--
4 files changed, 67 insertions(+), 13 deletions(-)
diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index d1402bc..936c386 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -365,9 +365,9 @@ sub CheckOff()
return ChangeStatus("dirty", "off", "done");
}
-sub SetupTestAgentd($$)
+sub SetupTestAgentd($$$)
{
- my ($VM, $Booting) = @_;
+ my ($VM, $Booting, $ResetStartCount) = @_;
Debug(Elapsed($Start), " Setting up the $VMKey TestAgent server\n");
LogMsg "Setting up the $VMKey TestAgent server\n";
@@ -379,6 +379,23 @@ sub SetupTestAgentd($$)
my $ErrMessage = $TA->GetLastError();
FatalError("Could not connect to the $VMKey TestAgent: $ErrMessage\n");
}
+
+ if ($ResetStartCount)
+ {
+ # If SetProperty() is not supported neither is --show-restarts.
+ # So it all works out.
+ $TA->SetProperty("start.count", 0);
+ }
+ else
+ {
+ # Check that TestAgentd is not displaying the "Has Windows rebooted?"
+ # warning.
+ my $Count = $TA->GetProperties("start.count");
+ if (defined $Count and $Count > 1)
+ {
+ FatalError("Cannot take a live snapshot because start.count=$Count > 1");
+ }
+ }
$TA->Disconnect();
}
@@ -435,9 +452,17 @@ sub Revert()
$CurrentStatus = "reverting";
my $DomainSnapshot = $VM->IdleSnapshot;
my $ExtraTimeout = 0;
- my $CreateSnapshot;
+ my ($SetLocale, $CreateSnapshot);
my $Domain = $VM->GetDomain();
+ if (!$Domain->HasSnapshot($DomainSnapshot) and
+ $DomainSnapshot =~ s/-([a-z]{2})[_-]([A-Z]{2})$//)
+ {
+ # Add some extra time to set up the VM locale and reboot it
+ $ExtraTimeout += $VMToolTimeout;
+ $SetLocale = "$1-$2";
+ Debug(Elapsed($Start), " $VMKey does not yet have a $DomainSnapshot-$SetLocale snapshot\n");
+ }
if (!$Domain->HasSnapshot($DomainSnapshot) and $DomainSnapshot =~ s/-live$//)
{
# Add some extra time to boot the VM and create the live snapshot
@@ -484,19 +509,49 @@ sub Revert()
# Mark the VM as sleeping which allows the scheduler to abort the revert in
# favor of higher priority tasks. But don't allow interruptions in the
# middle of snapshot creation!
- if (!$CreateSnapshot)
+ if (!$CreateSnapshot and !$SetLocale)
{
return 1 if (ChangeStatus("reverting", "sleeping"));
}
- # Set up the TestAgent server
- SetupTestAgentd($VM, $Booting);
+ # Set up the TestAgent server. Note that setting the locale will require a
+ # reboot so reset start.count in that case.
+ SetupTestAgentd($VM, $Booting, $SetLocale);
if ($CreateSnapshot)
{
- CreateSnapshot($Domain, $VM->IdleSnapshot);
+ $DomainSnapshot .= "-live";
+ CreateSnapshot($Domain, $DomainSnapshot);
}
- else
+
+ # Set up the VM locale
+ if ($SetLocale)
+ {
+ Debug(Elapsed($Start), " Setting up the $SetLocale locale on $VMKey\n");
+ if (system("$BinDir/SetWinLocale", "--vm", $VMKey, "--default", $SetLocale))
+ {
+ FatalError("Could not set the $VMKey locale to $SetLocale\n");
+ }
+
+ Debug(Elapsed($Start), " Wait for the $VMKey locale-setting reboot to complete\n");
+ LogMsg "Wait for the $VMKey locale-setting reboot to complete\n";
+ while (1)
+ {
+ my $TA = $VM->GetAgent();
+ my $Count = $TA->GetProperties("start.count");
+ $TA->Disconnect();
+
+ # SetupTestAgentd() has reset start.count to zero.
+ # It will only change after the reboot.
+ last if (defined $Count and $Count != 0);
+
+ sleep(1);
+ }
+
+ $DomainSnapshot .= "-$SetLocale";
+ CreateSnapshot($Domain, $DomainSnapshot);
+ }
+ elsif (!$CreateSnapshot)
{
my $Sleep = ($Booting and $SleepAfterBoot > $SleepAfterRevert) ?
$SleepAfterBoot : $SleepAfterRevert;
@@ -505,7 +560,7 @@ sub Revert()
sleep($Sleep);
}
- if ($CreateSnapshot)
+ if ($CreateSnapshot or $SetLocale)
{
# The activity monitor does not like it when VMs skip the sleeping step
return 1 if (ChangeStatus("reverting", "sleeping"));
diff --git a/testbot/scripts/SetWinLocale b/testbot/bin/SetWinLocale
similarity index 100%
rename from testbot/scripts/SetWinLocale
rename to testbot/bin/SetWinLocale
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index 1103120..2e62a2e 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -512,7 +512,7 @@ if ($NewStatus eq 'completed')
}
Debug(Elapsed($Start), " Recreating the $IdleSnapshot snapshot\n");
- $ErrMessage = $Domain->CreateSnapshot();
+ $ErrMessage = $Domain->CreateSnapshot($IdleSnapshot);
if (defined $ErrMessage)
{
# Without the snapshot the VM is not usable anymore but FatalError() will
diff --git a/testbot/lib/WineTestBot/LibvirtDomain.pm b/testbot/lib/WineTestBot/LibvirtDomain.pm
index 14bf71d..9613e83 100644
--- a/testbot/lib/WineTestBot/LibvirtDomain.pm
+++ b/testbot/lib/WineTestBot/LibvirtDomain.pm
@@ -328,14 +328,13 @@ sub RevertToSnapshot($$)
return (undef, $Reason != Sys::Virt::Domain::STATE_RUNNING_FROM_SNAPSHOT);
}
-sub CreateSnapshot($)
+sub CreateSnapshot($$)
{
- my ($self) = @_;
+ my ($self, $SnapshotName) = @_;
my ($ErrMessage, $Domain) = $self->_GetDomain();
return $ErrMessage if (defined $ErrMessage);
- my $SnapshotName = $self->{VM}->IdleSnapshot;
# FIXME: XML escaping
my $Xml = "<domainsnapshot><name>$SnapshotName</name></domainsnapshot>";
eval { $Domain->create_snapshot($Xml, 0) };
Module: tools
Branch: master
Commit: 358f63b80f3eeff4ce35b212263b12e962878719
URL: https://source.winehq.org/git/tools.git/?a=commit;h=358f63b80f3eeff4ce35b21…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Sep 25 08:51:22 2019 +0200
testbot/WineRunReconfig: Tweak formatting of a notification email.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/bin/WineRunReconfig.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index bfbc5ab..1103120 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -299,8 +299,8 @@ sub FatalTAError($$)
# since neither the VM nor the task are at fault.
Error("$ErrMessage\n");
NotifyAdministrator("Putting the ". $VM->Name ." VM offline",
- "A TestAgent operation to the ". $VM->Name ." VM failed:\n".
- "\n$ErrMessage\n".
+ "A TestAgent operation to the ". $VM->Name ." VM failed:\n\n".
+ "$ErrMessage\n\n".
"So the VM has been put offline and the TestBot will try to regain access to it.");
WrapUpAndExit('queued');
}