KVM usb passthrough就是将宿主机的usb接口直接给虚拟机使用,usb接口上的设备也就直接可以在虚拟机上使用。
测试环境
宿主机1 centos 6.6 64位 内核版本 2.6.32-431.1.2.0.1.el6.x86_64
宿主机2 fedora 21 内核版本 3.17.2-300.fc21.x86_64
虚拟机 windows 7 64位
配置方法
第一步 通过lsub或者virt-manager看看有那些usb口可供使用
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 002: ID 03f0:1027 Hewlett-Packard Virtual keyboard and mouse
Bus 001 Device 002: ID 058f:6387 Alcor Micro Corp. Flash Drive
Tue Dec 16 12:45:21 CST 2014

第二步 将需要的usb接口传给虚拟机

xml 配置文件为
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<vendor id='0x058f'/>
<product id='0x6387'/>
<address bus='1' device='2'/>
</source>
<alias name='hostdev0'/>
</hostdev>
第三步 测试
在测试过程中发现一个很奇怪的现象,在centos6的宿主机上的windows7,u盘不能识别

但是如果是centos6的虚拟机,U盘就可以正常使用,开始以为是windows7驱动的问题,但是尝试了各种驱动,问题依旧。
后来尝试了在fedora21上的windows7虚拟机,u盘插上去就可以直接使用

甚至不要做任何配置,应该和fedora上的usb转发器有关系,看来还是新的版本做了许多改进。


