QEMU Machine emulator and virtualizer
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
qemu-img create -f qcow2 <disk.qcow2> 20G
qemu-system-x86_64 -cdrom <install.iso> -hda
<disk.qcow2> -m 2G -boot d
qemu-system-x86_64 -accel kvm -cpu host -m 4G -smp 4 -hda
<disk.qcow2>
-nic user,hostfwd=::2222-:22
-nographicCtrl+a xqemu-img info <disk>
-snapshotConcepts
Run a VM
qemu-system-x86_64 -hda <disk>
-accel kvm-cpu host-m <size>-smp <n>-name <vm>
-machine q35-machine help-daemonize-loadvm <tag>
Disks and boot
-drive file=<disk>,format=qcow2,if=virtio
-cdrom <iso>
-boot d-boot order=<cdn>
-snapshot-drive file=<disk>,cache=none,aio=native
-drive
if=pflash,format=raw,readonly=on,file=<OVMF_CODE.fd>
-kernel <bzImage> -append
"<cmdline>"
Display and console
-nographic-display gtk-display vnc=:<n>
-vga virtio-serial mon:stdio
-monitor stdio-qmp unix:<sock>,server,nowait
Network
-nic user-nic user,hostfwd=::<host>-:<guest>
-nic user,model=virtio-net-pci
-nic tap,script=no,ifname=<tap>
-nic bridge,br=<br0>
-netdev
user,id=<n0>,hostfwd=tcp::<host>-:<guest>
-device virtio-net-pci,netdev=<n0>
Devices and sharing
-device help-usb-device
usb-host,vendorid=<vid>,productid=<pid>
-virtfs
local,path=<dir>,mount_tag=<tag>,security_model=mapped-xattr
-device vfio-pci,host=<bdf>
qemu-img
qemu-img create -f qcow2 <disk> <size>
qemu-img info <disk>
qemu-img convert -O qcow2 <in> <out>
qemu-img convert -c -p -O qcow2 <in>
<out>
qemu-img resize <disk> +<size>
qemu-img create -f qcow2 -b <base> -F qcow2
<overlay>
qemu-img info --backing-chain <disk>
qemu-img commit <overlay>
qemu-img check <disk>
qemu-img snapshot -l <disk>
qemu-img snapshot -c <tag> <disk>
qemu-img snapshot -a <tag> <disk>
qemu-img convert -f raw -O qcow2 <in.img>
<out.qcow2>
| -f / -O | Use for |
|---|---|
raw |
Plain bytes, fastest, no features |
qcow2 |
Sparse, snapshots, backing files |
vmdk |
VMware images |
vdi |
VirtualBox images |
vhdx |
Hyper-V images |
Monitor
Ctrl+a cCtrl+a xinfo statusinfo blockinfo networkstop / contsavevm <tag>
loadvm <tag>
delvm <tag>
system_powerdown
system_resetquitchange <dev> <file>
device_add <driver>,id=<id>
Recipes
qemu-img create -f qcow2 vm.qcow2 20Gqemu-system-x86_64 \ -accel kvm -cpu host -m 4G \ -drive file=vm.qcow2,if=virtio \ -cdrom <install.iso> -boot d
qemu-system-x86_64 -nographic \ -accel kvm -cpu host -m 2G \ -drive file=vm.qcow2,if=virtio \ -nic user,hostfwd=::2222-:22# then, from the hostssh -p 2222 <user>@localhost
qemu-img create -f qcow2 \ -b base.qcow2 -F qcow2 t.qcow2qemu-system-x86_64 -accel kvm \ -m 2G -drive file=t.qcow2,if=virtiorm t.qcow2
qemu-system-x86_64 -nographic \ -accel kvm -m 1G \ -kernel <bzImage> \ -append "console=ttyS0 root=/dev/vda" \ -drive file=<rootfs>,format=raw,if=virtio



