1

When I use a virtual machine on my i5 laptop, does it emulate every instruction or does it run normally?

How much is the speed decreased? Especially I am interested in QEMU and VirtualBox; how do they work? Will they run games without problems?

2 Answers 2

5

It depends on your virtualization software. Basically you have three choices:

  1. Emulate an entire PC, including CPU.
  2. Run the software as it is, using the hardware of the host, but intercept a few system calls and instructions.
  3. Modify the software so it runs on the hosts hardware, but the instructions which would be intercepted by 2) are now replaced by other routines.

All three work. All three are in use. All three have different performance characteristics.

1) Emulate
This will always be the slowest option. It has two advantages:

  • You can emulate a completely different host (e.g. emulate a ARM based computers on a AMD64).
  • You do not need any hardware support.

2) Intercept system calls

This answer is mostly AMD64 based. A modern x86 CPU has several levels with different permissions. These are called rings. The VM software takes over ring 0 (the ring with the most permissions) and gains the right to do just about anything on the computer. The software on the computer (both host and VMs) do not notice this. Using these rights it makes sure that multiple OS's do not interfere with each other.

As a result regular code runs at full speed (dnetc testing resulted at about 99% of the speed in a vm). Code which does system calls gets intercepted and modified, and is thus much slower. Usually the net result of this is a few percent speed loss.

3) Modified code

Instead of intercepting the system calls real time you can modify the software in advance. This way your code can be slightly faster, but you do needs to modify the software in advance.


Especially I am talking about QEMU and virtualbox, how are they?

I got a friend who is a programmer. She looked at QEMU's code. The recommended advice is not to touch it. Ever. Not even with a 10 foot pole. QEMU works with the out of the box configuration, but fails quite often if you do not use default settings. It allocates resources and never checks if that succeeded... I could go on, but the less it is mentioned the better.

Virtualbox: I used virtualbox once. It worked. The windows version of it had a nice understandable interface. I did not test any performance, nor did I play any games.

Will it run games without problems?

The only games I have run are under Vmware (player). That worked well enough for 2D games. 3D games usually crash my computer (both Vm and host).

1

In VirtualBox if you enabled the Extended Features and Hardware Virtualization you are exposing the native supported features of your Processor/CPU to the Guest OS. Performance vary depending on how much RAM and number of CPU cores you allocate. Although allocating a fixed amount of RAM and CPU core will not be utilize at all times, because it depends on what you are running inside the VM or Guest OS.

Say, I allocated 1 GB RAM and one CPU Core. Then I run some intensive application on the Guest OS like MATLAB, the application will use all available resources. You can even monitor what consumes them in Task Manager.

Normally, games (some) should work depending on their requirement, specially on the graphics department since games tend to use a lot of video memory, it crunches a lot of data so games is off topic if you want it to use on VMs.

You must log in to answer this question.

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