[libvirt] [PATCH] Leave all child processes running when stopping systemd service

From: "Daniel P. Berrange" <berrange@redhat.com> Currently the libvirt.service unit file for systemd does not specify any kill mode. So systemd kills off every process inside its cgroup. ie all dnsmasq processes, all virtual machines. This obviously not what we want. Set KillMode=process so that it only kills the top level process of libvirtd * daemon/libvirtd.service.in: Add KillMode=process Reported-By: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.service.in | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/daemon/libvirtd.service.in b/daemon/libvirtd.service.in index 8f2458a..d6e46ab 100644 --- a/daemon/libvirtd.service.in +++ b/daemon/libvirtd.service.in @@ -15,6 +15,7 @@ Before=libvirt-guests.service EnvironmentFile=-/etc/sysconfig/libvirtd ExecStart=@sbindir@/libvirtd $LIBVIRTD_ARGS ExecReload=/bin/kill -HUP $MAINPID +KillMode=process # Override the maximum number of opened files #LimitNOFILE=2048 -- 1.7.7.6

On Thu, 2012-03-22 at 14:03 +0000, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Currently the libvirt.service unit file for systemd does not specify any kill mode. So systemd kills off every process inside its cgroup. ie all dnsmasq processes, all virtual machines. This obviously not what we want. Set KillMode=process so that it only kills the top level process of libvirtd
* daemon/libvirtd.service.in: Add KillMode=process
I was still looking through this. Try doing: $> systemctl restart libvirtd.service It's killing the existing processes in the cgroup when starting the service. From poking at an strace, this looks like the code that's doing it: http://cgit.freedesktop.org/systemd/systemd/tree/src/service.c?id=75c8e3cf#n... Cheers, Mark.

On Thu, 2012-03-22 at 14:10 +0000, Mark McLoughlin wrote:
On Thu, 2012-03-22 at 14:03 +0000, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Currently the libvirt.service unit file for systemd does not specify any kill mode. So systemd kills off every process inside its cgroup. ie all dnsmasq processes, all virtual machines. This obviously not what we want. Set KillMode=process so that it only kills the top level process of libvirtd
* daemon/libvirtd.service.in: Add KillMode=process
I was still looking through this. Try doing:
$> systemctl restart libvirtd.service
It's killing the existing processes in the cgroup when starting the service. From poking at an strace, this looks like the code that's doing it:
http://cgit.freedesktop.org/systemd/systemd/tree/src/service.c?id=75c8e3cf#n...
Filed a bug: https://bugzilla.redhat.com/805942 Cheers, Mark.

On Thu, Mar 22, 2012 at 02:10:30PM +0000, Mark McLoughlin wrote:
On Thu, 2012-03-22 at 14:03 +0000, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Currently the libvirt.service unit file for systemd does not specify any kill mode. So systemd kills off every process inside its cgroup. ie all dnsmasq processes, all virtual machines. This obviously not what we want. Set KillMode=process so that it only kills the top level process of libvirtd
* daemon/libvirtd.service.in: Add KillMode=process
I was still looking through this. Try doing:
$> systemctl restart libvirtd.service
It's killing the existing processes in the cgroup when starting the service. From poking at an strace, this looks like the code that's doing it:
http://cgit.freedesktop.org/systemd/systemd/tree/src/service.c?id=75c8e3cf#n...
It didn't kill guests/dnsmasq in my testing. Are you sure you did a 'systemctl daemon-reload' after adding the KillMode flag to the unit file ? Daniel -- |: 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 :|

On Thu, 2012-03-22 at 14:22 +0000, Daniel P. Berrange wrote:
On Thu, Mar 22, 2012 at 02:10:30PM +0000, Mark McLoughlin wrote:
On Thu, 2012-03-22 at 14:03 +0000, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Currently the libvirt.service unit file for systemd does not specify any kill mode. So systemd kills off every process inside its cgroup. ie all dnsmasq processes, all virtual machines. This obviously not what we want. Set KillMode=process so that it only kills the top level process of libvirtd
* daemon/libvirtd.service.in: Add KillMode=process
I was still looking through this. Try doing:
$> systemctl restart libvirtd.service
It's killing the existing processes in the cgroup when starting the service. From poking at an strace, this looks like the code that's doing it:
http://cgit.freedesktop.org/systemd/systemd/tree/src/service.c?id=75c8e3cf#n...
It didn't kill guests/dnsmasq in my testing. Are you sure you did a 'systemctl daemon-reload' after adding the KillMode flag to the unit file ?
Yep: [markmc@zig ~]$ sudo systemctl show libvirtd.service | grep KillMode KillMode=process [markmc@zig ~]$ systemd-cgls /system/libvirtd.service /system/libvirtd.service: ├ 12660 /usr/sbin/libvirtd ├ 20598 /usr/bin/qemu-kvm -S -M pc-0.15 -enable-kvm -m 2048 -smp 1,sockets=1,cores=1,threads=1 -name instance-00000021 -uuid 39e9ec0e-2... └ 20665 /sbin/dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface ... [markmc@zig ~]$ sudo systemctl restart libvirtd.service [markmc@zig ~]$ systemd-cgls /system/libvirtd.service /system/libvirtd.service: └ 20742 /usr/sbin/libvirtd Cheers, Mark.

On Thu, Mar 22, 2012 at 02:27:59PM +0000, Mark McLoughlin wrote:
On Thu, 2012-03-22 at 14:22 +0000, Daniel P. Berrange wrote:
On Thu, Mar 22, 2012 at 02:10:30PM +0000, Mark McLoughlin wrote:
On Thu, 2012-03-22 at 14:03 +0000, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Currently the libvirt.service unit file for systemd does not specify any kill mode. So systemd kills off every process inside its cgroup. ie all dnsmasq processes, all virtual machines. This obviously not what we want. Set KillMode=process so that it only kills the top level process of libvirtd
* daemon/libvirtd.service.in: Add KillMode=process
I was still looking through this. Try doing:
$> systemctl restart libvirtd.service
It's killing the existing processes in the cgroup when starting the service. From poking at an strace, this looks like the code that's doing it:
http://cgit.freedesktop.org/systemd/systemd/tree/src/service.c?id=75c8e3cf#n...
It didn't kill guests/dnsmasq in my testing. Are you sure you did a 'systemctl daemon-reload' after adding the KillMode flag to the unit file ?
Yep:
[markmc@zig ~]$ sudo systemctl show libvirtd.service | grep KillMode KillMode=process [markmc@zig ~]$ systemd-cgls /system/libvirtd.service /system/libvirtd.service: ├ 12660 /usr/sbin/libvirtd ├ 20598 /usr/bin/qemu-kvm -S -M pc-0.15 -enable-kvm -m 2048 -smp 1,sockets=1,cores=1,threads=1 -name instance-00000021 -uuid 39e9ec0e-2... └ 20665 /sbin/dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface ... [markmc@zig ~]$ sudo systemctl restart libvirtd.service [markmc@zig ~]$ systemd-cgls /system/libvirtd.service /system/libvirtd.service: └ 20742 /usr/sbin/libvirtd
Hmm, that's not the behaviour I see, once I ran 'daemon-reload'. # systemd-cgls /system/libvirtd.service /system/libvirtd.service: ├ 19607 /usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --ex... ├ 19809 /usr/libexec/qemu-kvm -S -M pc-0.13 -enable-kvm -m 215 -smp 4,sockets=4,cores=1,threads=1 -name vm1 -uuid c7a3edbd-e... └ 19849 /usr/sbin/libvirtd [root@t500wlan system]# systemctl stop libvirtd.service [root@t500wlan system]# systemd-cgls /system/libvirtd.service /system/libvirtd.service: ├ 19607 /usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --ex... └ 19809 /usr/libexec/qemu-kvm -S -M pc-0.13 -enable-kvm -m 215 -smp 4,sockets=4,cores=1,threads=1 -name vm1 -uuid c7a3edbd-e... [root@t500wlan system]# systemctl start libvirtd.service [root@t500wlan system]# systemd-cgls /system/libvirtd.service /system/libvirtd.service: ├ 19607 /usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --ex... ├ 19809 /usr/libexec/qemu-kvm -S -M pc-0.13 -enable-kvm -m 215 -smp 4,sockets=4,cores=1,threads=1 -name vm1 -uuid c7a3edbd-e... └ 26391 /usr/sbin/libvirtd Daniel -- |: 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 :|
participants (2)
-
Daniel P. Berrange
-
Mark McLoughlin