Add tick counting during graceful shutdown to forcibly stop if blocked
This commit is contained in:
parent
b199039453
commit
ea97b51edb
|
@ -97,7 +97,8 @@ class NodeInstance(threading.Thread):
|
||||||
while True:
|
while True:
|
||||||
# Toggle state management of all VMs
|
# Toggle state management of all VMs
|
||||||
for domain, instance in self.s_domain.items():
|
for domain, instance in self.s_domain.items():
|
||||||
instance.manage_vm_state()
|
if instance.inshutdown == False:
|
||||||
|
instance.manage_vm_state()
|
||||||
|
|
||||||
# Remove any non-running VMs from our list
|
# Remove any non-running VMs from our list
|
||||||
for domain in self.domain_list:
|
for domain in self.domain_list:
|
||||||
|
|
|
@ -13,6 +13,7 @@ class VMInstance:
|
||||||
# These will all be set later
|
# These will all be set later
|
||||||
self.hypervisor = None
|
self.hypervisor = None
|
||||||
self.state = None
|
self.state = None
|
||||||
|
self.inshutdown = False
|
||||||
|
|
||||||
# Start up a new Libvirt connection
|
# Start up a new Libvirt connection
|
||||||
libvirt_name = "qemu:///system"
|
libvirt_name = "qemu:///system"
|
||||||
|
@ -79,8 +80,15 @@ class VMInstance:
|
||||||
print(">>> Stopping VM %s" % self.domuuid)
|
print(">>> Stopping VM %s" % self.domuuid)
|
||||||
self.dom.shutdown()
|
self.dom.shutdown()
|
||||||
try:
|
try:
|
||||||
while self.dom.state()[0] == libvirt.VIR_DOMAIN_RUNNING:
|
self.inshutdown = True
|
||||||
|
tick = 0
|
||||||
|
while self.dom.state()[0] == libvirt.VIR_DOMAIN_RUNNING and tick < 60:
|
||||||
|
tick += 1
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
if tick >= 60:
|
||||||
|
self.stop_vm()
|
||||||
|
return
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue