Product SiteDocumentation Site

3.4.10. isAlive

This method determines 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.

Example 3.21. Using isAlive

# Example-21.py
#!/usr/bin/env python3
import sys
import libvirt

conn = None
try:
    conn = libvirt.open("qemu:///system")
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)
    exit(1)

alive = conn.isAlive()

print("Connection is alive = " + str(alive))

conn.close()
exit(0)