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
virsh edit VIRTUALGUESTNAME
<hyperv> <relaxed state='on'/> <vapic state='on'/> <spinlocks state='on' retries='8191'/> </hyperv>
<hyperv> <relaxed state='on'/> <vapic state='on'/> <spinlocks state='on' retries='8191'/> <synic state='on'/> <stimer state='on'/> </hyperv>
Updated on 06-19-2020, this seems to be required for QEMU 3.1 and later
<hyperv> <relaxed state="on"/> <vapic state="on"/> <spinlocks state="on" retries="8191"/> <vpindex state="on"/> <synic state="on"/> <stimer state="on"/> </hyperv>
Set virtual guests CPU and host-passthrough, this provides the best performance. Note: this will prevent live migration between virtual hosts with different CPUs.
virsh edit VIRTUALGUESTNAME
<cpu mode='host-passthrough' check='none'/>
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?
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.
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.
Install Virtio SCSI, Virtio NIC, Virtio Serial on all guests, add channel qemu-ga; on Windows guests install drivers + qemu-agent.
For Windows Server Backup attached a disk as a USB interface instead of a SCSI interface seems to make it work more reliably.
sudo qemu-img create -f raw TEST.img 50G -o preallocation=off
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