当前位置: 首页 > article >正文

kvm qemu 优化 windows 虚拟机速度

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


http://www.kler.cn/news/234359.html

相关文章:

  • C++入门学习(二十七)跳转语句—continue语句
  • ubuntu20.04-编译安装Qt5.15.2-C++
  • 【后端高频面试题--Mybatis篇】
  • Vue-53、Vue技术vuex使用
  • 数据结构之基数排序
  • Pandas 对带有 Multi-column(多列名称) 的数据排序并写入 Excel 中
  • Java并发基础:LinkedBlockingDeque全面解析!
  • prometheus之redis_exporter部署
  • 数字孪生:构建未来智慧社区的关键技术
  • CVE-2022-0760 漏洞复现
  • 微服务OAuth 2.1认证授权可行性方案(Spring Security 6)
  • 爬虫为什么要使用代理?
  • Huggingface上传模型
  • 新型RedAlert勒索病毒针对VMWare ESXi服务器
  • PyTorch 2.2大更新!集成FlashAttention-2,性能提升2倍
  • 代码随想录 Leetcode55. 跳跃游戏
  • HiveSQL——设计一张最近180天的注册、活跃留存表
  • 自适应二次元404页面源码
  • antdpro框架npm install 报错,切换tyarn安装成功。
  • 2/7 算法每日N题(二分+双指针)
  • 【Java多线程案例】实现阻塞队列
  • Vue3快速上手(一)使用vite创建项目
  • 滑块验证码识别代码分享
  • 力扣236——二叉树的最近公共祖先
  • [2024]常用的pip指令
  • Docker 容器网络:C++ 客户端 — 服务器应用程序。
  • 【北邮鲁鹏老师计算机视觉课程笔记】01 introduction
  • 【服务器部署】Docker环境的安装
  • Linux内核有什么之内存管理子系统有什么——基础篇之struct vm_area_struct(2)
  • Bert与ChatGPT