LinuxCommandLibrary

qemu-system-x86_64

Run x86_64 virtual machines

TLDR

Boot from an image emulating the x86_64 architecture

$ qemu-system-x86_64 -hda [image_name.img] -m [4096]
copy

Boot a QEMU instance from a live ISO image
$ qemu-system-x86_64 -hda [image_name.img] -cdrom [os_image.iso] -boot d -m [4096]
copy

Boot from a physical device (e.g. from USB to test a bootable medium)
$ qemu-system-x86_64 -hda [/dev/storage_device] -m [4096]
copy

Do not launch a VNC server
$ qemu-system-x86_64 -hda [image_name.img] -m [4096] -nographic
copy

Exit non-graphical QEMU
$ <Ctrl a><x>
copy

List the supported machine types
$ qemu-system-x86_64 [[-M|-machine]] help
copy

SYNOPSIS

qemu-system-x86_64 [options] [disk_image]

Example usage:
  qemu-system-x86_64 \
    -m 2048 \
    -cpu host \
    -smp 4 \
    -drive file=./my_vm.qcow2,format=qcow2 \
    -cdrom ./ubuntu.iso \
    -boot d \
    -enable-kvm \
    -netdev user,id=vmnic \
    -device e1000,netdev=vmnic \
    -vnc :0

PARAMETERS

-m
    Set the amount of RAM for the virtual machine in megabytes.

-cpu
    Specify the CPU model to emulate (e.g., 'host' for host CPU, 'qemu64', 'Haswell').

-smp [,cores=][,threads=][,maxcpus=]
    Configure the number of virtual CPUs, cores, and threads. 'cpus' is the total number of vCPUs.

-drive file=[,format=][,if=][,bus=]
    Define a storage device. Specify the disk image file, format (e.g., qcow2, raw), interface (e.g., ide, scsi, virtio), and bus.

-hda
    Shorthand for -drive file=,if=ide,index=0 (main IDE hard disk).

-cdrom
    Specify a CD-ROM or DVD-ROM image file (e.g., an ISO).

-boot
    Set the boot device order ('a' for floppy, 'c' for hard disk, 'd' for CD-ROM, 'n' for network).

-enable-kvm
    Enable KVM hardware virtualization for significantly improved performance (Linux hosts only).

-netdev ,id=[,options]
    Define a virtual network backend (e.g., 'user' for NAT, 'bridge' for bridged networking, 'tap' for TAP device). Requires a corresponding -device.

-device [,netdev=][,options]
    Add a specific virtual device to the VM (e.g., 'e1000' network card, 'virtio-blk' block device, 'VGA' graphics card). For network devices, link to a -netdev ID.

-vnc
    Start a VNC server to access the VM's display. '' is usually ':' for display N (e.g., ':0').

-nographic
    Run the VM without a graphical display, useful for headless servers or console-only guests.

-monitor
    Connect to the QEMU monitor console (e.g., 'stdio' for standard I/O, 'tcp::' for network).

-daemonize
    Run QEMU in the background, detaching from the terminal.

-usb
    Enable USB support within the virtual machine.

-usbdevice
    Add a USB device to the VM (e.g., 'host-vendorid:productid' to pass through a host USB device).

DESCRIPTION

qemu-system-x86_64 is the command-line utility for launching and managing virtual machines that emulate a 64-bit x86 architecture. It is part of the QEMU (Quick EMUlator) suite, a versatile and open-source machine emulator and virtualizer. This specific executable emulates a complete PC system including CPU, memory, and various peripheral devices, allowing unmodified guest operating systems to run.

While it can purely emulate hardware (which is slower), its primary power comes from its ability to leverage hardware virtualization extensions (like Intel VT-x or AMD-V) via the Linux Kernel-based Virtual Machine (KVM) module. When used with KVM (via the -enable-kvm option), QEMU acts as a hypervisor, providing near-native performance for guest operating systems, making it a robust solution for server virtualization, development environments, and even desktop use.

CAVEATS

Using qemu-system-x86_64 directly can be complex due to the vast number of options and their interdependencies. Misconfigurations can lead to performance issues or non-booting VMs.

Optimal performance typically requires KVM acceleration, which is only available on Linux hosts with compatible hardware. Without KVM, performance can be significantly slower due to full software emulation.

Networking setup can be intricate, requiring understanding of different modes (user, bridge, tap) and potentially host-side network configuration.

KVM ACCELERATION

For high performance, always use the -enable-kvm option. This requires a Linux host system with CPU virtualization extensions (Intel VT-x or AMD-V) enabled in the BIOS/UEFI, and the KVM kernel module loaded. Without KVM, QEMU will perform full software emulation, which is considerably slower.

QEMU MONITOR

The QEMU Monitor (accessible via -monitor stdio or via VNC console 'Ctrl+Alt+2') is a powerful interface to interact with a running VM. You can issue commands to change disk images, save/restore state, eject CD-ROMs, query device status, and much more. Common commands include 'info status', 'info network', 'savevm', 'loadvm', 'quit'.

NETWORKING MODES

QEMU offers several networking modes:
  User-mode networking (-netdev user): Easiest to set up, but guests are behind a NAT, limited to outbound connections and port forwarding.
  Bridged networking (-netdev bridge): Guest gets an IP on the host's LAN, requires a Linux bridge on the host.
  TAP device networking (-netdev tap): Most flexible, allows advanced setups like routing, but requires manual configuration of TAP devices and permissions.

HISTORY

QEMU was originally written by Fabrice Bellard and first released in 2000. It quickly gained popularity for its ability to emulate a wide range of architectures and for its 'TCC' (Tiny C Compiler) based dynamic translation. The integration with the Linux Kernel-based Virtual Machine (KVM) in 2007, developed by Avi Kivity, transformed QEMU from primarily an emulator to a full-fledged hypervisor, capable of near-native performance. This synergy (QEMU providing device emulation and KVM handling CPU/memory virtualization) cemented its position as a leading open-source virtualization solution.

SEE ALSO

qemu-img(1), virsh(1), virt-manager(1), kvm(7) (Linux kernel module)

Copied to clipboard