问题
I'm trying to access VirtualBox through libvirt on OS X (Lion). I installed libvirt 0.9.4 using Homebrew. However, libvirt fails to connect to VirtualBox:
# virsh -c vbox:///session
error: internal error unable to initialize VirtualBox driver API
error: failed to connect to the hypervisor
In a similar SO question about Ubuntu, the answer was that the Ubuntu libvirt package doesn't build support for VirtualBox. How can I check if this is the problem in the case of the Homebrew package, or if it's a different issue? If it's the same problem, how do I rebuild the Homebrew package with VirtualBox support?
Edit: libvirt 0.9.7 has been released, and I no longer get this error.
回答1:
Your libvirt is build with VirtualBox support. I can tell because the error message you see comes from the VirtualBox driver in libvirt.
There was a similar problem reported on the libvirt users maling list today. The problem there was that support for VirtualBox 4.1 was added quite recently to libvirt. It's not in a released version yet and will be part of the next libvirt release 0.9.7.
To get some more useful information try running this:
LIBVIRT_LOG_FILTERS=1:vbox virsh -c vbox:///session
I suspect that you have VirtualBox 4.1 installed, but libvirt 0.9.4 supports only up to VirtualBox 4.0.
You can either a) upgrade your libvirt to current git version (that supports VirtualBox 4.1), or b) wait for the next libvirt release (it's expected in this week) or c) downgrade your VirtualBox version to 4.0 to fix this, assuming your problem is really as I suspect.
来源:https://stackoverflow.com/questions/7946994/libvirt-and-virtualbox-on-os-x