当使用 virsh list 命令时,遇到错误 error: failed to connect to the hypervisor error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory,表示无法连接到虚拟化管理程序。这是因为虚拟化管理程序的 UNIX 域套接字文件 '/var/run/libvirt/libvirt-sock' 不存在。

解决方法:

  1. 确保 libvirt 服务正在运行:

systemctl status libvirtd

如果服务未运行,请使用以下命令启动服务:

systemctl start libvirtd


2. **如果服务已经运行,但问题仍然存在,可以尝试重启 libvirt 服务:**

systemctl restart libvirtd


3. **如果问题仍然存在,可以尝试重新安装 libvirt 软件包:**

apt-get install --reinstall libvirt-daemon-system libvirt-clients


**关于 /var/run/libvirt/ 目录结构的问题:**

根据你提供的输出,目录结构似乎没有问题。UNIX 域套接字文件 (libvirt-sock) 应该存在,但是它在你的情况下似乎不存在。这可能是由于 libvirt 服务未正确启动或发生了其他错误导致的。通过上述步骤,你可以尝试解决连接问题。
解决 virsh list 报错: Failed to connect to the hypervisor

原文地址: https://www.cveoy.top/t/topic/fv6k 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录