Operating Systems · UGC NET: Virtual Machines
Virtualization Benefits and Techniques
Overview
Virtualization is the creation of a virtual version of a computing resource, such as a CPU, memory, storage, network, or a complete machine, so that multiple isolated execution environments can share one physical system.
In operating-systems terms, a virtual machine monitor (VMM) or hypervisor controls the physical hardware and presents one or more virtual machines (VMs) to guest operating systems.
This topic belongs to System Software and OS Extras under Virtual Machines and depends on earlier ideas of CPU privilege levels, traps, page tables, memory translation, I/O control, and process isolation.
The exam expects both conceptual understanding and small numerical reasoning about memory allocation, live migration, and overcommitment.
Key concepts
- Host: the physical machine and, for hosted virtualization, the operating system on which the virtualization software runs. Guest: the operating system and applications running inside a VM.
- Hypervisor / VMM: software or firmware that multiplexes physical resources among VMs and enforces isolation.
- Type 1 hypervisor: runs directly on bare hardware, with no underlying host OS, e.g. VMware ESXi, Xen, Hyper-V, KVM in common textbook classification.
Type 2 hypervisor: runs as an application on a host OS, e.g. VirtualBox, VMware Workstation. - Full virtualization: the guest OS is unmodified and is presented with complete virtual hardware. It may be implemented by binary translation or hardware-assisted virtualization.
- Paravirtualization: the guest OS is modified to know it runs under a hypervisor and uses hypercalls for privileged operations. Performance overhead can be lower, but guest compatibility is reduced.
- Trap-and-emulate: the guest runs in a less-privileged mode; a privileged instruction executed by the guest traps to the hypervisor, which emulates it and resumes the guest.
- Popek and Goldberg requirements for classical virtualizability: equivalence, performance, and safety; functionally, every sensitive instruction must be privileged so that it traps.
Innocuous instructions should execute natively. - Hardware-assisted virtualization: Intel VT-x and AMD-V add CPU execution modes for hypervisors, so privileged guest operations cause VM exits to the VMM rather than requiring binary translation for every sensitive instruction.
- Shadow page tables: the hypervisor maintains page tables mapping guest virtual addresses directly to host physical addresses; guest page-table updates are trapped and validated.
- Nested paging / EPT / NPT: hardware performs two-level translation, guest virtual to guest physical, then guest physical to host physical, reducing VM exits.
- Memory overcommitment: configured VM memory may exceed physical RAM because not all allocated pages are simultaneously active.
Ballooning lets a cooperative guest driver release pages to the hypervisor; copy-on-write page sharing deduplicates identical pages until a write occurs. - Live migration: moving a running VM to another host with minimal downtime. Snapshot: a point-in-time state of VM disk or memory, often using copy-on-write deltas.
- Container: OS-level virtualization that shares the host kernel and uses namespaces and cgroups for isolation, giving higher density but weaker kernel isolation than a conventional VM.
- Benefits of virtualization include higher hardware utilization, server consolidation, lower power and cooling, isolation, rapid provisioning, testing, legacy support, disaster recovery, snapshots, and live migration.
Costs include CPU virtualization overhead, memory-translation overhead, I/O overhead, management complexity, and security exposure.
How it works
- Trap-and-emulate execution. The hypervisor runs a guest OS in a non-privileged or guest CPU mode.
When the guest executes a privileged instruction such as changing page tables or disabling interrupts, the CPU traps to the hypervisor.
The hypervisor checks the operation, emulates it on virtual hardware, updates virtual CPU state, and returns to the guest.
This works cleanly only when sensitive instructions are privileged; otherwise the guest could perform an unsafe operation without trapping. - Binary translation. The hypervisor scans guest kernel code, replaces problematic sensitive instructions with safe emulation or hypercalls, caches translated blocks, and executes the rest natively.
The guest remains unmodified, but translation and cache management add overhead. - Paravirtualization. The guest OS is modified to issue hypercalls for privileged operations instead of executing instructions that must be trapped. This avoids many trap-and-emulate costs but requires a modified guest.
- Hardware-assisted virtualization. The CPU provides a hypervisor mode and guest mode. The guest runs in guest mode; privileged operations cause VM exits to the hypervisor, and the hypervisor resumes the guest with a VM entry.
This reduces the need for binary translation for privileged instructions. - Memory translation. The guest uses guest virtual addresses mapped to guest physical addresses.
In shadow paging, the hypervisor maintains a shadow table mapping guest virtual directly to host physical; guest page-table writes are trapped.
In nested paging, hardware walks the guest page table and then a nested host page table, reducing exits. - Live migration. The source hypervisor copies VM memory to the destination while the VM runs. Modified dirty pages are recopied iteratively.
When the remaining dirty set is small, the VM is briefly paused, final state is copied, and execution resumes on the destination. Pre-copy converges only when the dirty-page rate is less than the migration link throughput. - Memory overcommitment. The hypervisor does not necessarily back every configured guest page with physical RAM immediately.
Ballooning asks a cooperative guest to release pages; page sharing merges identical pages using copy-on-write; swapping may handle pressure.
This raises density but risks performance degradation if working sets exceed physical memory.
Drawing the diagram…
Formulas
- Let be usable host RAM, the hypervisor reservation, and the configured memory per VM, all in the same unit. With no overcommitment:
- With overcommitment, configured memory may satisfy , but steady-state feasibility requires working sets to satisfy:
-
where is configured memory and is actual working-set memory of VM .
-
For pre-copy live migration, let be total memory to transfer in MB, the copy bandwidth in MB/s, and the dirty-page generation rate in MB/s. Pre-copy converges if . Ignoring stop-and-copy threshold and setup time:
- If the remaining dirty memory at stop time is MB, approximate downtime is:
Worked examples
Example 1: memory capacity. Geeta has a host with 48 GB usable RAM. The hypervisor reserves 6 GB and each VM is configured with 7 GB with no overcommitment. Compute the maximum number of VMs.
Available for VMs GB. Number . Check: GB exactly. Seven VMs would need GB, which exceeds 48 GB. Answer: 6 VMs.
Example 2: hypervisor type. Ramesh installs VMware Workstation on an Ubuntu laptop and runs a Windows guest VM. Identify the hypervisor type and explain where privileged guest operations are handled.
VMware Workstation is a Type 2 hosted hypervisor because it runs as an application on the host OS. A privileged guest instruction traps to the hypervisor, which emulates the virtual hardware operation; physical device access ultimately goes through the host OS. Answer: Type 2 hypervisor above the host OS.
Example 3: live migration. Ankur migrates a VM with 6 GB memory. The link gives 600 MB/s copy throughput and the VM dirties pages at 400 MB/s. Convert 6 GB to 6144 MB. Is convergence possible, what is the pre-copy time, and what is downtime if the final residual is 240 MB?
Convergence requires : , so yes. Initial copy time s. During it, dirty pages generated MB. Iterative total time s. Final downtime for 240 MB s plus state-transfer overhead.
Answer: converges; about 30.72 s pre-copy; about 0.4 s final downtime.
Example 4: statement type. Consider: I. Innocuous instructions should execute natively without hypervisor intervention. II. For classical trap-and-emulate, sensitive instructions must be privileged. III. Paravirtualization requires no change to the guest OS.
I is true by the Popek–Goldberg performance requirement. II is true; otherwise sensitive operations may not trap. III is false; paravirtualization modifies the guest to use hypercalls. Answer: I and II true, III false.
Example 5: match type. Match: A. Full virtualization, B. Paravirtualization, C. Shadow page tables, D. Live migration.
Descriptions: i. unmodified guest with virtual hardware; ii. modified guest using hypercalls; iii. hypervisor maps guest virtual directly to host physical; iv. transfer a running VM to another host.
Answer: A–i, B–ii, C–iii, D–iv.
Comparison
| Feature | Type 1 hypervisor | Type 2 hypervisor |
|---|---|---|
| Position | Directly on hardware | As an application on a host OS |
| Host OS | Not required | Required |
| Performance | Generally higher, especially for servers | Lower for I/O-heavy guests due to extra layer |
| Typical use | Data centres, servers | Desktops, testing, development |
| Examples | VMware ESXi, Xen, Hyper-V, KVM commonly classified Type 1 | VirtualBox, VMware Workstation |
| Technique | Guest modified? | Main mechanism | Main trade-off |
|---|---|---|---|
| Trap-and-emulate | No | Privileged instruction traps to hypervisor | Needs sensitive instructions privileged |
| Binary translation | No | Rewrites sensitive instructions dynamically | Translation and cache overhead |
| Paravirtualization | Yes | Hypercalls | Better efficiency but less compatibility |
| Hardware-assisted | No | CPU guest mode and VM exits | Hardware dependency; memory/I/O still virtualized |
| Point | Shadow page tables | Nested paging / EPT / NPT |
|---|---|---|
| Mapping | Guest virtual to host physical via shadow table | Guest virtual to guest physical, then host physical |
| Maintained by | Hypervisor software | CPU hardware with hypervisor setup |
| Guest page-table writes | Trapped and emulated | Generally not trapped for mapping itself |
| VM exits | More | Fewer |
| Requirement | Works on older CPUs | Requires hardware support |
| Point | Conventional VM | Container |
|---|---|---|
| Kernel | Separate guest kernel | Shares host kernel |
| Isolation | Strong hardware-level isolation | Process-level isolation via namespaces and cgroups |
| Startup | Slower, full OS boot | Fast |
| Density | Lower | Higher |
| Best use | Different OSes, strong isolation | Many similar services on one kernel |
Revision summary
- Host is physical; guest is virtual. Hypervisor/VMM controls resources.
- Type 1 = bare metal; Type 2 = hosted application.
- Classical trap-and-emulate needs sensitive instructions to be privileged.
- Paravirtualization modifies the guest and uses hypercalls.
- Binary translation rewrites sensitive guest instructions; guest remains unmodified.
- Shadow page tables are software-made direct guest-virtual-to-host-physical maps; nested paging is hardware two-level translation.
- No overcommit: .
- Live migration pre-copy converges only if dirty rate < link bandwidth .
- Ballooning reclaims guest memory cooperatively; copy-on-write sharing deduplicates pages.
- Snapshot is point-in-time state; live migration moves a running VM.
- Containers share the host kernel, so density is higher but kernel-level isolation is weaker.
Previous-year exam insights
- Direct concept questions ask the definition of host, guest, Type 1 vs Type 2 hypervisor, and the primary benefit of server virtualization, especially consolidation and reduced power/cooling.
- Trap-and-emulate questions ask the exact sequence: guest executes privileged instruction, traps to hypervisor, hypervisor emulates, guest resumes.
- Technique-matching questions mix trap-and-emulate, shadow page tables, ballooning, hypercalls, VM exits, snapshots, live migration, and copy-on-write sharing.
- Statement questions test whether paravirtualization needs a modified guest, whether hardware-assisted virtualization adds CPU modes, and whether innocuous instructions run natively.
- Assertion–reason questions often contrast benefits with overhead: virtualization improves utilization but adds CPU, memory, and I/O overhead because resources are shared.
- Numeric questions use and live-migration convergence condition ; check units, especially GB to MB conversion.
- Common traps: confusing shadow page tables with nested paging, calling containers “VMs”, assuming live migration always converges, and forgetting the hypervisor memory reservation.
- Check first: host/guest terminology, which layer performs the action, whether the guest is modified, and whether the question asks for a benefit or a mechanism.
Practice at PARIKSHA
You are ready for the PARIKSHA tests of this sub-topic when you can:
- define host, guest, hypervisor, Type 1, and Type 2 without confusion;
- explain trap-and-emulate step by step and state the Popek–Goldberg sensitive-instruction condition;
- distinguish full virtualization, binary translation, paravirtualization, and hardware-assisted virtualization;
- compare shadow page tables with nested paging and explain why nested paging reduces VM exits;
- explain ballooning, memory overcommitment, and copy-on-write page sharing in one sentence each;
- compute the maximum number of VMs from host RAM, hypervisor reservation, and per-VM memory;
- decide whether live migration converges from dirty rate and link bandwidth, and compute approximate transfer time;
- match techniques such as snapshot, live migration, hypercall, VM exit, and ballooning to their functions;
- distinguish a conventional VM from a container using kernel sharing, isolation, startup, and density;
- identify the benefit and the overhead side of virtualization in assertion–reason questions.
Attempt the sub-topic test first, then the subject test.