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

时间:2022-05-18 18:16:17


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

脚本代码如下:


这个时候,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



先这样吧,有问题再改