User Mode Linux(UML)

Introduction 
 
User Mode Linux allows multiple virtual Linux systems to run on a single Linux system. It is an open source project developed by Jeff Dike As each guest is just a normal application running as a process in user space, this approach provides the user with a way of running multiple virtual Linux machines on a single piece of hardware, offering excellent security and safety without affecting the host environment's configuration or stability. One of the main applications of UML is for Kernel Debugging. It makes possible to do Kernel Debugging without the need for a separate machine. Also virtual network can be accomplished between virtual machines and can be used for testing or educational purposes [11].
 
Method of Operation
The user-mode kernel is a port of the Linux kernel to the Linux system call interface rather than to a hardware interface. This kernel is a full Linux kernel, lacking only hardware-specific code such as drivers. It runs the same user space as the native kernel. Processes run natively until they need to enter the kernel. There is no emulation of user space code. Processes running inside it see a self-contained environment. They have no access to any host resources other than those explicitly provided to the virtual machine.
Working of UML can be understood through following points (as mentioned in [10]):
 i.Design and Implementation
The basic design principle of UML is that it will run in the same user space as the host. For this design to be successful system calls generated by guest processes must be intercepted and run in virtual kernel. This achieved through Linux ptrace system call tracing facility. When a process invokes system call this thread gets notified and has the capability to cancel, change the arguments of system call and divert it to user space kernel. Another method through which a process can get executed by kernel is by a trap. The trap can be called by hardware like clock, some device or memory management unit. User mode Linux implements it by Linux signals i.e. clock is simulated by SIGALRM and SIGVTALRM, I/O device with SIGIO and memory management with SIGSEGV. The kernel declares its own handlers for these signals.
 ii.Virtual machine initialization
Before kernel starts booting some initialization has to be done to make process look like a real machine. The process arguments are inserted into the buffer where kernel intends to find them and special arguments about configuration of virtual machine are parsed at this point. Physical memory area is set up along with initial task structure, and tracing thread is also activated. The idle thread calls start_kernel and virtual machine boots up.
 iii.Process Creation and Destruction
UML creates a new process in the host for every new process in the virtual machine. This also is done by tracing thread. The new thread sets up signal handlers for SIGSEGV, SIGIO and SIGVTALRM, initializes the timer and sets itself to be ptraced. Once the initialization is done it send itself signal SIGSTOP. Tracing thread sees it and sets return value of System call to zero while in forking process it returns the pid of new process. Thus new process is created. The other end of lifecycle is easy. The only resources to be freed are buffers in the thread structure and process in the host needs to be killed. 
 iv.Context switch
If a process sleeps instead of returning immediately from a system call, it calls schedule. The scheduler selects a new process to run and calls the Architecture specific context switching code to actually perform the switch. In this port, that involves the running process sending a message to the tracing thread that it is being switched out in favor of another process. Since each process in the virtual machine is also a process in the host, the tracing thread performs the switch by stopping the old process and continuing the new one. The new process returns from the context switch that it entered when it last ran and continues whatever it was doing.
Software Performance 
Installation of UML is pretty straightforward. Since it is open source therefore very good documentation is available for it online. As it is with QEMU, UML also requires disk images to run. But major disadvantage of UML is its speed. Its performance is very low with comparison to Xen and QEMU. To improve its performance now it doesn’t come as a patch to the kernel. From Kernel 2.5+ it comes embedded into kernel source tree. A method of running a separate kernel address space (skas) that does not require host kernel patching has been implemented; This improves performance and security over the old Traced Thread approach, in which processes running in the UML share the same address space from the host's point of view, which leads the memory inside the UML to not be protected by the Memory management unit. As performance aspect is concerned future work in adding support for Virtualization Technology to UML may reduce this disadvantage.
Go Back:Virtualization and Open Source