Why VM QEMU is very slow ? Still a Newbie here

11,844

Solution 1

By default, qemu will ignore the presence of hardware virtualization capabilities. To quote the online documentation:

Depending on the target architecture, kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used.

"tcg" refers to the built-in "Tiny Code Generator" that is used to (slowly) emulate the guest CPU in software. The Alpine Linux live disc used for demonstration in the video you linked is lightweight enough to boot quickly even without assistance from hardware virtualization. The Ubuntu image you're trying to boot is a lot heavier, and personally, I'm surprised it even started within ten minutes. Also note that guest code running under tcg is assumed to be trusted, so I wouldn't recommend relying on qemu to contain malicious code in this mode.

Since the host platform in question is Windows, the hax or whpx accelerator will allow the emulator to use hardware virtualization. Downloads for the HAXM hypervisor are available here. Instructions for enabling the Windows Hypervisor Platform are here. Once one or the other is enabled, telling the emulator to use VT-x through HAXM or the Windows Hypervisor Platform with -accel hax or -accel whpx should result in a noticeable speedup.


qemu is inherently complex, and even the individuals who use it on a regular basis prefer to interact with an abstraction layer such as libvirt instead of driving the emulator by hand.

The alternative suggested by @user202729, to use a different virtualization package such as VirtualBox, is probably more straightforward than messing with qemu since other software products are "faster" in the sense that they can be installed and configured by the user in less time.

Solution 2

I had also decided to try QEMU because I heard that it is faster than Virtual Box. But I use it under Linux with KVM instead of Windows. I was lucky to start with GNOME Boxes, which is built on top of them, but is very simplified to setup in comparison to other QEMU-based tools. It is all GUI and point and click. If it works, than you will not need to look further. I run Windows 10 in GNOME Boxes on Debian daily for my office work. Unless you want Windows for games, it is much better experience than dual-booting because you can easily switch between Linux and Windows tools in your workflow. The only unobvious thing during the initial setup was to download and install SPICE guest tools in Windows 10 guest, which much improved its performance. The only setting I changed was the amount of RAM, which was pretty low by defualt, even though it worked. The performance and experience was fine with 4 GB when I had 8 GB in total, but my laptop was almost at its edge. It is better now with 6 GB when I have 16 GB. I suggest you try Boxes too. To try it on Ubuntu, just head to the Software Center and search for GNOME Boxes.

Share:
11,844
K4ll-of-D00ty
Author by

K4ll-of-D00ty

Updated on September 18, 2022

Comments

  • K4ll-of-D00ty
    K4ll-of-D00ty over 1 year

    I recently tried QEMU, so I can run both Windows and Linux/*nix at the same time.

    I looked for docs/tutorials online, but found they are way beyond my comprehension. So I just followed https://www.youtube.com/watch?v=al1cnTjeayk

    I just used a regular Ubuntu Mate 16.04.06 iso, but booting to the Ubuntu landing page took me about 10 minutes to load the page (the Ubuntu Linux install landing page).

    What could go wrong? I still run on Intel Core2Duo (old 2009 HW). I am still pretty much on default settings I think...

    I dont understand much about KVM and many of the hardware stuff.

    Still a newbie here..

    • user202729
      user202729 over 4 years
      Do you really need to use QEMU? VirtualBox or dual boot may be faster.
    • K4ll-of-D00ty
      K4ll-of-D00ty over 4 years
      I heard that QEMU is the fastest..