Delete AppVM after failed create only if it was (partially) created.

This commit is contained in:
Marek Marczykowski 2011-03-09 15:26:27 +01:00
parent c4cb54ab59
commit 161675cf6a

View File

@ -570,6 +570,7 @@ class VmManagerWindow(QMainWindow):
def do_create_appvm (self, vmname, label, template_vm, thread_monitor): def do_create_appvm (self, vmname, label, template_vm, thread_monitor):
vm = None
try: try:
self.qvm_collection.lock_db_for_writing() self.qvm_collection.lock_db_for_writing()
self.qvm_collection.load() self.qvm_collection.load()
@ -580,7 +581,8 @@ class VmManagerWindow(QMainWindow):
self.qvm_collection.save() self.qvm_collection.save()
except Exception as ex: except Exception as ex:
thread_monitor.set_error_msg (str(ex)) thread_monitor.set_error_msg (str(ex))
vm.remove_from_disk() if vm:
vm.remove_from_disk()
finally: finally:
self.qvm_collection.unlock_db() self.qvm_collection.unlock_db()