From b985bf3b65aa60238196984ce9f841d37d01a826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 3 May 2015 20:26:07 +0200 Subject: [PATCH] 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. --- core-modules/000QubesVm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index 73119e6a..5f637b43 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -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()