Skip to content

Commit 4a70232

Browse files
Robert Foleystsquad
authored andcommitted
tests/vm: add shutdown timeout in basevm.py
We are adding the shutdown timeout to solve an issue we now see where the aarch64 VMs timeout on shutdown under TCG. There is a new 3 second timeout in machine.py, which we override in basevm.py when shutting down. Signed-off-by: Robert Foley <[email protected]> Signed-off-by: Alex Bennée <[email protected]> Message-Id: <[email protected]> Message-Id: <[email protected]>
1 parent 80ded8e commit 4a70232

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/vm/basevm.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,16 @@ class BaseVM(object):
8080
arch = "#arch"
8181
# command to halt the guest, can be overridden by subclasses
8282
poweroff = "poweroff"
83+
# Time to wait for shutdown to finish.
84+
shutdown_timeout_default = 30
8385
# enable IPv6 networking
8486
ipv6 = True
8587
# This is the timeout on the wait for console bytes.
8688
socket_timeout = 120
8789
# Scale up some timeouts under TCG.
8890
# 4 is arbitrary, but greater than 2,
8991
# since we found we need to wait more than twice as long.
90-
tcg_ssh_timeout_multiplier = 4
92+
tcg_timeout_multiplier = 4
9193
def __init__(self, args, config=None):
9294
self._guest = None
9395
self._genisoimage = args.genisoimage
@@ -141,9 +143,12 @@ def __init__(self, args, config=None):
141143
if args.jobs and args.jobs > 1:
142144
self._args += ["-smp", "%d" % args.jobs]
143145
if kvm_available(self.arch):
146+
self._shutdown_timeout = self.shutdown_timeout_default
144147
self._args += ["-enable-kvm"]
145148
else:
146149
logging.info("KVM not available, not using -enable-kvm")
150+
self._shutdown_timeout = \
151+
self.shutdown_timeout_default * self.tcg_timeout_multiplier
147152
self._data_args = []
148153

149154
if self._config['qemu_args'] != None:
@@ -423,7 +428,7 @@ def print_step(self, text):
423428
def wait_ssh(self, wait_root=False, seconds=300, cmd="exit 0"):
424429
# Allow more time for VM to boot under TCG.
425430
if not kvm_available(self.arch):
426-
seconds *= self.tcg_ssh_timeout_multiplier
431+
seconds *= self.tcg_timeout_multiplier
427432
starttime = datetime.datetime.now()
428433
endtime = starttime + datetime.timedelta(seconds=seconds)
429434
cmd_success = False
@@ -441,14 +446,14 @@ def wait_ssh(self, wait_root=False, seconds=300, cmd="exit 0"):
441446
raise Exception("Timeout while waiting for guest ssh")
442447

443448
def shutdown(self):
444-
self._guest.shutdown()
449+
self._guest.shutdown(timeout=self._shutdown_timeout)
445450

446451
def wait(self):
447-
self._guest.wait()
452+
self._guest.wait(timeout=self._shutdown_timeout)
448453

449454
def graceful_shutdown(self):
450455
self.ssh_root(self.poweroff)
451-
self._guest.wait()
456+
self._guest.wait(timeout=self._shutdown_timeout)
452457

453458
def qmp(self, *args, **kwargs):
454459
return self._guest.qmp(*args, **kwargs)

0 commit comments

Comments
 (0)