hi,
when I want to offer a smartphone to my virtual machine, I have to attach it as "device_add usb-host,hostbus=X,hostport=Y,id=Z" otherwise, I lose the attachment on the virtual machine side when I switch the smartphone mode (MTP, USB connection sharing, etc...).
to avoid having to manually build the command line, I use this little bash function that bypasses the "Command "info usbhost " is not available." first warning and lets me quickly copy/paste :
usb-host() {
# qemu device_add helper
for usb in /sys/bus/usb/devices/[1-9]-[1-9]/
do
cat $usb/product
busport=$( basename $usb )
echo $(
sed -e 's/-/,hostport=/' \
-e 's/^/device_add usb-host,hostbus=/' \
-e 's/$/,id=id-'$busport/ <<< $busport
)
read vendor < $usb/idVendor
read product < $usb/idProduct
echo device_add usb-host,vendorid=0x$vendor,productid=0x$product,id=id-$vendor-$product
echo
done
}
unfortunately, this function doesn't report all USB device information ("Integrated Camera" and not "Chicony Electronics Co., Ltd Integrated Camera" for example).
I hope you'll find it useful, regards, lacsaP.