qemu可以模拟numa,设置numa内的memory,cpu,numa间distance。
qemu-system-x86_64 --help | grep numa -numa node[,mem=size][,cpus=firstcpu[-lastcpu]][,nodeid=node][,initiator=node] -numa node[,memdev=id][,cpus=firstcpu[-lastcpu]][,nodeid=node][,initiator=node] -numa dist,src=source,dst=destination,val=distance -numa cpu,node-id=node[,socket-id=x][,core-id=y][,thread-id=z]
-numa dist用来设置numa间的距离,src代表当前的numa节点,dst代表远端节点,当然也设置为本节点。举个例子,假设有3个numa节点,设置其相互之间的距离,那么就要设置9次。
-numa dist,src=0,dst=0,val=10 \ -numa dist,src=0,dst=1,val=15 \ -numa dist,src=0,dst=2,val=15 \ -numa dist,src=1,dst=0,val=15 \ -numa dist,src=1,dst=1,val=10 \ -numa dist,src=1,dst=2,val=15 \ -numa dist,src=2,dst=0,val=15 \ -numa dist,src=2,dst=1,val=15 \ -numa dist,src=2,dst=2,val=10
进入虚拟机查看numa distance,
# cat /sys/devices/system/node/node*/distance 10 15 15 15 10 15 15 15 10
libvirt也提供了对应的接口,可以在xml上设置numa distance。
<numa> <cell id='0' cpus='0-31' memory='50331648' unit='KiB'> <distances> <sibling id='0' value='10'/> <sibling id='1' value='15'/> <sibling id='2' value='15'/> </distances> </cell> <cell id='1' cpus='32-63' memory='50331648' unit='KiB'> <distances> <sibling id='0' value='15'/> <sibling id='1' value='10'/> <sibling id='2' value='15'/> </distances> </cell> <cell id='2' cpus='64-95' memory='50331648' unit='KiB'> <distances> <sibling id='0' value='15'/> <sibling id='1' value='15'/> <sibling id='2' value='10'/> </distances> </cell> </numa>
记录一个错误。
第一次在libvirt中设置numa distance时将distances写成distance,创建vm总是numa distance总是不生效,手动edit会报错:
error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng Extra element cpu in interleave Element domain failed to validate content Failed. Try again? [y,n,i,f,?]:
验证domain schemas失败,但是“Extra element cpu in interleave”这句具有误导性,其实跟cpu交错没关系。libvirt所有的schema存放在/usr/share/libvirt/schemas下,所有合法的设置都在里面,在查找distance元素时发现里面的distances element跟我写的不一致,修改之后通过了检查,进入虚拟机发现设置已经生效。但是奇怪的是,virsh edit显示并没有跟numa distances相关的设置。当前的xml验证还需要改进,如果能指出错误的具体原因,在本例中仅仅就是因为distances拼写错误,这个错误还是很容易定位的,如果能在验证时报出指定位置的错误就会节省很多debug的时间。
标签:distance,15,src,dst,numa,dist,qemu From: https://www.cnblogs.com/banshanjushi/p/18531770