阶段整理 ———— fedora20 安装配置spice,创建、连接虚拟机



一段在Fedora20上配置安装spice的脚本,不过也基本上是按照spice官网上的介绍,http://www.spice-space.org/page/Building_Instructions

脚本代码如下:

#!/bin/bash  
set -e  
  
SRC_ROOT=""  
INST_ROOT=""  
  
yum -y install gcc gcc-c++ glibc make cmake libtool automake autoconf pkgconfig  
  
yum install -y libgnomeui-devel  
  
yum install -y pixman-devel celt051-devel cegui-devel libjpeg-devel alsa-lib-devel log4cpp-devel openssl-devel libXrandr-devel libgcrypt-devel SDL-devel dev86 iasl pyparsing  
  
yum -y install nss-devel  
  
yum -y install libcacard  
  
yum -y install libjpeg-turbo-devel  
  
#==========  
SRC_ROOT=$HOME/Documents/spice  #set the path help yourself  
INST_ROOT=$HOME/spice  
#==========  
#if [ ! -e "$SRC_ROOT" ]; then mkdir -p $SRC_ROOT; fi  
#if [ ! -e "$INST_ROOT" ]; then mkdir -p $INST_ROOT; fi  
if [ ! -d "$SRC_ROOT" ]; then mkdir -p $SRC_ROOT; fi  
if [ ! -d "$INST_ROOT" ]; then mkdir -p $INST_ROOT; fi  
export PKG_CONFIG_PATH=$INST_ROOT/lib/pkgconfig:$INST_ROOT/share/pkgconfig  
  
  
yum -y install git  
  
yum -y install wget #maybe you need set the proxy for wget and yum  
  
  
  
git clone git://cgit.freedesktop.org/spice/qemu  
git clone git://cgit.freedesktop.org/pixman  
git clone git://cgit.freedesktop.org/spice/spice-protocol  
git clone git://cgit.freedesktop.org/spice/spice  
git clone git://cgit.freedesktop.org/spice/win32/vd_agent  
git clone git://cgit.freedesktop.org/spice/win32/qxl  
git clone git://cgit.freedesktop.org/spice/slirp  
  
wget http://downloads.us.xiph.org/releases/celt/celt-0.5.1.3.tar.gz  
tar xvzf celt-0.5.1.3.tar.gz  
  
  
################################################################  
SRC_ROOT=$HOME/Documents  
#INST_ROOT=""  
################################################################  
cd $SRC_ROOT/spice-protocol  
./autogen.sh --prefix=$INST_ROOT  
# if it complains about missing m4 directory do a  
#mkdir m4  
#./autogen.sh --prefix=$INST_ROOT  
make install  
  
  
cd $SRC_ROOT/celt-0.5.1.3  
./configure --prefix=$INST_ROOT  
make install  
  
  
# only if you don't have a recent enough version of pixman (spice configure will complain if you need it)  
cd $SRC_ROOT/pixman  
sudo ./autogen.sh --prefix=$INST_ROOT  
make install  
  
yum -y install libcacard-devel  
yum -y install cyrus-sasl-devel  
  
cd $SRC_ROOT/spice  
./autogen.sh --prefix=$INST_ROOT --enable-smartcard  
make install  
  
cd $SRC_ROOT/qemu  
./configure --prefix=$INST_ROOT --target-list=x86_64-softmmu --enable-spice  
make  
  
#-----------------------  
#this is a important command, if no this ,the qemu can not find spice  
export LD_LIBRARY_PATH=$INST_ROOT/lib  
  
echo "Install finished"  

这个时候,spice server基本上算是架好了。




下面来安装虚拟机,win7为例:

#在qemu的目录执行
#!/bin/bash


#create virtual disk
qemu-img create -f qcow2 win7.qcow2 20G

#install win7 

./x86_64-softmmu/qemu-system-x86_64 -drive file=win7.qcow2,if=ide -soundhw ac97 -L pc-bios -vga qxl -usbdevice tablet -enable-kvm -m 1024 -device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent -boot d -cdrom win7.iso

#link spice

./x86_64-softmmu/qemu-system-x86_64 -drive file=win7.qcow2,if=ide -soundhw ac97 -L pc-bios -vga qxl -spice port=5999,disable-ticketing -usbdevice tablet -enable-kvm -m 024 -device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent -device virtserialport,chardev=vdagent,name=win7


echo "done!"

这时候就可以通过VirtViewer来访问这台虚拟机了。



PS:

操作过程中可能会遇到要求配置yum和wget的proxy的问题,所以写了个小脚本;

#!/bin/bash


#==============for wget proxy==============
echo "  " >> "/etc/wgetrc"

echo "https_proxy = http://10.43.146.9:8080" >> "/etc/wgetrc"
echo "http_proxy = http://10.43.146.9:8080" >> "/etc/wgetrc"
echo "ftp_proxy = http://10.43.146.9:8080" >> "/etc/wgetrc"

echo "  " >> "/etc/wgetrc"

## If you do not want to use proxy at all, set "use_proxy = off".
echo "use_proxy = on" >> "/etc/wgetrc"

echo "  " >> "/etc/wgetrc"
#==========================================



#==============for yum proxy============
echo "  " >> "/etc/yum.conf"

echo "proxy=http://10.43.146.9:8080" >> "/etc/yum.conf"

echo "  " >> "/etc/yum.conf"
#========================================



可能会遇到防火墙的问题;

#disable firewall
systemctl stop firewall.service
systemctl disable firewalld.service
gedit /etc/sysconfig/selinux 
# set SELINUX=disable
#	#SELINUX=enforcing
#	SELINUX=disable



先这样吧,有问题再改


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值