1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
<TITLE>User Mode Linux HOWTO : The Management Console</TITLE>
<LINK HREF="UserModeLinux-HOWTO-11.html" REL=next>
<LINK HREF="UserModeLinux-HOWTO-9.html" REL=previous>
<LINK HREF="UserModeLinux-HOWTO.html#toc10" REL=contents>
</HEAD>
<BODY>
<A HREF="UserModeLinux-HOWTO-11.html">Next</A>
<A HREF="UserModeLinux-HOWTO-9.html">Previous</A>
<A HREF="UserModeLinux-HOWTO.html#toc10">Contents</A>
<HR>
<H2><A NAME="mconsole"></A> <A NAME="s10">10.</A> <A HREF="UserModeLinux-HOWTO.html#toc10">The Management Console</A></H2>
<P> </P>
<P>The UML management console is a low-level interface to the kernel,
somewhat like the i386 SysRq interface. Since there is a full-blown
operating system under UML, there is much greater flexibility possible
than with the SysRq mechanism.</P>
<P>
There are a number of things you can do with the mconsole interface:
<UL>
<LI>get the kernel version
</LI>
<LI>add and remove devices
</LI>
<LI>halt or reboot the machine
</LI>
<LI>send SysRq commands
</LI>
<LI>pause and resume the UML
</LI>
<LI>make online backups without shutting down the UML
</LI>
<LI>receive notifications of events of interest from within UML
</LI>
<LI>monitor the internal state of the UML
</LI>
</UL>
</P>
<P>
You need the mconsole client (uml_mconsole) which is present in CVS
(/tools/mconsole) in 2.4.5-9um and later, and will be in the RPM in 2.4.6.</P>
<P>
You also need CONFIG_MCONSOLE (under 'General Setup') enabled in UML.
When you boot UML, you'll see a line like:
<BLOCKQUOTE><CODE>
<PRE>
mconsole initialized on /home/jdike/.uml/umlNJ32yL/mconsole
</PRE>
</CODE></BLOCKQUOTE>
If you specify a unique machine id one the UML command line, i.e.
<BLOCKQUOTE><CODE>
<PRE>
umid=debian
</PRE>
</CODE></BLOCKQUOTE>
you'll see this
<BLOCKQUOTE><CODE>
<PRE>
mconsole initialized on /home/jdike/.uml/debian/mconsole
</PRE>
</CODE></BLOCKQUOTE>
That file is the socket that uml_mconsole will use to communicate
with UML. Run it with either the umid or the full path as its argument:
<BLOCKQUOTE><CODE>
<PRE>
host% uml_mconsole debian
</PRE>
</CODE></BLOCKQUOTE>
or
<BLOCKQUOTE><CODE>
<PRE>
host% uml_mconsole /home/jdike/.uml/debian/mconsole
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>You'll get a prompt, at which you can run one of these commands:
<UL>
<LI>version
</LI>
<LI>halt
</LI>
<LI>reboot
</LI>
<LI>config
</LI>
<LI>remove
</LI>
<LI>sysrq
</LI>
<LI>help
</LI>
<LI>cad
</LI>
<LI>stop
</LI>
<LI>go
</LI>
<LI>log
</LI>
<LI>proc
</LI>
</UL>
</P>
<H2><A NAME="ss10.1">10.1</A> <A HREF="UserModeLinux-HOWTO.html#toc10.1">version</A>
</H2>
<P>This takes no arguments. It prints the UML version.
<BLOCKQUOTE><CODE>
<PRE>
(mconsole) version
OK Linux usermode 2.4.5-9um #1 Wed Jun 20 22:47:08 EDT 2001 i686
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>There are a couple actual uses for this. It's a simple no-op which
can be used to check that a UML is running. It's also a way of
sending an interrupt to the UML. This is sometimes useful on SMP
hosts, where there's a bug which causes signals to UML to be lost,
often causing it to appear to hang. Sending such a UML the mconsole
version command is a good way to 'wake it up' before networking has
been enabled, as it does not do anything to the function of the UML.</P>
<H2><A NAME="ss10.2">10.2</A> <A HREF="UserModeLinux-HOWTO.html#toc10.2">halt and reboot</A>
</H2>
<P>These take no arguments. They shut the machine down immediately, with
no syncing of disks and no clean shutdown of userspace. So, they are
pretty close to crashing the machine.
<BLOCKQUOTE><CODE>
<PRE>
(mconsole) halt
OK
</PRE>
</CODE></BLOCKQUOTE>
</P>
<H2><A NAME="ss10.3">10.3</A> <A HREF="UserModeLinux-HOWTO.html#toc10.3">config</A>
</H2>
<P>"config" adds a new device to the virtual machine or queries the configuration of an existing device.</P>
<P>
Currently the ubd and network drivers support pulling devices. It takes one
argument, which is the device to add, with the same syntax as the
kernel command line.
<BLOCKQUOTE><CODE>
<PRE>
(mconsole)
config ubd3=/home/jdike/incoming/roots/root_fs_debian22
OK
(mconsole) config eth1=mcast
OK
</PRE>
</CODE></BLOCKQUOTE>
Querying the configuration of a device is handy when you don't know
before the boot what host device the UML device will attach to. This
is a problem with attaching consoles and serial lines to host pty or
pts devices. You have no way of knowing how to access them without
parsing the kernel messages. So, the syntax for this is the same as
above, except you don't specify a configuration
<BLOCKQUOTE><CODE>
<PRE>
(mconsole) config ssl0
OK pty:/dev/ptyp0
(mconsole) config ubd0
OK /home/jdike/roots/cow.debian,/home/jdike/roots/debian_22
</PRE>
</CODE></BLOCKQUOTE>
This is supported by the console, serial line, and ubd drivers. As
yet, the network drivers don't support this.</P>
<H2><A NAME="ss10.4">10.4</A> <A HREF="UserModeLinux-HOWTO.html#toc10.4">remove</A>
</H2>
<P>"remove" deletes a device from the system. Its argument is just the
name of the device to be removed. The device must be idle in
whatever sense the driver considers necessary. In the case of the ubd
driver, the removed block device must not be mounted, swapped on, or
otherwise open, and in the case of the network driver, the device must be down.
<BLOCKQUOTE><CODE>
<PRE>
(mconsole) remove ubd3
OK
(mconsole) remove eth1
OK
</PRE>
</CODE></BLOCKQUOTE>
</P>
<H2><A NAME="ss10.5">10.5</A> <A HREF="UserModeLinux-HOWTO.html#toc10.5">sysrq</A>
</H2>
<P>This takes one argument, which is a single letter. It calls the
generic kernel's SysRq driver, which does whatever is called for by
that argument. See the SysRq documentation in Documentation/sysrq.txt
in your favorite kernel tree to see what letters are valid and what
they do.</P>
<H2><A NAME="ss10.6">10.6</A> <A HREF="UserModeLinux-HOWTO.html#toc10.6">help</A>
</H2>
<P>"help" returns a string listing the valid commands and what each one does.</P>
<H2><A NAME="ss10.7">10.7</A> <A HREF="UserModeLinux-HOWTO.html#toc10.7">cad</A>
</H2>
<P>This invokes the Ctl-Alt-Del action on init. What exactly this ends
up doing is up to /etc/inittab. Normally, it reboots the machine.
With UML, this is usually not desired, so if a halt would be better,
then find the section of inittab that looks like this
<BLOCKQUOTE><CODE>
<PRE>
# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
</PRE>
</CODE></BLOCKQUOTE>
and change the command to halt.</P>
<H2><A NAME="ss10.8">10.8</A> <A HREF="UserModeLinux-HOWTO.html#toc10.8">stop</A>
</H2>
<P>This puts the UML in a loop reading mconsole requests until a 'go'
mconsole command is recieved. This is very useful for making backups of
UML filesystems, as the UML can be stopped, then synced via 'sysrq s', so
that everything is written to the filesystem. You can then copy the
filesystem and then send the UML 'go' via mconsole.</P>
<P>
Note that a UML running with more than one CPU will have problems after
you send the 'stop' command, as only one CPU will be held in a mconsole
loop and all others will continue as normal. This is a bug, and will
be fixed.</P>
<H2><A NAME="ss10.9">10.9</A> <A HREF="UserModeLinux-HOWTO.html#toc10.9">go</A>
</H2>
<P>This resumes a UML after being paused by a 'stop' command. Note that
when the UML has resumed, TCP connections may have timed out and if the
UML is paused for a long period of time, crond might go a little crazy,
running all the jobs it didn't do earlier.</P>
<H2><A NAME="ss10.10">10.10</A> <A HREF="UserModeLinux-HOWTO.html#toc10.10">log</A>
</H2>
<P>This takes a string as its argument, and will cause the UML to printk
the string so that it ends up in the kernel message log. This is
intended for use in honeypots by allowing the UML-specific stuff in
the kernel log to be replaced with messages that don't expose the
machine as being a UML.</P>
<H2><A NAME="ss10.11">10.11</A> <A HREF="UserModeLinux-HOWTO.html#toc10.11">proc</A>
</H2>
<P>This takes a filename as its argument. It will return the contents of
the corresponding /proc file inside the UML. Example:
<BLOCKQUOTE><CODE>
<PRE>
(mconsole) proc uptime
</PRE>
</CODE></BLOCKQUOTE>
will return the contents of the UML's /proc/uptime.</P>
<H2><A NAME="ss10.12">10.12</A> <A HREF="UserModeLinux-HOWTO.html#toc10.12">Making online backups</A>
</H2>
<P>It is possible to make a backup of a UML's data without shutting it
down. The idea is to pause it, make it flush out its data, copy the
filesystem to a safe place, and then resume it. This should usually
take seconds, while shutting down and rebooting the UML could take
minutes. The exact procedure is this:
<BLOCKQUOTE><CODE>
<PRE>
(mconsole) stop
</PRE>
</CODE></BLOCKQUOTE>
<BLOCKQUOTE><CODE>
<PRE>
(mconsole) sysrq s
</PRE>
</CODE></BLOCKQUOTE>
<BLOCKQUOTE><CODE>
<PRE>
host% # Copy the UML's filesystem someplace safe
</PRE>
</CODE></BLOCKQUOTE>
<BLOCKQUOTE><CODE>
<PRE>
(mconsole) go
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>By causing UML to flush its data out to disk, the 'sysrq s' will cause
the filesystem to be a clean image. Of course, no guarantees are made
for process data which hadn't been written back to the kernel, but the
filesystem itself won't need an fsck if it's booted.</P>
<H2><A NAME="ss10.13">10.13</A> <A HREF="UserModeLinux-HOWTO.html#toc10.13">Event notification</A>
</H2>
<P>The mconsole interface also provides a mechanism for processes inside
a UML to send messages to an mconsole client on the host. The
procedure is this:
<UL>
<LI>Create a unix socket and pass that to UML on the command line as the
mconsole notification socket
<BLOCKQUOTE><CODE>
<PRE>
mconsole=notify:<bf>socket
</PRE>
</CODE></BLOCKQUOTE>
</LI>
<LI>A /proc/mconsole file will be created inside UML
</LI>
<LI>Anything that is written to it will be turned into an mconsole
notification which your mconsole client should be listening for on the
notification socket
</LI>
</UL>
A common use for this mechanism is to have an rc script inside UML
send a message out that the UML has booted to a certain stage, and
that something on the host which depends on that can proceed.
However, this is a completely general mechanism which can be used to
communicate any information at all to the host.</P>
<P>
There is a demo mconsole notification client in the utilities tarball
in mconsole/notify.pl. This is only a demo, and as such, isn't very
useful by itself. It should be customized to fit into whatever
environment you are setting up.</P>
<HR>
<A HREF="UserModeLinux-HOWTO-11.html">Next</A>
<A HREF="UserModeLinux-HOWTO-9.html">Previous</A>
<A HREF="UserModeLinux-HOWTO.html#toc10">Contents</A>
</BODY>
</HTML>
|