Page MenuHomeFreeBSD

Jail init process and virtual reboot
Needs ReviewPublic

Authored by jamie on Wed, Sep 16, 11:17 PM.
Tags
None
Referenced Files
F172328959: D59748.id186925.diff
Thu, Sep 17, 6:47 PM
F172325517: D59748.id186925.diff
Thu, Sep 17, 6:14 PM
F172314379: D59748.diff
Thu, Sep 17, 4:27 PM
F172292572: D59748.diff
Thu, Sep 17, 12:45 PM
F172238544: D59748.id186925.diff
Thu, Sep 17, 3:42 AM
F172238306: D59748.diff
Thu, Sep 17, 3:39 AM

Details

Reviewers
olce
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

Prisons can currently run /sbin/init, which acts a reaper for processes started under it. This extends and formalizes the virtual init concept.

The "init" jail parameter specifies a jail with virtual init. When the parameter is set, an init process is forked off, similar to how the real init (process 1) is created on bootup. The prison field pr_initproc points to this process, and is used in some places that used to check global initproc. prison0.pr_initproc points to the same process as global initproc.

A lot of system management depends on init being pid 1, and a lot of the changes here are so looking up pid 1 in a jail returns its init process instead of the global one, and also any reporting about that process (from within the jail) shows its pid as 1.

When reboot(2) is called from withinga jail with init, its runs a virtual halt: all processes in that jail are killed, an OSD PR_METHOD_REBOOT call is made (which can reset things to a newish state), and then either a new init process is forked off (virtual reboot) or the prison is marked as no longer having an init process. A virtually halted jail may go away once its processes are dead, though it may not, depending on such things as child jails, persistent status, or non-init-related processes.

At this time, there is no concept of a virtual single-user mode, or a virtual console, both of which are necessary for a proper init-based system. The virtual init is also not a universal parent process in the prison, as any process attached to prison keep their own parent processes and reapers.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped