QEMU: Difference between revisions

From Computernewb Wiki
Jump to navigation Jump to search
m (1 revision imported)
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[File:Qemu.png|thumb|350px|QEMU running [[Windows 2000]] on Red Hat Linux.]]
[[File:Qemu.png|thumb|350px|QEMU system emulation running [[Windows 2000]] on Red Hat Linux.]]


'''QEMU''' ('''Q'''uick '''Emu'''lator) is a free, open-source hypervisor and emulator that runs on several operating systems, including many major Linux distros, macOS, Microsoft Windows, and BSD, and a few others.
'''QEMU''' ('''Q'''uick '''Emu'''lator) is a free, open-source hypervisor and emulator that runs on several operating systems, including many major Linux distros, macOS, Microsoft Windows, BSD, as well as a few others.


It is capable of running pretty much all major x86 operating systems, including Windows, Linux, MS-DOS and BSD (and much more), and in addition is also capable of emulating other architectures, including ARM, MIPS, SPARC, PowerPC and MicroBlaze, there are also many forks of QEMU that add emulation of other systems like the Xbox, Z80 and Macintosh 128K.
It is capable of running pretty much all major x86 operating systems, including Windows, Linux, MS-DOS and BSD (and much more), and in addition is also capable of emulating other architectures, including ARM, MIPS, SPARC, PowerPC and MicroBlaze, there are also many forks of QEMU that add emulation of other systems like the Xbox, Z80 and Macintosh 128K.
Line 9: Line 9:
==Operating modes==
==Operating modes==


===System emulation===
===User emulation===
System emulation mode emulates an entire computer system, including peripherals. As mentioned above, it is capable of booting nearly all major x86 operating systems. System emulation mode is very slow (although faster than Bochs, at a cost of accuracy) - it should only be used if:


User emulation mode emulates a target CPU (always using the Tiny Code Generator), and additionally a given system call ABI (usually Linux), allowing programs from another architecture or operating system to run as if they are native applications (in most cases). This is useful for poking around embedded Linux firmware, for instance, but beyond that generally is more of a curiosity than something useful.
*The host server is running an OpenVZ variant of Linux.
*You do not have root permissions (or you are NOT in the <kbd>kvm</kbd> user group, or have not started the <kbd>kvm</kbd> module if it is optional.) on the OS.
*The host operating system does not run well with KVM (e.g. [[Windows 98]] should not be ran with KVM)


===KVM===
===System emulation===
System emulation mode (known also as <code>softmmu</code>) emulates an entire computer system, including peripherals. As mentioned above, it is capable of booting practically all major operating systems. By default, system emulation uses the Tiny Code Generator (TCG), which is generally slower (although faster than Bochs, at a cost of accuracy).
QEMU can run operating systems at near native speeds with KVM. QEMU still emulates the hardware, but the execution of the guest is done by KVM as requested by QEMU. You can enable KVM by adding <kbd>-accel kvm</kbd> to the startup arguments.


TCG should only be used if:
If installed, you can check if you are ready to enable kvm by checking the command <kbd>kvm-ok</kbd>.


*The host server does not have KVM/virtualization enabled.
==Table of contents==
*The host server is running an OpenVZ variant of Linux.
*'''[[{{PAGENAME}}/Installation|Installation]]'''
*You are NOT in the <kbd>kvm</kbd> user group, or have not started the <kbd>kvm</kbd> module on the OS.
*The host operating system does not run well with KVM (e.g. [[Windows 98]] does not run with KVM on most systems)


===System emulation with KVM===
::'''[[{{PAGENAME}}/Compiling from source|Compiling from source]]'''
With KVM, the Linux kernel's API for utilizing CPU native virtualization support, QEMU's system emulation can run operating systems at near native speeds.


When enabled, instead of using TCG to ''emulate'' each vCPU present in the configured machine, QEMU will instead request KVM run the vCPU, greatly increasing the performance of the virtualized system. Most of QEMU's hardware/system emulation still runs in usermode with KVM enabled, however some performance sensitive chipset emulation functionality is by default moved into KVM, helping increase performance further.
:::'''[[{{PAGENAME}}/Compiling from source/Linux|Linux]]'''


You can enable KVM by adding <kbd>-accel kvm</kbd> to the startup arguments, or by appending <kbd>,accel=kvm</kbd> to your <kbd>-machine</kbd>/<kbd>-M</kbd> option.
:::'''[[{{PAGENAME}}/Compiling from source/Windows|Windows]]'''


If installed, you can check if you are ready to enable kvm by checking the command <kbd>kvm-ok</kbd>, or alternatively <kbd>ls /dev/kvm</kbd>.
*'''[[{{PAGENAME}}/Devices|Devices]]'''


==Table of contents==
::[[{{PAGENAME}}/Devices/Network|Networking]]

::[[{{PAGENAME}}/Devices/Machines|Machines]]

::[[{{PAGENAME}}/Devices/Video cards|Video cards]]

::[[{{PAGENAME}}/Devices/Sound cards|Sound cards]]

*'''[[{{PAGENAME}}/Getting started|Getting started]]'''


{{Special:PrefixIndex/QEMU/|stripprefix=1}}
::[[{{PAGENAME}}/Getting started/Setting up a VM|Setting up a VM]]


[[Category:QEMU guides]]
[[Category:QEMU guides]]

Revision as of 09:25, 24 July 2024

QEMU system emulation running Windows 2000 on Red Hat Linux.

QEMU (Quick Emulator) is a free, open-source hypervisor and emulator that runs on several operating systems, including many major Linux distros, macOS, Microsoft Windows, BSD, as well as a few others.

It is capable of running pretty much all major x86 operating systems, including Windows, Linux, MS-DOS and BSD (and much more), and in addition is also capable of emulating other architectures, including ARM, MIPS, SPARC, PowerPC and MicroBlaze, there are also many forks of QEMU that add emulation of other systems like the Xbox, Z80 and Macintosh 128K.

QEMU is the only emulator supported in CollabVM 1.2. CollabVM 2.0 has a wider selection of virtualizers and emulators.

Operating modes

User emulation

User emulation mode emulates a target CPU (always using the Tiny Code Generator), and additionally a given system call ABI (usually Linux), allowing programs from another architecture or operating system to run as if they are native applications (in most cases). This is useful for poking around embedded Linux firmware, for instance, but beyond that generally is more of a curiosity than something useful.

System emulation

System emulation mode (known also as softmmu) emulates an entire computer system, including peripherals. As mentioned above, it is capable of booting practically all major operating systems. By default, system emulation uses the Tiny Code Generator (TCG), which is generally slower (although faster than Bochs, at a cost of accuracy).

TCG should only be used if:

  • The host server does not have KVM/virtualization enabled.
  • The host server is running an OpenVZ variant of Linux.
  • You are NOT in the kvm user group, or have not started the kvm module on the OS.
  • The host operating system does not run well with KVM (e.g. Windows 98 does not run with KVM on most systems)

System emulation with KVM

With KVM, the Linux kernel's API for utilizing CPU native virtualization support, QEMU's system emulation can run operating systems at near native speeds.

When enabled, instead of using TCG to emulate each vCPU present in the configured machine, QEMU will instead request KVM run the vCPU, greatly increasing the performance of the virtualized system. Most of QEMU's hardware/system emulation still runs in usermode with KVM enabled, however some performance sensitive chipset emulation functionality is by default moved into KVM, helping increase performance further.

You can enable KVM by adding -accel kvm to the startup arguments, or by appending ,accel=kvm to your -machine/-M option.

If installed, you can check if you are ready to enable kvm by checking the command kvm-ok, or alternatively ls /dev/kvm.

Table of contents