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:
parent
7ae55d46b2
commit
84528b30c1
@ -22,7 +22,8 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from qubes.qubes import QubesVmCollection
|
from qubes.qubes import QubesVmCollection
|
||||||
from optparse import OptionParser;
|
from optparse import OptionParser
|
||||||
|
import libvirt
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -82,7 +83,11 @@ def main():
|
|||||||
if options.remove_from_db_only:
|
if options.remove_from_db_only:
|
||||||
# normally it is done by vm.remove_from_disk(), but it isn't
|
# normally it is done by vm.remove_from_disk(), but it isn't
|
||||||
# called in this case
|
# called in this case
|
||||||
|
try:
|
||||||
vm.libvirt_domain.undefine()
|
vm.libvirt_domain.undefine()
|
||||||
|
except libvirt.libvirtError:
|
||||||
|
# ignore the case when it was never defined
|
||||||
|
pass
|
||||||
if vm.installed_by_rpm:
|
if vm.installed_by_rpm:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print >> sys.stderr, "--> VM installed by RPM, leaving all the files on disk"
|
print >> sys.stderr, "--> VM installed by RPM, leaving all the files on disk"
|
||||||
|
Loading…
Reference in New Issue
Block a user