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

Intro

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 Virtual Machine.

Configuration

Hypervisor Configuration

Installation

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

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=192.168.76.0/24,dhcpstart=192.168.76.9,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
Licence Creative Commons
This website http://shebangthedolphins.net is licensed to the public under a licence Creative Commons Attribution licence.
Contact :