When starting a misconfigured guest (such that the emulator thread is pinned onto NUMA node(s) distinct to NUMA node(s) of guest memory) AND using allocation threads (/domain/memoryBacking/allocation/@threads), the guest refuses to start with an error.
This is because those allocation threads have their affinity set to those NUMA nodes of the guest memory, but are created from the context of the emulator thread (which itself is already restricted to given NUMA nodes).
These patches prune inaccessible NUMA nodes by computing an intersection between two sets of NUMA nodes and setting affinity to only the intersecting ones. This allows guest to start again.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory (libvirt bug fix update), and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2023:2632
Verify this bug on libvirt-9.0.0-10.1.el9_2.x86_64: S1: bind emulatorpin to node0 cpus and memory to node1 with numatune + emulatorpin + hugepages 1. # lscpu ... NUMA: NUMA node(s): 2 NUMA node0 CPU(s): 0-15,32-47 NUMA node1 CPU(s): 16-31,48-63 ... 2. set guest emulatorpin to use node0 CPUs and numatune to node1: # virsh dumpxml vm1 <memoryBacking> <hugepages> <page size='2048' unit='KiB'/> </hugepages> </memoryBacking> <vcpu placement='static'>2</vcpu> <cputune> <emulatorpin cpuset='0-15'/> </cputune> <numatune> <memory mode='strict' nodeset='1'/> <memnode cellid='0' mode='strict' nodeset='1'/> <memnode cellid='1' mode='strict' nodeset='1'/> </numatune> ... <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>1</node> </target> <address type='dimm' slot='0'/> </memory> 3. start guest # virsh start vm1 Domain 'vm1' started 4. check qemu command line and verify that libvirt didn't use thread-context -object {"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/dev/hugepages/libvirt/qemu/1-vm1","prealloc":true,"size":1073741824,"host-nodes":[1],"policy":"bind"} -numa node,nodeid=0,cpus=0,memdev=ram-node0 -object {"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/dev/hugepages/libvirt/qemu/1-vm1","prealloc":true,"size":1073741824,"host-nodes":[1],"policy":"bind"} -numa node,nodeid=1,cpus=1,memdev=ram-node1... -object {"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/dev/hugepages/libvirt/qemu/1-vm1","prealloc":true,"size":536870912,"host-nodes":[1],"policy":"bind"} -device {"driver":"pc-dimm","node":1,"memdev":"memdimm0","id":"dimm0","slot":0} 5. attach a new memory device: # cat mem.xml <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>0</node> </target> </memory> # virsh attach-device vm1 mem.xml Device attached successfully S2: bind emulatorpin to node0 cpus and memory to node1 with numatune + emulatorpin 1. set guest emulatorpin to use node0 CPUs and numatune to node1: <cputune> <emulatorpin cpuset='0-15'/> </cputune> <numatune> <memory mode='strict' nodeset='1'/> <memnode cellid='0' mode='strict' nodeset='1'/> <memnode cellid='1' mode='strict' nodeset='1'/> </numatune> ... <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>1</node> </target> <address type='dimm' slot='0'/> </memory> 2. start guest # virsh start vm1 Domain 'vm1' started 3. check qemu command line and verify that libvirt didn't use thread-context # ps aux|grep qemu -object {"qom-type":"memory-backend-ram","id":"ram-node0","size":1073741824,"host-nodes":[1],"policy":"bind"} -numa node,nodeid=0,cpus=0,memdev=ram-node0 -object {"qom-type":"memory-backend-ram","id":"ram-node1","size":1073741824,"host-nodes":[1],"policy":"bind"} -numa node,nodeid=1,cpus=1,memdev=ram-node1...-object {"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/dev/hugepages/libvirt/qemu/3-vm1","prealloc":true,"size":536870912,"host-nodes":[1],"policy":"bind"} -device {"driver":"pc-dimm","node":1,"memdev":"memdimm0","id":"dimm0","slot":0} 4. # cat mem.xml <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>0</node> </target> </memory> # virsh attach-device vm1 mem.xml Device attached successfully S3: bind emulatorpin to node0 cpus and memory to node0-1 with numatune + emulatorpin + hugepages 1. guest xml like this: <memoryBacking> <hugepages> <page size='2048' unit='KiB'/> </hugepages> </memoryBacking> <vcpu placement='static'>2</vcpu> <cputune> <emulatorpin cpuset='0-15'/> </cputune> <numatune> <memory mode='strict' nodeset='0-1'/> <memnode cellid='0' mode='strict' nodeset='0-1'/> <memnode cellid='1' mode='strict' nodeset='1'/> </numatune> ... <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>0</node> </target> <address type='dimm' slot='0'/> </memory> 2. start guest # virsh start vm1 Domain 'vm1' started 3. check qemu command line and verify that libvirt use thread-context and "node-affinity" is node 0: # ps aux|grep qemu -object {"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":[0]} -object {"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/dev/hugepages/libvirt/qemu/5-vm1","prealloc":true,"size":1073741824,"host-nodes":[0,1],"policy":"bind","prealloc-context":"tc-ram-node0"} -numa node,nodeid=0,cpus=0,memdev=ram-node0 -object {"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/dev/hugepages/libvirt/qemu/5-vm1","prealloc":true,"size":1073741824,"host-nodes":[1],"policy":"bind"} -numa node,nodeid=1,cpus=1,memdev=ram-node1...-object {"qom-type":"thread-context","id":"tc-memdimm0","node-affinity":[0]} -object {"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/dev/hugepages/libvirt/qemu/5-vm1","prealloc":true,"size":536870912,"host-nodes":[0,1],"policy":"bind","prealloc-context":"tc-memdimm0"} -device {"driver":"pc-dimm","node":0,"memdev":"memdimm0","id":"dimm0","slot":0} 4. # cat mem.xml <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>0</node> </target> </memory> # virsh attach-device vm1 mem.xml Device attached successfully S4: bind emulatorpin to node0 cpus and memory to node0-1 with numatune + emulatorpin 1. guest xml like this: <cputune> <emulatorpin cpuset='0-15'/> </cputune> <numatune> <memory mode='strict' nodeset='0-1'/> <memnode cellid='0' mode='strict' nodeset='0-1'/> <memnode cellid='1' mode='strict' nodeset='1'/> </numatune> ... <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>0</node> </target> <address type='dimm' slot='0'/> </memory> 2. start guest # virsh start vm1 Domain 'vm1' started 3. check qemu command line and verify that libvirt use thread-context and "node-affinity" is node 0: # ps aux|grep qemu -object {"qom-type":"memory-backend-ram","id":"ram-node0","size":1073741824,"host-nodes":[0,1],"policy":"bind"} -numa node,nodeid=0,cpus=0,memdev=ram-node0 -object {"qom-type":"memory-backend-ram","id":"ram-node1","size":1073741824,"host-nodes":[1],"policy":"bind"} -numa node,nodeid=1,cpus=1,memdev=ram-node1...-object {"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/dev/hugepages/libvirt/qemu/9-vm1","prealloc":true,"size":536870912,"host-nodes":[0,1],"policy":"bind","prealloc-context":"tc-memdimm0"} -device {"driver":"pc-dimm","node":0,"memdev":"memdimm0","id":"dimm0","slot":0} 4. # cat mem.xml <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>0</node> </target> </memory> # virsh attach-device vm1 mem.xml Device attached successfully S5: bind emulatorpin to node0-1 cpus and memory to node1 with numatune + emulatorpin + hugepages 1. guest xml like this: <memoryBacking> <hugepages> <page size='2048' unit='KiB'/> </hugepages> </memoryBacking> <vcpu placement='static'>2</vcpu> <cputune> <emulatorpin cpuset='0-31'/> </cputune> <numatune> <memory mode='strict' nodeset='1'/> <memnode cellid='0' mode='strict' nodeset='1'/> <memnode cellid='1' mode='strict' nodeset='1'/> </numatune> ... <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>0</node> </target> <address type='dimm' slot='0'/> </memory> 2. start guest # virsh start vm1 Domain 'vm1' started 3. check qemu command line and verify that libvirt use thread-context and "node-affinity" is node 1: # ps aux|grep qemu -object {"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":[1]} -object {"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/dev/hugepages/libvirt/qemu/10-vm1","prealloc":true,"size":1073741824,"host-nodes":[1],"policy":"bind","prealloc-context":"tc-ram-node0"} -numa node,nodeid=0,cpus=0,memdev=ram-node0 -object {"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":[1]} -object {"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/dev/hugepages/libvirt/qemu/10-vm1","prealloc":true,"size":1073741824,"host-nodes":[1],"policy":"bind","prealloc-context":"tc-ram-node1"} -numa node,nodeid=1,cpus=1,memdev=ram-node1 4. # cat mem.xml <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>0</node> </target> </memory> # virsh attach-device vm1 mem.xml Device attached successfully S6: bind emulatorpin to node0-1 cpus and memory to node1 with numatune + emulatorpin 1. guest xml like this: <cputune> <emulatorpin cpuset='0-31'/> </cputune> <numatune> <memory mode='strict' nodeset='1'/> <memnode cellid='0' mode='strict' nodeset='1'/> <memnode cellid='1' mode='strict' nodeset='1'/> </numatune> ... <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>0</node> </target> <address type='dimm' slot='0'/> </memory> 2. start guest # virsh start vm1 Domain 'vm1' started 3. check qemu command line and verify that libvirt use thread-context and "node-affinity" is node 1: # ps aux|grep qemu -object {"qom-type":"memory-backend-ram","id":"ram-node0","size":1073741824,"host-nodes":[1],"policy":"bind"} -numa node,nodeid=0,cpus=0,memdev=ram-node0 -object {"qom-type":"memory-backend-ram","id":"ram-node1","size":1073741824,"host-nodes":[1],"policy":"bind"} -numa node,nodeid=1,cpus=1,memdev=ram-node1...-object {"qom-type":"thread-context","id":"tc-memdimm0","node-affinity":[1]} -object {"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/dev/hugepages/libvirt/qemu/11-vm1","prealloc":true,"size":536870912,"host-nodes":[1],"policy":"bind","prealloc-context":"tc-memdimm0"} -device {"driver":"pc-dimm","node":0,"memdev":"memdimm0","id":"dimm0","slot":0} 4. # cat mem.xml <memory model='dimm'> <source> <pagesize unit='KiB'>2048</pagesize> </source> <target> <size unit='KiB'>524288</size> <node>0</node> </target> </memory> # virsh attach-device vm1 mem.xml Device attached successfully Triggered numa, cpu and memory auto test jobs to test libvirt-9.0.0-10.1.el9_2.x86_64 and there is no failed cases.