Download Diplomarbeit Lightweight Virtualization on Microkernel
Transcript
4.5 Virtual Machine Monitor During the whole VM lifetime, the VMM has access to VM (physical) memory, which can be used for efficient shared memory communication between the VM and the VMM. An alternative to allocating all memory at once is demand paging. Whenever the VM accesses a page that has not been used before, the VMM receives a page fault and maps a fresh page into the VM. In this thesis I chose the former approach because it allows the mapped memory region to be contiguous in physical memory. Whereas this allocation scheme is more wasteful on system memory, it simplifies the address translation if the guest is allowed to directly drive DMA enabled devices. 4.5.2 Platform Virtualization As described in Chapter 2.2.4, the VMM has to implement platform devices such as an interrupt controller (IC) and a timer device. For the design of the IC, it is reasonable to align it with the high level abstractions of Linux. If done so, the Linux operations correspond directly to IC ones. As for a virtual device, interrupts are flagged by helper threads in a shared data structure, and delivered to the VM by the VMM’s control loop. The timer thread periodically blocks with a timeout, upon which it flags the timer interrupt at the virtual IC. 4.5.3 Peripheral Devices For a VM to be useful, it has to be provided with virtual devices. The L4 system includes device managers, servers that multiplex access to hardware. For example Ankh implements a virtual network switch, thereby multiplexing the physical network card. Similarly, we have a secure console that securely multiplexes the system’s frame buffer and maintains a secure input indicator, which cannot be forged by clients. These device managers consist of a device driver and multiplexing logic. Client communication with device managers is done with IPC and shared memory. These services are a natural choice for the back ends of virtual devices. The VMM makes use of to the device managers to present the VM with a custom interface. The guest OS needs special drivers to communicate with the virtual devices. Because these drivers implement an abstracted interface only, I will call them stub drivers. The VMM’s task is limited to translating the stub driver’s commands into IPC messages, which are forwarded to the device manager. Asynchronous events, such as the availability of packets, are signaled using IPC or asynchronously using User-Irqs. For each device manager, the VMM employs a blocking helper thread to receive the notification and flag the event as interrupt at the virtual IC. Virtio provides a para-virtualization interface, which is used by Lguest and by KVM (optionally). It implements device drivers for a network card, a serial console and a generic block driver [Rus08]. It is up to the VMM to implement back ends to the virtio device interfaces. By using the virtio interface, I could benefit from existing drivers, but would have to implement complex mappings to the L4 device manager’s interfaces, which would significantly increase the complexity of the VMM. 35