ERROR1:
背景:虚拟机的镜像文件放在nfs服务器的共享文件夹中,源主机将共享目录挂载到本机的/mnt/nfs文件夹中,镜像文件为vdisk.img,当源主机启动虚拟机时报如下错误:
[root@qinshang mnt]# virsh start vdisk
error: Failed to start domain vdisk
error: 内部错误 Process exited while reading console log output: char device redirected to /dev/pts/1
qemu-system-x86_64: -drive file=/mnt/nfs/vdisk.img,if=none,id=drive-ide0-0-0,format=qcow2: could not open disk image /mnt/nfs/vdisk.img: Permission denied
Analytics:
SELinux is preventing /usr/bin/qemu-system-x86_64 from open access on the file /mnt/nfs/vdisk.img.
Soution:
If you want to allow confined virtual guests to manage nfs files.Then you must tell SELinux about this by enabling the 'virt_use_nfs' boolean.You can read 'virt_selinux' man page for more details.
Do
setsebool -P virt_use_nfs 1
If you believe that qemu-system-x86_64 should be allowed open access on the vdisk.img file by default.
Then you should report this as a bug.You can generate a local policy module to allow this access.
Do allow this access for now by executing:
grep qemu-system-x86 /var/log/audit/audit.log | audit2allow -M mypol
semodule -i mypol.pp
ERROR2:
背景:有时候查看挂载nfs共享文件的目录的时候,会出现 stale file handle错误,错误原因这里就不解释了,有兴趣的话,可以访问以下网址:
Solution2:
先用umount -f /mnt/nfs/命令,如果还不奏效的话,再用umount -l /mnt/nfs/命令,如果依然不奏效的话,多敲几下这些命令,再不行的话,关掉nfs服务器,然后重新启动,接着再重新挂载即可解决!
ERROR3:
背景:运行virsh start centos(此处为具体的虚拟机名字)时候,会出现以下错误
error: Failed to reconnect to the hypervisor
error: no valid connection
error: Failed to connect socket to '/usr/local/var/run/libvirt/libvirt-sock': No such file or directory
Solution3:
ln -s /var/run/libvirt/libvirt-sock /usr/local/var/run/libvirt/libvirt-sock
ERROR4:
背景:运行virsh命令的时候,显示以下错误
error: failed to connect to the hypervisor
error: no valid connection
error: Failed to connect socket to '/usr/local/var/run/libvirt/libvirt-sock': Connection refused
分析:
ibvirtd is not running, or running but waiting on '/var/run/libvirt/libvirt-sock' where your virsh is try to look up'/usr/local/var/run/libvirt/libvirt-sock'
Solution4:
先运行libvirtd -d , 如果virsh命令能用的话,说明libvirtd已经启动,如果这时候打开virtual manager来管理虚拟机报错的话,再运行命令 systemctl restart libvirtd.service 即可解决!
这时候运行 ps aux | grep libvirtd 查看libvirtd进程的时候可以看到以下结果
暂时先到这,有发现新的问题会再补充