[libvirt-users] How to tell if a hypervisor connection has died?

Hi, What's the best way to tell if a virConnect object is not good to use anymore? (For example because the libvirtd on the other side crashed/has been stopped or because of some network failure) When I try this, the first API call I do on a broken connection yields an error with error number 38 (VIR_ERR_SYSTEM_ERROR) and all subsequent calls yield an error number 1 (VIR_ERR_INTERNAL_ERROR). Both of those are really unhelpful and could mean just about anything... Guido

On 04/25/2013 11:49 AM, Guido Winkelmann wrote:
Hi,
What's the best way to tell if a virConnect object is not good to use anymore? (For example because the libvirtd on the other side crashed/has been stopped or because of some network failure)
Try using virConnectIsAlive(). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Am Donnerstag, 25. April 2013, 12:04:21 schrieb Eric Blake:
On 04/25/2013 11:49 AM, Guido Winkelmann wrote:
Hi,
What's the best way to tell if a virConnect object is not good to use anymore? (For example because the libvirtd on the other side crashed/has been stopped or because of some network failure)
Try using virConnectIsAlive().
That did the trick, thanks! Guido

On Thu, Apr 25, 2013 at 07:49:02PM +0200, Guido Winkelmann wrote:
Hi,
What's the best way to tell if a virConnect object is not good to use anymore? (For example because the libvirtd on the other side crashed/has been stopped or because of some network failure)
When I try this, the first API call I do on a broken connection yields an error with error number 38 (VIR_ERR_SYSTEM_ERROR) and all subsequent calls yield an error number 1 (VIR_ERR_INTERNAL_ERROR). Both of those are really unhelpful and could mean just about anything...
Use the virConnectRegisterCloseCallback API to register a callback. This will be invoked when the connection is closed for any reason. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Guido Winkelmann