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
| Flag | Example | What it does |
|---|---|---|
| -accel | kvm | Hardware acceleration through /dev/kvm |
| -machine | q35 | Modern chipset with PCIe (default pc is i440fx) |
| -cpu | host | Pass through host CPU model and flags |
| -m / -smp | 4G / 4 | Memory and number of vCPUs |
| -drive | file=disk.qcow2,if=virtio | Attach a disk using virtio-blk |
| -nic | user,hostfwd=tcp::2222-:22 | User-mode NAT with SSH port forward |
| -nographic | No window; serial console on your terminal | |
| -bios / -drive if=pflash | OVMF_CODE.fd | UEFI firmware instead of SeaBIOS |
| -monitor | unix:qmp.sock,server,nowait | Expose the monitor for control |
User-mode networking and port forwarding
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_powerdownA complete one-liner
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=virtioThrowaway 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 -nographicBoot 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.