Change shutdown_vm_gracefully method so that it invokes
'destroy' if 'shutdown' has not completed after 30 seconds.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
lib/Sys/Virt/TCK/NetworkHelpers.pm | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/Sys/Virt/TCK/NetworkHelpers.pm b/lib/Sys/Virt/TCK/NetworkHelpers.pm
index 8bd3802..5d19736 100644
--- a/lib/Sys/Virt/TCK/NetworkHelpers.pm
+++ b/lib/Sys/Virt/TCK/NetworkHelpers.pm
@@ -118,13 +118,15 @@ sub build_domain{
return ($guest, $install);
}
-sub shutdown_vm_gracefully{
+sub shutdown_vm_gracefully {
my $dom = shift;
+ my $target = time() + 30;
$dom->shutdown;
- while($dom->is_active()) {
+ while ($dom->is_active()) {
sleep(1);
diag ".. waiting for virtual machine to shutdown.. ";
+ $dom->destroy() if time() > $target;
}
sleep(1);
diag ".. shutdown complete.. ";
--
1.8.5.3