我正在尝试通过 libvirt java 绑定通过简单地调用来连接到 Ubuntu 10.04 机器上的 vbox 管理程序:
Connect conn = new Connect("vbox:///session", false);
但我得到了这个例外:
libvir: warning : Failed to find the interface: Is the daemon running ?
libvir: Remote error : unable to connect to '/var/run/libvirt/libvirt-sock': Connection refused
libvir: warning : Failed to find a node driver: Is the libvirtd daemon running ?
libvir: Remote error : unable to connect to '/var/run/libvirt/libvirt-sock': Connection refused
libvir: warning : Failed to find a secret storage driver: Is the daemon running ?
org.libvirt.LibvirtException: Failed to find a secret storage driver: Is the daemon running ?
at org.libvirt.ErrorHandler.processError(ErrorHandler.java:28)
at org.libvirt.Connect.<init>(Connect.java:195)
at VBOX.main(VBOX.java:32)
否则,从 virsh,我可以正确连接到 vbox 管理程序:
$ export LIBVIRT_DEBUG=1
$virsh -c vbox:///session list --all
11:37:18.318: debug : virInitialize:336 : register drivers
11:37:18.318: debug : virRegisterDriver:837 : registering Test as driver 0
11:37:18.318: debug : virRegisterNetworkDriver:675 : registering Test as network driver 0
11:37:18.318: debug : virRegisterInterfaceDriver:706 : registering Test as interface driver 0
11:37:18.318: debug : virRegisterStorageDriver:737 : registering Test as storage driver 0
11:37:18.318: debug : virRegisterDeviceMonitor:768 : registering Test as device driver 0
11:37:18.318: debug : virRegisterSecretDriver:799 : registering Test as secret driver 0
11:37:18.318: debug : virRegisterDriver:837 : registering Xen as driver 1
11:37:18.318: debug : virRegisterDriver:837 : registering OPENVZ as driver 2
11:37:18.336: debug : vboxRegister:83 : VBoxCGlueInit found API version: 3.1.6 (3001006)
11:37:18.336: debug : vboxRegister:100 : VirtualBox API version: 3.1
11:37:18.336: debug : virRegisterDriver:837 : registering VBOX as driver 3
11:37:18.336: debug : virRegisterNetworkDriver:675 : registering VBOX as network driver 1
11:37:18.336: debug : virRegisterStorageDriver:737 : registering VBOX as storage driver 1
11:37:18.336: debug : virRegisterDriver:837 : registering remote as driver 4
11:37:18.336: debug : virRegisterNetworkDriver:675 : registering remote as network driver 2
11:37:18.336: debug : virRegisterInterfaceDriver:706 : registering remote as interface driver 1
11:37:18.336: debug : virRegisterStorageDriver:737 : registering remote as storage driver 2
11:37:18.336: debug : virRegisterDeviceMonitor:768 : registering remote as device driver 1
11:37:18.336: debug : virRegisterSecretDriver:799 : registering remote as secret driver 1
11:37:18.336: debug : virConnectOpenAuth:1337 : name=vbox:///session, auth=0x231638, flags=0
11:37:18.336: debug : do_open:1106 : name "vbox:///session" to URI components:
scheme vbox
opaque (null)
authority (null)
server (null)
user (null)
port 0
path /session
11:37:18.336: debug : do_open:1116 : trying driver 0 (Test) ...
11:37:18.336: debug : do_open:1122 : driver 0 Test returned DECLINED
11:37:18.336: debug : do_open:1116 : trying driver 1 (Xen) ...
11:37:18.336: debug : do_open:1122 : driver 1 Xen returned DECLINED
11:37:18.336: debug : do_open:1116 : trying driver 2 (OPENVZ) ...
11:37:18.336: debug : do_open:1122 : driver 2 OPENVZ returned DECLINED
11:37:18.336: debug : do_open:1116 : trying driver 3 (VBOX) ...
11:37:18.589: debug : vboxOpen:836 : in vboxOpen
11:37:18.589: debug : do_open:1122 : driver 3 VBOX returned SUCCESS
11:37:18.589: debug : do_open:1142 : network driver 0 Test returned DECLINED
11:37:18.589: debug : vboxNetworkOpen:5439 : network initialized
11:37:18.589: debug : do_open:1142 : network driver 1 VBOX returned SUCCESS
11:37:18.589: debug : do_open:1161 : interface driver 0 Test returned DECLINED
11:37:18.589: debug : doRemoteOpen:564 : proceeding with name = vbox:///session
11:37:18.590: debug : remoteIO:8455 : Do proc=66 serial=0 length=28 wait=(nil)
11:37:18.590: debug : remoteIO:8517 : We have the buck 66 0xb7516008 0xb7516008
11:37:18.595: debug : remoteIODecodeMessageLength:7939 : Got length, now need 64 total (60 more)
11:37:18.595: debug : remoteIOEventLoop:8381 : Giving up the buck 66 0xb7516008 (nil)
11:37:18.595: debug : remoteIO:8548 : All done with our call 66 (nil) 0xb7516008
11:37:18.596: debug : remoteIO:8455 : Do proc=1 serial=1 length=56 wait=(nil)
11:37:18.596: debug : remoteIO:8517 : We have the buck 1 0x95eb908 0x95eb908
11:37:18.659: debug : remoteIOEventLoop:8402 : Giving up the buck due to I/O error 1 0x95eb908 (nil)
11:37:18.660: debug : do_open:1161 : interface driver 1 remote returned ERROR
11:37:18.660: debug : do_open:1181 : storage driver 0 Test returned DECLINED
11:37:18.660: debug : vboxStorageOpen:6191 : vbox storage initialized
11:37:18.660: debug : do_open:1181 : storage driver 1 VBOX returned SUCCESS
11:37:18.660: debug : do_open:1201 : node driver 0 Test returned DECLINED
11:37:18.660: debug : doRemoteOpen:564 : proceeding with name = vbox:///session
11:37:18.661: debug : do_open:1201 : node driver 1 remote returned ERROR
11:37:18.661: debug : do_open:1228 : secret driver 0 Test returned DECLINED
11:37:18.661: debug : doRemoteOpen:564 : proceeding with name = vbox:///session
11:37:18.661: debug : do_open:1228 : secret driver 1 remote returned ERROR
11:37:18.661: debug : virConnectNumOfDomains:1714 : conn=0x95a1910
11:37:18.663: debug : virConnectNumOfDefinedDomains:4554 : conn=0x95a1910
11:37:18.664: debug : virConnectListDefinedDomains:4593 : conn=0x95a1910, names=0x95e9b58, maxnames=1
Id Name State
----------------------------------
11:37:18.666: debug : virDomainLookupByName:1974 : conn=0x95a1910, name=tty
11:37:18.669: debug : virGetDomain:345 : New hash entry 0x95dad48
11:37:18.669: debug : virDomainGetInfo:2825 : domain=0x95dad48, info=0xbfeca708
- tty shut off
11:37:18.673: debug : virDomainFree:2062 : domain=0x95dad48
11:37:18.673: debug : virUnrefDomain:422 : unref domain 0x95dad48 tty 1
11:37:18.673: debug : virReleaseDomain:376 : release domain 0x95dad48 tty
11:37:18.673: debug : virReleaseDomain:392 : unref connection 0x95a1910 2
11:37:18.673: debug : virConnectClose:1355 : conn=0x95a1910
11:37:18.673: debug : virUnrefConnect:259 : unref connection 0x95a1910 1
11:37:18.673: debug : vboxNetworkClose:5448 : network uninitialized
11:37:18.673: debug : vboxStorageClose:6200 : vbox storage uninitialized
11:37:18.673: debug : vboxClose:843 : VBOX: in vboxClose
11:37:18.681: debug : virReleaseConnect:216 : release connection 0x95a1910
即使有一些警告/错误。
你有什么提示吗?谢谢