Chapter 2. A Quick Look at UML


This chapter will take a quick look at the inside of a UML. I will concentrate on the relationship between the UML and the host. For many people, encountering a virtual machine for the first time can be confusing because it may not be clear where the host ends and the virtual machine starts.

For example, the virtual machine obviously is part of the host since it can't exist without the host. However, it is totally separate from the host in other ways. You can be root inside the UML and have no privileges [1]whatsoever on the host. When UML is run, it is provided some host resources to use as its own. The root user within UML has absolute control over those, but no control, not even access, to anything else on the host. It's this extremely sharp distinction between what the UML has access to and what it doesn't that makes UML useful for a large number of applications.

[1] In order to run a process, you obviously need some level of privilege on the system. However, a UML host can be set up such that the user that owns the UML processes on the host can do nothing but run the UML process.

A second common source of confusion is the duality of UML. It is both a Linux kernel and a Linux process. It is useful, and instructive, to look at UML from both perspectives. However, to many people, a kernel and a process are two completely different things, and there can be no overlap between them. So, we will look at a UML from both inside and outside, on the host, in order to compare the two views to each other. We will see different views of the same things. They will look different but will both be correct in their own ways. Hopefully, by the end of the chapter, it will be clear how something can be both a Linux kernel and a Linux process.

Figure 2.1 shows the relationship among a UML instance, the host kernel, and UML processes. To the host kernel, the UML instance is a normal process. To the UML processes, the UML instance is a kernel. Processes interact with the kernel by making system calls, which are like procedure calls except that they request the kernel do something on their behalf.

Figure 2.1. UML as both a process and a kernel


Like all other processes on the host, UML makes system calls to the host kernel in order to do its work. Unlike the other host processes, UML has its own system call interface for its processes to use. This is the source of the duality of UML. It makes system calls to the host, which makes it a process, and it implements system calls for its own processes, making it a kernel.

Let's take a look at the UML binary, which is normally called linux:

host% ls -l linux -rwxrw-rw-  2 jdike jdike 23346513 Jan 27 12:16 linux


This is a normal Linux ELF binary, as you can see by running file on it:

host% file linux linux: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), \ for GNU/Linux 2.2.5, statically linked, not stripped


It is also a Linux kernel, so it may be instructive to compare it to the kernel running on this machine:

host% ls -l /boot/vmlinuz-2.4.26 -rw-r--r--  1 root root 945800 Sep 18 17:12 /boot/vmlinuz-2.4.26


The UML binary is quite a bit larger than the kernel on the host, but it has a full symbol table, as you can see from the output of file above. So, let's strip it and see what that does:

 host% ls -l linux -rwxrw-rw-  2 jdike jdike 2236936 Jan 27 15:01 linux


It's a bit more than twice as large as the host kernel, possibly because the configurations are different. I tend to build options into UML, which on the host are modules. Checking this by adding up the sizes of the modules loaded on the host yields this:

host% lsmod Module                  Size  Used by usblp                  17473  0 parport_pc             31749  1 lp                     16713  0 parport                39561  2 parport_pc,lp autofs4                23493  2 sunrpc                145541  1 ... host% lsmod | awk '{n += $2} END {print n}' 1147092


Adding that to the file size of vmlinuz-2.4.26 gives us something close to the size of the UML binary after the symbol table has been stripped off.

What is the point of this comparison? It is to introduce the fact that UML is both a Linux kernel and a Linux process. As a Linux process, it can be run just like any other executable on the system, such as bash or ls.



User Mode Linux
User Mode Linux
ISBN: 0131865056
EAN: 2147483647
Year: N/A
Pages: 116
Authors: Jeff Dike

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net