# KVM for application engineers: what hardware virtualization gives you that namespaces do not

> A plain explanation of KVM, the VMM, vCPUs and guest kernels, and why a virtual machine boundary differs from a container boundary when you run code you did not write. No kernel background needed.

A plain explanation of KVM, the VMM, vCPUs and guest kernels, and why a virtual machine boundary differs from a container boundary when you run code you did not write. No kernel background needed.

November 26, 2026 · 4 min read · The Sandscale team

If you run agent code, you will hear “microVM” and “KVM” a lot, usually next to “stronger than containers”. That claim is right, but it is easy to repeat without knowing why. This post explains the moving parts in application-engineer terms: what KVM is, what the VMM does, what a guest kernel is for, and which attacks the boundary actually changes.

Sources are the Linux kernel’s [KVM API documentation](https://docs.kernel.org/virt/kvm/api.html) and Firecracker’s [design document](https://github.com/firecracker-microvm/firecracker/blob/main/docs/design.md).

## Start with what a container is

A container is a normal Linux process with a restricted view. Namespaces give it its own view of process IDs, mounts, network and hostname. Cgroups limit its CPU and memory. Seccomp filters which system calls it may make. All of that is enforced by **the host kernel**, and the container talks to that kernel directly every time it opens a file, allocates memory or sends a packet.

So the host kernel is the wall, and the container is standing right next to it, able to call any system call the filter allows. If one of those calls has a bug, the container is one bug away from the host. Our post on [four container escapes](https://sandscale.dev/blog/container-escape-cves-lessons-for-agent-sandboxes) walks through real examples.

## What KVM adds

Modern x86 and Arm CPUs have virtualization extensions (Intel VT-x, AMD-V, Arm’s virtualization extensions). They let the CPU run code in a special guest mode where privileged operations, such as touching page tables or talking to hardware, trap out to a supervisor instead of happening directly.

**KVM** is the part of the Linux kernel that uses these extensions. It exposes `/dev/kvm`, and a user-space program can ask it, through `ioctl` calls described in the kernel’s KVM API docs, to create a virtual machine, give it memory, create virtual CPUs and run them. Each vCPU is a thread on the host. When the guest does something the hardware will not let it do on its own, the CPU exits back to KVM, which handles it or passes it up to user space.

Memory isolation is done by the hardware too. The guest has its own page tables, and a second level of translation (Intel EPT, AMD NPT) maps guest-physical memory to host memory. The guest cannot form an address that reaches memory it was not given.

## The VMM: the program that owns the VM

KVM does not emulate disks or network cards. A user-space **virtual machine monitor** does: QEMU, Cloud Hypervisor or Firecracker. It opens `/dev/kvm`, sets up the VM, and emulates the devices the guest sees, usually as virtio devices, which are simple, paravirtualized interfaces designed for VMs.

The VMM’s size matters for security, because when the guest talks to a virtual device, it is talking to VMM code. Firecracker’s design document states the goal plainly: a minimal device model (a virtio network device, a virtio block device, a serial console, and a few others) so there is less code for a guest to attack. It also runs each VMM inside a jailer with seccomp filters, cgroups and namespaces, so a compromised VMM process still has very little access. We covered that layer in [Firecracker’s jailer and seccomp](https://sandscale.dev/blog/firecracker-jailer-and-seccomp-explained).

## The guest kernel: why “its own kernel” matters

Inside the VM runs a complete Linux kernel, the guest kernel. The agent’s code makes system calls to **that** kernel, not to the host’s. A bug in the guest kernel’s file system code lets an attacker take over the guest kernel, which is a VM that was already theirs. To reach the host they need a second bug: in KVM’s handling of VM exits, or in the VMM’s device emulation.

That is the whole argument for VMs over containers, in one line: the attack surface exposed to untrusted code moves from the host kernel’s full system call interface to the much narrower interface of virtual hardware.

## What the boundary does not change

A VM boundary is not a guarantee, and it does not solve everything:

- **Hypervisor and VMM bugs exist.** They are rarer and the surface is smaller, but they are not zero. Keep hosts patched.
- **Hardware side channels** cross VM boundaries in some cases. Mitigations live in microcode, kernels and how workloads are scheduled.
- **Anything you hand the VM is theirs.** Credentials in its environment, a network path to your database, a mounted directory: the VM boundary does nothing for data you gave the guest.
- **Network policy is a separate layer.** Firecracker’s design document notes it does not filter egress itself. Something outside must decide what the VM can reach.

## Why this used to be too heavy, and is not now

Traditional VMs emulate a full PC, boot through firmware and carry a large device model, which made them expensive to start for each short task. MicroVM monitors such as Firecracker strip that down: a minimal device set and a small, purpose-built VMM. That is why per-run VMs became practical for serverless functions and now for agent code.

## Where Sandscale fits

Sandscale runs every agent run in its own Firecracker microVM with its own kernel, so nothing is shared with the run next to it. The network is a separate layer: sandboxes start with network mode `none`, and `allowlist` opens only your organization’s egress allowlist. See [sandboxes](https://sandscale.dev/sandboxes) and [security](https://sandscale.dev/security).

If you take one thing from this post, take the question it gives you for any sandbox: when untrusted code makes a system call, whose kernel answers it?

**On this page**

1. Start with what a container is
2. What KVM adds
3. The VMM: the program that owns the VM
4. The guest kernel: why “its own kernel” matters
5. What the boundary does not change
6. Why this used to be too heavy, and is not now
7. Where Sandscale fits

**Run your agents in a box of their own**

Each sandbox is a Firecracker microVM. Free includes 100 awake vCPU-hours a month.

[Start free](https://cloud.sandscale.dev/auth/signup)

## Keep reading

- [November 26, 2026 · **30 questions to ask any agent sandbox provider before you sign up** · A vendor-neutral checklist for choosing where your agents run code: isolation, network, secrets, lifecycle, billing for waiting time, governance, data location, reliability and leaving. With where to find each answer for Sandscale.](https://sandscale.dev/blog/questions-to-ask-an-agent-sandbox-provider)
- [November 26, 2026 · **Agent sandbox glossary: 41 terms in plain English** · Plain definitions for the words that come up when you run AI agent code in isolation: microVM, VMM, KVM, jailer, gVisor, seccomp, namespaces, egress allowlist, lease, snapshot, warm pool, awake vCPU-hour and more.](https://sandscale.dev/blog/agent-sandbox-glossary)

---
Source: https://sandscale.dev/blog/kvm-basics-for-application-engineers
