I have a device I want a guest to see. I've configured the following:
% cat /etc/libvirt/HotPlug/owon.xml <hostdev mode='subsystem' type='usb'> <source> <vendor id='0x5345'/> <product id='0x1234'/> </source> </hostdev>
And then in udev: % cat /etc/udev/rules.d/90-owon.rules ACTION=="add", \ SUBSYSTEM=="usb", \ SYSFS{idVendor}=="5345", \ SYSFS{idProduct}=="1234", \ RUN+="/usr/bin/virsh attach-device XP_VM1 /etc/libvirt/HotPlug/owon.xml"
ACTION=="remove", \ SUBSYSTEM=="usb", \ SYSFS{idVendor}=="5345", \ SYSFS{idProduct}=="1234", \ RUN+="/usr/bin/virsh detach-device XP_VM1 /etc/libvirt/HotPlug/owon.xml"
Now this works; I plug the device in and the guest sees it.
The problem is that, each time, it shows up at a different address on the guest's USB bus. And, Windows XP being Windows, this means it asks to load a device driver each and every time (I've never understood why Windows wants to load a new device driver just because you plug a device into a different port).
Does anyone know of a way of adding a device so that it's at a known fixed address inside the guest?
On Tue, 26 Nov 2013, Stephen Harris wrote:
I have a device I want a guest to see. I've configured the following:
And then in udev: % cat /etc/udev/rules.d/90-owon.rules ACTION=="add", \ SUBSYSTEM=="usb", \ SYSFS{idVendor}=="5345", \ SYSFS{idProduct}=="1234", \ RUN+="/usr/bin/virsh attach-device XP_VM1 /etc/libvirt/HotPlug/owon.xml"
Now this works; I plug the device in and the guest sees it.
most USB persistent enumeration are done by the device serial number, which should appear along with the Vendor and Product.
Can you expose that through the udev rules as well?
Does anyone know of a way of adding a device so that it's at a known fixed address inside the guest?
seeking to 'nail it to' a fixed address is probably not the right way to do it, as that is detection order dependant
-- Russ herrold
On Tue, Nov 26, 2013 at 11:45:43AM -0500, R P Herrold wrote:
On Tue, 26 Nov 2013, Stephen Harris wrote:
% cat /etc/udev/rules.d/90-owon.rules ACTION=="add", \ SUBSYSTEM=="usb", \ SYSFS{idVendor}=="5345", \ SYSFS{idProduct}=="1234", \ RUN+="/usr/bin/virsh attach-device XP_VM1 /etc/libvirt/HotPlug/owon.xml"
Now this works; I plug the device in and the guest sees it.
most USB persistent enumeration are done by the device serial number, which should appear along with the Vendor and Product.
Can you expose that through the udev rules as well?
udev merely triggers virsh to expose the device; the actual connection of the device into the VM is done by the "attach-device" rule.
However I don't seem to be able to see the serial number inside the VM and I can't work out how to expose it.
Hmm.