您的位置:首页 > 其它

Ubuntu 12.04 Spice源码编译安装方法

2014-08-30 10:08 701 查看
由于ubuntu 12.04的QEMU是1.0版本的,QEMU在1.14以下的版本都不支持Spice访问,为了可以在ubuntu 12.04下使用spice访问虚拟机,通过spice源码的方式安装spice和QEMU源码的方法安装1.14以下的版本的QEMU,两者的结合可以使得我们可以使用spice访问虚拟机。在本文中,我们对源码安装的方式进行说明。

以下是安装步骤:

1)安装编译依赖包:

sudo apt-get install build-essential autoconf git-core libtool liblog4cpp5-dev libavcodec-dev libssl-dev xlibmesa-glu-dev libasound-dev libpng12-dev libfreetype6-dev libfontconfig1-dev libogg-dev libxrandr-dev kvm libgcrypt-dev libsdl-dev libnss3-dev libpixman-1-dev libxfixes-dev libjpeg8-dev libsasl2-dev python-pyparsing

2)然后进入根目录,并创建spice的源码目录:

cd
mkdir spice-sources
cd spice-sources


3)安装Spice所需要的依赖软件:

A、安装libcacard,Spice用于支持智能卡和智能卡读卡器

git clone git://people.freedesktop.org/~alon/libcacard
cd libcacard
./autogen.sh
make
sudo make install
cd ..


B、安装Spcie协议头部

wget http://spice-space.org/download/releases/spice-protocol-0.8.0.tar.bz2 tar xjvf spice-protocol-0.8.0.tar.bz2
cd spice-protocol-0.8.0
mkdir m4
./configure
make
sudo make install
cd ..

说明:这里的spice协议可以更新到最新的版本。

C、安装Celt,用于音频的低延时编解码

wget http://downloads.us.xiph.org/releases/celt/celt-0.5.1.3.tar.gz tar xvzf celt-0.5.1.3.tar.gz
cd celt-0.5.1.3/
./configure
make
sudo make install
cd ..


D、安装Spice和Spice客户端

wget http://spice-space.org/download/releases/spice-0.8.1.tar.bz2 tar xjvf spice-0.8.1.tar.bz2
cd spice-0.8.1
./configure --enable-smartcard
make
sudo make install
cd ..

说明:可以使用更新的版本

4)安装Qemu,将并启用Spice

A、输出所需的环境变量

echo "export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}" >> ~/.bashrc
source ~/.bashrc

B、下载一个1.14版本一下的QEMU进行编译安装

wget http://download.savannah.gnu.org/releases/qemu/qemu-0.14.0.tar.gz tar xzvf qemu-0.14.0.tar.gz
cd qemu-0.14.0
./configure --enable-spice --enable-kvm --enable-io-thread --audio-drv-list=alsa,oss --enable-system
make
sudo make install

下载地址参考:
http://download.savannah.gnu.org/releases/qemu/ http://git.qemu.org/
C、拷贝一下BIOS文件,以便VM启用Spice功能

sudo cp pc-bios/vgabios-qxl.bin /usr/share/qemu/
sudo cp pc-bios/pxe-e1000.bin /usr/share/qemu/
cd ..

pxe-e1000.bin有可能是pxe-e1000.rom

D、此时,支持spice的qemu已经安装在/usr/local/bin/目录下,为了与原系统的qemu区分和方便调用,我们将编译后的QEMU执行文件改一个新的名字:

cd /usr/local/bin
sudo cp qemu qemu-spice
sudo cp qemu-system-x86_64 qemu-kvm-spice


此时就可以使用qemu-spice和qemu-kvm-spcie命令启动虚拟机,并通过spicec进行客户端接入了:

5)启动虚拟机

qemu-spice -spice port=5930,disable-ticketing -drive file=/path/to/image -vga qxl -device AC97 -usbdevice tablet -m 1024 -enable-kvm -net nic -net user

参数说明:

qxl graphics (you need this for spice to be of any use)

an AC97 sound device

a tablet input device (using a virtualized tablet generally gives better results than a virtualized mouse)

1024M of memory available

KVM support enabled (you really want this, as the guest is quite slow otherwise)

a user-controllable virtualized nic

如果使用virtio,参数修改为:

-drive file=/path/to/image,if=virtio -net nic,model=virtio


本人使用的启动虚拟机的命令如下:

qemu-kvm-spice -spice port=5930,disable-ticketing -drive file=win7-64-finish-3.qcow2,if=virtio,format=qcow2 -vga qxl -usbdevice tablet -m 2048 -enable-kvm -net nic -net user -boot c


网上参考的命令如下:

kvm -smp 4 -m 1516 -drive file=/yourpath/xp.img,cache=writeback,if=virtio -boot c -vga qxl --full-screen -net nic,model=virtio,macaddr=28-55-26-66-58-D6 -net user -localtime -soundhw ac97 -usb -usbdevice tablet -spice port=3636,disable-ticketing


说明:如果启动win7虚拟机,内存至少为2GB

6)使用spice的客户端进行访问

spicec -h <server hostname> -p <port number>


7)参考文档
http://docs.cslabs.clarkson.edu/wiki/SPICE
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: