---
title: "Virtual machine"
url: https://www.daytona.com/compute-glossary/virtualization/virtual-machine
---

# Virtual machine

Part of the [Compute Glossary](https://www.daytona.com/compute-glossary.md), section [Virtualization](https://www.daytona.com/compute-glossary/virtualization.md).

Also called VM, Guest.

A virtual machine is a software-defined computer that runs a complete operating system, its own [kernel](https://www.daytona.com/compute-glossary/kernel/kernel.md) included, as if it owned the hardware. The physical machine underneath is the host, and the operating system inside is the guest. One host can run many guests, each unaware of the others. To the software inside, nothing looks different from a real computer.

A [hypervisor](https://www.daytona.com/compute-glossary/virtualization/hypervisor.md) decides which physical resources back each guest and keeps guests apart. Most guest code runs directly on the physical processor, so a guest runs close to the speed of the host. Only the events the hypervisor chooses to intercept, such as privileged instructions or access to a virtual device, are trapped and handled by it. Each guest behaves as if it had the processor to itself.

Because the whole machine is defined in software, its state can be saved as a [snapshot](https://www.daytona.com/compute-glossary/sandboxes/snapshot.md) and restored later, on the same host or another. The same property lets one host run guests of different operating systems side by side. A saved disk can also be copied to start many identical machines, which is how cloud images work. Backups and rollbacks can work on a whole machine for the same reason.

## Virtual hardware

Virtual hardware is the machine a guest sees, built from the resources of the host. Its processors are [vCPUs](https://www.daytona.com/compute-glossary/virtualization/vcpu.md), threads on the host that run guest code directly, and its memory is host memory mapped in by the processor. A guest can be given more or fewer vCPUs than the host has cores, within limits. Memory can be resized too, through hot-plug or a balloon driver, if the guest supports it.

Disks and network cards are usually paravirtual devices such as virtio. A guest driver talks to them through queues in shared memory instead of through an emulated copy of real hardware, which is faster and simpler. Guests need matching drivers, which mainstream operating systems now ship. The guest then knows it runs in a virtual machine and cooperates with the hypervisor.

A device can also be passed through whole, so the guest drives a real network card or [GPU](https://www.daytona.com/compute-glossary/hardware/gpu.md) itself. Passthrough gives native device speed but ties the guest to the hardware of that host. Some devices can be split into slices, each passed through to a different guest. That lets several guests share one card at close to native speed.

## Live migration

Live migration is the move of a running guest from one host to another without stopping it. The hypervisor copies the guest's memory in rounds while the guest keeps running, and sends again the pages that changed. Each round has fewer changed pages to send, so the rounds get shorter. A guest that writes memory faster than the network can send it never catches up, so the hypervisor may slow it down to finish.

When little is left to move, the guest pauses briefly while the last pages and its device state are copied. It then resumes on the new host and carries on from where it stopped. Network traffic is redirected to the new host, so open connections survive. The pause is usually short enough that users do not notice.

Migration lets operators repair or replace a host without shutting down its guests. It works only when every device of the guest can be recreated on the new host, which rules out most passthrough hardware. It also needs hosts with compatible processors, since a guest cannot lose processor features it already uses.

## Overhead

The overhead of a virtual machine is the cost of booting and running a guest kernel before any workload starts. A general-purpose virtual machine also boots firmware and emulates a full PC, which adds time and memory. Each guest also keeps its own kernel caches in memory, which the host cannot easily share. Booting also takes time that a long-running server barely notices but a short task does.

That cost is why [microVMs](https://www.daytona.com/compute-glossary/virtualization/microvm.md) exist. They keep the hardware [isolation boundary](https://www.daytona.com/compute-glossary/sandboxes/isolation.md) and drop most of the machine around it, so short-lived workloads can each get a kernel of their own. Restoring a snapshot cuts the cost further, since a restored guest skips the boot. The guest kernel still costs memory, but far less time.

A [container](https://www.daytona.com/compute-glossary/virtualization/container.md) avoids the cost by sharing the host kernel, but a flaw in that kernel can expose every container on the host. A guest that breaks its own kernel still has to get through the hypervisor. The choice weighs the cost of a kernel per workload against how far the workload is trusted. For code from unknown sources, most operators now accept that cost.

| **Kind**                            | **Kernel**            | **Boundary**                                | **Start time**                                    | **Overhead**                                                |
| ----------------------------------- | --------------------- | ------------------------------------------- | ------------------------------------------------- | ----------------------------------------------------------- |
| **General-purpose virtual machine** | Its own.              | Hardware virtualization and the hypervisor. | Seconds.                                          | A guest kernel and tens to hundreds of megabytes of memory. |
| **MicroVM**                         | Its own.              | Hardware virtualization and the hypervisor. | Much less than a general-purpose virtual machine. | A small guest kernel and a few megabytes for the monitor.   |
| **Container**                       | Shared with the host. | Kernel features.                            | Usually well under a second.                      | A few processes.                                            |

## Related terms

- [Hypervisor](https://www.daytona.com/compute-glossary/virtualization/hypervisor.md)
- [vCPU](https://www.daytona.com/compute-glossary/virtualization/vcpu.md)
- [MicroVM](https://www.daytona.com/compute-glossary/virtualization/microvm.md)
- [Container](https://www.daytona.com/compute-glossary/virtualization/container.md)
- [Isolation](https://www.daytona.com/compute-glossary/sandboxes/isolation.md)
- [Snapshot](https://www.daytona.com/compute-glossary/sandboxes/snapshot.md)
