本章仅介绍单vCPU绑定到单物理CPU上的境况,在KVM环境中测试虚拟系统品质时

在KVM环境中测试虚拟系统质量时,借使宿主机是有七个CPU
socket的硬件,会碰着由于vCPU在区别物理CPU上扭转导致测试大切诺基FC254四时面世少量丢包的情景,测试结果11分不平稳。可以将vCPU绑定到大体CPU来优化那么些题材(无法完全幸免),本章仅介绍单vCPU绑定到单物理CPU上的意况。绑定到单物理CPU上得以一时规避少量丢包的难题,不过也设有宿主机上单个物理CPU满载后其实虚拟系统未到达品质上限的事态,本章也暂不深刻。

在KVM环境中测试虚拟系统性卯时,假设宿主机是有多个CPU
socket的硬件,会碰着由于vCPU在不一样物理CPU上转变导致测试LX570FC2544时出现少量丢包的光景,测试结果丰裕不平稳。能够将vCPU绑定到大体CPU来优化那几个题材(不能够完全制止),本章仅介绍单vCPU绑定到单物理CPU上的状态。绑定到单物理CPU上能够目前规避少量丢包的题材,然则也设有宿主机上单个物理CPU满载后实在虚拟系统未到达品质上限的场地,本章也暂不深远。

 

 

一、查看当前运维的虚拟系统名称

1、查看当前运作的虚拟系统名称

[root@localhost ~]# virsh list
setlocale: No such file or directory

[root@localhost ~]# virsh list
setlocale: No such file or directory

Id Name State

4 vOS2 running

 

二、查看虚拟机的配置

[root@localhost ~]# virsh dumpxml vOS2
setlocale: No such file or directory
<domain type=’kvm’ id=’4′>
<name>vOS2</name>
<uuid>9c31cd50-f719-4d35-90b2-3044dfdc95bb</uuid>
<memory unit=’KiB’>4194304</memory>
<currentMemory unit=’KiB’>4194304</currentMemory>
<vcpu
placement=’static’>2</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch=’x86_64′
machine=’pc-i440fx-rhel7.0.0′>hvm</type>
<boot dev=’hd’/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode=’host-model’>
<model fallback=’allow’/>
<topology sockets=’1′ cores=’2′
threads=’1’/>
</cpu>
<clock offset=’utc’>
<timer name=’rtc’ tickpolicy=’catchup’/>
<timer name=’pit’ tickpolicy=’delay’/>
<timer name=’hpet’ present=’no’/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>
<suspend-to-mem enabled=’no’/>
<suspend-to-disk enabled=’no’/>
</pm>

…省略大批量音信

 

3、查看qemu进程号

[root@localhost ~]# ps -ef |grep vOS2
qemu 8480 1 51 16:43 ? 00:25:54 /usr/libexec/qemu-kvm -name vOS2 -S
-machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -cpu
SandyBridge,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,+smx,+est,+tm2,+xtpr,+pdcm,+pcid,+dca,+osxsave,+f16c,+rdrand,+arat,+fsgsbase,+smep,+erms,+xsaveopt,+pdpe1gb
-m 4096 -realtime mlock=off -smp 2,sockets=1,cores=2,threads=1 -uuid
9c31cd50-f719-4d35-90b2-3044dfdc95bb -no-user-config -nodefaults
-chardev
socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-4-vNGFW2/monitor.sock,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control -rtc
base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard
-no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global
PIIX4_PM.disable_s4=1 -boot strict=on -device
ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 -device
ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6
-device
ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x6.0x1
-device
ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x6.0x2
-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive
file=/var/lib/libvirtvNGFW2.qcow2,format=qcow2,if=none,id=drive-ide0-0-0
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1
-drive if=none,id=drive-ide0-0-1,readonly=on -device
ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 -netdev
tap,fd=27,id=hostnet0,vhost=on,vhostfd=29 -device
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:28:21:fe,bus=pci.0,addr=0x3
-chardev pty,id=charserial0 -device
isa-serial,chardev=charserial0,id=serial0 -chardev
spicevmc,id=charchannel0,name=vdagent -device
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0
-spice
port=5900,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on
-vga qxl -global qxl-vga.ram_size=67108864 -global
qxl-vga.vram_size=67108864 -global qxl-vga.vgamem_mb=16 -device
intel-hda,id=sound0,bus=pci.0,addr=0x4 -device
hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -chardev
spicevmc,id=charredir0,name=usbredir -device
usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=1 -chardev
spicevmc,id=charredir1,name=usbredir -device
usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=2 -device
vfio-pci,host=01:00.0,id=hostdev0,bus=pci.0,addr=0x8 -device
vfio-pci,host=01:00.1,id=hostdev1,bus=pci.0,addr=0x9 -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7 -msg timestamp=on
root 10036 7775 0 17:34 pts/3 00:00:00 grep –color=auto vOS2

 

四、反复查看vcpu消息,最后1列是cpu的数码,能够看到qemu进程是在分歧的CPU上不停的漂移的

[root@localhost ~]# ps -eLo ruser,pid,ppid,lwp,psr|grep 8480 
qemu 8480 1 8480 3
qemu 8480 1 8491 2
qemu 8480 1 8494 4
qemu 8480 1 8505 9
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# ps -eLo ruser,pid,ppid,lwp,psr|grep 8480
qemu 8480 1 8480 6
qemu 8480 1 8491 2
qemu 8480 1 8494 4
qemu 8480 1 8505 9
[root@localhost ~]# 
[root@localhost ~]# ps -eLo ruser,pid,ppid,lwp,psr|grep 8480
qemu 8480 1 8480 6
qemu 8480 1 8491 2
qemu 8480 1 8494 4
qemu 8480 1 8505 9
qemu 8480 1 10056 11

 

5、通过绑定进度到cpu比较坚苦,能够直接绑定vCPU到大体CPU。反复通过virsh命令查看vCPU对应的情理CPU,能够看到也是转变的

[root@localhost ~]# virsh vcpuinfo vOS2
setlocale: No such file or directory
VCPU: 0
CPU: 2
State: running
CPU time: 107.3s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy   //那里看看是宿主机全部物理CPU 主旨,Y代表有可以动用,基于CPU时间片来回切换

VCPU: 1
CPU: 0
State: running
CPU time: 116.3s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy

[root@localhost ~]# 
[root@localhost ~]# virsh vcpuinfo vOS2
setlocale: No such file or directory
VCPU: 0
CPU: 3
State: running
CPU time: 107.8s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy

VCPU: 1
CPU: 8
State: running
CPU time: 116.8s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy

[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# virsh vcpuinfo vOS2
setlocale: No such file or directory
VCPU: 0
CPU: 0
State: running
CPU time: 108.0s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy

VCPU: 1
CPU: 9
State: running
CPU time: 117.1s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy

陆、绑定vCPU到大体CPU,那里将vCPU绑定到主CPU上

[root@localhost ~]# virsh vcpupin vOS2 0 2
setlocale: No such file or directory

[root@localhost ~]# virsh vcpupin vOS2 1 4
setlocale: No such file or directory

查阅绑定结果,能够观望曾经将vCPU0绑定到大体CPU2,vCPU一绑定到大体CPU4上

[root@localhost ~]# virsh vcpuinfo vOS2
setlocale: No such file or directory
VCPU: 0
CPU: 2
State: running
CPU time: 630.1s
CPU Affinity: –y—————–

VCPU: 1
CPU: 4
State: running
CPU time: 880.7s
CPU Affinity: —-y—————

[root@localhost ~]# virsh vcpuinfo vOS2
setlocale: No such file or directory
VCPU: 0
CPU: 2
State: running
CPU time: 693.0s
CPU Affinity: –y—————–

VCPU: 1
CPU: 4
State: running
CPU time: 993.7s
CPU Affinity: —-y—————

[root@localhost ~]# virsh dumpxml vOS2
setlocale: No such file or directory
<domain type=’kvm’ id=’4′>
<name>vOS2</name>
<uuid>9c31cd50-f719-4d35-90b2-3044dfdc95bb</uuid>
<memory unit=’KiB’>4194304</memory>
<currentMemory unit=’KiB’>4194304</currentMemory>
<vcpu placement=’static’>2</vcpu>
<cputune>
<vcpupin vcpu=’0′
cpuset=’2’/>
<vcpupin vcpu=’1′
cpuset=’4’/>
</cputune>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch=’x86_64′
machine=’pc-i440fx-rhel7.0.0′>hvm</type>
<boot dev=’hd’/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode=’host-model’>
<model fallback=’allow’/>
<topology sockets=’1′ cores=’2′ threads=’1’/>
</cpu>
<clock offset=’utc’>
<timer name=’rtc’ tickpolicy=’catchup’/>
<timer name=’pit’ tickpolicy=’delay’/>
<timer name=’hpet’ present=’no’/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>

 

7、再一次测试ENCOREFC254四性能,相比较绑定前后结果:

 

未绑定CPU,延续测试64,51二,1518字节时,测试到1518字节的时候会产出越发不平静的丢包现象,要求单独测试151八字节才能获得3个测试结果

图片 1

绑定CPU,数10遍测试,结果基本平稳

图片 2

图片 3

图片 4

 

Id Name State

4 vOS2 running

 

二、查看虚拟机的配备

[root@localhost ~]# virsh dumpxml vOS2
setlocale: No such file or directory
<domain type=’kvm’ id=’4′>
<name>vOS2</name>
<uuid>9c31cd50-f719-4d35-90b2-3044dfdc95bb</uuid>
<memory unit=’KiB’>4194304</memory>
<currentMemory unit=’KiB’>4194304</currentMemory>
<vcpu
placement=’static’>2</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch=’x86_64′
machine=’pc-i440fx-rhel7.0.0′>hvm</type>
<boot dev=’hd’/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode=’host-model’>
<model fallback=’allow’/>
<topology sockets=’1′ cores=’2′
threads=’1’/>
</cpu>
<clock offset=’utc’>
<timer name=’rtc’ tickpolicy=’catchup’/>
<timer name=’pit’ tickpolicy=’delay’/>
<timer name=’hpet’ present=’no’/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>
<suspend-to-mem enabled=’no’/>
<suspend-to-disk enabled=’no’/>
</pm>

…省略大批量消息

 

3、查看qemu进程号

[root@localhost ~]# ps -ef |grep vOS2
qemu 8480 1 51 16:43 ? 00:25:54 /usr/libexec/qemu-kvm -name vOS2 -S
-machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -cpu
SandyBridge,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,+smx,+est,+tm2,+xtpr,+pdcm,+pcid,+dca,+osxsave,+f16c,+rdrand,+arat,+fsgsbase,+smep,+erms,+xsaveopt,+pdpe1gb
-m 4096 -realtime mlock=off -smp 2,sockets=1,cores=2,threads=1 -uuid
9c31cd50-f719-4d35-90b2-3044dfdc95bb -no-user-config -nodefaults
-chardev
socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-4-vNGFW2/monitor.sock,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control -rtc
base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard
-no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global
PIIX4_PM.disable_s4=1 -boot strict=on -device
ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 -device
ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6
-device
ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x6.0x1
-device
ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x6.0x2
-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive
file=/var/lib/libvirtvNGFW2.qcow2,format=qcow2,if=none,id=drive-ide0-0-0
-device
ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1
-drive if=none,id=drive-ide0-0-1,readonly=on -device
ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 -netdev
tap,fd=27,id=hostnet0,vhost=on,vhostfd=29 -device
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:28:21:fe,bus=pci.0,addr=0x3
-chardev pty,id=charserial0 -device
isa-serial,chardev=charserial0,id=serial0 -chardev
spicevmc,id=charchannel0,name=vdagent -device
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0
-spice
port=5900,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on
-vga qxl -global qxl-vga.ram_size=67108864 -global
qxl-vga.vram_size=67108864 -global qxl-vga.vgamem_mb=16 -device
intel-hda,id=sound0,bus=pci.0,addr=0x4 -device
hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -chardev
spicevmc,id=charredir0,name=usbredir -device
usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=1 -chardev
spicevmc,id=charredir1,name=usbredir -device
usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=2 -device
vfio-pci,host=01:00.0,id=hostdev0,bus=pci.0,addr=0x8 -device
vfio-pci,host=01:00.1,id=hostdev1,bus=pci.0,addr=0x9 -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7 -msg timestamp=on
root 10036 7775 0 17:34 pts/3 00:00:00 grep –color=auto vOS2

 

4、反复查看vcpu音讯,最终一列是cpu的号子,可以看到qemu进度是在差异的CPU上不停的漂移的

[root@localhost ~]# ps -eLo ruser,pid,ppid,lwp,psr|grep 8480 
qemu 8480 1 8480 3
qemu 8480 1 8491 2
qemu 8480 1 8494 4
qemu 8480 1 8505 9
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# ps -eLo ruser,pid,ppid,lwp,psr|grep 8480
qemu 8480 1 8480 6
qemu 8480 1 8491 2
qemu 8480 1 8494 4
qemu 8480 1 8505 9
[root@localhost ~]# 
[root@localhost ~]# ps -eLo ruser,pid,ppid,lwp,psr|grep 8480
qemu 8480 1 8480 6
qemu 8480 1 8491 2
qemu 8480 1 8494 4
qemu 8480 1 8505 9
qemu 8480 1 10056 11

 

伍、通过绑定进度到cpu比较费心,能够平昔绑定vCPU到大体CPU。反复通过virsh命令查看vCPU对应的物理CPU,可以看到也是转变的

[root@localhost ~]# virsh vcpuinfo vOS2
setlocale: No such file or directory
VCPU: 0
CPU: 2
State: running
CPU time: 107.3s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy   //那里看看是宿主机全体物理CPU 宗旨,Y代表有能够利用,基于CPU时间片来回切换

VCPU: 1
CPU: 0
State: running
CPU time: 116.3s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy

[root@localhost ~]# 
[root@localhost ~]# virsh vcpuinfo vOS2
setlocale: No such file or directory
VCPU: 0
CPU: 3
State: running
CPU time: 107.8s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy

VCPU: 1
CPU: 8
State: running
CPU time: 116.8s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy

[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# virsh vcpuinfo vOS2
setlocale: No such file or directory
VCPU: 0
CPU: 0
State: running
CPU time: 108.0s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy

VCPU: 1
CPU: 9
State: running
CPU time: 117.1s
CPU Affinity: yyyyyyyyyyyyyyyyyyyy

6、绑定vCPU到大体CPU,那里将vCPU绑定到主CPU上

[root@localhost ~]# virsh vcpupin vOS2 0 2
setlocale: No such file or directory

[root@localhost ~]# virsh vcpupin vOS2 1 4
setlocale: No such file or directory

查看绑定结果,能够看出曾经将vCPU0绑定到大体CPU2,vCPU一绑定到大体CPU四上

[root@localhost ~]# virsh vcpuinfo vOS2
setlocale: No such file or directory
VCPU: 0
CPU: 2
State: running
CPU time: 630.1s
CPU Affinity: –y—————–

VCPU: 1
CPU: 4
State: running
CPU time: 880.7s
CPU Affinity: —-y—————

[root@localhost ~]# virsh vcpuinfo vOS2
setlocale: No such file or directory
VCPU: 0
CPU: 2
State: running
CPU time: 693.0s
CPU Affinity: –y—————–

VCPU: 1
CPU: 4
State: running
CPU time: 993.7s
CPU Affinity: —-y—————

[root@localhost ~]# virsh dumpxml vOS2
setlocale: No such file or directory
<domain type=’kvm’ id=’4′>
<name>vOS2</name>
<uuid>9c31cd50-f719-4d35-90b2-3044dfdc95bb</uuid>
<memory unit=’KiB’>4194304</memory>
<currentMemory unit=’KiB’>4194304</currentMemory>
<vcpu placement=’static’>2</vcpu>
<cputune>
<vcpupin vcpu=’0′
cpuset=’2’/>
<vcpupin vcpu=’1′
cpuset=’4’/>
</cputune>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch=’x86_64′
machine=’pc-i440fx-rhel7.0.0′>hvm</type>
<boot dev=’hd’/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode=’host-model’>
<model fallback=’allow’/>
<topology sockets=’1′ cores=’2′ threads=’1’/>
</cpu>
<clock offset=’utc’>
<timer name=’rtc’ tickpolicy=’catchup’/>
<timer name=’pit’ tickpolicy=’delay’/>
<timer name=’hpet’ present=’no’/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>

 

柒、再一次测试凯雷德FC254四品质,相比绑定前后结果:

 

未绑定CPU,一连测试64,51贰,151八字节时,测试到151八字节的时候会产出特别不平静的丢包现象,须求单独测试151八字节才能赢得五个测试结果

图片 5

绑定CPU,多次测试,结果基本平稳

图片 6

图片 7

图片 8

 

相关文章