Commit 4ad45119 authored by Guido Trotter's avatar Guido Trotter
Browse files

KVMHypervisor: use the StopInstance retry feature

Since we know StopInstance is going to be called more than once (at
least twice, once with force and once without, but normally quite a lot
more) we don't need our own sleep/loop, and we can just send one monitor
command per call.
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarOlivier Tharan <>
parent e4e9b806
......@@ -521,32 +521,16 @@ class KVMHypervisor(hv_base.BaseHypervisor):
return result
def _RetryInstancePowerdown(self, instance, pid, timeout=30):
"""Wait for an instance to power down.
# Wait up to $timeout seconds
end = time.time() + timeout
wait = 1
while time.time() < end and utils.IsProcessAlive(pid):
self._CallMonitorCommand(, 'system_powerdown')
# Make wait time longer for next try
if wait < 5:
wait *= 1.3
def StopInstance(self, instance, force=False, retry=False):
"""Stop an instance.
if retry:
pidfile, pid, alive = self._InstancePidAlive(
if pid > 0 and alive:
if force or not instance.hvparams[constants.HV_ACPI]:
self._RetryInstancePowerdown(instance, pid)
self._CallMonitorCommand(, 'system_powerdown')
if not utils.IsProcessAlive(pid):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment