Catch libvirt startup errors and reset state to stop

This commit is contained in:
Joshua Boniface 2018-06-02 00:30:25 -04:00
parent 7f87ac76fb
commit 2b2f672e39
1 changed files with 5 additions and 3 deletions

View File

@ -32,9 +32,11 @@ class VMInstance:
# Start up the VM # Start up the VM
def start_vm(self, conn, xmlconfig): def start_vm(self, conn, xmlconfig):
print("Starting VM %s" % self.domuuid) print("Starting VM %s" % self.domuuid)
dom = conn.createXML(xmlconfig, 0) try:
if dom == None: dom = conn.createXML(xmlconfig, 0)
print('Failed to create a domain from an XML definition.') except libvirt.libvirtError:
print('Failed to create domain %s' % self.domuuid)
self.zk.set(self.zkey + '/status', 'stop'.encode('ascii'))
exit(1) exit(1)
if not self.domuuid in self.thishypervisor.domain_list: if not self.domuuid in self.thishypervisor.domain_list:
self.thishypervisor.domain_list.append(self.domuuid) self.thishypervisor.domain_list.append(self.domuuid)