From nobody Tue May 7 06:48:00 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1567078024; cv=none; d=zoho.com; s=zohoarc; b=YPeHXLGaWLZ4OZK97/OmSR++S6wCNwx7dogo95wqMM6uO5zGNiKN6HwavZQVmy9mLgexaXdvE163p2UaVZNRO3VNq4rM92/RE+3ifSfbSuy6uJvcDM7rvC7Hti5pswv/5cV8GkGzulffYw39cX7mp5IpAokzLv3l2UM1Csq0vMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567078024; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=2qEniRXM9Yk1K5y9w56yRg6r33z85feWBq/6iOQZ3f4=; b=Ig+a9RqArgeqy27ie28kx28iwzbqfgiwlVfmxsnylOswQ1j1bRLd+KF8ayjK+rXo4rVqnDJA7PLE7RN+3CVFtWJChUt0hTSGWTDBLME6I2XJXSqN5zanqBtgFqrYbGjCimR1H3SMJImFCUpnOhUs7++KKg1q9nP+O+Ffrup/yl8= ARC-Authentication-Results: i=1; mx.zoho.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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1567078024481668.083683486515; Thu, 29 Aug 2019 04:27:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CBD0718B3D87; Thu, 29 Aug 2019 11:27:02 +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 0E048600C1; Thu, 29 Aug 2019 11:27:02 +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 F3770180B536; Thu, 29 Aug 2019 11:27:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7TBQxxe005532 for ; Thu, 29 Aug 2019 07:26:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id B49145D9E2; Thu, 29 Aug 2019 11:26:59 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-60.ams2.redhat.com [10.36.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id A495C5D9C9; Thu, 29 Aug 2019 11:26:55 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 12:26:53 +0100 Message-Id: <20190829112653.13803-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH REPOST] Revert "lxc: Try harder to stop/reboot containers" 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: , Content-Type: text/plain; charset="utf-8" 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Thu, 29 Aug 2019 11:27:03 +0000 (UTC) This reverts commit 14b6a1854fb4c02c5fb2f51679f8ff099f28f53c. If virLXCDomainSetRunlevel returns -1 this indicates a serious error / failure that must be propagated to the caller. We must not carry on with other shutdown methods in this case. If virLXCDomainSetRunlevel return 0, this indicates that no initctl was found and it is thus reasonable to fallback to sending SIGTERM. The commit being reverted is broken because it would fallback to SIGTERM when virLXCDomainSetRunlevel returns -1, and would not fallback when virLXCDomainSetRunlevel returns 0. ie it did the exact opposite of what was required. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/lxc/lxc_driver.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 5453f49064..ca0090de59 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3271,7 +3271,7 @@ lxcDomainShutdownFlags(virDomainPtr dom, virLXCDomainObjPrivatePtr priv; virDomainObjPtr vm; int ret =3D -1; - int rc =3D -1; + int rc; =20 virCheckFlags(VIR_DOMAIN_SHUTDOWN_INITCTL | VIR_DOMAIN_SHUTDOWN_SIGNAL, -1); @@ -3300,17 +3300,19 @@ lxcDomainShutdownFlags(virDomainPtr dom, (flags & VIR_DOMAIN_SHUTDOWN_INITCTL)) { int command =3D VIR_INITCTL_RUNLEVEL_POWEROFF; =20 - 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; - } + 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; } + } else { + rc =3D 0; } =20 - if (rc < 0 && + if (rc =3D=3D 0 && (flags =3D=3D 0 || (flags & VIR_DOMAIN_SHUTDOWN_SIGNAL))) { if (kill(priv->initpid, SIGTERM) < 0 && @@ -3347,7 +3349,7 @@ lxcDomainReboot(virDomainPtr dom, virLXCDomainObjPrivatePtr priv; virDomainObjPtr vm; int ret =3D -1; - int rc =3D -1; + int rc; =20 virCheckFlags(VIR_DOMAIN_REBOOT_INITCTL | VIR_DOMAIN_REBOOT_SIGNAL, -1); @@ -3376,17 +3378,19 @@ lxcDomainReboot(virDomainPtr dom, (flags & VIR_DOMAIN_REBOOT_INITCTL)) { int command =3D VIR_INITCTL_RUNLEVEL_REBOOT; =20 - 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; - } + 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; } + } else { + rc =3D 0; } =20 - if (rc < 0 && + if (rc =3D=3D 0 && (flags =3D=3D 0 || (flags & VIR_DOMAIN_REBOOT_SIGNAL))) { if (kill(priv->initpid, SIGHUP) < 0 && --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list