23

I use Ubuntu 12.04 64-bit and KVM, my CPU is Core i5 3.3 GHz and I have 8 GB of DDR3 RAM. I run Windows 7 in KVM and it's extremely slow. My co-worker use Debian on the same PC configuration and can run Windows 7 extremely fast! Where can be my problem?

[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: I've enabled Intel-VT before installing KVM. I've successfully installed VirtIO drivers, and it gave me a few of performance, but, for example, when I open Firefox in Windows, even mouse moves very slowly, and GUI is very slow too.

KVM virtual machines manager

5
  • 1
    Does your CPU support VT technology ?
    – daisy
    Sep 6, 2012 at 7:20
  • yes, it does :)
    – Guy Fawkes
    Sep 6, 2012 at 7:35
  • 1
    Thx - the - Storage format: raw - Cache mode: none (not default!) - I/O mode: native - + Disk bus : SATA did it. "Expanding Windows files" during Win7 Installation did start counting up immediately after the change instead of hanging around @ 0% for hours. I wonder why disabling caching does the trick, as I tried first attempt with SATA NATIVE and Caching (Writeback), which sucked completely, and SATA NATIVE with caching set to NONE solved it obviously...Normally I'd expect a performance gain from writeback caching ?
    – user97113
    Jan 5, 2015 at 15:12
  • What is the name of this application?
    – thiagowfx
    Jan 5, 2015 at 15:14
  • @ThiagoPerrotta That's virt-manager (Virtual Machine Manager)
    – doug65536
    Oct 25, 2019 at 7:25

6 Answers 6

18

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
2
  • Excellent point about the storage format. Using a raw partition instead of a file container may also improve a little more. Jan 5, 2015 at 15:28
  • 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
    Jan 18, 2017 at 23:39
14

For a start, you've got the VM configured to be emulating an IDE bus, which is pretty slow. Try changing it to a SATA bus.

Better yet, install the virtio drivers in Windows 7, and change it to a virtio bus.

NOTE: Windows may complain about the hardware being changed underneath it, and may have difficulty finding the boot disk after it has changed from IDE to SATA or Virtio.

Similarly, you will get improved network performance if you change the NIC type to virtio.

What version of KVM and kernel are you running on ubuntu? And what version of same on debian?

One other thing worth checking is: is your co-worker using a disk-image for the VM, same as you are, or are they using a raw disk partition or an LVM volume or similar? disk-images are very slow compared to partitions or LVM.

5
  • Can you describe how to install VirtIO drivers?
    – Guy Fawkes
    Sep 5, 2012 at 10:15
  • not really, they're windows drivers. not my area of expertise. i'd guess you install them in the usual way that windows drivers are installed. i did install them a few times on some windows VMs a year or two ago. IIRC it was something clumsy like mount the CD image and hunt for the installer program in one of the subdirectories and click on it.
    – cas
    Sep 5, 2012 at 12:03
  • I was never able to add VirtIO drivers on an migrated-existent Windows image. Redefining the Disk bus to VirtIO and Windows would not start; and try to install the VirtIO drivers without the right Diskbus I would have like to have been allowed. Nov 5, 2014 at 12:14
  • Actually you can do it serverfault.com/questions/452854/…
    – Darokthar
    Dec 1, 2015 at 21:22
  • 2
    yes, in short you have to add a second disk to the VM and install the virtio drivers for that. afterwards you can switch the original disk to use virtio, and optionally detach/delete the second disk.
    – cas
    Dec 1, 2015 at 22:59
12

For anyone who installed Windows on an IDE HDD for KVM usage and now wishes to switch to virtIO.

A convenient way to do it is to follow this procedure.

  1. Shutdown your VM.

  2. Create a secondary (non-boot) virtIO disk.

  3. Boot your VM on the existing IDE disk, Windows will require a driver to read on our new secondary virtIO disk. This should works more easily.

  4. After the required virtio drivers has been installed, shutdown your VM again. Reconfigure our existing IDE disk to use be now a virtIO disk, without removing our new secondary virtIO disk.

  5. Restart your VM. You have just booted on a virtIO disk which is related to the image of the existing IDE disk.

You may want to remove the secondary virtIO disk after that.

5

Using all your answers, I found my way in this order :

Installation :

HDD configuration like Sergey said. When creating the VM with virt-manager, don't create the disk immediately (unclick "enable storage..."), clic "customize configuration before install" on the next screen, and create the HDD manually just after, with this options :

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

For me, the installation is done in less than 15min (rather than 27% of progression after more than 2H with default parameters)

First reboot :

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

Halt the system, rechange the disk bus to virtio, reboot, that's it !

'joy !

3

You should install VirtIO drivers under Windows. You can download drivers built by Fedora or build your own from source, see the KVM documentation for information.

1
  • 4
    Please don't just post a link, summarize the main points directly in your answer and provide the link for further reference. See my edit for the sort of minimum that we expect in an answer. Or see Craig's answer which provides this link with an explanation and far more besides. Read how to answer for more information. Sep 4, 2012 at 21:44
0

I'm running Ubunto 20.04 with KVM and Windows 2019 Guests. I was getting between 100Kb and 2.5Mb on a 1Gb Bridge... I remembered that on VMware, VMware has recommended to disable all offload options for high performance environments. I modified the E1000 NICs in my guests to disable all of the offload functions, and immediately started getting between 860Mb and 980Mb on a 1Gb connection. Problem solved.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .