Download

User Mode Linux Job Wrapper

This is a simple python script that runs a command inside of user-mode-linux. This allows you, for example, to run binaries that require a different linux version than the host operating system.

You will need a UML kernel and root filesystem. I have successfully used linux-2.4.22-8um/linux and root_fs.rh-7.2-full.pristine.20020312.bz2, running on host operating systems of either Red Hat 6.x, 7.x, or 9.x vintage. It also works on Fedora.

You can also use a smaller root filesystem, such as root_fs.rh-7.2-server.pristine.20020312.bz2, but you will need to install python (1.5 or higher) for the inner job wrapper.

Here are the steps taken by the job wrapper to run the command in user-mode-linux:

  1. Boot up the UML kernel in single-user mode.
  2. Mount the host file system if /mnt/host is not already there.
  3. Run uml_inner_job_wrapper on a file containing all information about the command, such as command-line arguments and environment.
  4. In order to work transparently, the inner wrapper runs with the same working directory as the outer wrapper. This means that the host filesystem is mounted inside UML and may be modified by the job. An option to do "sandboxing" could be added but is not currently implemented.
  5. In order for host file permissions to be handled correctly inside of UML, the inner wrapper runs the job with user and group ids that are identical to the user that is running the outer wrapper.
  6. Also, for software on the host filesystem that may expect to exist at a specific path, the inner wrapper ensures that certain directories on the host filesystem are symlinked to the same paths within the UML filesystem. By default, just the job's working directory and /afs are treated this way.
  7. Print any output from the job as it runs.
  8. When the inner wrapper finishes executing the job, the outer wrapper checks the return status, shuts down UML, and exits with the exit status of the job.

Examples

The following command will run 'free' inside of the UML kernel. Be patient while UML boots up and shuts down, or use the --echo option to see what is happening during the pauses.

uml_job_wrapper free

You can control various UML parameters, such as memory/swap size using environment variables or command-line options. Example:

uml_job_wrapper --mem=100M free

See uml_job_wrapper --help for additional usage information.

Quick Setup

A complete UML package, including the wrapper script, a UML kernel, and a UML filesystem may be found here: uml_rh7.tgz.

Known Problems

Using linux-2.4.22-8um, an application (OSCAR) has been observed to consistently fail with mem>=300M. The failure happens after 12+ hours and often causes the UML tracing thread and the application to enter some sort of rapid interaction that causes the rate of context switches to become very high and no further progress is made by the job. When strace is used on the tracing thread, it appears to be delivering SEGFAULT signals to the application. Setting mem=200M (with 200M swap) allows the application to run to completion. A similar problem seems to happen in skas mode. In both cases, it is suspicious that with the memory over the limit of what works, the UML kernel displays something like the following message when booting up: "Kernel virtual memory size shrunk to 217055232 bytes".