Virtual Machine
A virtual machine (VM) is a software-based emulation of a computer. It runs an operating system and applications as if it were a separate physical computer — but it's actually running inside another computer. VMs are used everywhere: cloud computing, software testing, server management, and sandboxing.
Learning Objectives
- 12.3.4.3 Explain the concept of a virtual machine
Conceptual Anchor
The Apartment Building Analogy
A physical computer is like a building. A virtual machine is like an apartment within that building — it has its own rooms (memory), kitchen (CPU allocation), and entrance (network), but shares the building's structure. The hypervisor is the building manager — it allocates space, prevents apartments from interfering with each other, and manages shared resources.
What Is a Virtual Machine?
| Concept | Explanation |
|---|---|
| Virtual machine | A software emulation of a physical computer, running its own OS and applications |
| Host machine | The physical computer that provides the hardware resources |
| Guest machine | The virtual machine running on the host — it "thinks" it has its own hardware |
| Hypervisor | Software that creates and manages VMs by allocating hardware resources |
| Isolation | Each VM is isolated — a crash or virus in one VM does NOT affect others |
Types of Hypervisor
| Feature | Type 1 — Bare Metal | Type 2 — Hosted |
|---|---|---|
| Runs on | Directly on hardware (no host OS needed) | On top of a host OS (like an application) |
| Performance | Better — less overhead | Slower — extra layer (host OS) |
| Use case | Data centres, cloud servers | Personal use, testing, development |
| Examples | VMware ESXi, Microsoft Hyper-V, Xen | VirtualBox, VMware Workstation, Parallels |
✓ Architecture Diagram
━━ Type 1 (Bare Metal) ━━ ━━ Type 2 (Hosted) ━━
┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐
│ VM 1 │ │ VM 2 │ │ VM 3 │ │ VM 1 │ │ VM 2 │
│ (Win)│ │(Linux│ │(macOS│ │ (Win)│ │(Linux│
└──────┘ └──────┘ └──────┘ └──────┘ └──────┘
┌─────────────────────────┐ ┌─────────────────────┐
│ Hypervisor │ │ Hypervisor │
│ (Type 1) │ │ (VirtualBox/VMware) │
└─────────────────────────┘ ├─────────────────────┤
┌─────────────────────────┐ │ Host OS │
│ Physical Hardware │ │ (Windows/macOS) │
└─────────────────────────┘ ├─────────────────────┤
│ Physical Hardware │
└─────────────────────┘Advantages & Disadvantages
| ✅ Advantages | ❌ Disadvantages |
|---|---|
| Isolation — VMs are independent; a crash in one doesn't affect others | Performance overhead — VMs are slower than running directly on hardware |
| Cost savings — run multiple servers on one physical machine | Resource sharing — VMs compete for CPU, RAM, and storage |
| Testing — test software in different OS environments safely | Complexity — requires hypervisor management and configuration |
| Snapshots — save VM state and restore if something goes wrong | Hardware support — needs powerful hardware with virtualisation support |
| Security — malware in a VM stays contained within the VM | Licensing — each guest OS may need its own licence |
| Portability — VM files can be moved between physical hosts | Not for high-performance — gaming, GPU-intensive tasks suffer |
Real-World Use Cases
| Use Case | How VMs Help |
|---|---|
| Cloud computing | AWS, Azure, Google Cloud run thousands of VMs on shared hardware |
| Software development | Developers test apps on different OSes without needing multiple physical machines |
| Server consolidation | Run 10 virtual servers on 1 physical server instead of buying 10 machines |
| Legacy software | Run old software (e.g., Windows XP apps) in a VM on modern hardware |
| Cybersecurity | Analyze malware in an isolated VM — if it destroys the VM, just restore |
| Education | Students can practice with Linux/servers without risk to school computers |
Pitfalls & Common Errors
Thinking VMs Are Physical Computers
A VM does NOT have its own physical hardware. It emulates hardware using software. The hypervisor allocates portions of the host's CPU, RAM, and storage to each VM.
Confusing VMs with Docker Containers
VMs emulate entire computers (including OS). Containers share the host OS kernel and are lighter, but provide less isolation. For exams, focus on VMs — containers are a related but different concept.
Pro-Tips for Exams
VM Question Strategy
- Define VM → software emulation of a physical computer
- Mention the hypervisor and explain its role (resource allocation + isolation)
- Give at least 3 advantages: isolation, cost savings, snapshots
- Give at least 2 disadvantages: performance overhead, resource competition
- Provide a real-world example: cloud computing, testing environments
Graded Tasks
Define: virtual machine, hypervisor, host machine, guest machine. Give 2 examples of hypervisors.
Explain how a hypervisor manages resources between multiple virtual machines running on one physical computer.
A company has 5 physical servers, each running one application. Explain how virtual machines could reduce costs while maintaining the 5 separate applications.
Compare Type 1 and Type 2 hypervisors. Explain when each would be the better choice.