From nobody Fri May 3 09:31:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1551897599861621.1372605160411; Wed, 6 Mar 2019 10:39:59 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6AC7E307D853; Wed, 6 Mar 2019 18:39:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99BAB60E3D; Wed, 6 Mar 2019 18:39:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 639BF181A12C; Wed, 6 Mar 2019 18:39:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x26IdrmN019827 for ; Wed, 6 Mar 2019 13:39:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id AFD33611A0; Wed, 6 Mar 2019 18:39:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A92FA6090C for ; Wed, 6 Mar 2019 18:39:51 +0000 (UTC) Received: from srv05.mailrelay.rbc.ru (srv05.mailrelay.rbc.ru [80.68.253.53]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 774BC309265C for ; Wed, 6 Mar 2019 18:39:46 +0000 (UTC) Received: from ops-node05.infra.rbc.ru (unknown [80.68.243.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by srv05.mailrelay.rbc.ru (Postfix) with ESMTPS id 44F2cH48tFz115H; Wed, 6 Mar 2019 21:39:43 +0300 (MSK) Received: (from root@localhost) by ops-node05.infra.rbc.ru (8.14.7/8.14.7/Submit) id x26IdhSu003422; Wed, 6 Mar 2019 21:39:43 +0300 Authentication-Results: ohr7ungaeTh1Re.rbc.ru; dkim=none From: Maxim Kozin To: libvir-list@redhat.com Date: Wed, 6 Mar 2019 21:39:11 +0300 Message-Id: <1551897551-3122-1-git-send-email-kolomaxes@gmail.com> X-Greylist: Sender passed SPF test, ACL 242 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 06 Mar 2019 18:39:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 06 Mar 2019 18:39:50 +0000 (UTC) for IP:'80.68.253.53' DOMAIN:'srv05.mailrelay.rbc.ru' HELO:'srv05.mailrelay.rbc.ru' FROM:'root@rbc.ru' RCPT:'' X-RedHat-Spam-Score: 1.451 * (DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, NML_ADSP_CUSTOM_MED, SPF_HELO_PASS, SPF_PASS) 80.68.253.53 srv05.mailrelay.rbc.ru 80.68.253.53 srv05.mailrelay.rbc.ru X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Maxim Kozin Subject: [libvirt] [PATCH] LXC containers don't stopped under some conditions X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 06 Mar 2019 18:39:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" LXC containers can be started, but time to time can't be stopped. 1) virsh shutdown with option "--mode initctl" always stop container, but virsh report error: "Container does not provide an initctl pipe" In container present /dev/initctl 2) virsh shutdown with option "--mode signal" never stop lxc container, at least for centos 7.5/7.6 In container log: systemd: Received SIGTERM. systemd: Reexecuting. systemd: systemd 219 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN) systemd: Detected virtualization lxc-libvirt. systemd: Detected architecture x86-64. 3) virsh shutdown without option "--mode" can stop lxc container, but in 2 = cases: - cointainer not under heavy load - in gdb when perform step-by-setp debug But most often not, with simptoms as with --mode signal. Patch tested only with host centos 7.6 and guests centos 7.5/7.6 Short comments to patch. lxcDomainShutdownFlags() return rc=3D0 and container begin stopped. We not go to endjob label, but later we pass check: if (rc =3D=3D 0 && (flags =3D=3D 0 || (flags & VIR_DOMAIN_SHUTDOWN_SIGNAL))) { And trying next shutdown method with sigterm to PID 1. If container heavy loaded, it not stopped. IF not or if you wait in gdb, th= en first method succefully perform shutdown. Signed-off-by: Maxim Kozin --- src/lxc/lxc_driver.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index b1ef221..760f9f8 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3269,7 +3269,7 @@ lxcDomainShutdownFlags(virDomainPtr dom, virLXCDomainObjPrivatePtr priv; virDomainObjPtr vm; int ret =3D -1; - int rc; + int rc =3D -1; =20 virCheckFlags(VIR_DOMAIN_SHUTDOWN_INITCTL | VIR_DOMAIN_SHUTDOWN_SIGNAL, -1); @@ -3298,19 +3298,17 @@ lxcDomainShutdownFlags(virDomainPtr dom, (flags & VIR_DOMAIN_SHUTDOWN_INITCTL)) { int command =3D VIR_INITCTL_RUNLEVEL_POWEROFF; =20 - if ((rc =3D virLXCDomainSetRunlevel(vm, command)) < 0) - goto endjob; - if (rc =3D=3D 0 && flags !=3D 0 && - ((flags & ~VIR_DOMAIN_SHUTDOWN_INITCTL) =3D=3D 0)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("Container does not provide an initctl pipe")= ); - goto endjob; + if ((rc =3D virLXCDomainSetRunlevel(vm, command)) < 0) { + if (flags !=3D 0 && + (flags & VIR_DOMAIN_SHUTDOWN_INITCTL)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Container does not provide an initctl pi= pe")); + goto endjob; + } } - } else { - rc =3D 0; } =20 - if (rc =3D=3D 0 && + if (rc < 0 && (flags =3D=3D 0 || (flags & VIR_DOMAIN_SHUTDOWN_SIGNAL))) { if (kill(priv->initpid, SIGTERM) < 0 && @@ -3347,7 +3345,7 @@ lxcDomainReboot(virDomainPtr dom, virLXCDomainObjPrivatePtr priv; virDomainObjPtr vm; int ret =3D -1; - int rc; + int rc =3D -1; =20 virCheckFlags(VIR_DOMAIN_REBOOT_INITCTL | VIR_DOMAIN_REBOOT_SIGNAL, -1); @@ -3376,19 +3374,17 @@ lxcDomainReboot(virDomainPtr dom, (flags & VIR_DOMAIN_REBOOT_INITCTL)) { int command =3D VIR_INITCTL_RUNLEVEL_REBOOT; =20 - if ((rc =3D virLXCDomainSetRunlevel(vm, command)) < 0) - goto endjob; - if (rc =3D=3D 0 && flags !=3D 0 && - ((flags & ~VIR_DOMAIN_SHUTDOWN_INITCTL) =3D=3D 0)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("Container does not provide an initctl pipe")= ); - goto endjob; + if ((rc =3D virLXCDomainSetRunlevel(vm, command)) < 0) { + if (flags !=3D 0 && + (flags & VIR_DOMAIN_REBOOT_INITCTL)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Container does not provide an initctl pi= pe")); + goto endjob; + } } - } else { - rc =3D 0; } =20 - if (rc =3D=3D 0 && + if (rc < 0 && (flags =3D=3D 0 || (flags & VIR_DOMAIN_REBOOT_SIGNAL))) { if (kill(priv->initpid, SIGHUP) < 0 && --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list