[RFC] new initctl command
Surbhi Palande
surbhi.palande at canonical.com
Mon Jun 20 17:15:47 UTC 2011
Hi Scott,
On 06/15/2011 07:47 PM, Scott James Remnant wrote:
> A few notes:
>
> - the D-Bus command needs to issue a method return to allow the
> initctl command to exit ;-)
Ok! I have uploaded a new diff with this change. Since we need to return
(along with sending a reply) before doing an execvp, we need two threads
of execution. I have used fork to achieve this.
Before returning to initctl, the child process changes the default
SIGTERM handler to a new one which on invocation calls exit(). Then the
child process returns to the initctl command whereas the parent process
waits for this child process to exit. When initctl gets a successful
return, initctl sends the child process a SIGTERM signal upon which the
child process exits. The parent process continues to execvp the new
requested init after it unblocks from the blocking waitpid().
I weighed this against other alternatives and found this to be simpler
than others. Please do let me know if you think this is ok or something
else that could be done in a more efficient/elegant way.
I also added code to remove the inotify handlers against the
configuration directories/files. This is otherwise invoked when you try
to free memory by deleting the contents of the initramfs - i.e when you
delete these configuration directories and files (you see some messages
on the console)
Also as suggested by Evan Broder, removed the moving of the /dev (/dev
-> @rootfs/dev) from upstart. Kept this in the udev job script.
I also need to include a few other changes (namely using libnih function
to do the directory walking/reading ) suggested by James. I will do that
once the "returning to initctl" is resolved.
Thanks!
Warm Regards,
Surbhi.
>
> - I would say you should move /proc, /sys & /dev over simply because
> Upstart happens to use two of those, and it makes everyone's lives easier
>
>
> On Wed, Jun 15, 2011 at 8:06 AM, Surbhi Palande
> <surbhi.palande at canonical.com <mailto:surbhi.palande at canonical.com>> wrote:
>
> Hi Scott,
>
> I have uploaded a new diff for the new initctl "pivot" command at:
>
> https://code.launchpad.net/~csurbhi/upstart/upstart-add-pivot-handling
>
> Background:
> --------------
> The pivot command is used for changing the root filesystem in the
> initramfs from the memory based "/" to the disk based real root
> filesystem. This command can be issued as follows:
>
> initctl pivot <ROOTFS> <INIT>
>
> where ROOTFS is the root filesystem that we want to move to while in
> the initramfs. INIT is the first program that we wish to execute
> once this move to the real root filesystem is made.
>
> This command is intended to be used when upstart is executed in
> initramfs for making the initramfs event driven.
>
> It is assumed that a user can specify a different ROOTFS, INIT or
> arguments to this new INIT at the grub command prompt. The console
> used for logging the messages is /dev/console and is a not a boot
> argument which can be changed.
>
> This command has no effect when it is executed from a non memory
> based root filesystem.
> ---------------
>
> The uploaded diff has the following changes:
>
> 1. Added the pivot related code in pivot.c, pivot.h.
> 2. Added support for compiling pivot.c
> 3. Made the code in pivot.c modular.
> 4. Added the handling of moving the virtual filesystem from / to the
> requested new rootfs.
> 5. The default console used is /dev/console. No other console can be
> specified. However, if we want to make the console device a boot
> parameter or a command line argument for the pivot command then this
> can be added. Would like to know views on this. Currently at least
> Ubuntu's initramfs does not change the console when it executes
> run_init.
>
> I would also love to know any views on whether the pivot command is
> the right place to handle the moving of the virtual filesystems
> (/dev, /proc, /sys to @rootfs/). Personally, I think that this
> virtual filesystem movement is needed _only_ for the correct
> execution of the pivot command and so it should be handled by the
> pivot command.
>
> Please do let me know your views on this diff. Thanks a lot!
>
> Warm Regards,
> Surbhi.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
More information about the upstart-devel
mailing list