Product SiteDocumentation Site

3.4.3. getInfo

The getInfo method can be used to obtain various information about the virtualization host. The method returns a Python list if successful and None if and error occurred. The Python list contains the following members:

Table 3.5. virNodeInfo structure members

Member
Description
list[0]
string indicating the CPU model
list[1]
memory size in megabytes
list[2]
the number of active CPUs
list[3]
expected CPU frequency (mhz)
list[4]
the number of NUMA nodes, 1 for uniform memory access
list[5]
number of CPU sockets per node
list[6]
number of cores per socket
list[7]
number of threads per core
The following code demonstrates the use of virNodeGetInfo:

Example 3.13. Using getInfo

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

nodeinfo = conn.getInfo()

print('Model: '+str(nodeinfo[0]))
print('Memory size: '+str(nodeinfo[1])+'MB')
print('Number of CPUs: '+str(nodeinfo[2]))
print('MHz of CPUs: '+str(nodeinfo[3]))
print('Number of NUMA nodes: '+str(nodeinfo[4]))
print('Number of CPU sockets: '+str(nodeinfo[5]))
print('Number of CPU cores per socket: '+str(nodeinfo[6]))
print('Number of CPU threads per core: '+str(nodeinfo[7]))

conn.close()
exit(0)