libvirt安装过程中遇到的问题 分类: ubuntu学习 ...

环境:ubuntu14.04

有些问题可以直接百度到:

http://liuzhijun.iteye.com/blog/1728617

http://blog.csdn.net/scape1989/article/details/11002315


有些问题稍微转了下弯:

1,You must install the pciaccess module to build with udev

解决问题:

查看:http://www.0937686468.com/

(此文中解决方式:yum install libpciaccess-devel)

           http://blog.csdn.net/scape1989/article/details/11002315

我的yum好像不行,解决方式:

#apt-get install -y libpciaccess-dev

2,libvirtd: error while loading shared libraries: libvirt-lxc.so.0: cannot open shared object file: No such file or directory

查询:http://www.cnblogs.com/fuleying/p/3669228.html

             http://www.eefocus.com/pengwr/blog/2012-02/235057_baf52.html

解决方式稍微变了点:

$sudo find -name libvirt-lxc.so.0
/home/cloud/Downloads/libvirt-1.2.1/src/.libs/libvirt-lxc.so.0
/usr/local/lib/libvirt-lxc.so.0
$sudo gedit /etc/ld.so.conf    //打开之后,添加
include /usr/local/lib
sudo ldconfig


3,

cloud@cloud:~$ sudo virsh version
Compiled against library: libvirt 1.2.1
Using library: libvirt 1.2.1
Using API: QEMU 1.2.1
error: failed to get the hypervisor version
error: internal error: Cannot find suitable emulator for x86_64

百度说是qemu没有安装好,所以我一连安装qemu-kvm, qemu, qemu-common, qemu-utils

不过忘记是否当即好了,我周一看的时候已经好了,所以不清楚是不是我解决的


4,在python程序中调用‘import libvirt’报错:

ImportError: No module named libvirt

解决办法:安装python-libvirt

来源:http://iam42.iteye.com/blog/1750527


5,

cloud_backend.exception.LibvirtError: authentication failed: polkit: polkit\56retains_authorization_after_challenge=1
Authorization requires authentication but no agent is available.

原因:配置文件没有配好

在/etc/libvirt/libvirtd.conf或者/usr/local/etc/libvirt/libvirtd.conf,解注释:

auth_unix_rw = "none"

我顺便将auth_unix_ro = "none"也解注释了,不知是否影响此处


6,

cloud_backend.exception.LibvirtError: Failed to connect socket to '/usr/local/var/run/libvirt/libvirt-sock': Connection refused

解决:用root权限启动libvirt。将原来的libvirt进程杀死,然后sudo libvirtd -d


7,

libvirt: XML-RPC error : authentication failed: polkit: Not authorized

谷歌一个好像说是权限问题,libvirtd要root启动。来源:http://forums.opensuse.org/showthread.php/491253-How-to-run-KVM-with-user-privileges

不过我的是root启动的,于是我考虑配置文件。

cloud@backplatform0:~$ sudo find / -name libvirtd.conf
[sudo] password for cloud: 
/etc/libvirt/libvirtd.conf
/home/cloud/libvirt-0.9.13/tests/confdata/libvirtd.conf
/home/cloud/libvirt-0.9.13/daemon/libvirtd.conf
/home/cloud/vebula-install/libvirt-0.9.13/tests/confdata/libvirtd.conf
/home/cloud/vebula-install/libvirt-0.9.13/daemon/libvirtd.conf
/home/cloud/libvirt-0.9.8/tests/confdata/libvirtd.conf
/home/cloud/libvirt-0.9.8/daemon/libvirtd.conf
/home/cloud/zhuanyi/Downloads/vebula-install/libvirt-0.9.13/tests/confdata/libvirtd.conf
/home/cloud/zhuanyi/Downloads/vebula-install/libvirt-0.9.13/libvirtd.conf
/home/cloud/zhuanyi/Downloads/vebula-install/libvirt-0.9.13/daemon/libvirtd.conf
/home/liang/libvirt/tests/confdata/libvirtd.conf
/home/liang/libvirt/daemon/libvirtd.conf
/usr/local/etc/libvirt/libvirtd.conf
/usr/local/lib/sysctl.d/libvirtd.conf

其中/etc/libvirt/libvirtd.conf是以前改过的没问题,那么/usr/local/etc/libvirt/libvirtd.conf就很可疑了。我估计是因为我后来用压缩包安装时,没有卸载掉原来的,结果变成这样。所以把/usr/local/etc/libvirt/libvirtd.conf改的和/etc/libvirt/libvirtd.conf一样:

unix_sock_group = "libvirtd"

unix_sock_ro_perms = "0777"

unix_sock_rw_perms = "0777"

auth_unix_ro = "none"

auth_unix_rw = "none"

这些都是以前改过的,至于哪个是对权限起作用的就自己测试吧。我杀掉libvirtd进程后再启动,没报这个错了:$sudo libvirtd -d


8,用xml创建qemu虚拟机时:

libvirt: QEMU Driver error : unsupported configuration: Multiple legacy USB controllers are not supported

忘了怎么回事,但是我只是测试,所以将xml中usb的数量设置为1个就可以了,继续。。。


9,libvirt: QEMU Driver error : unsupported configuration: hda-duplex not supported in this QEMU binary

网上查好像与/dev/kvm的权限有关,或者与libvirt相关插件有关

来源:http://www.linux-kvm.com/content/problem-some-kvm-features-debian-sid

https://bugzilla.redhat.com/show_bug.cgi?id=967836

http://meetbot.fedoraproject.org/fedora-test-day/2013-05-28/fedora-test-day.2013-05-28-11.10.log.txt

不过我的没有这个文件,所以xml中将声卡等设备都去掉。继续。。。


10,依然是xml创建qemu虚拟机,

error: Operation not supported: JSON monitor is required

我查询后,感觉是版本不合的原因,因为我在ubuntu12.04上,有个成功的范例:

Compiled against library: libvirt 1.2.1
Using library: libvirt 1.2.1
Using API: QEMU 1.2.1
Running hypervisor: QEMU 1.6.2

而我现在测试的,实在ubuntu14.04上,只有qemu的版本不同:Running hypervisor: QEMU 1.7.91

所以我准备降低qemu版本,但是失败了。而且我感觉思路有点不准,继续查。

然后认为是libvirt的版本问题,因为我安装的python-libvirt和qemu一样,是从系统的源下载的,其中python-libvirt的版本为1.2.2:

$ aptitude show python-libvirt
Package: python-libvirt           
State: installed
Automatically installed: no
Version: 1.2.2-0ubuntu1

。。。

而我的libvirt的是我下载的安装包安装的,版本是1.2.1:

$ sudo virsh version
[sudo] password for cloud: 
Compiled against library: libvirt 1.2.1
Using library: libvirt 1.2.1
Using API: QEMU 1.2.1
Running hypervisor: QEMU 1.7.91

网上有个例子是需要两者版本一致的,来源:http://comments.gmane.org/gmane.comp.emulators.libvirt.user/6477

所以我卸载掉libvirt-1.2.1,重新安装libvirt-1.2.2。终于成功了

经过之后的测试,发现这步成功后,上面的8,9的问题都不复重现

11,卸载libvirt-1.2.1的过程也不顺利,卸载重装后,查看libvirt版本老是显示为旧版本1.2.1,后来发现是旧版本1.2.1没有卸载成功。

报错结尾没有记录,格式类似:

make[1]: *** [uninstall-recursive] Error 1

make[1]: Leaving directory `/home/cloud/Downloads/libvirt-1.2.1/docs'

make[2]: *** [uninstall-local] Error 1 

make[2]: Leaving directory `/home/cloud/Downloads/libvirt-1.2.1/docs'

我认为没有卸载干净,百度了一下,按以下步骤卸载:

$sudo make distclean

$sudo make clean

$sudo make uninstall

来源:http://blog.163.com/lgh_2002/blog/static/44017526201183011437764/

(**这个方法卸载不成功:http://smilejay.com/2013/03/libvirt-compilation-installation/)

另外,重新安装时,配置环境那一步,我使用几个参数,据说是覆盖原有libvirt

$./configure --prefix=/usr --localstatedir=/var  --sysconfdir=/etc

来源:http://liuzhijun.iteye.com/blog/1728617


12,重装完libvirt后启动:$sudo libvirtd -d

报错:libvirtd: error: Unable to obtain pidfile. Check /var/log/messages or run without --daemon for more

这个好查多了,原因 动记录文件还存在,需要先删除”,解决步骤如下:

(1)查找到libvirtd.pid文件,根据libvirt的安装不同,位置可能不同:

$ sudo find / -name libvirtd.pid
[sudo] password for cloud: 
/usr/local/var/run/libvirtd.pid

(2)删除:$sudo rm /usr/local/var/run/libvirtd.pid

(3)启动:$sudo libvirtd -d

来源:http://www.tuicool.com/articles/Qfyamy




版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/heybob/p/4718957.html

你可能感兴趣的:(libvirt安装过程中遇到的问题 分类: ubuntu学习 ...)