When I use virtual machine on my i5 laptop, does it emulate every instruction or does it run normally? How much is speed decreased? Especially I am interested in QEMU and virtualbox, how do they work? Will they run games without problems?
It depends on your virtualization software. Basically you have three choices:
All three work. All three are in use. All three have different performance characteristics.
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.
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.
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).
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 on how much RAM and number of CPU Core 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 1GB RAM and 1 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 on 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.