From 41c6fbed72b349e6bc61d09897a9e5bb4304c65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Sat, 10 Aug 2019 22:10:31 +0200 Subject: [PATCH] qvm-device: handle 'list-device-classes' and 'list-classes' QubesOS/qubes-issues#5213 --- qubesadmin/qubesadmin | 1 + qubesadmin/tools/qvm_device.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 120000 qubesadmin/qubesadmin diff --git a/qubesadmin/qubesadmin b/qubesadmin/qubesadmin new file mode 120000 index 0000000..d8da336 --- /dev/null +++ b/qubesadmin/qubesadmin @@ -0,0 +1 @@ +/home/user/qubes-builder/qubes-src/core-admin-client/qubesadmin \ No newline at end of file diff --git a/qubesadmin/tools/qvm_device.py b/qubesadmin/tools/qvm_device.py index 0121b5f..c5a880d 100644 --- a/qubesadmin/tools/qvm_device.py +++ b/qubesadmin/tools/qvm_device.py @@ -263,6 +263,9 @@ def get_parser(device_class=None): attach_parser.set_defaults(func=attach_device) detach_parser.set_defaults(func=detach_device) + parser.add_argument('--list-device-classes', action='store_true', + default=False) + return parser @@ -272,7 +275,13 @@ def main(args=None, app=None): devclass = None if basename.startswith('qvm-') and basename != 'qvm-device': devclass = basename[4:] + args = get_parser(devclass).parse_args(args, app=app) + + if args.list_device_classes: + print('\n'.join(qubesadmin.Qubes().list_deviceclass())) + return 0 + try: args.func(args) except qubesadmin.exc.QubesException as e: @@ -282,4 +291,10 @@ def main(args=None, app=None): if __name__ == '__main__': + # Special treatment for '--list-device-classes' (alias --list-classes) + curr_action = sys.argv[1:] + if set(curr_action).intersection( + {'--list-device-classes', '--list-classes'}): + sys.exit(main(args=['', '--list-device-classes'])) + sys.exit(main())