guest: Don't repeatedly overwrite self.domain

Since clearing it is important, just set it at the end when things
have succeeded
This commit is contained in:
Cole Robinson
2017-04-13 14:56:03 -04:00
parent 2099a1946e
commit 93085d2b9d

View File

@@ -394,28 +394,28 @@ class Guest(XMLBuilder):
meter.start(size=None, text=meter_label)
if transient:
self.domain = self.conn.createXML(install_xml or final_xml, 0)
domain = self.conn.createXML(install_xml or final_xml, 0)
else:
# Not all hypervisors (vz) support createXML, so avoid it here
self.domain = self.conn.defineXML(install_xml or final_xml)
domain = self.conn.defineXML(install_xml or final_xml)
# Handle undefining the VM if the initial startup fails
if doboot or self.installer.has_install_phase():
try:
self.domain.create()
domain.create()
except:
import sys
exc_info = sys.exc_info()
try:
self.domain.undefine()
self.domain = None
domain.undefine()
except:
pass
raise exc_info[0], exc_info[1], exc_info[2]
if install_xml and install_xml != final_xml:
self.domain = self.conn.defineXML(final_xml)
domain = self.conn.defineXML(final_xml)
self.domain = domain
try:
logging.debug("XML fetched from libvirt object:\n%s",
self.domain.XMLDesc(0))