libvirt 和 VirtualBox / 入门

发布于 2024-08-31 15:57:24 字数 405 浏览 19 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你与昨日 2024-09-07 15:57:24

如果您在 Ubuntu 上执行此操作,那么问题出在其 libvirt 软件包上构建时没有 VirtualBox 支持

您可以非常轻松地在支持下重建软件包。类似于:

apt-get source -d libvirt
sudo apt-get build-dep libvirt
dpkg-source -x libvirt*dsc

进入 libvirt 目录并编辑 debian/rules,这样它就不再是 --without-vbox 而是 --使用-vbox。您可以在 debian/changelog 顶部添加一个条目,以便将包编译为不同的版本(例如,将 ~local1 附加到版本中)。

dpkg-buildpackage -us -uc -b -rfakeroot

您将在上面的目录中获得新的 .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:

apt-get source -d libvirt
sudo apt-get build-dep libvirt
dpkg-source -x libvirt*dsc

Go into the libvirt directory and edit debian/rules so that instead of --without-vbox it says --with-vbox. You can add an entry to the top of debian/changelog so the package is compiled as a different version (e.g., append ~local1 to the version).

dpkg-buildpackage -us -uc -b -rfakeroot

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).

So尛奶瓶 2024-09-07 15:57:24

仔细检查您是否具有对 /var/run/libvirt/libvirt-sock 的写入权限。

套接字文件应该具有类似于以下内容的权限:

$ sudo ls -la /var/run/libvirt/libvirt-sock
srwxrwx--- 1 root libvirtd 0 2010-08-24 14:54 /var/run/libvirt/libvirt-sock

我认为通过在 shell 中运行以下命令来增加 libvirt 日志记录功能也可能会有所帮助:

export LIBVIRT_DEBUG=1

Double-check whether or not you have write access to /var/run/libvirt/libvirt-sock.

The socket file should have permissions similar to:

$ sudo ls -la /var/run/libvirt/libvirt-sock
srwxrwx--- 1 root libvirtd 0 2010-08-24 14:54 /var/run/libvirt/libvirt-sock

I think it could be helpful also to increase the libvirt logging capabilities by running this in your shell:

export LIBVIRT_DEBUG=1
不羁少年 2024-09-07 15:57:24

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文