Running QEMU Directly: qemu-system-x86_64 Without libvirt

Learn the qemu-system-x86_64 command line: CPU, memory, virtio disks, user and tap networking, UEFI, serial console, the QEMU monitor and port forwarding.

Published November 27, 2026

libvirt is great for long-lived machines, but sometimes you want a VM for ten minutes: test a kernel, boot an image in CI, or debug a bootloader. Running qemu-system-x86_64 directly is perfect for that, and understanding its flags also demystifies what libvirt is doing behind the scenes.

The concept

A QEMU command line describes a computer from scratch: the machine type (chipset), the CPU, the amount of RAM, and every device. Modern QEMU encourages -device and -blockdev style options, but the older shorthand flags (-drive, -nic) remain the easiest way to start.

The single most important flag is -accel kvm (equivalent to -enable-kvm). Without it, QEMU emulates the CPU in software. Pair it with -cpu host to expose your real CPU's features to the guest, and -machine q35 for a modern PCIe chipset.

Flags worth memorising

FlagExampleWhat it does
-accelkvmHardware acceleration through /dev/kvm
-machineq35Modern chipset with PCIe (default pc is i440fx)
-cpuhostPass through host CPU model and flags
-m / -smp4G / 4Memory and number of vCPUs
-drivefile=disk.qcow2,if=virtioAttach a disk using virtio-blk
-nicuser,hostfwd=tcp::2222-:22User-mode NAT with SSH port forward
-nographicNo window; serial console on your terminal
-bios / -drive if=pflashOVMF_CODE.fdUEFI firmware instead of SeaBIOS
-monitorunix:qmp.sock,server,nowaitExpose the monitor for control

User-mode networking and port forwarding

TCPhostfwdguest :22eth0 10.0.2.15slirpuser-mode NAThost :2222localhost
User networking needs no root: QEMU NATs traffic in userspace.

The QEMU monitor

The monitor is a control console for the running VM. With -nographic, press Ctrl+A then C to toggle between the serial console and the monitor. From there you can inspect devices, hot-plug disks, take snapshots or quit.

(qemu) info status
VM status: running
(qemu) info block
virtio0 (#block123): disk.qcow2 (qcow2)
(qemu) savevm clean-boot
(qemu) system_powerdown

A complete one-liner

qemu-system-x86_64 -accel kvm -machine q35 -cpu host -m 2G -smp 2 \
-drive file=noble.qcow2,if=virtio -nic user,model=virtio-net-pci,hostfwd=tcp::2222-:22 \
-nographic
[ 0.000000] Linux version 6.8.0-49-generic ...
Ubuntu 24.04.1 LTS ubuntu ttyS0
ubuntu login:
ssh -p 2222 ubuntu@localhost
A headless VM in one command, reachable over SSH on port 2222.

Practical examples

Boot with UEFI firmware

Copy the vars file so each VM keeps its own NVRAM.

cp /usr/share/OVMF/OVMF_VARS_4M.fd my_vars.fd
qemu-system-x86_64 -accel kvm -machine q35 -m 4G \
  -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd \
  -drive if=pflash,format=raw,file=my_vars.fd \
  -drive file=disk.qcow2,if=virtio

Throwaway runs with -snapshot

All writes go to a temporary file and are discarded on exit, perfect for CI.

qemu-system-x86_64 -accel kvm -m 2G -snapshot -drive file=golden.qcow2,if=virtio -nographic

Boot a kernel directly for kernel development

No bootloader or disk install needed; attach gdb on port 1234 with -s.

qemu-system-x86_64 -accel kvm -m 1G -nographic -s \
  -kernel arch/x86/boot/bzImage -initrd initramfs.cpio.gz \
  -append "console=ttyS0 nokaslr"

Common mistakes

  • Leaving out -accel kvm and getting software emulation speed.
  • Using -nic user and expecting ping to work. User networking does not forward ICMP by default.
  • Pressing Ctrl+C in -nographic mode, which kills QEMU. Use Ctrl+A X to quit cleanly.
  • Sharing one OVMF_VARS file between VMs, which mixes their boot entries.

Key takeaways

  • -accel kvm -cpu host -machine q35 is the fast, modern baseline.
  • User networking needs no privileges; use hostfwd for inbound ports.
  • -snapshot and -kernel make QEMU ideal for CI and kernel work.
  • Ctrl+A C switches between serial console and monitor.

FAQ

Do I need root to run QEMU with KVM?

No, just read/write access to /dev/kvm, usually granted by the kvm group. Tap networking and bridges need extra privileges or a helper.

What is QMP?

The QEMU Machine Protocol, a JSON version of the monitor used by libvirt and scripts to control QEMU programmatically.

Can QEMU emulate ARM on x86?

Yes, with qemu-system-aarch64 using TCG. It is slower than KVM but great for testing ARM images without ARM hardware.

More Linux articles