qvm-device fix handling of non block devices

This commit is contained in:
Bahtiar `kalkin-` Gadimov 2017-03-31 16:30:54 +02:00
parent 9d08e4b792
commit 6caaa6f66d
No known key found for this signature in database
GPG Key ID: 07799AE179ED4FD4

View File

@ -169,15 +169,22 @@ def get_parser(device_class=None):
init_list_parser(sub_parsers)
attach_parser = sub_parsers.add_parser(
'attach', help="Attach device to domain", aliases=('at', 'a'))
attach_parser.add_argument('VMNAME', action=qubes.tools.RunningVmNameAction)
attach_parser.add_argument(metavar='BACKEND:DEVICE_ID', dest='device',
action=qubes.tools.VolumeAction)
attach_parser.set_defaults(func=detach_device)
detach_parser = sub_parsers.add_parser(
"detach", help="Detach device from domain", aliases=('d', 'dt'))
attach_parser.add_argument('VMNAME', action=qubes.tools.RunningVmNameAction)
detach_parser.add_argument('VMNAME', action=qubes.tools.RunningVmNameAction)
detach_parser.add_argument(metavar='BACKEND:DEVICE_ID', dest='device',
action=qubes.tools.VolumeAction)
if device_class == 'block':
attach_parser.add_argument(metavar='BACKEND:DEVICE_ID', dest='device',
action=qubes.tools.VolumeAction)
detach_parser.add_argument(metavar='BACKEND:DEVICE_ID', dest='device',
action=qubes.tools.VolumeAction)
else:
attach_parser.add_argument(metavar='BACKEND:DEVICE_ID', dest='device')
detach_parser.add_argument(metavar='BACKEND:DEVICE_ID', dest='device')
attach_parser.set_defaults(func=attach_device)
detach_parser.set_defaults(func=detach_device)
return parser