From 84528b30c1f7a9cfc61ef5638dc4baf4ae38cb4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 9 Sep 2016 12:47:11 +0200 Subject: [PATCH] qvm-remove: don't fail on removing template which was never started When a template never was started, it isn't defined in libvirt, so attempt to undefine it will fail. Fixes QubesOS/qubes-issues#2290 --- qvm-tools/qvm-remove | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qvm-tools/qvm-remove b/qvm-tools/qvm-remove index b574d0de..3e957d8f 100755 --- a/qvm-tools/qvm-remove +++ b/qvm-tools/qvm-remove @@ -22,7 +22,8 @@ # from qubes.qubes import QubesVmCollection -from optparse import OptionParser; +from optparse import OptionParser +import libvirt import os import sys @@ -82,7 +83,11 @@ def main(): if options.remove_from_db_only: # normally it is done by vm.remove_from_disk(), but it isn't # called in this case - vm.libvirt_domain.undefine() + try: + vm.libvirt_domain.undefine() + except libvirt.libvirtError: + # ignore the case when it was never defined + pass if vm.installed_by_rpm: if options.verbose: print >> sys.stderr, "--> VM installed by RPM, leaving all the files on disk"