在 KVM 中运行时如何提高 Windows 性能

Guy*_*kes 21 kvm windows virtualization

我使用 Ubuntu 12.04 64 位和 KVM,我的 CPU 是 Core i5 3.3 GHz,我有 8 GB 的 DDR3 RAM。我在 KVM 中运行 Windows 7,它非常慢。我的同事在相同的 PC 配置上使用 Debian,并且可以非常快地运行 Windows 7!我的问题在哪里?

[guyfawkes@guyfawkes-pc ~/work]$ sudo cat /etc/libvirt/qemu/windows.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE 
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh edit windows
or other application using the libvirt API.
-->

<domain type='kvm'>
  <name>windows</name>
  <uuid>5c685175-baea-0ca6-591f-8269d923ffb8</uuid>
  <memory>2097152</memory>
  <currentMemory>2097152</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-1.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/windows.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    </disk>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:94:63:91'/>
      <source network='default'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
    <sound model='ich6'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <video>
      <model type='vga' vram='262144' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
</domain>
Run Code Online (Sandbox Code Playgroud)

UPD:我在安装 KVM 之前启用了 Intel-VT。我已经成功安装了 VirtIO 驱动程序,它给了我一些性能,但是,例如,当我在 Windows 中打开 Firefox 时,即使鼠标移动也很慢,GUI 也很慢。

KVM 虚拟机管理器

小智 17

我的虚拟硬盘的性能也非常慢。
新硬盘上的以下设置纠正了一切:

  • 存储格式:raw
  • 缓存模式:无(非默认!)
  • I/O模式:原生


cas*_*cas 13

首先,您已将 VM 配置为模拟 IDE 总线,这非常慢。尝试将其更改为 SATA 总线。

更好的是,在 Windows 7 中安装virtio 驱动程序,并将其更改为 virtio 总线。

注意:Windows 可能会抱怨其下的硬件被更改,并且在从 IDE 更改为 SATA 或 Virtio 后可能难以找到引导磁盘。

同样,如果您将 NIC 类型更改为 virtio,您将获得改进的网络性能。

您在 ubuntu 上运行的是什么版本的 KVM 和内核?什么版本的 debian 相同?

另一件值得检查的事情是:您的同事是否与您一样使用虚拟机的磁盘映像,或者他们是否使用原始磁盘分区或 LVM 卷或类似内容?与分区或 LVM 相比,磁盘映像非常慢。

  • 是的,简而言之,您必须向 VM 添加第二个磁盘并为此安装 virtio 驱动程序。之后您可以将原始磁盘切换为使用 virtio,并可选择分离/删除第二个磁盘。 (2认同)

小智 10

对于安装在 IDE 上并且现在希望切换到 virtIO 的任何人:一个方便的方法是创建一个辅助(非引导)virtIO 磁盘,引导虚拟机——此时 Windows 将要求 virtIO 驱动程序,它它以某种方式拒绝以其他方式安装 - 随后将引导分区切换到 virtIO。


tis*_*sc0 5

使用您的所有答案,我按以下顺序找到了自己的方法:

安装 :

像谢尔盖所说的硬盘配置。使用 virt-manager 创建 VM 时,不要立即创建磁盘(取消单击“启用存储...”),在下一个屏幕上单击“安装前自定义配置”,然后手动创建硬盘,使用此选项:

- Storage format: raw
- Cache mode: none (not default!)
- I/O mode: native
- + Disk bus : SATA
Run Code Online (Sandbox Code Playgroud)

对我来说,安装在不到 15 分钟内完成(而不是使用默认参数超过 2 小时后进度的 27%)

第一次重启:

- Disk bus : IDE (or windows will not boot)
- Installation of the [latest drivers][1] 
  (For that, devices management/install old components/type: storage)
Run Code Online (Sandbox Code Playgroud)

暂停系统,将磁盘总线重新更改为 virtio,重新启动,就这样!

'快乐!