Openstack使用Spice

Spice简介

SPICE (Simple Protocol for Independent Computing Environment) 是Red Hat收购Qumranet后获得虚拟技术,被Qumranet使用在其商业虚拟桌面产品SolidIce中。SPICE能用于在服务器和远程计算机如桌 面和瘦客户端设备上部署虚拟桌面。它类似于其它用于远程桌面管理的渲染协议,如微软的Remote Desktop Protocol或Citrix的Independent Computing Architecture。它支持Windows XP、Windows 7和Red Hat Enterprise Linux等虚拟机实例。大部分SPICE代码是采用GNU GPLv2许可证发布,部分代码是采用LGPL许可证。

实验环境

操作系统:centos 6.3

openstack:G-2013.1.3

spice-server:0.12.0

安装websockify

1
2
git clone https://github.com/kanaka/websockify.git
cd websockify

or

1
pip install websockify

安装spice

需要libvirt版本0.9.4-23或更高

实验环境:libvirt-0.10.2、qemu-0.15.0

1
yum install spice-server spice-client spice-protocol

如果主机有完整的图像界面,可以继续安装以下:

1
yum install cairo-spice ffmpeg-spice-libs ngspice pixman-spice spice-glib spice-gtk spice-gtk-python spice-gtk-tools spice-xpi

安装spice-html5

spice-html5

1
2
3
4
5
6
wget http://cgit.freedesktop.org/spice/spice-html5/snapshot/spice-html5-0.1.3.tar.gz
tar xf spice-html5-0.1.3.tar.gz
cd spice-html5-0.1.3
cp apache.conf.sample /etc/httpd/conf.d/spice.conf
cd ..
cp -r spice-html5-0.1.3 /usr/share/spice-html5

检查/ect/httpd/conf.d/spice.conf文件

1
2
3
4
5
6
7
8
9
10
11
cat /etc/httpd/conf.d/spice.conf
#
# spice-html5 is a Javascript SPICE client
#
Alias /spice /usr/share/spice-html5
<Directory /usr/share/spice-html5>
# This page is broadly available, tune here to make it more restricted.
Allow from all
Satisfy Any
DirectoryIndex spice.html
</Directory>

创建启动脚本

1
vi /etc/init.d/openstack-nova-spicehtml5proxy

内容略

修改nova.conf

增加spice的相关配置

1
2
3
4
5
6
7
[spice]
agent_enabled=True
enabled=True
html5proxy_base_url=http://<your host ip>:6082/spice_auto.html
server_listen=0.0.0.0
server_proxyclient_address=<your host ip>
keymap=en-us

注意,需要关闭novnc,否则创建虚拟机会失败

1
sed -i "s/novnc_enabled=.*/novnc_enabled=False/g" /etc/nova/nova.conf

启动进程

1
/etc/init.d/openstack-nova-spicehtml5proxy start

spice启动成功