qubes: don't fail VM removal if already undefined in libvirt

This may happen when it was manually undefined for some reason. Or
during tests cleanup (tearDown).
This commit is contained in:
Marek Marczykowski-Górecki 2016-08-08 00:15:46 +02:00
parent 53562799cd
commit 5ab860a18c
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -444,7 +444,12 @@ class VMCollection(object):
msg = msg.format(vm, vm.get_power_state())
raise qubes.exc.QubesVMNotHaltedError(msg)
self.app.fire_event_pre('domain-pre-delete', vm)
vm.libvirt_domain.undefine()
try:
vm.libvirt_domain.undefine()
except libvirt.libvirtError as e:
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
# already undefined
pass
del self._dict[vm.qid]
self.app.fire_event('domain-delete', vm)