Skip to content

Commit

Permalink
q-dev: assign only device
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 14, 2024
1 parent 1ad66e5 commit 5ead756
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions qubesadmin/tools/qvm_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,10 @@ def assign_device(args):
"""
vm = args.domains[0]
device = args.device
if args.port:
if args.only_port:
device.device_id = None
if args.only_device:
device.port = None
options = dict(opt.split('=', 1) for opt in args.option or [])
if args.ro:
options['read-only'] = 'yes'
Expand Down Expand Up @@ -453,12 +455,20 @@ def get_parser(device_class=None):
"be required to the qube's startup and then"
" automatically attached)")

assign_parser.add_argument('--port',
action='store_true',
default=False,
help="Ignore device presented identity and "
"attach any device connected to the given "
"port number")
id_parser = assign_parser.add_mutually_exclusive_group()
id_parser.add_argument('--port',
dest='only_port',
action='store_true',
default=False,
help="Ignore device presented identity and "
"attach later any device connected "
"to the given port")
id_parser.add_argument('--device',
dest='only_device',
action='store_true',
default=False,
help="Ignore current port identity and "
"attach this device connected to any port")
attach_parser.set_defaults(func=attach_device)
detach_parser.set_defaults(func=detach_device)
assign_parser.set_defaults(func=assign_device)
Expand Down

0 comments on commit 5ead756

Please sign in to comment.