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

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

我使用 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>

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

KVM虚拟机管理器

答案1

我的虚拟硬盘的性能也非常慢。
新硬盘上的以下设置纠正了所有问题:

  • 存储格式:原始
  • 缓存模式:无(非默认!)
  • I/O模式:本机

答案2

首先,您已将虚拟机配置为模拟 IDE 总线,但速度相当慢。尝试将其更改为 SATA 总线。

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

注意:Windows 可能会抱怨其下的硬件发生更改,并且在从 IDE 更改为 SATA 或 Virtio 后可能很难找到启动磁盘。

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

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

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

答案3

对于在 IDE HDD 上安装 Windows 以供 KVM 使用且现在希望切换到的任何人虚拟IO

一种方便的方法是遵循此过程。

  1. 关闭您的虚拟机。

  2. 创建辅助(非引导)virtIO 磁盘。

  3. 在现有 IDE 磁盘上启动您的虚拟机,Windows 将需要一个驱动程序来读取我们新的辅助 virtIO 磁盘。这应该更容易工作。

  4. 安装所需的 virtio 驱动程序后,再次关闭虚拟机。重新配置现有的 IDE 磁盘以使其成为 virtIO 磁盘,而无需删除新的辅助 virtIO 磁盘。

  5. 重新启动您的虚拟机。您刚刚在与现有 IDE 磁盘的映像相关的 virtIO 磁盘上启动。

之后您可能需要删除辅助 virtIO 磁盘。

答案4

您应该在 Windows 下安装 VirtIO 驱动程序。你可以下载 Fedora 构建的驱动程序或者从源代码构建您自己的,请参阅KVM文档供参考。

相关内容