Product SiteDocumentation Site

3.4.6. Get Library and Driver Versions

The libvirt library has version information, both for the package and for the library itself. They can be printed as can be seen below.

Example 3.16. Using virConnectGetVersion

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

print("Package Version: " + libvirt.sys.version)
print("Library Version: " + str(libvirt.sys.version_info))

exit(0)
Each driver that the library supports also has their own version. Version numbers are integers: 1000000*major + 1000*minor + release. The following example demonstrates how to print the version number for a driver.

Example 3.17. Using virConnectGetVersion

# Example-15.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)

ver = conn.getVersion()
print('Version: '+str(ver))

conn.close()
exit(0)