主要优化磁盘 io 和网络 io
都选为 virtio
windows 驱动下载
https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.185-2/virtio-win-0.1.185.iso
I also had incredibly slow performance with my virtual HDD.
The following setting on new HDD corrected everything:
Storage format: raw
Cache mode: none (not default!)
I/O mode: native
Excellent point about the storage format. Using a raw partition instead of a file container may also improve a little more. –
1
this should be the accepted answer. qcow2 works fine as a format though, but no cache and native definitely lead to a huge boost. –
John
<disk type=“file” device=“disk”>
<driver name=“qemu” type=“raw” cache=“none” io=“native”/> “只有这一行 - 把其他所有东西都留!!!
<源文件=“/mnt/DV2/XPVIORAW”/>
<target dev=“vdb” bus=“virtio”/> <address type=“pci” domain=“0x0000” bus=“0x00” slot=“0x0a” function=“0x0”/></disk>
优化 Hyper-V、时钟和 cpu
我在配备第 10 代 i11 和 16GB RAM(与您的笔记本电脑规格相似)的 Chromebook 上运行性能良好的 Windows 16 虚拟机。查看您的 libvirt XML,您可以进行一些优化:应用所有可用的 Hyper-V 启蒙 - XML 的部分应如下所示:<hyperv><hyperv><relaxed state='on'/><vapic state='on'/><spinlocks state='on' retries='8191'/><vpindex state='on'/><synic state='on'/><stimer state='on'><direct state='on'/></stimer><reset state='on'/><frequencies state='on'/><reenlightenment state='on'/><tlbflush state='on'/><ipi state='on'/>
</hyperv>
禁用除 - XML 部分之外的所有计时器,如下所示:hypervclock<clock><clock offset='localtime'><timer name='rtc' present='no' tickpolicy='catchup'/><timer name='pit' present='no' tickpolicy='delay'/><timer name='hpet' present='no'/><timer name='kvmclock' present='no'/><timer name='hypervclock' present='yes'/>
</clock>
仅这两项改进就应该会带来巨大的加速。不过,可以进行进一步的改进。我建议使用 CPU 固定 - 这会强制将每个虚拟 CPU 固定到物理 CPU 内核(或在本例中为虚拟 Crostini 内核),从而减少内核不断将虚拟 CPU 交换到不同线程的性能开销。例如,我执行以下操作(8 核主机上的 VM 为 6 个核心):<vcpu placement='static'>6</vcpu>
<iothreads>1</iothreads>
<cputune><vcpupin vcpu='0' cpuset='1'/><vcpupin vcpu='1' cpuset='5'/><vcpupin vcpu='2' cpuset='2'/><vcpupin vcpu='3' cpuset='6'/><vcpupin vcpu='4' cpuset='3'/><vcpupin vcpu='5' cpuset='7'/><emulatorpin cpuset='0,4'/><iothreadpin iothread='1' cpuset='0,4'/>
</cputune>
我强烈建议使用 virtio 作为您的磁盘类型,因为这允许磁盘访问半虚拟化,从而进一步减少开销。这需要 Windows 端的驱动程序支持 - 启用此功能的最简单方法是重新安装 Windows,并在对磁盘进行分区时,将 virtio-win 驱动程序 ISO 插入虚拟机,以便在安装过程中可以识别磁盘。我在我的XML中使用它:<disk type='file' device='disk'><driver name='qemu' type='qcow2' cache='none' io='threads' discard='unmap' iothread='1' queues='6'/><source file='/var/lib/libvirt/images/win11.qcow2'/><target dev='vda' bus='virtio'/><boot order='2'/><address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
</disk>
最后,请确保安装 Spice 来宾工具,以改进 VM 处理来宾和主机之间的鼠标输入的方式,并在窗口调整大小时自动更改 VM 的分辨率。
https://unix.stackexchange.com/questions/47082/how-to-improve-windows-perfomance-when-running-inside-kvm
https://www.reddit.com/r/ChromeOSFlex/comments/ucno4b/qemukvm_virtmanager_windows_vm_very_slow/
https://www.tenforums.com/virtualization/176433-mega-optimising-disk-i-o-windows-guests-kvm.html
介绍的非常详细
https://leduccc.medium.com/improving-the-performance-of-a-windows-10-guest-on-qemu-a5b3f54d9cf5
红帽官方优化文档
https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/virtualization_tuning_and_optimization_guide/sect-virtualization_tuning_optimization_guide-introduction-kvm_architecture_overview
中文测试各种磁盘模式读写速度
https://www.lanbu.net/d/251/3