From nobody Fri May 16 00:39:36 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1500905499805761.4472336085927; Mon, 24 Jul 2017 07:11:39 -0700 (PDT) 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 B29387EA89; Mon, 24 Jul 2017 14:11:34 +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 54F0394C78; Mon, 24 Jul 2017 14:11:34 +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 0358B180597C; Mon, 24 Jul 2017 14:11:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6OE9orT007578 for ; Mon, 24 Jul 2017 10:09:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 43EDD87F81; Mon, 24 Jul 2017 14:09:50 +0000 (UTC) Received: from caroline.brq.redhat.com (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBC1987F80 for ; Mon, 24 Jul 2017 14:09:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B29387EA89 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B29387EA89 From: Martin Kletzander To: libvir-list@redhat.com Date: Mon, 24 Jul 2017 16:09:33 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] lxc: Make lxcProcessStop callable even without PID being available 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.28]); Mon, 24 Jul 2017 14:11:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This way the function can work as a central point of clean-up code and we don't have to duplicate code. And it works similarly to the qemu driver. Signed-off-by: Martin Kletzander --- src/lxc/lxc_process.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 2658ea61f89e..724297d128d0 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -845,12 +845,6 @@ int virLXCProcessStop(virLXCDriverPtr driver, =20 priv =3D vm->privateData; =20 - if (vm->pid <=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid PID %d for container"), vm->pid); - return -1; - } - virSecurityManagerRestoreAllLabel(driver->securityManager, vm->def, false, false); virSecurityManagerReleaseLabel(driver->securityManager, vm->def); @@ -895,7 +889,7 @@ int virLXCProcessStop(virLXCDriverPtr driver, _("Some processes refused to die")); return -1; } - } else { + } else if (vm->pid > 0) { /* If cgroup doesn't exist, just try cleaning up the * libvirt_lxc process */ if (virProcessKillPainfully(vm->pid, true) < 0) { @@ -1210,8 +1204,6 @@ int virLXCProcessStart(virConnectPtr conn, virCgroupPtr selfcgroup; int status; char *pidfile =3D NULL; - bool clearSeclabel =3D false; - bool need_stop =3D false; =20 if (virCgroupNewSelf(&selfcgroup) < 0) return -1; @@ -1331,9 +1323,6 @@ int virLXCProcessStart(virConnectPtr conn, then generate a security label for isolation */ VIR_DEBUG("Generating domain security label (if required)"); =20 - clearSeclabel =3D vm->def->nseclabels =3D=3D 0 || - vm->def->seclabels[0]->type =3D=3D VIR_DOMAIN_SECLABEL= _DEFAULT; - if (vm->def->nseclabels && vm->def->seclabels[0]->type =3D=3D VIR_DOMAIN_SECLABEL_DEFAULT) vm->def->seclabels[0]->type =3D VIR_DOMAIN_SECLABEL_NONE; @@ -1468,7 +1457,6 @@ int virLXCProcessStart(virConnectPtr conn, goto cleanup; } =20 - need_stop =3D true; priv->stopReason =3D VIR_DOMAIN_EVENT_STOPPED_FAILED; priv->wantReboot =3D false; vm->def->id =3D vm->pid; @@ -1574,23 +1562,7 @@ int virLXCProcessStart(virConnectPtr conn, } if (rc !=3D 0) { err =3D virSaveLastError(); - if (need_stop) { - virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); - } else { - virSecurityManagerRestoreAllLabel(driver->securityManager, - vm->def, false, false); - virSecurityManagerReleaseLabel(driver->securityManager, vm->de= f); - /* Clear out dynamically assigned labels */ - if (vm->def->nseclabels && - (vm->def->seclabels[0]->type =3D=3D VIR_DOMAIN_SECLABEL_DY= NAMIC || - clearSeclabel)) { - VIR_FREE(vm->def->seclabels[0]->model); - VIR_FREE(vm->def->seclabels[0]->label); - VIR_FREE(vm->def->seclabels[0]->imagelabel); - VIR_DELETE_ELEMENT(vm->def->seclabels, 0, vm->def->nseclab= els); - } - virLXCProcessCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); - } + virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); } virCommandFree(cmd); for (i =3D 0; i < nveths; i++) --=20 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list