QEMU/Options

This article describes some of the options useful for configuring QEMU virtual machines. For the most up to date options for the current QEMU install run at a terminal. It is important to note that the command has changed from to  to launch QEMU as a 64-bit virtual machine.

Display options
There are a few available options to specify the kind of display to use in QEMU.


 * - Display video output via SDL (usually in a separate graphics window).


 * - Displays video output via curses.


 * - Do not display video output. This option is different than the  option. See the man page for more information.


 * - Display video output in a GTK window. This is probably the option most users are looking for.


 * - Start a VNC server on display X (accepts an argument (X) for the display number). Substitute X for the number of the display (0 will then listen on 5900, 1 on 5901, etc).

For example to have QEMU send the display to a GTK window add the following option to the list:

Machine

 * - Modern chipset (PCIe, AHCI, ...) and hardware virtualization acceleration


 * - Pass-through for host random number generator. Accelerates startup of e.g. Debian VMs because of missing entropy.

Processor

 * - Specify a processor architecture to emulate. To see a list of supported architectures, run:


 * - (Recommended) Emulate the host processor.


 * - Specify the number of cores the guest is permitted to use. The number can be higher than the available cores on the host system. Use  to use all currently available cores.

RAM

 * - Specify the amount of memory (default: 128 MB). For instance: (M stands for Megabyte, G for Gigabyte).

Hard drive

 * - Set a virtual hard drive and use the specified image file for it.


 * - Advanced configuration of a virtual hard drive:


 * -device virtio-scsi-pci,id=scsi0 -drive file=/dev/your/block,if=none,format=raw,discard=unmap,aio=native,cache=none,id=someid -device scsi-hd,drive=someid,bus=scsi0.0 Very fast Virtio SCSI emulation for block discards (TRIM), native command queuing (NCQ). You need at least one -controller and for each block device a   and   pair.


 * - Set a virtual VirtIO-BLK hard drive and use the specified image file for it.


 * - Set a virtual VirtIO-BLK hard drive and use the specified partition for it.


 * - Set emulation layer for an ICH-9 AHCI controller and use the specified image file for it. The AHCI emulation supports NCQ, so multiple read or write requests can be outstanding at the same time.

Optical drives

 * - Set a virtual CDROM drive and use the specified image file for it.


 * - Set a virtual CDROM drive and use the host drive for it.


 * - Advanced configuration of a virtual CDROM drive:


 * - Set a virtual CDROM drive and use the specified image file for it. With this syntax you can set multiple drives.

Boot order

 * - Boot the first virtual hard drive.


 * - Boot the first virtual CD-ROM drive.


 * - Boot from virtual network.

Graphics card
QEMU can emulate several graphics cards:


 * - Simple graphics card. Every guest OS has a built-in driver.


 * - Support resolutions >= 1280x1024x16. Linux, Windows XP and newer guest have a built-in driver.


 * - VMware SVGA-II, more powerful graphics card. Install in Linux guests, VMware Tools in Windows XP and newer guests.


 * - More powerful graphics card for use with SPICE.

To get more performance use the same color depth for your host as you use in the guest.

PCI pass-through
Find the host PCI device:

Note down the device (00:1b.0) and vendor (8086:284b) ID.

Unbind it:

And bind it to guest:

Networking
Default - without any  option - is Pass-through.

Pass-through

 * - The QEMU process will create TCP and UDP connections for each connection in the VM. The virtual machine does not have an address reachable from the outside.


 * - (Recommended) Pass-through with VirtIO support.


 * - Let QEMU listen on port 9001. Connections to that port will be relayed to the VM on port 22.  will thus log into the VM.

Virtual network cable (TAP)

 * - A new device is created by QEMU on the host, the other end of the "cable" is at the VM.

Network bridge
With this setup, we create a TAP interface (see above) and connect it to a virtual switch (the bridge).

Please first read about network bridging and QEMU about configuring kernel to support bridging.

OpenRC
Assuming a simple case with only one Virtual Machine with tap0 net interface and only one net interface on host with eth0.

systemd
Create the bridge:

Configure the bridge's address:

Now we can run VM with the TAP networking option:

When the VM boots, the script will add the newly created device to the bridge. When you start another VM, both devices are in the bridge and the VMs can communicate with each other.

A more advanced networking concept is outlined below, which enables guest access to an external network and also works with both wired and wireless adapters on the host. If desired, a DHCP server can also be setup on the host to allow for dynamic guest IP configurations. There are many different tutorials available online to further understand these concepts.

Required packages
This example networking configuration needs some extra software installed:

Creating TUN/TAP device
This allows the guest to communicate with the bridge. QEMU's default group is, ensure that the correct group is given permissions to control the TAP. Enabling promiscuous mode for the adapter might be unnecessary.

Create network bridge
Creating a network bridge seems necessary, even if only 1 guest is configured. Create the bridge and add each TAP to it. Spanning tree protocol is disabled because there is only 1 bridge.

Packet forwarding and NAT
Allows for proper packet routing (be sure to replace  with an appropriate network interface name):

Guest configuration
The following should be added to the configuration:

or, with QEMU 2.12.0 or newer:

After starting the guest, the IP should be configured to be on the vlan and the gateway should be the IP given to the bridge. The exact process will vary based on OS.

QEMU's built-in SMB server
If the host system has a SMB server installed, QEMU can emulate a virtual SMB server for the guest system using the  optionː


 * - specify the folder to be shared, and it will be available to the guest as.

Automatically generated file located at

USB

 * - (Recommended) Use a USB tablet instead of the default PS/2 mouse. Recommend, because the tablet sends the mouse cursor's position to match the host mouse cursor.


 * - Pass-through of a host USB device to the virtual machine. Determine with the device's vendor and product ID, e.g.:


 * is the vendor ID,  is the product ID.

Keyboard layout

 * - Set the keyboard layout, e.g. de for german keyboards. Recommend for VNC connections.

Snapshot

 * - Temporary snapshot: write all changes to temporary files instead of hard drive image.


 * - Overlay snapshot: write all changes to an overlay image instead of hard drive image. The original image is kept unmodified. To create the overlay image: