# QEMU — Open-Source Machine Emulator and Virtualizer > A generic open-source machine emulator and virtualizer that can run operating systems for any architecture on any supported host. ## Install Save in your project root: # QEMU ## Quick Use ```bash sudo apt install qemu-system-x86 # Create a disk and boot an ISO: qemu-img create -f qcow2 disk.qcow2 20G qemu-system-x86_64 -hda disk.qcow2 -cdrom ubuntu.iso -m 4096 -enable-kvm -boot d ``` ## Introduction QEMU (Quick Emulator) is an open-source machine emulator and virtualizer. In emulation mode it can run software built for one CPU architecture on another. When paired with KVM on Linux, it becomes a high-performance hypervisor capable of running virtual machines at near-native speed. QEMU underpins many cloud platforms and virtualization tools. ## What QEMU Does - Emulates full systems including CPU, memory, storage, and network devices for 20+ architectures - Provides near-native VM performance when combined with KVM hardware acceleration - Creates and manages disk images in qcow2, raw, vmdk, and other formats - Supports live migration of running VMs between physical hosts - Offers user-mode emulation for running individual binaries built for foreign architectures ## Architecture Overview QEMU uses a Tiny Code Generator (TCG) for dynamic binary translation when emulating foreign architectures. With KVM enabled, it offloads CPU virtualization to the Linux kernel via `/dev/kvm`, handling only device emulation in userspace. QEMU models each VM as a process with threads for vCPUs and I/O. Virtio paravirtualized devices provide efficient disk, network, and memory balloon interfaces between guest and host. ## Self-Hosting & Configuration - Install via package managers: `apt install qemu-system` or `dnf install qemu-kvm` - Enable KVM by loading the `kvm_intel` or `kvm_amd` kernel module - Create disk images with `qemu-img create -f qcow2` for copy-on-write snapshots - Pass `-enable-kvm -cpu host` for best performance on compatible hardware - Use `-nic user` for simple NAT networking or `-nic tap` for bridged access ## Key Features - Supports x86, ARM, RISC-V, MIPS, PowerPC, s390x, and many more architectures - Snapshot and rollback of entire VM state including memory and disk - Live migration for moving VMs between hosts with minimal downtime - Virtio device framework for high-throughput paravirtualized I/O - Serves as the backend for libvirt, Proxmox, OpenStack, and Firecracker ## Comparison with Similar Tools - **VirtualBox** — desktop-focused with a GUI; QEMU is more flexible and powers production cloud infrastructure - **VMware ESXi** — enterprise hypervisor with proprietary management; QEMU/KVM is free and equally performant - **Firecracker** — micro-VM engine built on KVM for serverless; QEMU provides full system emulation with richer device support - **Hyper-V** — Windows-native hypervisor; QEMU/KVM is the Linux standard and supports cross-architecture emulation ## FAQ **Q: How does QEMU relate to KVM?** A: KVM is a Linux kernel module that provides hardware virtualization. QEMU uses KVM for CPU acceleration and handles device emulation, networking, and disk I/O. **Q: Can QEMU run macOS guests?** A: Technically possible with the right configuration, but Apple restricts macOS to Apple hardware in their EULA. **Q: What is qcow2?** A: QEMU Copy-On-Write v2 is a disk image format supporting snapshots, compression, and thin provisioning. **Q: Is QEMU suitable for production workloads?** A: Yes. With KVM acceleration, QEMU powers major cloud providers and enterprise virtualization platforms like OpenStack and Proxmox. ## Sources - https://github.com/qemu/qemu - https://www.qemu.org/docs/master/ --- Source: https://tokrepo.com/en/workflows/6cd0348b-43e8-11f1-9bc6-00163e2b0d79 Author: AI Open Source