How Xen does I/O virtualization
As a concrete example, we discuss Xen Project's approach to I/O virtualization. As we pointed out earlier, to get around the problem of having device drivers for the hypervisor as well as the guest OSs, Xen Project collocates its hypervisor with a traditional general-purpose OS. Figure 4 shows a host OS and the Xen Project hypervisor executing in full privileges at ring 0. Guest OSs run unprivileged at ring 1, while all processes at all domains (i.e., virtual machines) run unprivileged at ring 3. Clearly, the figure assumes a system with four rings (e.g., Intel IA-32). On systems with only two levels of privileges, the hypervisor and the host OS can execute in system mode, while domains and processes can execute in user mode. As illustrated in the figure, Xen Project eliminates the device drivers entirely from guest OSs and provides a direct communication between guest OSs at domain U and the host OS at domain 0. More precisely, every domain Ui in Xen will not hold any virtual I/O devices or relevant drivers. Rather, every I/O request is now transferred directly to domain 0, which by default hosts all the required device drivers necessary to satisfy all I/O requests. For instance, rather than using a device driver to control a virtual network card interface (vNIC), with the Xen Project network, frames/packets are transferred through event channels directly to and from domain 0. This is done using NIC front-end and back-end interfaces at domain Uj (in which j > 0) and U0, respectively. Likewise, no virtual disk is exposed to any guest OS, and all disk data blocks imposed by file reads and writes are delegated by Xen Project to domain 0.
Figure 4: Xen Project's approach to I/O virtualization, assuming a system with four rings (e.g., Intel IA-32). Xen Project collocates an OS at a VM called domain 0, with the hypervisor on the physical platform to "borrow" its device drivers and avoid coding them in the hypervisor. This makes the hypervisor "thinner" and accordingly more reliable. Also, it makes it easier on the hypervisor developers.