A very short premise.
Libvirt supports dynamic memory expansion of virtual machines, but Windows virtual machines first need to install the Virtio-win driver.
Virtio-win drivers provided by KVM:
Http://www.linux-kvm.org/page/WindowsGuestDrivers/Download_Drivers
http://alt.fedoraproject.org/pub/alt/virtio-win/
Here are the chestnuts
Image: Windows2008r2,64 bit
Virtio-win:virtio-win-0.1-100.iso
Disk: Differential Mirroring (qemu-img create-f qcow2-b./windows_2008r2_x86_64 disk)
Use the QEMU command to start the virtual machine and load the Virtio driver:
qemu-system-x86_64 -hda ./windows_2008R2_x86_64 -drive file=./disk,if=virtio -drive file=./virtio-win-0.1-100.iso,media=cdrom,index=1 -net nic,model=virtio -net user -boot d -vga std -m 4096 -usbdevice tablet -vnc :50 -enable-kvm
To access the virtual machine via VNC, do the following:
- Go to "Device Manager"-"System device", install "Unknown Device" as "Virtio Balloon Driver"
- Copy the Win7/x86 directory from the Virtio-win optical drive to the "C:/Program Files/balloon"
- Use the cmd command line as an administrator to enter the above directory
- Perform "blnsvr.exe-i" to install the BLNSVR service
- Normal shutdown Save Settings
At this point, the disk file has the ability to obtain detailed memory information, dynamically adjust the memory size, the following methods are verified:
Memory details Get Validation:
1. Use the disk file to start the virtual machine, add the following paragraph in the XML file to enable the balloon device, and set the acquisition period to 10s
...<devices> <memballoon model=‘virtio‘> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x02‘function=‘0x0‘/> <stats period=‘10‘/> </memballoon> </devices></domain>
2. Acquisition time can be set manually
virsh dommemstat <dommain> --period <time(sec)>
3. Get the current memory usage of the virtual machine
virsh dommemstat <dommain>
Memory Dynamic Resizing verification:
1. Turn off the virtual machine
virsh destroy <domain>
2. Set the virtual machine maximum memory value (if the XML file has already been written can be skipped)
virsh setmaxmem <domain> --size <max_size>
3. Start the virtual machine
virsh start <domain>
4. Dynamic adjustment
virsh setmem <domain> --size <mem_size>
A bit different from the Linux system is that Windows displays the set maximum memory value, which can be confusing.
References :
Https://pve.proxmox.com/wiki/Dynamic_Memory_Management#Ballooning
Another address
Dynamic memory management for Windows virtual machines in Libvirt