Just got this working (well, lsusb and sane-find-scanner in the guest report results):
Goal: passthrough a USB scanner (could also be another device) to an OpenVZ guest.
Adjusted from the USB printing howto from OpenVZ: http://wiki.openvz.org/USB_Printing_in_VE as well as some posts on getting Dahdi/Zaptel devices passed through when working with the Asterisk VOIP PABX.
Using a Canon scanner as an example; adjust where required.
Host USB device name
We want our scanner to have a fixed name that we can forward to the guest. We use udev rules to create an extra, fixed name depending on device. I had also set up sane on the host and set up sane rules so the host device is assigned to the scanner. Don't know if this is necessary, I presume it isn't.
Host passthrough
Assuming we're using vmid 102; adjust as required.
Guest device setup
In the guest, we should now have a /dev/flatbedscanner. However, that is not enough for sane as it apparently expects/looks for/dev/usb/..something.
We will make it happy:
Also, in the guest I set up sane, and assigned /dev/flatbedscanner using udev rules, but I wonder whether this is necessary.
Hope this helps; corrections and confirmations welcome.
Goal: passthrough a USB scanner (could also be another device) to an OpenVZ guest.
Adjusted from the USB printing howto from OpenVZ: http://wiki.openvz.org/USB_Printing_in_VE as well as some posts on getting Dahdi/Zaptel devices passed through when working with the Asterisk VOIP PABX.
Using a Canon scanner as an example; adjust where required.
Host USB device name
We want our scanner to have a fixed name that we can forward to the guest. We use udev rules to create an extra, fixed name depending on device. I had also set up sane on the host and set up sane rules so the host device is assigned to the scanner. Don't know if this is necessary, I presume it isn't.
Code:
#Use lsusb to find out your own scanner's vendor and product codes
#<vendor>:<product>... and adjust commands accordingly
lsusb
cat >> /lib/udev/rules.d/99-local-installation.rules << "EOF_DOCUMENT"
#make sure the scanner is reachable under the same name (/dev/flatbedscanner) regardless of USB port etc.
#obviously, adjust vendor and product codes
ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1313", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes", SYMLINK+="flatbedscanner"
EOF_DOCUMENT
#Restart udev:
/etc/init.d/udev restart
#Unplug the scanner and plug it in again.
#the device should now appear:
ls -al /dev/flatbedscanner
Host passthrough
Assuming we're using vmid 102; adjust as required.
Code:
# stop machine
vzctl stop 102
#pass through scanner, and save into config for vm 102
#which should create /dev/flatbedscanner in the guest
#with read/write access
vzctl set --devnode flatbedscanner:rw --save 102
#check config
cat /etc/pve/openvz/102.conf
Guest device setup
In the guest, we should now have a /dev/flatbedscanner. However, that is not enough for sane as it apparently expects/looks for/dev/usb/..something.
We will make it happy:
Code:
vzctl start 102
vzctl enter 102
# more or less a random bus, presumably good idea to pick one that doesn't exist; adjust other commands accordingly
mkdir -p /dev/bus/usb/001
# just link the /dev/bus/usb/001/002 device to the device the hosted passed on to us:
ln -s /dev/flatbedscanner /dev/bus/usb/001/002
reboot
#back in host
vzctl enter 102
#now you should see the scanner:
lsusb
#if you have sane installed, try this:
sane-find-scanner
Hope this helps; corrections and confirmations welcome.