On Wed, 11 Feb 2004, Mark Lawrence wrote:
> Therefore I would like to propose the following interface between
> kernel/vshelper.
> vshelper <action> <ctx> [<arg...>]
...
> vshelper reboot <ctx> reboot|halt|poweroff|cad_on|cad_off|{restart2 arg}
>
> (actually I would just let the kernel pass the actual hex value of flag).
So I've implemented and tested this, and it works beautifully. From a
virtual server I can now run the native halt or reboot command, which
talks to init via /dev/initctl. Init does its magic and then calls reboot
-f which does the sys_reboot.
sys_reboot calls vshelper with the appropriate arguments and with the
following patch to /usr/sbin/vserver cleans things up. I have no rebootmgr
on the system :)
I therefore submit the following for inclusion...
userspace helper:
http://rekudos.net/download/vshelper-new.
and the following patches to vserver to add "vserver <host> kill" command
and to sys.c (apply over vserver patch) to slighly modify the calling
parameters of vshelper.
Also need to do:
echo "location of vshelper" > /proc/sys/kernel/vshelper
The next step for proper integration would be to change "vserver <host>
stop" and "start" to actually use the init/halt without fiddling
with rc scripts.
Cheers, Mark.
--
Mark Lawrence ([EMAIL PROTECTED])
--- vserver Fri Feb 6 22:10:50 2004
+++ vserver-new Wed Feb 25 21:13:24 2004
@@ -651,6 +651,23 @@
cd /
test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh post-stop $1
ifconfig_iproot_off $1
+elif [ "$2" = "kill" ] ; then
+ echo killing virtual server $1
+ IPROOT=
+ IPROOTMASK=
+ IPROOTBCAST=
+ IPROOTDEV=
+ CAPS=
+ IS_MINIT=
+ readlastconf $1
+ echo Killing all processes
+ $CHBIND_CMD --silent $IPOPT \
+ $CHCONTEXT_CMD $CAPS --secure --silent --ctx
$S_CONTEXT \
+ $VSERVERKILLALL_CMD
+ umountproc $VROOTDIR/$1
+ cd /
+ test -x /etc/vservers/$1.sh && /etc/vservers/$1.sh post-stop $1
+ ifconfig_iproot_off $1
elif [ "$2" = "restart" ] ; then
if $0 $1 running
then
--- sysold.c Thu Feb 12 18:42:08 2004
+++ sys.c Wed Feb 25 21:03:33 2004
@@ -286,9 +286,10 @@
* the following arguments
*
* argv [0] = vshelper_path;
- * argv [1] = context identifier
- * argv [2] = "restart", "halt", "poweroff", ...
- * argv [3] = additional argument (restart2)
+ * argv [1] = "reboot"
+ * argv [2] = context identifier
+ * argv [3] = cmd (first argument to this function, as hexidecimal
string)
+ * argv [4] = additional argument (restart2 only)
*
* envp [*] = type-specific parameters
*/
@@ -298,38 +299,28 @@
{
char id_buf[8], cmd_buf[32];
char uid_buf[32], pid_buf[32];
- char buffer[256];
+ char buffer[256];
- char *argv[] = {vshelper_path, id_buf, NULL, NULL, 0};
+ char *argv[] = {vshelper_path, "reboot", id_buf, cmd_buf, 0, 0};
char *envp[] = {"HOME=/", "TERM=linux",
"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
- uid_buf, pid_buf, cmd_buf, 0};
+ uid_buf, pid_buf, 0};
snprintf(id_buf, sizeof(id_buf)-1, "%d", current->vx_id);
+ snprintf(cmd_buf, sizeof(cmd_buf)-1, "0x%08x", cmd);
- snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
- switch (cmd) {
- case LINUX_REBOOT_CMD_RESTART:
- argv[2] = "restart";
- break;
-
- case LINUX_REBOOT_CMD_HALT:
- argv[2] = "halt";
- break;
-
- case LINUX_REBOOT_CMD_POWER_OFF:
- argv[2] = "poweroff";
- break;
-
+ switch (cmd) {
case LINUX_REBOOT_CMD_RESTART2:
if (strncpy_from_user(&buffer[0], (char *)arg,
sizeof(buffer) - 1) < 0)
return -EFAULT;
argv[3] = buffer;
+ case LINUX_REBOOT_CMD_CAD_ON:
+ case LINUX_REBOOT_CMD_CAD_OFF:
+ return 0
default:
- argv[2] = "restart2";
break;
}
_______________________________________________
Vserver mailing list
[EMAIL PROTECTED]
http://list.linux-vserver.org/mailman/listinfo/vserver