====Fix high CPU usage on Windows 10 1803+ On CentOS 7====
Note: this doesn't workin on CentOS 8.1; 8.0 and 8.2+ when released should work agian: https://bugzilla.redhat.com/show_bug.cgi?id=1794868
https://bugs.centos.org/view.php?id=16025
* Login to the virtual host
* Edit the xml file of the virtual guest: virsh edit VIRTUALGUESTNAME
* Find the lines containing the hyperv options, they will look like this:
* Add and so it looks like this:
Updated on 06-19-2020, this seems to be required for QEMU 3.1 and later
====Improve CPU performance of all Guests====
Set virtual guests CPU and host-passthrough, this provides the best performance. Note: this will prevent live migration between virtual hosts with different CPUs.
* Edit the virtual guest configuration file: virsh edit VIRTUALGUESTNAME
* Change the "cpu mode" line so that it matches:
====Windows Graceful Shutdowns====
In Windows 7, after clicking "Shut down" button, the system might prompt "X programs still needed to close" and ask you whether to force shutdown or cancel. How to cancel this prompt?
==Solution==
Press "Window +R" keys to start "Run" dialogue box and type "gpedit.msc" in the dialogue box.
Click "OK", "Local Group Policy Editor" window will pop up.
Navigate to "Computer Configuration" --> "Administrative Templates" --> "System" --> "Shutdown Options". Double-click "Turn off automatic termination of applications that block or cancel shutdown" on the right panel. In the new dialogue box popped up, set configuration option as "Disabled".
Next time when you shut down your machine, the machine will be shut down directly without prompt.
====Windows ACPI Shutdown====
To Allow Windows Server to shutdown in response to ACPI shutdown:
Once in the Group Policy Editor expand “Computer Configuration“, then “Windows Settings“, then “Security Settings“, then “Local Policies” and click on “Security Options”
Scroll down the list in the right pane and find “Shutdown: Allow system to be shut down without having to log on“. In server versions of Windows this option will be “Disabled” by default, enable it.
====Guest Hardware Config====
Install Virtio SCSI, Virtio NIC, Virtio Serial on all guests, add channel qemu-ga; on Windows guests install drivers + qemu-agent.
====Windows Server Backup Disk Image====
For Windows Server Backup attached a disk as a USB interface instead of a SCSI interface seems to make it work more reliably.
====Disk Images====
* Use RAW images without preallocation: sudo qemu-img create -f raw TEST.img 50G -o preallocation=off
* Disk cache should be set to none, threads to native, discard mode set to unmap and detect zeros set to unmap
* Virtual guests should have trim enabled (fstrim timer on linux, Windows seems to be automatic on Server2012 and up)
* Virtual guests should have swap file activity limited (linux) or swap file size made small or disabled (windows). More than adequate RAM should be allocated to guests to limit need of swap. Virtualization host should have swap file on non-SSD drive if possible and design of memory allocation should be that the host swap is used before guests use swap.
==FSTRIM on on CentOS 8/7==
fstrim is normally for SSDs but it works well with RAW disk images as well since it notifies the host of free blocks (or whatever) and the host can then do it's trim thing or if no SSD in involved then when you make a backup image of the RAW disk it will be smaller since all "free space" will be empty.
sudo systemctl enable fstrim.timer
sudo systemctl start fstrim.timer
Check status of timer by showing systemd timers: systemctl list-timers
Check trim support by: lsblk --discard
Stop writing a timestamp every time a file is accessed
Edit the /etc/fstab file and add noatime to everything except swap (unless you have a reason not to).
sudo vim /etc/fstab
For example:
/dev/mapper/rhel-root / xfs defaults 1 1
becomes:
/dev/mapper/rhel-root / xfs defaults,noatime 1 1
On CentOS 7 only, if using LVM enable Trim function by editing /etc/lvm/lvm.conf and change
issue_discards = 0
to
issue_discards = 1