vzeventd: initial implementation

Recent OpenVZ kernels provided vzevent module which sends CT
start/stop/reboot events (see bug #1427). This commit adds
vzevent daemon, which reacts to such events and performs
appropriate actions.

Before vzeventd, the problem of restarting a CT which was rebooted from
the inside, and the problem of cleaning up CT0 networking for a CT which
was stopped from the inside were solved by using shell scripts run from
cron, with some trickery inside a CT to mark it for reboot. The solution
was suboptimal, cumbersome and ugly -- hopefully now with vzevent those
kludges will be removed (by a separate commit).

vzeventd is implemented as a daemon, plus there is a separate vzeventd
initscript to start/stop it (and also load vzevent kernel module with
the appropriate parameter). Since we now have two initscripts, common code
(for init.d compatibility between Red Hat/Debian/SUSE) is moved into
a separate file vzfunctions which is sourced from both initscripts.

vzeventd listens to the events from the kernel (delivered via netlink
socket). Current list of known events and associated vzeventd actions are:
	start		ignore
	stop		run /usr/lib/vzctl/scripts/vzevent-stop
	mount		ignore
	umount		ignore
	reboot		run /usr/lib/vzctl/scripts/vzevent-reboot

Events mount/umount are currently not implemented in the kernel for simfs.

Event 'stop' is generated when CT is being stopped (either by vzctl or
from inside the container, e.g. by executing halt). Script vzevent-stop
does the following:
	1. Waits till CT is stopped
	2. Umounts CT if it's not unmounted
	3. Cleans up CT0 network setup (i.e. arp and route records)

Event 'reboot' is generated when CT is rebooted from inside (e.g. by
executing reboot). Script vzevent-reboot does the following:
	1. Waits till CT is stopped
	2. Starts it (by running vzctl start).

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
14 files changed