pincpu
custom property. Where the custom property is not set no action is taken.
pincpu=^[\^]?\d+(-\d+)?(,[\^]?\d+(-\d+)?)*$
pincpu
custom property for a given virtual machine to specify:
pincpu=0
, specifies that only CPU 0 be used), or
pincpu=1-4
, specifies that CPUs 1 through 4 be used), or
pincpu=^3
, specifies that CPU 3 not be used), or
pincpu=1-4,6
, specifies that CPUs 1 to 4, and 6 be used).
/usr/libexec/vdsm/hooks/before_vm_start/50_pincpu
#!/usr/bin/python import os import sys import hooking import traceback ''' pincpu usages ============= pincpu=0 (use the first cpu) pincpu=1-4 (use cpus 1-4) pincpu=^3 (dont use cpu 3) pincpu=1-4,6 (or all together) ''' if os.environ.has_key('pincpu'): try: domxml = hooking.read_domxml() vcpu = domxml.getElementsByTagName('vcpu')[0] if not vcpu.hasAttribute('cpuset'): sys.stderr.write('pincpu: pinning cpu to: %s\n' % os.environ['pincpu']) vcpu.setAttribute('cpuset', os.environ['pincpu']) hooking.write_domxml(domxml) else: sys.stderr.write('pincpu: cpuset attribute is present in vcpu, doing nothing\n') except: sys.stderr.write('pincpu: [unexpected error]: %s\n' % traceback.format_exc()) sys.exit(2)
numaset
custom property. Where the custom property is not set no action is taken.
numaset=^(interleave|strict|preferred):[\^]?\d+(-\d+)?(,[\^]?\d+(-\d+)?)*$
numaset
custom property for a given virtual machine to specify both the allocation mode (interleave
, strict
, preferred
) and the node to use. The two values are separated by a colon (:
). The regular expression allows specification of the nodeset
as:
numaset=strict:1
, specifies that only node 1 be used), or
numaset=strict:1-4
, specifies that nodes 1 through 4 be used), or
numaset=strict:^3
, specifies that node 3 not be used), or
numaset=strict:1-4,6
, specifies that nodes 1 to 4, and 6 be used).
/usr/libexec/vdsm/hooks/before_vm_start/50_numa
#!/usr/bin/python import os import sys import hooking import traceback ''' numa hook ========= add numa support for domain xml: <numatune> <memory mode="strict" nodeset="1-4,^3" /> </numatune> memory=interleave|strict|preferred numaset="1" (use one NUMA node) numaset="1-4" (use 1-4 NUMA nodes) numaset="^3" (don't use NUMA node 3) numaset="1-4,^3,6" (or combinations) syntax: numa=strict:1-4 ''' if os.environ.has_key('numa'): try: mode, nodeset = os.environ['numa'].split(':') domxml = hooking.read_domxml() domain = domxml.getElementsByTagName('domain')[0] numas = domxml.getElementsByTagName('numatune') if not len(numas) > 0: numatune = domxml.createElement('numatune') domain.appendChild(numatune) memory = domxml.createElement('memory') memory.setAttribute('mode', mode) memory.setAttribute('nodeset', nodeset) numatune.appendChild(memory) hooking.write_domxml(domxml) else: sys.stderr.write('numa: numa already exists in domain xml') sys.exit(2) except: sys.stderr.write('numa: [unexpected error]: %s\n' % traceback.format_exc()) sys.exit(2)