virtio-win / kvm-guest-drivers-windows

Windows paravirtualized drivers for QEMU\KVM
https://www.linux-kvm.org/page/WindowsGuestDrivers
BSD 3-Clause "New" or "Revised" License
2.01k stars 385 forks source link

windows vm allocating all memory configured in currentMemory at startup #964

Open WosunOO opened 1 year ago

WosunOO commented 1 year ago

Describe the bug My windows vm is allocating all memory configured in currentMemory at startup. Changing currentMemory with virsh setmem or virsh qemu-monitor-command instance-00000001 --hmp "balloon 4096" can successfully change memory status in my windows vms, so the balloon service and balloon driver is working I think. Also checked the balloon driver's tracing events with TraceView.exe. Any help will be appreciated. Thank you! image image image

To Reproduce Well, it's always appearing in my env.

Expected behavior As for linux vms in my env, they use memory much lesser than currentMemory configured in vm's xml (RES value seen with host's top command). When setting memory balloon linux vms RES value seen on host will decrese to which the vm really needs. But windows vms are not working this way. I did a lot of searching and found proxmox wiki on windows vm memory ballooning(https://pve.proxmox.com/wiki/Dynamic_Memory_Management#Requirements_for_Windows_VM), did proxmox changed the mechanism of qemu simulator?

Screenshots windows vm memory usage seen on host: image

Host:

VM:

WosunOO commented 1 year ago

I have read issue #568 carefully, behaviors seem to be the same. Also found that automatically changing memory balloon (currentMemory) is never completed on linux-kvm page. Main concerns are the difference between windows and linux vms on memory usage shown on host.

YanVugenfirer commented 1 year ago

Hello,

Is balloon service running? It is mentioned in Proxmox link.

WosunOO commented 1 year ago

Hello,

Is balloon service running? It is mentioned in Proxmox link.

Yes, blnsvr is installed and process running; Also tried different versions of blnsvr, all the same. Or maybe I should try older versions?

By the way, does Memory Management Registry affect this behavior, also tried turning off PAE etc...

YanVugenfirer commented 1 year ago

What I am missing is the host statistics when Windows VM is running with and without inflated balloon. Otherwise the difference between Linux \Window can be a natural difference between those OSes.

BTW: KSM is a good way to save memory with Windows VMs that are not too active because Windows is actively zeroing unused memory.

WosunOO commented 1 year ago

What I am missing is the host statistics when Windows VM is running with and without inflated balloon. Otherwise the difference between Linux \Window can be a natural difference between those OSes.

BTW: KSM is a good way to save memory with Windows VMs that are not too active because Windows is actively zeroing unused memory.

Thank you for replying. I just tried uninstalled blnsvr service and disabled virtio-balloon driver. Then my vm's memory cannot be set by balloon. On the host the memory occupation is always the maximum value, in my case 10GB. It works normal when enabled virtio-balloon driver, without installing blnsvrservice. Wondering what role is blnsvr service playing? So it's due to the difference between OSes? Have no idea how proxmox makes windows works just like linux vms. Have been exploring their git repo like pve-qemu, but didn't find any patch may related to this issue.

jshen28 commented 1 year ago

I am curious if windows zeros out all pages during booting up. Because if it is, then it is reasonable that Linux kernel will eventually allocates all pages.

izeroo commented 9 months ago

CurrentMemory should be set the same as MaxMemory unless you known what really you are doing. Inconsistent values can cause problem like this. I encounterd this problem as well.