Skip to content

Commit

Permalink
qvm-device: improve error message on invalid device type
Browse files Browse the repository at this point in the history
Fixes QubesOS/qubes-issues#6057

(cherry picked from commit 07dfe82)
  • Loading branch information
marmarek committed Oct 24, 2020
1 parent 818445c commit 00030da
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions qubesadmin/tools/qvm_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,22 @@ def list_devices(args):
app = args.app

devices = set()
if hasattr(args, 'domains') and args.domains:
for domain in args.domains:
for dev in domain.devices[args.devclass].attached():
devices.add(dev)
for dev in domain.devices[args.devclass].available():
devices.add(dev)

else:
for domain in app.domains:
for dev in domain.devices[args.devclass].available():
devices.add(dev)
try:
if hasattr(args, 'domains') and args.domains:
for domain in args.domains:
for dev in domain.devices[args.devclass].attached():
devices.add(dev)
for dev in domain.devices[args.devclass].available():
devices.add(dev)

else:
for domain in app.domains:
for dev in domain.devices[args.devclass].available():
devices.add(dev)
except qubesadmin.exc.QubesDaemonAccessError:
raise qubesadmin.exc.QubesException(
"Failed to list '%s' devices, this device type either "
"does not exist or you do not have access to it.", args.devclass)

result = {dev: Line(dev) for dev in devices}

Expand Down

0 comments on commit 00030da

Please sign in to comment.