kvm qemu 优化 windows 虚拟机速度

31 篇文章 0 订阅

主要优化磁盘 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

  • 21
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
armv8 kvm qemu 是一种用于模拟 ARMv8 架构的虚拟,用于在 ARMv8 架构的处理器上运行不同的操作系统和软件。在启动 armv8 kvm qemu 时,可以使用以下参数进行配置和设置: 1. -cpu 参数:用于指定所模拟的处理器类型。例如,可以使用 "-cpu cortex-a57" 指定为 Cortex-A57 处理器模拟。 2. -m 参数:用于指定模拟的内存大小。可以使用 "-m 2G" 来模拟 2GB 内存。 3. -kernel 参数:用于指定要运行的内核镜像文件。例如,可以使用 "-kernel uImage" 来指定 uImage 文件作为内核。 4. -append 参数:用于指定内核启动时的命令行参数。例如,可以使用 "-append 'root=/dev/sda2 rw console=ttyAMA0'" 来指定根文件系统、读写权限和控制台参数。 5. -drive 参数:用于指定磁盘镜像文件和参数。可以使用 "-drive file=ubuntu.img,if=none,id=hd0 -device virtio-blk-device,drive=hd0" 来指定磁盘镜像文件和 VirtIO 块设备驱动。 6. -netdev 参数:用于指定网络设备配置。可以使用 "-netdev user,id=eth0" 来创建一个用户模式的网络设备。 7. -device 参数:用于指定设备驱动配置。例如,可以使用 "-device virtio-net-device,netdev=eth0" 来为网络设备指定 VirtIO 驱动。 8. -usb 参数:用于启用 USB 设备模拟器。例如,可以使用 "-usb -device usb-host,vendorid=0xNNNN,productid=0xNNNN" 启用 USB 模拟器并指定特定的设备的 vendorid 和 productid。 通过这些启动参数,我们可以配置并启动 armv8 kvm qemu,以模拟 ARMv8 架构的虚拟环境,并在其中运行所需的操作系统和软件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值