[libvirt-users] java binding and virtualbox-ose
Andrea Turli
andrea.turli at eng.it
Mon Nov 15 09:58:15 UTC 2010
Matthias,
On 11/14/2010 11:47 PM, Matthias Bolte wrote:
> 2010/11/14 Andrea Turli<andrea.turli at eng.it>:
>
>> I'm trying to connect to vbox hypervisor on an Ubuntu 10.04 machine
>> through libvirt java binding (libvirt-java-0.4.6) by simply invoking:
>>
>> Connect conn = new Connect("vbox:///session", false);
>> but I got this exception:
>>
>> 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)
>>
>>
> This is a bit tricky and took me a moment to understand.
>
Thank you for your time.
> libvirt's error handling can report warnings. This feature is not used
> often in libvirt, basically only in the virConnectOpen* functions to
> report missing subdrivers.
>
> The Java bindings now have two problems:
>
> 1) The error processing in the bindings is done unconditional, it
> always checks for an error even if the called function succeeded. Also
> this results in an unnecessary call to the JNA interface for each
> successful libvirt call.
>
> 2) The error processing raises an exception for all error, even for
> errors with level VIR_ERR_WARNING.
>
> This results in the exception you see. The call to virConnectOpen
> succeeds but libvirt reports a warning about missing sudrivers and the
> bindings turn this into an exception.
>
> You can apply this workaround to the Java bindings code:
>
>
> diff --git a/src/main/java/org/libvirt/ErrorHandler.java
> b/src/main/java/org/libvirt/ErrorHandler.java
> index e30291b..de66518 100644
> --- a/src/main/java/org/libvirt/ErrorHandler.java
> +++ b/src/main/java/org/libvirt/ErrorHandler.java
> @@ -25,7 +25,11 @@ public class ErrorHandler {
> if (errorCode> 0) {
> Error error = new Error(vError);
> libvirt.virResetLastError();
> - throw new LibvirtException(error);
> +
> + /* FIXME: Don't throw exceptions for VIR_ERR_WARNING
> level errors */
> + if (error.getLevel() == Error.ErrorLevel.VIR_ERR_ERROR) {
> + throw new LibvirtException(error);
> + }
> }
> }
> }
>
>
I've applied this patch and it worked for me. So, do you think we should
expect this fix in the next release? if yes, is it already scheduled?
> The actually fix is more involved as it includes making the error
> processing conditional.
>
> Matthias
>
>
Thank you again,
Andrea
--
Andrea Turli
Ricercatore
Direzione Ricerca e Innovazione
andrea.turli at eng.it
Engineering Ingegneria Informatica spa
Via Riccardo Morandi, 32 00148 Roma (RM)
Tel. +39 06 8307 4710
Fax +39 06 8307 4200
www.eng.it
More information about the libvirt-users
mailing list