Skip to contentSkip to conversation

best way for init-script to start/stop UML

uml-devel roland 3 participants 3 messages May 19, 2004 – Jun 2, 2004 1 message not in the archive User-mode Linux (UML)

lore
Share & tools
lore

roland

author
#1 lore raw
In reply to a message not in the archive
Quoted 1 line

How can i gracefully halt a UML-machine? Is there something more simular

i think changing the cad-handler in /etc/inittab would do the trick:
in line:
ca::ctraltdel...
change
"-r" to "-h"

then you should be able to shutdown your uml with "uml_mconsole cad"

imho, it should be possible to issue init-commands to a running uml via uml_mconsole, to switch uml guest systems to whatever init-level we like. is such feature existing or being planned ?

regards
roland

----- Original Message -----
From: "Sven Köhler" <[email protected]>
To: <[email protected]>
Sent: Wednesday, May 05, 2004 3:41 PM
Subject: [uml-user] best way for init-script to start/stop UML

Quoted 29 lines

hi,

i'm about to write some init-scripts that are supposed to start/stop UML machines if the computer started/stopped. I think i can easily start the UML-kernel, but stopping it is a problem for me.

I can imagine to do it with mconsole, since there is a halt-command, but after the issuing the halt-command in mconsole, the UML-kernel stopps running immediatly. I worry about the filesystems of the UML-machine that might get damaged.

How can i gracefully halt a UML-machine? Is there something more simular to the issuing a halt-command inside the UML?

Since using mconsole is kind of tricky, i'd like to use the old-fashioned way with signals. What about SIGINT, SIGTERM, etc. Is it safe to send any of those to the UML-kernel? Is any of the signals simular to mconsole's halt-command?

Another way could be to send the halt-command directly to the UNIX-Socket that mconsole would use. Is there any way of soing that from the command-line?

Thx
Sven

Quoted 10 lines

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
User-mode-linux-user mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#2 lore raw
Quoted 2 lines

imho, it should be possible to issue init-commands to a running uml via uml_mconsole, to switch uml guest systems to whatever init-level we like. is such feature existing or being planned ?

That would be a good if not the best sollution. Are there any distos that don't use init? i don't think so (having that said, i should better check gentoo, cause it has a different run-level concept etc.).

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#3 lore raw

Alle 02:08, giovedì 20 maggio 2004, Sven Köhler ha scritto:

Quoted 3 lines
Quoted 3 lines

imho, it should be possible to issue init-commands to a running uml via uml_mconsole, to switch uml guest systems to whatever init-level we like. is such feature existing or being planned ?

A lot of time ago I implemented (not in a very good way probably) a patch, which worked, to execute via Mconsole any command inside UML. It is attached. It is old, ugly and very bad. However, it's already published.

It has no support for console I/O to the command, so it's just a bit of a generalization to your request (think of modprobe, for instance). I planned a big change which could make it easier: at that time I wrote an ugly parsing routine to split the command line in the argv[] array; after that I thought that I could pass it to bash:

char *argv[] = {"/bin/sh", "-c", passedString};

exec_usermodehelper(3, argv, envp); /*a wrapper of execve which is normally used to call modprobe when needed*/

but I never implemented this, which could also allow a big simplification of the patch. This solution would allow I/O, if you use a redirection on the mconsole command line!

Btw: I didn't know at that time I could include uml-config.h and do #ifdef UML_CONFIG_MCONSOLE_EXEC. So I did another hack for this.

Quoted 3 lines

That would be a good if not the best sollution. Are there any distos that don't use init? i don't think so (having that said, i should better check gentoo, cause it has a different run-level concept etc.).

Any distro uses init, but Slackware uses a BSD init by default (so that runlevels are meaningless except for what is specified inside /etc/inittab), Debian uses to run on runlevel 2 (IIRC, never used Debian: stable is old and unstable needs fast Internet connection + lot of braveness).

Bye

Signature · 2 lines
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
arch/um/drivers/mconsole_user.c renamed from arch/um/drivers/mconsole_user.c.saved +1 -0
@@ -21,6 +21,7 @@
 	{ "version", mconsole_version, MCONSOLE_INTR },
 	{ "halt", mconsole_halt, MCONSOLE_PROC },
 	{ "reboot", mconsole_reboot, MCONSOLE_PROC },
+        { "exec", mconsole_exec, MCONSOLE_PROC },
 	{ "config", mconsole_config, MCONSOLE_PROC },
 	{ "remove", mconsole_remove, MCONSOLE_PROC },
 	{ "sysrq", mconsole_sysrq, MCONSOLE_INTR },
arch/um/drivers/mconsole_kern.c renamed from arch/um/drivers/mconsole_kern.c.saved +152 -1

177 lines not on this page · raw message

arch/um/config.in renamed from arch/um/config.in.saved +1 -0
@@ -40,6 +40,7 @@
 tristate 'Host filesystem' CONFIG_HOSTFS
 tristate 'Honeypot proc filesystem' CONFIG_HPPFS
 bool 'Management console' CONFIG_MCONSOLE
+dep_bool 'Execution through management console' CONFIG_MCONSOLE_EXEC $CONFIG_MCONSOLE
 dep_bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ $CONFIG_MCONSOLE
 bool '2G/2G host address space split' CONFIG_HOST_2G_2G
 bool 'Symmetric multi-processing support' CONFIG_UML_SMP
arch/um/include/mconsole.h renamed from arch/um/include/mconsole.h.saved +1 -0
@@ -73,6 +73,7 @@
 extern void mconsole_help(struct mc_request *req);
 extern void mconsole_halt(struct mc_request *req);
 extern void mconsole_reboot(struct mc_request *req);
+extern void mconsole_exec(struct mc_request *req);
 extern void mconsole_config(struct mc_request *req);
 extern void mconsole_remove(struct mc_request *req);
 extern void mconsole_sysrq(struct mc_request *req);