getCellsFreeMemory
method can be used to obtain the amount of free memory (in kilobytes) in some or all of the NUMA nodes in the system. It takes as input the starting cell and the maximum number of cells to retrieve data from. If successful, Python list
is returned with the amount of free memory in each node. On failure None
is returned. The following code demonstrates the use of getCellsFreeMemory
:
Example 3.14. Using getCellsFreeMemory
# Example-13.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() numnodes = nodeinfo[4] memlist = conn.getCellsFreeMemory(0, numnodes) cell = 0 for cellfreemem in memlist: print('Node '+str(cell)+': '+str(cellfreemem)+' bytes free memory') cell += 1 conn.close() exit(0)