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
This commit is contained in:
Marek Marczykowski-Górecki 2016-09-09 12:47:11 +02:00
parent 7ae55d46b2
commit 84528b30c1
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -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"