Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
virt-manager: vm's cpu config doesn't presists when on [fix]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5135

PostPosted: Sat Nov 25, 2017 7:53 am    Post subject: virt-manager: vm's cpu config doesn't presists when on [fix] Reply with quote

Greetings,

I've successfully migrated a vbox based vm to kvm but with one small issue, I've configured the vm's cpu to copy the host's cpuinfo and allocated 4 cores (host cpu is Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz with 8 cores), before the boot, when I check the vm's cpu config section all is good, when I boot the vm the config changes and אhe guest (windows 7 ultimate) shows a different cpu type (Intel Xeon E312xx) with only 2 cores.
what is weirder is that I have another vm with windows 7 home on it, it shows the same issue but with only one core.
I'm pretty sure I saw all 4 cores on that vm. I'm using kernel 4.14.1, virt-manager 1.4.3.

any ideas what can be the issue?
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
ProjectFootball


Last edited by DaggyStyle on Sat Dec 02, 2017 12:39 pm; edited 2 times in total
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 11434

PostPosted: Sun Nov 26, 2017 12:15 am    Post subject: Reply with quote

What is the full command line used to invoke qemu/kvm? You may need to specify the number of virtual CPUs explicitly via -smp.
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5135

PostPosted: Fri Dec 01, 2017 3:47 pm    Post subject: Reply with quote

here:
Code:
qemu      6230 95.0 26.3 5239948 4189324 ?     Sl   12:38   0:07 /usr/bin/qemu-system-x86_64 -name guest=Windows7_HP,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-1-Windows7_HP/master-key.aes -machine pc-i440fx-2.9,accel=kvm,usb=off,vmport=off,dump-guest-core=off -cpu SandyBridge,vme=on,ss=on,pcid=on,hypervisor=on,arat=on,tsc_adjust=on,xsaveopt=on -m 4096 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid 3c8cb165-3ef3-4023-92ff-af97dca4d992 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-1-Windows7_HP/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=delay -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=0x5.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x5.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x5.0x2 -device ahci,id=sata0,bus=pci.0,addr=0x6 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x7 -drive file=/home/virt_admin/Machines/kvm/Windows7_home-qcow2.img,format=qcow2,if=none,id=drive-sata0-0-0 -device ide-hd,bus=sata0.0,drive=drive-sata0-0-0,id=sata0-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=21,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:58:d8:d2,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 -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 -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 virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8 -msg timestamp=on

_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
ProjectFootball
Back to top
View user's profile Send private message
hceline
n00b
n00b


Joined: 30 Aug 2015
Posts: 26

PostPosted: Fri Dec 01, 2017 6:47 pm    Post subject: Reply with quote

My guess Is that you have to set threads and sockets in virt-manager. If that does not stick, I'll recommend upgrading virt-manager because that function had a known bug earlier (sorry, do not remember what version).
Edit: After reading again, I see your version should not be a problem. Unless bug has regressed, have not booted my KVM after last update.
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5135

PostPosted: Fri Dec 01, 2017 8:02 pm    Post subject: Reply with quote

hceline wrote:
My guess Is that you have to set threads and sockets in virt-manager. If that does not stick, I'll recommend upgrading virt-manager because that function had a known bug earlier (sorry, do not remember what version).
Edit: After reading again, I see your version should not be a problem. Unless bug has regressed, have not booted my KVM after last update.

tried both 1.4.3 and 1.4.2, the issue presists.
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
ProjectFootball
Back to top
View user's profile Send private message
hceline
n00b
n00b


Joined: 30 Aug 2015
Posts: 26

PostPosted: Fri Dec 01, 2017 8:59 pm    Post subject: Reply with quote

Do you have "Manually set CPU topology" checked in virt-manager? It should be, and the part below should be Sockets 1, Cores 4, Threads 2 to emulate a std 4 core, 8 thread CPU.
The above is for 8 logical CPU's in guest, if you use 4 it would be: Sockets 1, Cores 2, Threads 2.
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5135

PostPosted: Sat Dec 02, 2017 9:41 am    Post subject: Reply with quote

hceline wrote:
Do you have "Manually set CPU topology" checked in virt-manager? It should be, and the part below should be Sockets 1, Cores 4, Threads 2 to emulate a std 4 core, 8 thread CPU.
The above is for 8 logical CPU's in guest, if you use 4 it would be: Sockets 1, Cores 2, Threads 2.

no, I'd expect it to be auto if I define current cpu allocation to 4 and max cpu allocation to 4, anyway i've set it to the right topology and updated the current to 4 and I see 4 cores.
that's one issue solved, now the cpu type is still an issue, I tick the use host cpu and when I turn it on, I see it gets unicked and the cpu showed is different. any ideas?
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
ProjectFootball
Back to top
View user's profile Send private message
hceline
n00b
n00b


Joined: 30 Aug 2015
Posts: 26

PostPosted: Sat Dec 02, 2017 12:16 pm    Post subject: Reply with quote

To get exact same CPU as host, use: "host-passthrough" (without the quotes) in The "Model:" field. This is not in the list, you have to type it in manually.
On a side-note: If you want to take advantage of cache locality, you have to set the correct threads and pin the CPU-cores. I'll put the relevant parts of my .xml for reference below (I got 1 CPU with 4 cores and total 8 threads on host, and I duplicate the whole CPU to guest).

Code:
  <vcpu placement='static'>8</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='3,7'/>
    <vcpupin vcpu='1' cpuset='2,6'/>
    <vcpupin vcpu='2' cpuset='1,5'/>
    <vcpupin vcpu='3' cpuset='0,4'/>
    <vcpupin vcpu='4' cpuset='3,7'/>
    <vcpupin vcpu='5' cpuset='2,6'/>
    <vcpupin vcpu='6' cpuset='1,5'/>
    <vcpupin vcpu='7' cpuset='0,4'/>
  </cputune>
  <cpu mode='host-passthrough' check='none'>
    <topology sockets='1' cores='4' threads='2'/>
    <cache mode='passthrough'/>
  </cpu>


Edit: Just for explanation of the strange numbers in vcpupin: I've reversed the numbering of the cores when duplicating the cpu to the guest because I noticed that almost all interrupts go to core 0 both on host and guest. This way i distribute host irq to core 0 and guest irq to core 3 (I believe, can't say fore sure if it has any effect). I also map two host cores to each guest core in cache-local pairs to try avoiding forced scheduling of idle guest cores (Edit2: or rather non scheduling of busy guest cores where same core is busy on host)(do no know for sure if that works either). A direct copy would be:

Code:
<cputune>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
    <vcpupin vcpu='2' cpuset='2'/>
    <vcpupin vcpu='3' cpuset='3'/>
    <vcpupin vcpu='4' cpuset='4'/>
    <vcpupin vcpu='5' cpuset='5'/>
    <vcpupin vcpu='6' cpuset='6'/>
    <vcpupin vcpu='7' cpuset='7'/>
  </cputune>
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5135

PostPosted: Sat Dec 02, 2017 12:38 pm    Post subject: Reply with quote

excellent! that did it!, I've opened virt-manager, went into my vm's cpu config, replaced the model with host-passthrough and unticked the copy cpu checkbox.
now I'll see if it is stable enough to deploy on my other vms, thanks!.
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
ProjectFootball
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum