kvm与selinux

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kvm与selinux相关的知识,希望对你有一定的参考价值。

 

 Desktop virsh start 16lnmp
error: Failed to start domain 16lnmp
error: unsupported configuration: Unable to find security driver for label selinux
查看看selinux是关闭的:
?  Desktop grep -i ^selinux /etc/sysconfig/selinux
SELINUX=disabled
SELINUXTYPE=targeted 

查看libvirtd的启动日志:

?  Desktop tailf /var/log/libvirt/libvirtd.log

2016-09-11 22:38:33.812+0000: 3579: error : virSecurityManagerGenLabel:376 : unsupported configuration: Unable to find security driver for label selinux
2016-09-11 22:38:33.812+0000: 3579: error : qemuRemoveCgroup:824 : internal error Unable to find cgroup for 16lnmp
2016-09-11 22:38:33.812+0000: 3579: warning : qemuProcessStop:4617 : Failed to remove cgroup for 16lnmp
2016-09-11 22:38:33.813+0000: 3579: warning : qemuDomainObjStart:6252 : Unable to restore from managed state /var/lib/libvirt/qemu/save/16lnmp.save. Maybe the file is corrupted?

造成这个错误的原因是:

由于机器开机状态时,将SElinux的状态信息save在虚拟机中,导致SElinux关闭之后,虚拟找不到对应的label,从而导致vm启动失败。

如果配置配置文件中有selinux相关的配置,将其删除,如果没有,则可能已经保存在vm状态中,将原有的状态删除即可(对应路径/var/lib/libvirt/qemu/save),如下:

 ~ ls /var/lib/libvirt/qemu/save 
13svn.save  14git.save  15samba.save  16lnmp.save  26svn.save  centos7.save
?  ~ rm /var/lib/libvirt/qemu/save/16lnmp.save 
?  ~ virsh start 16lnmp
Domain 16lnmp started
#启动成功!!!

 

以上是关于kvm与selinux的主要内容,如果未能解决你的问题,请参考以下文章

Kvm虚拟化安装与虚拟机创建

centos7 kvm

kvm 安全相关:selinux svirt

KVM之KVM安装部署

KVM安装与配置

centos7安装kvm