📝 Type 2 hypervisor hosted (9 MCQs)
Virtualisation Software Hosted by an Operating System
A Type 2 hypervisor is virtualisation software that runs as an application on a conventional host operating system. It creates virtual hardware environments and executes guest operating systems within them. The host OS manages physical device drivers and basic hardware access, while the hosted hypervisor coordinates guest CPU execution, memory, virtual disks, and network interfaces.
Why Desktop Users Need Virtual Machines Without Rebooting
Developers and users often need a separate operating system for testing, compatibility, or training without replacing their primary environment. A hosted hypervisor allows a guest to run alongside ordinary host applications. This convenience depends on the host operating system and introduces an additional software layer between guests and physical hardware.
Guest Execution Through the Host Operating System
The user launches the virtualisation application and creates a virtual machine configuration. The hypervisor allocates guest resources and uses host OS services and drivers to access hardware. Guest instructions may execute with processor support, while virtual disk and network requests pass through the host's storage and networking facilities.
Example of Running Linux on a Windows Laptop
A developer uses a Windows laptop with 16 GB RAM and installs a hosted hypervisor. A Linux guest receives four virtual CPUs and 6 GB memory. The guest runs a web server while Windows continues to support ordinary applications, sharing processor, memory, storage, and network resources.
Convenience and Dependence on Host Performance
Type 2 hypervisors are useful for desktop testing, software development, demonstrations, and running alternate operating systems. Their extra software layer can introduce overhead, and host resource shortages affect guest performance. A host OS crash can interrupt every hosted guest, while desktop hardware may provide fewer enterprise management and availability features.
Misconceptions About Hosted Hypervisors
'A Type 2 hypervisor replaces the host operating system' is false because it depends on that system. 'Guests cannot run while host applications are active' ignores shared execution. 'Every Type 2 VM is slower in every workload' is too broad because hardware support and workload characteristics affect actual performance.
Exam Focus: Host OS and Guest Execution Layers
Draw the host operating system, hosted hypervisor, virtual hardware, and guest operating system in the correct order. Compare this structure with a Type 1 hypervisor. Questions may ask how device access reaches physical hardware or why host OS failures and resource contention affect hosted guests.
Key Terms of Type 2 Hypervisors
- Type 2 - Hypervisor hosted by an operating system.
- Host OS - Operating system running the hypervisor application.
- Guest OS - Operating system inside the virtual machine.
- Virtual hardware - Devices presented to a guest.
- Host driver - Software controlling physical host devices.
📝 All Type 2 hypervisor hosted MCQs
Q1. What term describes the virtual representation of a CPU that a VMM maintains for each guest?
📖 Explanation: The correct answer is VCPU because the VMM creates a data structure that holds the guest’s registers, flags, and control state, effectively mimicking a physical CPU for that guest. \Virtual Register Set\ is a vague phrase that does not convey the full context of virtualization. \Guest Thread\ refers to a thread of execution, not the CPU state. \HyperThread\ is a hardware feature unrelated to virtual CPUs. In real systems the VCPU enables the hypervisor to save and restore guest state quickly, similar to a PCB for processes.
Q2. Why does a type‑2 hypervisor depend on the host operating system's kernel for device access?
📖 Explanation: The correct answer is that it uses the host’s device drivers because the hypervisor runs as an application on top of the host OS and therefore relies on the host kernel to interact with hardware. Saying it runs in kernel mode is false; a type‑2 hypervisor runs in user mode. Claiming it provides its own drivers ignores the fact that most drivers are already present in the host. Replacing the host kernel would describe a type‑1 hypervisor, not a type‑2 solution.
Q3. A guest OS tries to execute a privileged instruction while running under a type‑2 hypervisor. Which mechanism handles this situation?
📖 Explanation: Trap-and-emulate is the correct mechanism because the privileged instruction causes a trap that the VMM intercepts and then emulates the required effect in software. Binary translation would rewrite code ahead of time, which is not the immediate response to a trap. Direct execution would allow the instruction to run unmodified, violating protection. I/O virtualization deals with device access, not privileged CPU instructions. In practice the trap‑and‑emulate flow preserves isolation while letting the guest think it ran in kernel mode.
Q4. How does trap-and-emulate keep the guest kernel isolated from the physical kernel?
📖 Explanation: Converting privileged instructions into traps is the correct answer because each time the guest kernel attempts a privileged operation, the CPU raises a trap that the VMM catches and emulates, preventing the guest from executing in real kernel mode. Sharing page tables would expose both kernels to each other’s memory. Allowing the guest kernel to run in kernel mode defeats isolation. Binary translation is a different technique that rewrites code, not the trap mechanism. This approach is what enables safe multi‑tenant environments.
Q5. If the host CPU lacks virtualization extensions, which technique can a type‑2 hypervisor employ to run an unmodified guest OS?
📖 Explanation: Binary translation is the correct technique because it dynamically rewrites guest code that contains privileged instructions into safe sequences that can run in user mode. Paravirtualization requires the guest to be modified to call hypervisor interfaces, which contradicts “unmodified.” Hardware‑assisted virtualization is unavailable without CPU support. Direct execution would allow privileged instructions to run unchecked, breaking isolation. Binary translation therefore provides a software‑only path to virtualization on legacy hardware.
Q6. A cloud provider runs several Linux VMs on a Windows host using a type‑2 hypervisor. What is the primary role of the VCPU for each VM?
📖 Explanation: Providing a snapshot of the guest’s CPU state for context switches is correct because the VCPU records registers, flags, and control information so the hypervisor can pause one VM and resume another efficiently. Simply storing registers is incomplete without the context‑switch purpose. Network I/O and storage I/O are handled by virtual devices, not by the VCPU structure. In real deployments this snapshot mechanism allows many VMs to share the same physical core without losing their execution state.
Q7. What is the main limitation of trap-and-emulate without hardware support when a guest OS makes frequent system calls?
📖 Explanation: High overhead due to frequent mode switches is the correct limitation because each system call triggers a trap that the VMM must handle, causing many transitions between user and kernel modes and slowing performance. Virtualizing memory is still possible, though slower. I/O virtualization is a separate concern and can be implemented independently. Scheduling VMs is managed by the hypervisor’s scheduler, not directly affected by the trap mechanism. This overhead is why hardware‑assisted virtualization is desirable for high‑frequency calls.
Q8. When a guest OS receives an interrupt, which sequence correctly describes the trap‑and‑emulate process in a type‑2 hypervisor?
📖 Explanation: The correct sequence is that the guest’s privileged instruction causes a trap, the VMM emulates the interrupt handling, and then control returns to the guest, because the hypervisor must intercept the interrupt while the guest thinks it ran in kernel mode. Receiving the interrupt directly would break isolation. Forwarding to the host OS adds an unnecessary layer and does not preserve the guest’s view. Ignoring the interrupt would lead to missed events. This flow ensures that the guest perceives a normal interrupt while the hypervisor maintains security.
Q9. In a typical type‑2 hypervisor, in which CPU mode does the hypervisor itself execute?
📖 Explanation: User mode is the correct answer because a type‑2 hypervisor runs as an ordinary application on top of the host operating system, therefore it executes in the host’s user space. Running in kernel mode would imply a type‑1 hypervisor or a kernel module. “Hypervisor mode” is not a standard CPU mode, and “Supervisor mode” is another name for kernel mode on some architectures, which again does not describe a type‑2 hypervisor. Understanding this distinction helps administrators know the privilege level and potential performance impact of the hypervisor.