Track status of VM state thread

This commit is contained in:
Joshua Boniface 2021-09-26 22:55:21 -04:00
parent 341073521b
commit e10ac52116
1 changed files with 8 additions and 2 deletions

View File

@ -67,6 +67,9 @@ class VMInstance(object):
self.inshutdown = False
self.instop = False
# State thread
self.state_thread = None
# Libvirt domuuid
self.dom = self.lookupByUUID(self.domuuid)
@ -83,8 +86,8 @@ class VMInstance(object):
# Perform a management command
self.logger.out('Updating state of VM {}'.format(self.domuuid), state='i')
state_thread = Thread(target=self.manage_vm_state, args=(), kwargs={})
state_thread.start()
self.state_thread = Thread(target=self.manage_vm_state, args=(), kwargs={})
self.state_thread.start()
# Get data functions
def getstate(self):
@ -716,6 +719,9 @@ class VMInstance(object):
else:
self.terminate_vm()
self.state_thread = None
return
# This function is a wrapper for libvirt.lookupByUUID which fixes some problems
# 1. Takes a text UUID and handles converting it to bytes
# 2. Try's it and returns a sensible value if not