Better information on error in qvm-remove
If qvm-remove fails because the VM is in use, it will display information about where it is used. fixes QubesOS/qubes-issues#3193
This commit is contained in:
parent
ca848ca7bd
commit
ad2a6e3408
@ -85,6 +85,10 @@ class QubesNoTemplateError(QubesVMError):
|
||||
'''Cannot start domain, because there is no template'''
|
||||
|
||||
|
||||
class QubesVMInUseError(QubesVMError):
|
||||
'''VM is in use, cannot remove.'''
|
||||
|
||||
|
||||
class QubesValueError(QubesException, ValueError):
|
||||
'''Cannot set some value, because it is invalid, out of bounds, etc.'''
|
||||
pass
|
||||
|
@ -25,6 +25,7 @@ import sys
|
||||
|
||||
import qubesadmin.exc
|
||||
from qubesadmin.tools import QubesArgumentParser
|
||||
import qubesadmin.utils
|
||||
|
||||
parser = QubesArgumentParser(description=__doc__,
|
||||
want_app=True,
|
||||
@ -47,6 +48,15 @@ def main(args=None, app=None): # pylint: disable=missing-docstring
|
||||
for vm in args.domains:
|
||||
try:
|
||||
del args.app.domains[vm.name]
|
||||
except qubesadmin.exc.QubesVMInUseError:
|
||||
dependencies = qubesadmin.utils.vm_dependencies(vm.app, vm)
|
||||
print("VM {} cannot be removed. It is in use as:".format(
|
||||
vm.name))
|
||||
for (holder, prop) in dependencies:
|
||||
if holder:
|
||||
print(" - {} for {}".format(prop, holder.name))
|
||||
else:
|
||||
print(" - global property {}".format(prop))
|
||||
except qubesadmin.exc.QubesException as e:
|
||||
parser.error_runtime(e)
|
||||
retcode = 0
|
||||
|
Loading…
Reference in New Issue
Block a user