From nobody Sun May 5 16:48:55 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=1562233698; cv=none; d=zoho.com; s=zohoarc; b=hG8mFqYCKvHJbwj7gzEbIYpSSlOPZlAeW0DQ/KsNptUq8EOdEd+2yOuLFXLVETO57HkJEpda+NUukh4EK68Tavx8VLao+XGT5u6LHR2YtstL3cQufhXCUB0/7UbHcsBMolCdDr0IYiOHwc3ewIs6jN9VuuJvrsfuPdJOxPLWFTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562233698; h=Content-Type:Content-Transfer-Encoding:Cc: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=fv8fzVNwmMKsRlzOv3M0bbOsx0SykxrKt5TKRTntXWQ=; b=maa9wLxLtC5hEZhmZ4JMOyXIF1nKw0Quh9mhMYTOyvkleqH+8mCe4G+cs6EXKOfW1yMOCkOzC+U8OafrxmaIiWlQb5G90TYB+N4hAy1vvnRzDhfEt6ZYXo5TJG9mGgt9Do2GhgIZMs99EkLG0T3DI33yFoVpZd9tzIWi4cX8tUY= 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 1562233698562956.5892675177756; Thu, 4 Jul 2019 02:48:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4EEE730BC56E; Thu, 4 Jul 2019 09:47:22 +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 6BA4318A76; Thu, 4 Jul 2019 09:47:15 +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 4C09518184B6; Thu, 4 Jul 2019 09:47:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x649l028007120 for ; Thu, 4 Jul 2019 05:47:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3896610018F9; Thu, 4 Jul 2019 09:47:00 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C3901001B12; Thu, 4 Jul 2019 09:46:53 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 10:46:49 +0100 Message-Id: <20190704094649.24301-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , Maxim Kozin , Lubomir Rintel Subject: [libvirt] [PATCH] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 04 Jul 2019 09:48:08 +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 --- 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 9db2a02dee..01af5f6db8 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3262,7 +3262,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); @@ -3291,17 +3291,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 && @@ -3338,7 +3340,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); @@ -3367,17 +3369,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