core: fix removing VMs not registered in libvirt

It can happen that VM will not be registered in libvirt (for example
when it was never started). It shouldn't be a problem when we want to
remove it.
This commit is contained in:
Marek Marczykowski-Górecki 2015-05-03 20:26:07 +02:00
parent ed03fb4313
commit b985bf3b65

View File

@ -1281,7 +1281,14 @@ class QubesVm(object):
for hook in self.hooks_remove_from_disk:
hook(self)
self.libvirt_domain.undefine()
try:
self.libvirt_domain.undefine()
except libvirt.libvirtError as e:
if e.err[0] == libvirt.VIR_ERR_NO_DOMAIN:
# already undefined
pass
else:
raise
self.storage.remove_from_disk()