Product SiteDocumentation Site

4.3.7. Get the Domain hardware info

The info method returns some general information about the domain hardware. a managed save image. There should be eight entries returned in a Python list which consist of the state, maxmemory, memory, cpus and cpu time for the domain.
from __future__ import print_function
import sys
import libvirt
from xml.dom import minidom

domName = 'CentOS7'

conn ='qemu:///system')
if conn == None:
    print('Failed to open connection to qemu:///system', file=sys.stderr)

dom = conn.lookupByName(domName)
if dom == None:
    print('Failed to find the domain '+domName, file=sys.stderr)

state, maxmem, mem, cpus, cput =
print('The state is ' + str(state))
print('The max memory is ' + str(maxmem))
print('The memory is ' + str(mem))
print('The number of cpus is ' + str(cpus))
print('The cpu time is ' + str(cput))

Example 4.13. Get the domain info