Further update: I've found the USB device is added to qemu after the vm has started through hot plugging. It seems this is done in xenopsd. It even has explicit code to support USB v1 devices in there
According to xenopsd sources from 0.101.0 from the XCP-NG 8.0 SRPM, the code is
let vusb_plug ~xs ~privileged ~domid ~id ~hostbus ~hostport ~version =
debug "vusb_plug: plug VUSB device %s" id;
let get_bus v =
if String.startswith "1" v then
"usb-bus.0"
else begin
(* Here plug usb controller according to the usb version*)
let usb_controller_driver = "usb-ehci" in
let driver_id = "ehci" in
vusb_controller_plug ~xs ~domid ~driver:usb_controller_driver ~driver_id;
Printf.sprintf "%s.0" driver_id;
end
in
if Qemu.is_running ~xs domid then
begin
(* Need to reset USB device before passthrough to vm according to CP-24616.
Also need to do deprivileged work in usb_reset script if QEMU is deprivileged.
*)
begin match Qemu.pid ~xs domid with
| Some pid -> usb_reset_attach ~hostbus ~hostport ~domid ~pid ~privileged
| _ -> raise (Xenopsd_error (Internal_error (Printf.sprintf "qemu pid does not exist for vm %d" domid)))
end;
let cmd = Qmp.(Device_add Device.(
{ driver = "usb-host";
device = USB {
USB.id = id;
params = Some USB.({bus = get_bus version; hostbus; hostport})
}
}
))
in qmp_send_cmd domid cmd |> ignore
end
unfortunately I cannot find where the mysterious "version" parameter is that needs to be set to "1" to enable the use of USB bus 0 in the guest, which is USB 1. I'm wondering if it's stupidly reading the version string of the USB device itself rather than something else
I note that the latest code in the upstream xapi-project/xenopsd device.ml line 1818 is radically different and now has a "speed" parameter. This was added in commit ab15e6c3b1b06b2eac4f2a8be724eac50c9d4b22 in Oct 2019 for CA-328130 (whatever that is). It looks like code was also added to the upstream xapi-project/xenapi to add the "speed" parameter to the data model there. So there may be a fix in a future version of XCP-NG if they pull in these fixes. I haven't looked at 8.1-beta but I suspect it's too late to go making wholesale changes there if the code hasn't already been merged.
ok, just downloaded the SRPM from 8.1 xenopsd and it still has the old code for vusb plug, so I'm guessing 8.1 doesn't have this fixed (yet)