Managing Long-Lived UML Instances


It is common to want a UML instance to outlive the login session in which it is started. As with other processes, it is possible to background a UML instance and have it survive the end of the login session. The problem with this is the main console. It is natural to have it attached to the standard input and standard output of the UML instance's main process. But this means that the UML instance must be the foreground process. It can be backgrounded (with some difficulty because it sets the terminal raw, so Ctrl-Z and Ctrl-C don't send SIGTSTP and SIGINT, respectively, to the process), and once it is, and you log out, the main console is lost.

To avoid this, you can use a very handy tool called screen. Upon running it with no arguments, you get a new shell. At this point, you can run your UML instance as you normally do. When you decide to log out, you can detach the screen session, and it will, in effect, background the UML instance in a way that lets you reattach to it later.

Run screen -r and the session, with the UML instance and main console intact, will return. So, in the simplest case, here is the procedure for maintaining a long-lived UML instance.

  1. Run screen.

  2. Start the UML instance inside the resulting screen session.

  3. Detach the screen session with Ctrl-A Ctrl-D.

  4. Log out.

  5. Later, log back in and run screen -r.

  6. Detach, reattach, and repeat as often as necessary.

With a number of UML instances running on the host, the same procedure will work. The problem is knowing which screen session belongs to the UML instance you want to reattach to. The result of running screen -r may be something like this:

There are several suitable screens on:        28348.pts-1.tp-w        (Detached)        28368.pts-1.tp-w        (Detached)        28448.pts-1.tp-w        (Detached)        28408.pts-1.tp-w        (Detached)        28308.pts-1.tp-w        (Detached)        28488.pts-1.tp-w        (Detached)        28530.pts-1.tp-w        (Detached)        28328.pts-1.tp-w        (Detached)        28428.pts-1.tp-w        (Detached)        28550.pts-1.tp-w        (Detached)        28468.pts-1.tp-w        (Detached)        28288.pts-1.tp-w        (Detached)        28510.pts-1.tp-w        (Detached)        28388.pts-1.tp-w        (Detached) Type "screen [-d] -r [pid.]tty.host" to resume one of them.


This is not helpful in figuring out which one you want to resume. To simplify this, screen has the ability to attach names to screen sessions. The -S switch will assign a meaningful name to the session and this name is what you will use to resume it. So, will start a screen session named joes-uml. You can assign a name to each session you start. Then when you want to resume a particular one, run screen -r and you'll see something like this:

host% screen -S joes-uml


There are several suitable screens on:        28868.work-uml          (Detached)        28826.spare3-uml        (Detached)        28910.simulator-uml     (Detached)        28890.devel-uml         (Detached)        28804.spare2-uml        (Detached)        28784.spare1-uml        (Detached)        28848.dmz-uml           (Detached)        28764.janes-uml         (Detached)        28742.named-uml         (Detached)        28700.joes-uml          (Detached) Type "screen [-d] -r [pid.]tty.host" to resume one of them.


It is now easy to pick out the one you want:

host% screen -r joes-uml


With good enough names, it may not even be necessary to look at the list in order to remember which one you want.

Finally, you may wish to start a set of UML instances during the host boot sequence. There is no terminal for the new UML instances to use as their main consoles, unless, of course, you provide them one. screen is useful here as well. The -d -m switch will start the screen session detached. Now you're not available to start the UML instances by hand, so screen will need to do this automatically. This can be accomplished, along with the other tricks we've seen, with something like this:

host% screen -d -m -S boot-uml ./linux con0=fd:0,fd:1 \    con1=none con=pts ssl=pts umid=debian mem=450M \     ubda=../../debian30 devfs=nomount mconsole=notify:/tmp/notify


This starts the screen session detached, runs the UML command that follows the screen switches, and names the screen session boot-uml. screen -r shows it like this:

       16799.boot-uml         (Detached)


Now, once the host has booted, and the UML instances with it, you can log in to the host and attach to whatever UML instance you wish.



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