一、首先安装qemu
使用命令 sudo apt-get install qemu
/********************************************************/
/********************************************************/
二、安装 libvirt
解压libvirt-0.9.11.3.tar.gz
cd libvirt-0.9.11.3
./configure
出现:
checking libxml2 xml2-config >= 2.6.0..
则:
sudo apt-get install libxml2 libxml2-dev
configrue: error: you must install the gnutls library in order to compile and run libvirt
则:
sudo apt-get install gnutls-doc gnutls-bin
sudo apt-get install libneon27-gnutls libcurl4-gnutls-dev
提示缺少
configure: error: You must install the YAJL development package in order to compile libvirt
从网上下载YAJL(yajl_1.0.8.orig.tar.gz),然后解压缩tar -zxvf yajl_1.0.8.orig.tar.gz
进入解压后的文件夹中:cd lloyd-yajl-ce86b0f。安装YAJL。
先安装C++/C编译器,如果已经了就可以跳过该步执行:
sudo apt-get install build-essential
然后执行:
sudo apt-get install cmake
sudo apt-get install ruby
最后执行:
(1)./configure
(2)make install
又提示缺少device-mapper-devel
从网上下载device-mapper.1.02.28.tgz,然后解压缩tar -zxvf device-mapper.1.02.28.tgz,
进入解压后的文件夹中:cd device-mapper.1.02.28。安装device-mapper。
(1) ./configure
(2) sudo make
(3) sudo make install
然后退出该文件夹,重新安装libvirt
You must install python-devel to build Python bindings
sudo apt-get install python-dev
configure: error: libnl-devel >= 1.1 is required for macvtap support
sudo apt-get install libnl-dev
最后:
sudo make
sudo make install
出现问题及解决方法:
(1)解决error while loading shared libraries: libvirt.so.0
第一种:
定义shell变量 LD_LIBRARY_PATH
$ LD_LIBRARY_PATH=/usr/local/lib
$ export LD_LIBRARY_PATH
$ ./example
第二种:
修改系统动态链接库配置文件
(the system dynamic linker configuration)
进入目录/etc/ld.so.conf.d
添加一个文件libvirt.conf,内容是:
# libvirt default configuration
/usr/local/lib
更新动态链接库缓存
sudo ldconfig
(2)解决failed to connect socket to '/usr/local/var/run/libvirt/libvirt-sock':no such file or directory
添加libvirt用户组
sudo groupadd libvirt
添加当前用户到libvirt组里
sudo gpasswd -a root libvirt
记得要重启,才能有用
(3) error: ebiptablesDriverInit:4129 : essential tools to support ip(6) tables firewalls could not be located
编辑文件/usr/local/etc/libvirt/libvirtd.conf
取消一下几项的注释
unix_sock_group = "libvirt"
unix_sock_ro_perms = "0777"
unix_sock_rw_perms = "0770"
unix_sock_dir = "/var/run/libvirt"修改为
unix_sock_dir = "/usr/local/var/run/libvirt"
auto_unix_ro = "none"
auth_unix_rw = "none"
最后:如果要启动自动运行libvirtd
编辑文件/etc/rc.local
在exit 0之前添加
sudo libvirtd &
/********************************************************/
/********************************************************/
三、安装Virtual Machine Manager (这不是必要的)
sudo apt-get install virt-manager