kvm与selinux

时间:2022-07-27 02:31:30
 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

-- ::33.812+: : error : virSecurityManagerGenLabel: : unsupported configuration: Unable to find security driver for label selinux
-- ::33.812+: : error : qemuRemoveCgroup: : internal error Unable to find cgroup for 16lnmp
-- ::33.812+: : warning : qemuProcessStop: : Failed to remove cgroup for 16lnmp
-- ::33.813+: : warning : qemuDomainObjStart: : 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
#启动成功!!!