[libvirt-users] signal for shutdown in lxc driver

Daniel P. Berrange berrange at redhat.com
Fri Nov 20 15:19:13 UTC 2015

On Fri, Nov 20, 2015 at 04:19:59PM +0300, Boris Savelev wrote:
> Hello!
> Try to use libvirt with lxc.
> I use latest centos6 amd64 as a libvirt host (libvirt from xen4 repo)
> libvirt-daemon-1.2.15-3.el6.x86_64
> In container I also use latest centos6 amd64. Container starts with
> /sbin/init. CentOS 6 came with upstart as default init.
> My problem is that I could not shutdown container correctly with libvirt.
> virsh -c lxc:/// shutdown test
> Domain test is being shutdown
> In container I see only:
> "init: Re-executing /sbin/init"
> in syslog messages
> Why it is happened?
> lxcDomainShutdownFlags [1] send SIGTERM to initpid. Upstart got it and
> reloaded himself instead shutdown. It's default behavior... [2]
> The question is why libvirt send SIGTERM? As I can see lxc-stop [3]
> send SIGPWR (that works correctly with upstart) and also have ability
> to change default signals.
> I can understand that when container start with some script not
> /sbin/init that handle SIGTERM this situation is ok. But then
> container use /sbin/init it is not.

The choice of signal is essentially abitrary, since there is no
common standard used across different init systems. As such we
chose signal numbers that were useful in the context of containers
running applications (ie containers with an init). We then added
logic to be able to use /dev/initctl to trigger shutdown of init
based containers.  This works with sysvinit and with systemd,
and various other init systems, but it seems upstart does not
support this. If there is another mechanism for instructing
upstart to shutdown that we can reliably detect, then we could
use that.

|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

More information about the libvirt-users mailing list