Hey there,
I was trying out attaching usb devices to qubes and thought this might be useful to other people. If you have a device with a complicated description (eg a Yubikey) it can be a pain to figure out what device ID it's being attached to in sys-usb so you can use qvm-usb attach
to send it to an AppVM.
[sean@dom0 ~]# qvm-usb
BACKEND:DEVID DESCRIPTION USED BY
fedora-25:1-1 QEMU_QEMU_USB_Tablet_42
p:1-1 QEMU_QEMU_USB_Tablet_42
sys-firewall:1-1 QEMU_QEMU_USB_Tablet_42
sys-usb:1-3 Yubico_Yubikey_4_OTP+U2F+CCID
sys-usb:1-6 0489_e076
vault:1-1 QEMU_QEMU_USB_Tablet_42
Typing qvm-usb
, looking down for where my Yubikey is, then looking accross for the sys-usb:1-3
next to it, then typing qvm-usb attach somevm sys-usb:1-3
will get pretty old pretty fast.
Luckily, unix is awesome. I have created a couple of small shell functions which search the output of qvm-usb on the description and attach or detach. Thus:
[sean@dom0 ~]# usb-attach somevm Yubi
[sean@dom0 ~]# qvm-usb
BACKEND:DEVID DESCRIPTION USED BY
fedora-25:1-1 QEMU_QEMU_USB_Tablet_42
p:1-1 QEMU_QEMU_USB_Tablet_42
sys-firewall:1-1 QEMU_QEMU_USB_Tablet_42
sys-usb:1-3 Yubico_Yubikey_4_OTP+U2F+CCID somevm
sys-usb:1-6 0489_e076
vault:1-1 QEMU_QEMU_USB_Tablet_42
...and likewise...
[sean@dom0 ~]# usb-detach somevm Yubi
If you like them you could put them (or something similar) in your ~/.bashrc
in your dom0.
Here they are:
function usb-attach() {
qvm-usb attach "${1}" $( qvm-usb | awk "/${2}/"'{print $1;exit}' )
}
function usb-detach() {
qvm-usb detach "${1}" $( qvm-usb | awk "/${2}/"'{print $1;exit}' )
}
Cheers,
Sean