KVM/QEMU Virtualization Setup on Linux
Sometimes bare metal hits cost or flexibility limits — and then KVM/QEMU comes in. Clients often come with a problem: "We want virtualization, but without vendor lock-in and with full control." We configure KVM/QEMU turnkey, integrating it into your stack: Terraform, Ansible, GitOps, Prometheus. No GUI, only CLI and API — maximum performance and zero licensing costs. Over the past 5 years, we have implemented more than 50 virtualization projects based on KVM — from small labs to production clusters with 200+ virtual machines. Average budget savings compared to commercial hypervisors — about 40% due to the absence of license fees.
Why Choose KVM/QEMU for Production?
Proxmox is convenient, but its updates and licensing (Community vs Enterprise) may not suit strict environments. KVM/QEMU is a Linux kernel module: you get native performance, not an abstraction layer. According to Red Hat documentation, with VirtIO guests run at 95–98% of bare metal. Live migration, CPU balancing via virsh vcpupin, SLO under 99.9% — all available out of the box without additional overlays. For example, in one project we replaced VMware vSphere with KVM — licensing costs dropped 5 times, and performance increased by 12% thanks to direct kernel access.
How to Ensure KVM Fault Tolerance?
For high-availability environments, we use a combination of live migration and shared storage (NFS, Ceph). Locking setup according to the "2-3 hosts + Quorum" scheme via corosync/pacemaker. Average recovery time (RTO) upon node failure — no more than 15 minutes. Backup plan: qcow2 snapshots every 4 hours, full backup once daily to a separate server. For critical VMs, we configure automatic restart on the neighboring host.
What We Do as Part of KVM/QEMU Setup
- Hardware audit: check support for VT-x/AMD-V, IOMMU, NUMA. Optimize vCPU and memory placement. On a typical server with 2 sockets of 16 cores each and 256 GB RAM, you can host up to 30 medium-load VMs.
- Installation and configuration: qemu-kvm, libvirt-daemon, bridge-utils, virtinst. Set up default network (NAT or bridge).
- Network: create bridge interfaces, VLANs (bridge per VLAN), Open vSwitch optionally. Guarantee NetworkPolicy and isolation. Example: for microservice architecture, we set up one bridge per project.
- Storage: qcow2 with
cache=none,io=native, LVM thin provisioning. Connect NFS/Ceph for live migration. - VM templates: cloud-init, images of Ubuntu 22.04 LTS, Debian 12, CentOS Stream 9. Everything via
virt-installor Terraform. - Monitoring: Prometheus + libvirt_exporter, Grafana dashboards. Metrics: CPU steal, disk latency, memory ballooning.
- Backups: virt-backup or rsync snapshots. RPO — 1 hour, RTO — 15 minutes.
How to Set Up KVM Monitoring?
Install libvirt_exporter, attach it to Prometheus. Grafana has ready-made dashboards. Key metrics:
-
kvm_domain_info— guest states -
kvm_domain_cpu_time_seconds— steal time -
kvm_domain_balloon_current_bytes— memory leaks
Alerting by MTTR and SLO. Runbook: if steal exceeds 10% — check CPU pinning or load on neighboring VMs.
Network Bridge for VMs
Create a Linux bridge like this:
# /etc/netplan/01-bridge.yaml (Ubuntu)
network:
version: 2
ethernets:
enp3s0:
dhcp4: false
bridges:
br0:
interfaces: [enp3s0]
addresses: [192.168.1.10/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8]
parameters:
stp: false
forward-delay: 0
netplan apply
For VLAN-tagged traffic, create br-vlan300 over enp3s0.300 — each VLAN gets its own bridge, VMs connect to the appropriate one.
Creating a VM via qemu-system and virt-install
# Create VM disk (qcow2 — thin provisioned, supports snapshots)
qemu-img create -f qcow2 /var/lib/libvirt/images/webserver01.qcow2 40G
# Install VM from ISO
virt-install \
--name webserver01 \
--ram 4096 \
--vcpus 4 \
--cpu host \
--disk path=/var/lib/libvirt/images/webserver01.qcow2,format=qcow2,bus=virtio \
--network bridge=br0,model=virtio \
--os-variant ubuntu22.04 \
--cdrom /tmp/ubuntu-22.04-server.iso \
--graphics none \
--console pty,target_type=serial \
--extra-args 'console=ttyS0,115200n8'Key point: --cpu host passes real processor flags to the VM — maximum performance. If VMs need to migrate between hosts with different CPUs, use --cpu qemu64 for compatibility.
bus=virtio and model=virtio — paravirtualized drivers for disk and network. Performance is significantly higher than emulated IDE/e1000 (3–5 times). Guest OS must have VirtIO drivers (in Linux they are built into the kernel, Windows requires separate installation).
Snapshots and Cloning
# Create a snapshot before update
virsh snapshot-create-as webserver01 \
--name "before-update" \
--description "Before kernel update" \
--atomic
# List snapshots
virsh snapshot-list webserver01
# Revert to snapshot
virsh snapshot-revert webserver01 before-update
# Clone VM
virt-clone --original webserver01 \
--name webserver02 \
--file /var/lib/libvirt/images/webserver02.qcow2qcow2 snapshots store only delta from the base image. With a deep snapshot chain, disk performance degrades — merge old snapshots via qemu-img commit. Manage snapshots via libvirt.
Performance and Tuning
For I/O-intensive VMs, enable cache=none,io=native on disks — disables double caching between guest and host. For network loads — multiqueue on virtio-net: number of queues = number of VM vCPUs.
CPU pinning for latency-sensitive workloads:
# Bind VM vCPUs to specific physical cores virsh vcpupin webserver01 0 2 virsh vcpupin webserver01 1 3 | Parameter | Production Value | Effect |
|---|---|---|
cache=none,io=native | Yes | ↑ IOPS by 20–30% |
multiqueue | Number of vCPUs | ↑ network throughput |
| CPU pinning | Dedicated cores | ↓ latency, ↑ stability |
--cpu host | All flags | Maximum performance |
KVM vs Alternatives
| Hypervisor | License | Performance | Savings |
|---|---|---|---|
| KVM/QEMU | GPL (free) | 95–98% bare metal | up to 40% budget |
| VMware vSphere | Paid (per CPU/year) | ~90% | - |
| Hyper-V | Windows License | ~90% | - |
| Proxmox VE | GPL + Subscription | ~95% | moderate |
What's Included in Our KVM/QEMU Setup Service
- Infrastructure audit: analyze current loads, select CPU/RAM/disks.
- Installation and configuration: KVM, libvirt, bridge, storage, cloud-init.
- Create VM templates: Ubuntu, Debian, CentOS, Windows Server (with VirtIO drivers).
- Integrate monitoring: Prometheus + Grafana dashboards, SLO alerts.
- Documentation: network diagram, recovery runbook, backup plan.
- Team training: 2–3 sessions on managing virsh, virt-manager (optional).
We've been working with KVM for over 5 years, have delivered projects for 50+ companies — from startups to enterprise.
Setup timeline: from 3 to 5 business days — turnkey, with SLA 99.9% guarantee.
Order an audit of your infrastructure — we'll assess the project and propose the optimal solution. Contact us for a consultation.
Key parameters checklist before starting a VM
- [ ] VT-x/AMD-V support verified in BIOS
- [ ] IOMMU enabled in GRUB (intel_iommu=on)
- [ ] Bridge configured for networking
- [ ] virtio model selected for disk and network
- [ ] CPU pinning assigned for critical VMs
- [ ] Alerts set up for steal and ballooning







