[Lxc-users] shutdown on dom0 warns containers

Daniel Lezcano daniel.lezcano at free.fr
Wed Mar 23 11:48:49 UTC 2011


On 03/23/2011 05:25 AM, Trent W. Buck wrote:
> When you run something like "shutdown -r 18:30" on a host, users will
> receive a bunch of notifications via (I think) wall(1), like
>
>      Message from root:
>      The system will reboot in 180 minutes!
>
> Unsurprisingly, if you schedule a reboot of the host system, people
> logged into containers don't receive warnings.  But it would be awesome
> if they did -- any ideas how best to achieve that?

You are right, shutdown uses the wall command. This one browse /dev/pts 
and write a message to all pty it found in this directory.

As the containers have their own pts instance, they are not seen by 
'wall'. One solution would be to share the /dev/pts with the system and 
the containers (maybe not a good solution).

Other solution could be to write a lxc-wall command where a message is 
took from the command line and send to all the containers via 
/proc/<pid>/root/dev/pts

Maybe also, the 'wall' command could be changed to take into account 
/proc/<pid>/dev/pts, instead of /dev/pts. By this way, it would take 
into account all the pty of all the processes for all the containers.
Relying on the device number which differs between mount points in each 
container, we can prevent of notifying several times the same ptys.

For example:

for i in /proc; do

	if (i != pid)
		continue;

	if (already_notified(device_nr(/proc/pid/root/dev/pts)))
		continue;

	for j in /proc/pid/root/dev/pts; do

		if (j == ptmx)
			continue;

		write_message(/proc/pid/root/dev/pts/j, msg);
	done

	register_notified(device_nr(/proc/pid/root/dev/pts));

done




More information about the lxc-users mailing list