libvirt-qemu-虚拟机cpu分配和cpu热插拔
2018-01-28 17:15
681 查看
[align=center](文章来自作者维护的社区微信公众号【虚拟化云计算】)[/align]
在libvrit的domain的xml文件中有两个地方控制cpu数量和拓扑,一个是cpu,一个是vcpu,其中cpu段控制虚拟机cpu的模式和拓扑,vcpu段控制cpu的分配和热插拔情况。
cpu模式和拓扑cpu段来控制cpu的模式和拓扑,cpu模式一般有下面两种配置方式:<domain> ... <cpu mode='host-model'> <model fallback='allow'/> <topology sockets='1' cores='2' threads='1'/> </cpu> ...</domain>cpu mode:可取值为custom host-model host-passthrouth
<domain> ... <cpu match='exact'> <model fallback='allow'>core2duo</model> <vendor>Intel</vendor> <topology sockets='1' cores='2' threads='1'/> <cache level='3' mode='emulate'/> <feature policy='disable' name='lahf_lm'/> </cpu> ...</domain>cpu match:可取值为exact minimum strict另外cpu的numa配置也在这里配。topology :控制虚拟机的cpu拓扑结构,这只是控制拓扑结构,具体的虚拟机里有几个cpu,实在vcpu段控制的。
vcpu分配
<domain> ... <vcpu placement='static' cpuset="1-4,^3,6" current="1">2</vcpu> <vcpus> <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/> <vcpu id='1' enabled='no' hotpluggable='yes'/> </vcpus> ...</domain>vcpu:最大vcpu数量,不能超出cpu拓扑中的数值。cpuset:指定CPU的亲和性,如果cputune中制定了vcpupin的亲和性,这里的将被忽略。current:开机时给虚拟机分配的cpu数量。vcpus:配置单个vcpu的状态。备注:从cpu和vcpu两段来看,cpu的数量是受到current、vcpu、topology控制的。
cpu热插
当前配置: <vcpu placement='static' current='2'>4</vcpu> <cpu> <topology sockets='1' cores='4' threads='1'/> </cpu>根据上述配置,此虚拟机开机时有两个cpu,另外有两个cpu可以后插入。
libvirt监控状态:virsh # vcpucount instance-0000000dmaximum config 4maximum live 4current config 2current live 2
virsh # vcpuinfo instance-0000000dVCPU: 0CPU: 2State: runningCPU time: 1.3sCPU Affinity: yyyyVCPU: 1CPU: 3State: runningCPU time: 0.5sCPU Affinity: yyyy
virsh # cpu-stats instance-0000000dCPU0: cpu_time 0.000000000 seconds vcpu_time 0.000000000 secondsCPU1: cpu_time 0.000000000 seconds vcpu_time 0.000000000 secondsCPU2: cpu_time 1.559106643 seconds vcpu_time 1.149663485 secondsCPU3: cpu_time 1.006847058 seconds vcpu_time 0.701462772 secondsTotal: cpu_time 2.565953701 seconds user_time 0.540000000 seconds system_time 0.710000000 seconds
虚拟机内部CPU列表:
插入cpu:# virsh setvcpus instance-0000000d --count 4 --live
在虚拟机内部激活新插入的cpu:
[align=left]==============================================================[/align][align=center]关注微信公众号【虚拟化云计算】,阅读更多虚拟化云计算知识,纯技术干货更新不停。[/align]
在libvrit的domain的xml文件中有两个地方控制cpu数量和拓扑,一个是cpu,一个是vcpu,其中cpu段控制虚拟机cpu的模式和拓扑,vcpu段控制cpu的分配和热插拔情况。
cpu模式和拓扑cpu段来控制cpu的模式和拓扑,cpu模式一般有下面两种配置方式:<domain> ... <cpu mode='host-model'> <model fallback='allow'/> <topology sockets='1' cores='2' threads='1'/> </cpu> ...</domain>cpu mode:可取值为custom host-model host-passthrouth
<domain> ... <cpu match='exact'> <model fallback='allow'>core2duo</model> <vendor>Intel</vendor> <topology sockets='1' cores='2' threads='1'/> <cache level='3' mode='emulate'/> <feature policy='disable' name='lahf_lm'/> </cpu> ...</domain>cpu match:可取值为exact minimum strict另外cpu的numa配置也在这里配。topology :控制虚拟机的cpu拓扑结构,这只是控制拓扑结构,具体的虚拟机里有几个cpu,实在vcpu段控制的。
vcpu分配
<domain> ... <vcpu placement='static' cpuset="1-4,^3,6" current="1">2</vcpu> <vcpus> <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/> <vcpu id='1' enabled='no' hotpluggable='yes'/> </vcpus> ...</domain>vcpu:最大vcpu数量,不能超出cpu拓扑中的数值。cpuset:指定CPU的亲和性,如果cputune中制定了vcpupin的亲和性,这里的将被忽略。current:开机时给虚拟机分配的cpu数量。vcpus:配置单个vcpu的状态。备注:从cpu和vcpu两段来看,cpu的数量是受到current、vcpu、topology控制的。
cpu热插
当前配置: <vcpu placement='static' current='2'>4</vcpu> <cpu> <topology sockets='1' cores='4' threads='1'/> </cpu>根据上述配置,此虚拟机开机时有两个cpu,另外有两个cpu可以后插入。
libvirt监控状态:virsh # vcpucount instance-0000000dmaximum config 4maximum live 4current config 2current live 2
virsh # vcpuinfo instance-0000000dVCPU: 0CPU: 2State: runningCPU time: 1.3sCPU Affinity: yyyyVCPU: 1CPU: 3State: runningCPU time: 0.5sCPU Affinity: yyyy
virsh # cpu-stats instance-0000000dCPU0: cpu_time 0.000000000 seconds vcpu_time 0.000000000 secondsCPU1: cpu_time 0.000000000 seconds vcpu_time 0.000000000 secondsCPU2: cpu_time 1.559106643 seconds vcpu_time 1.149663485 secondsCPU3: cpu_time 1.006847058 seconds vcpu_time 0.701462772 secondsTotal: cpu_time 2.565953701 seconds user_time 0.540000000 seconds system_time 0.710000000 seconds
虚拟机内部CPU列表:
插入cpu:# virsh setvcpus instance-0000000d --count 4 --live
在虚拟机内部激活新插入的cpu:
[align=left]==============================================================[/align][align=center]关注微信公众号【虚拟化云计算】,阅读更多虚拟化云计算知识,纯技术干货更新不停。[/align]
相关文章推荐
- libvirt-qemu-虚拟机设备热插拔实践
- libvirt-qemu-虚拟机设备热插拔
- 【虚拟机】虚拟化技术以及KVM、QEMU与libvirt介绍
- 虚拟机如何分配内存和CPU
- Ubuntu 下安装kvm, qemu, libvirt,并新建虚拟机的过程
- vSphere正确分配虚拟机CPU资源
- 使用libvirt和qemu将pci pass through设备添加到虚拟机上
- libvirt-qemu-用cgroup对虚拟机进行资源分割
- libvirt-qemu-虚拟机qos控制
- 使用libvirt和qemu将pci pass through设备添加到虚拟机上
- LIBVIRT报告qemu-system-x86_64: CPU feature cmt not found的解决办法
- 使用libvirt和qemu将pci pass through设备添加到虚拟机上
- CPU常识+Qemu虚拟机CPU配置
- 在Virtualbox中的Ubuntu虚拟机中,安装Guest Additions客户端增强包时出错:分配介质 虚拟光盘 xxx\VBoxsGuestAdditions.iso 到虚拟电脑 xxx 失
- QEMU-KVM创建虚拟机的入口
- Windows Server 2012 R2 Hyper-V 02之基于虚拟机CPU资源调整性能测试01
- openstack, kvm, qemu-kvm以及libvirt之关系
- Linux TOP命令 按内存占用排序和按CPU占用排序 分类: 测试 ubuntu 虚拟机 2013-11-06 14:38 396人阅读 评论(0) 收藏
- CentOS7.1 KVM虚拟化之虚拟机内存、CPU调整
- 04 随着libvirt开始和创建你的第一台虚拟机