How To Virtualize a Windows 7 machine with a USB peripheral with KVM


I have a Canon CanoScan 4400F and I haven't found a way to directly use it with GNU/Linux. So I scan through a KVM Windows 7 Virtual Machine.


Hypervisor Configuration


root@host:~# pacman -S qemu; modprobe virtio

Virtual Disk Creation

root@host:~# qemu-img create -f raw WIN_HDD01 20G

Grow disk size

root@host:~# qemu-img resize -f raw WIN_HDD01 +30G

Download virtio drivers


Install Windows

[user@host ~]$ qemu-system-x86_64 -vga cirrus -m 2048 -enable-kvm -cdrom en_windows_7_ultimate_x64.iso -boot order=d -drive file=/vdisks/WIN_HDD01,index=0,media=disk,if=virtio,format=raw -drive file=/tmp/virtio-win-0.1.118.iso,media=cdrom,index=3

Get Scanner device informations

root@host:~# lsusb
Bus 001 Device 003: ID 04a9:2228 Canon, Inc. CanoScan 4400F

Start VM with RDP redirection and USB

[user@host ~]$ qemu-system-x86_64 -smp 2 -net nic,model=e1000,macaddr=52:55:01:11:34:53 -net user,id=mynet0,net=,dhcpstart=,hostfwd=tcp::5555-:3389 -cpu host -vga cirrus -m 4096 -enable-kvm -boot order=d -drive file=/vdisks/WIN_HDD01,index=0,media=disk,if=virtio,format=raw -device nec-usb-xhci -device usb-host,hostbus=1,hostaddr=3

RDP to the VM with a shared folder

[user@host ~]$ rdesktop 127.1:5555 -r disk:docs=/share/scans -0 -r sound:remote
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Contact :