libvirt 和 VirtualBox / 入门
我正在尝试使用 VirtualBox 作为虚拟化解决方案来开始使用 libvirt。我安装了所有内容,并且在使用 VBoxHeadless 命令时 VirtualBox 本身正在运行。 但是,libvirt 无法连接到 VirtualBox:
# virsh -c vbox:///session
libvir: error : could not connect to vbox:///session
error: failed to connect to the hypervisor
我在 libvirt 文档中找不到任何提示,表明在使用 virsh 之前是否必须进行任何特定于域的配置。
有人有提示吗?或者甚至更好,也许是一个从头开始使用 libvirt、virsh 或其 API(我后来的目标)的教程。
I'm trying to get started on libvirt with VirtualBox as a virtualization solution. I installed everything and VirtualBox itself is running when using their VBoxHeadless command.
However, libvirt fails to connect to VirtualBox:
# virsh -c vbox:///session
libvir: error : could not connect to vbox:///session
error: failed to connect to the hypervisor
I could not find any hints in the libvirt documentation that point to whether I have to make any domain specific configuration before using virsh.
Does anyone have a hint? Or even better, maybe a tutorial that works through the way of using libvirt, virsh or it's APIs (my later goal) from the ground up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您在 Ubuntu 上执行此操作,那么问题出在其 libvirt 软件包上构建时没有 VirtualBox 支持。
您可以非常轻松地在支持下重建软件包。类似于:
进入
libvirt
目录并编辑debian/rules
,这样它就不再是--without-vbox
而是--使用-vbox。您可以在
debian/changelog
顶部添加一个条目,以便将包编译为不同的版本(例如,将 ~local1 附加到版本中)。您将在上面的目录中获得新的 .debs 文件。使用 dpkg -i 来安装相关的(libvirt0、libvirt0-bin 以及任何您想要的)。
If you are doing this on Ubuntu, then the problem is their libvirt package is built without VirtualBox support.
You can rebuild the package with support very easily. Something like:
Go into the
libvirt
directory and editdebian/rules
so that instead of--without-vbox
it says--with-vbox
. You can add an entry to the top ofdebian/changelog
so the package is compiled as a different version (e.g., append ~local1 to the version).You'll get new .debs built in the directory above. Use
dpkg -i
to install the relevant ones (libvirt0, libvirt0-bin, and whatever else you want).仔细检查您是否具有对
/var/run/libvirt/libvirt-sock
的写入权限。套接字文件应该具有类似于以下内容的权限:
我认为通过在 shell 中运行以下命令来增加 libvirt 日志记录功能也可能会有所帮助:
Double-check whether or not you have write access to
/var/run/libvirt/libvirt-sock
.The socket file should have permissions similar to:
I think it could be helpful also to increase the libvirt logging capabilities by running this in your shell:
Ubuntu PPA for libvirt 支持 VirtualBox: https://launchpad.net/~cxl/ +存档/ubuntu/libvirt
There is Ubuntu PPA for libvirt with VirtualBox support: https://launchpad.net/~cxl/+archive/ubuntu/libvirt