目前网络上多种spice usb重定向环境搭建,但是大多较为复杂,且杂乱,本人最近搭建了一个spice的usb重定向环境,现记录如下:
请注意,下面涉及到的软件如果提及版本,请严格按照版本去使用,否则可能会出现各种依赖而导致十分复杂,从而偏离了看到usb重定向的demo的目的。
1.kvm对应机器安装redhat 6.5(通过使用centos源达到yum安装软件的目的)。安装桌面版本并且选择虚拟化相关的软件配置。
2.客户端操作系统,ubuntu14.04 x86_64版本
客户端软件列表如下:
apt-get install libnss3-dev libogg-dev libpixman-1-dev openssl intltool libssl-dev libsasl2-dev libgtk-3-dev libpulse-dev libjpeg8-dev libgudev-1.0-dev libxml2-dev
wget http://www.spice-space.org/download/libcacard/libcacard-0.1.2.tar.gz
./configure , make, makeinstall
!!!!!!!!!可能出现无法链接到pthread_create等函数的错误。通过在configure文件中将“ -Werror”后面添加“ -lpthread”。也就是强制在ld参数中增加链接pthread库以规避问题。
wget https://launchpad.net/~dev-zero/+archive/ubuntu/spice/+files/celt_0.5.1.3.orig.tar.gz ./configure,make ,make install
wget https://www.spice-space.org/download/releases/spice-protocol-0.12.12.tar.bz2 ./configure,make ,make install
wget http://www.spice-space.org/download/usbredir/usbredir-0.7.1.tar.bz2 apt-get install libusb-1.0-0-dev ./configure , make,sudo make install
wget https://www.spice-space.org/download/gtk/spice-gtk-0.20.tar.bz2 ./configure --with-gtk=3.0 --enable-usbdir=yes --enable-smartcard=yes,make -j4,make install
wget https://fedorahosted.org/released/virt-viewer/virt-viewer-0.5.6.tar.gz ./configure --with-gtk=3.0 --with-spice-gtk,make,make install
spice server端的配置:
更改虚拟机对应好的xml文件:
<!-- 移除xml文件中其它的USB设备,然后添加下面的部分 --> <controller type=‘usb‘ index=‘0‘ model=‘ich9-ehci1‘/> <controller type=‘usb‘ index=‘0‘ model=‘ich9-uhci1‘> <master startport=‘0‘/> </controller> <controller type=‘usb‘ index=‘0‘ model=‘ich9-uhci2‘> <master startport=‘2‘/> </controller> <controller type=‘usb‘ index=‘0‘ model=‘ich9-uhci3‘> <master startport=‘4‘/> </controller> <redirdev bus=‘usb‘ type=‘spicevmc‘/> <redirdev bus=‘usb‘ type=‘spicevmc‘/> <redirdev bus=‘usb‘ type=‘spicevmc‘/> <redirdev bus=‘usb‘ type=‘spicevmc‘/>