2011/11/6 Brian Candler <B.Candler(a)pobox.com>:
I have a new OSX Lion Macbook and would like to control VirtualBox
using
"virsh" (as I do with KVM under Ubuntu).
I've got this far:
* Installed VirtualBox
Which version?
But now I'm a bit stuck :-)
I ran VirtualBox itself, and created a test VM successfully.
If I try to use virsh, this is what I get:
Brians-MacBook-Air:~ $ virsh -c vbox:///session
error: internal error unable to initialize VirtualBox driver API
error: failed to connect to the hypervisor
vbox:///session is the correct URI.
Brians-MacBook-Air:~ $ virsh -c vbox+unix:///session
error: Failed to connect socket to '(a)/Users/brian/.libvirt/libvirt-sock': No such
file or directory
error: failed to connect to the hypervisor
If I try to start libvirtd, this is what I get:
Brians-MacBook-Air:~ $ /usr/local/sbin/libvirtd
00:00:18.970: -1: info : libvirt version: 0.9.6
00:00:18.970: -1: error : virNetSocketNewListenUNIX:340 : Failed to bind socket to
'(a)/Users/brian/.libvirt/libvirt-sock': No such file or directory
[but directory /Users/brian/.libvirt was created]
IIRC the problem here is that libvirtd uses anonymous UNIX sockets
that are specific to Linux. Anyway, you don't need libvirtd for
VirtualBox, virsh -c vbox:///session is just fine.
However, VirtualBox itself is running OK:
Brians-MacBook-Air:~ $ VBoxManage list vms
"test" {d0d74c25-1dfc-44a4-8a2b-1d25b7972e7c}
Furthermore, dtruss suggests that virsh is finding the installed VirtualBox:
Brians-MacBook-Air:~ $ sudo dtruss -f virsh -c vbox:///session 2>&1 | grep -i
virtualbox
error: internal error unable to initialize VirtualBox driver API
48916/0x3cc08: write_nocancel(0x2, "internal error unable to initialize VirtualBox
driver API\n\0", 0x3A) = 58 0
48916/0x3cc08: access("/usr/lib/virtualbox/VBoxXPCOMC.dylib\0", 0x0, 0x0)
= -1 Err#2
48916/0x3cc08: access("/usr/lib/virtualbox-ose/VBoxXPCOMC.dylib\0", 0x0, 0x0)
= -1 Err#2
48916/0x3cc08: access("/usr/lib64/virtualbox/VBoxXPCOMC.dylib\0", 0x0, 0x0)
= -1 Err#2
48916/0x3cc08: access("/usr/lib64/virtualbox-ose/VBoxXPCOMC.dylib\0", 0x0,
0x0) = -1 Err#2
48916/0x3cc08: access("/usr/lib/VirtualBox/VBoxXPCOMC.dylib\0", 0x0, 0x0)
= -1 Err#2
48916/0x3cc08: access("/opt/virtualbox/VBoxXPCOMC.dylib\0", 0x0, 0x0)
= -1 Err#2
48916/0x3cc08: access("/opt/VirtualBox/VBoxXPCOMC.dylib\0", 0x0, 0x0)
= -1 Err#2
48916/0x3cc08: access("/opt/virtualbox/i386/VBoxXPCOMC.dylib\0", 0x0, 0x0)
= -1 Err#2
48916/0x3cc08: access("/opt/VirtualBox/i386/VBoxXPCOMC.dylib\0", 0x0, 0x0)
= -1 Err#2
48916/0x3cc08: access("/opt/virtualbox/amd64/VBoxXPCOMC.dylib\0", 0x0, 0x0)
= -1 Err#2
48916/0x3cc08: access("/opt/VirtualBox/amd64/VBoxXPCOMC.dylib\0", 0x0, 0x0)
= -1 Err#2
48916/0x3cc08: access("/usr/local/lib/virtualbox/VBoxXPCOMC.dylib\0", 0x0,
0x0) = -1 Err#2
48916/0x3cc08: access("/usr/local/lib/VirtualBox/VBoxXPCOMC.dylib\0", 0x0,
0x0) = -1 Err#2
48916/0x3cc08:
access("/Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMC.dylib\0", 0x0,
0x0) = 0 0
48916/0x3cc08:
stat64("/Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMC.dylib\0",
0x7FFF685D0980, 0x7FFF685D1810) = 0 0
48916/0x3cc08:
open("/Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMC.dylib\0", 0x0,
0x0) = 4 0
48916/0x3cc08:
stat64("/Applications/VirtualBox.app/Contents/MacOS/VBoxRT.dylib\0",
0x7FFF685D0750, 0x7FFF685D15D0) = 0 0
48916/0x3cc08:
open("/Applications/VirtualBox.app/Contents/MacOS/VBoxRT.dylib\0", 0x0, 0x0)
= 4 0
48916/0x3cc08:
stat64("/Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOM.dylib\0",
0x7FFF685D0750, 0x7FFF685D15D0) = 0 0
48916/0x3cc08:
open("/Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOM.dylib\0", 0x0, 0x0)
= 4 0
That's good, so libvirt actually finds the required XPCOM library.
The error you're getting indicates that libvirt has a problem
initializing the XPCOM library.
Has anybody got libvirt + OSX Lion + VirtualBox working, and if so,
how did
you do it?
I don't have an OSX at hand for testing, but you can try
LIBVIRT_LOG_FILTERS=1:vbox virsh -c vbox:///session
and post the output here. This might give a hint about what's wrong.
--
Matthias Bolte
http://photron.blogspot.com