How To : Virtualize a Windows 10 host 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
root@host:~# wget 'https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso'

Get Scanner device informations

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

Change rights

root@host:~# chown user:user /dev/bus/usb/001/003
Bus 001 Device 003: ID 04a9:2228 Canon, Inc. CanoScan 4400F

Install Windows

[user@host ~]$ qemu-system-x86_64 -smp 2 -net nic,model=e1000,macaddr=52:54:00:12:34:56 -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 -cdrom /data/en_windows_10_enterprise_ltsc_2019_x64_dvd_74865958.iso -enable-kvm -boot order=d -drive file=/data/WIN_10_LTSB_HDD01,index=0,media=disk,if=virtio,format=raw -drive file=/tmp/virtio-win.iso,media=cdrom,index=3

Load driver

Prevent Windows 10 Blue Screen

root@host:~# echo "options kvm ignore_msrs=1" >> /etc/modprobe.d/kvm.conf

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=/tmp/share -0 -r sound:remote
[user@host ~]$ mkdir /tmp/share;xfreerdp /v:127.0.0.1:5555 /w:1900 /h:1024 /cert-ignore /drive:share,/tmp/share
Licence Creative Commons
This website http://shebangthedolphins.net is licensed to the public under a licence Creative Commons Attribution licence.
Contact :