diff --git a/node-daemon/pvcnoded/objects/VMInstance.py b/node-daemon/pvcnoded/objects/VMInstance.py index 9b3a55ff..67fdc486 100644 --- a/node-daemon/pvcnoded/objects/VMInstance.py +++ b/node-daemon/pvcnoded/objects/VMInstance.py @@ -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