Skip to content

Commit 858b9ce

Browse files
jamepark4danpawlik
authored andcommitted
[libvirt_manager] Allow for multi-numa guest deployment
Allow for guests to deploy with multiple numa nodes if a numa key is supplied to the cifmw_libvirt_manager_configuration when defining a guest. This is useful when testing multi-numa environments that take advantage of NUMA affinity and managing cpu policy across a slightly more complex architecture. Logic assumes operator will define an evenly distributed system and will not take into account remainders. Signed-off-by: James Parker jparker@redhat.com
1 parent b5916f2 commit 858b9ce

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

roles/libvirt_manager/templates/domain.xml.j2

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,20 @@
1616
<boot dev='hd'/>
1717
<bootmenu enable='{{ vm_data.bootmenu_enable | default('no') }}'/>
1818
</os>
19-
<cpu mode='host-passthrough' check='none'/>
19+
<cpu mode='host-passthrough' check='none'>
20+
{% if vm_data.numa is defined and vm_data.numa|int > 1 %}
21+
<numa>
22+
{% set cores_per_node = (vm_data.cpus|int // vm_data.numa|int) %}
23+
{% set mem_per_node = (vm_data.memory|int // vm_data.numa|int) %}
24+
{% set cpu_ns = namespace(cpu_start=0) %}
25+
{% for i in range(vm_data.numa|int) %}
26+
{% set cpu_end = cpu_ns.cpu_start + cores_per_node - 1 %}
27+
<cell id='{{ i }}' cpus='{{ cpu_ns.cpu_start }}-{{ cpu_end }}' memory='{{ mem_per_node }}' unit='GB'/>
28+
{% set cpu_ns.cpu_start = cpu_end + 1 %}
29+
{% endfor %}
30+
</numa>
31+
{% endif %}
32+
</cpu>
2033
<clock offset='utc'>
2134
<timer name='rtc' tickpolicy='catchup'/>
2235
<timer name='pit' tickpolicy='delay'/>

0 commit comments

Comments
 (0)