Make extra sure VMs terminate when told
When doing a stop_vm or terminate_vm, check again after 0.2 seconds and try re-terminating if it's still running. Covers cases where a VM doesn't stop if given the 'stop' state.
This commit is contained in:
parent
f12de6727d
commit
f0fd3d3f0e
|
@ -335,6 +335,13 @@ class VMInstance(object):
|
||||||
self.instop = True
|
self.instop = True
|
||||||
try:
|
try:
|
||||||
self.dom.destroy()
|
self.dom.destroy()
|
||||||
|
time.sleep(0.2)
|
||||||
|
try:
|
||||||
|
if self.getdom().state()[0] == libvirt.VIR_DOMAIN_RUNNING:
|
||||||
|
# It didn't terminate, try again
|
||||||
|
self.dom.destroy()
|
||||||
|
except libvirt.libvirtError:
|
||||||
|
pass
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.logger.out('Failed to terminate VM', state='e', prefix='Domain {}'.format(self.domuuid))
|
self.logger.out('Failed to terminate VM', state='e', prefix='Domain {}'.format(self.domuuid))
|
||||||
self.removeDomainFromList()
|
self.removeDomainFromList()
|
||||||
|
@ -351,6 +358,13 @@ class VMInstance(object):
|
||||||
self.instop = True
|
self.instop = True
|
||||||
try:
|
try:
|
||||||
self.dom.destroy()
|
self.dom.destroy()
|
||||||
|
time.sleep(0.2)
|
||||||
|
try:
|
||||||
|
if self.getdom().state()[0] == libvirt.VIR_DOMAIN_RUNNING:
|
||||||
|
# It didn't terminate, try again
|
||||||
|
self.dom.destroy()
|
||||||
|
except libvirt.libvirtError:
|
||||||
|
pass
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.logger.out('Failed to stop VM', state='e', prefix='Domain {}'.format(self.domuuid))
|
self.logger.out('Failed to stop VM', state='e', prefix='Domain {}'.format(self.domuuid))
|
||||||
self.removeDomainFromList()
|
self.removeDomainFromList()
|
||||||
|
|
Loading…
Reference in New Issue