On 13.06.2014 11:35, Sijo Jose wrote:
Hi Michal,
virConnectOpen is for connecting to a host right..?
I want to check the host status, whether the connection to the host is
active or not..
for that purpose we have to use virConnectIsAlive()
I'm using libvirt python bindings,
here is the function defnintion.
def isAlive(self):
"""Determine if the connection to the hypervisor is still alive
A connection will be classed as alive if it is either local, or
running
over a channel (TCP or UNIX socket) which is not closed. """
ret = libvirtmod.virConnectIsAlive(self._o)
if ret == -1: raise libvirtError ('virConnectIsAlive() failed',
conn=self)
return ret
Once if you connect to a host thereafter it is always giving status as
1(true), no matter whether the connection is broken or not..
You need to use recent libvirt which added keep-alive support (last
stable version is 1.2.1 or newer) and then have a separate thread to run
the event loop. Once you have all of these, isAlive() should work just fine.
Michal