Product SiteDocumentation Site

3.4.2. getMaxVcpus

The getMaxVcpus method can be used to obtain the maximum number of virtual CPUs per-guest the underlying virtualization technology supports. It takes a virtualization "type" as input (which can be None), and if successful, returns the number of virtual CPUs supported. If an error occurred, -1 is returned instead. The following code demonstrates the use of getMaxVcpus:

Example 3.12. Using getMaxVcpus

#!/usr/bin/env python3
import sys
import libvirt

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

vcpus = conn.getMaxVcpus(None)
print('Maximum support virtual CPUs: '+str(vcpus))