From nobody Wed Apr 24 09:08:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1616776034; cv=none; d=zohomail.com; s=zohoarc; b=UDSS1bbVy5HClpgPbAJ8QhWXyXthwzFQblMF0yiHhTqMn6E9xOi/qMZY1WUvxpBIynmb6bhbtPasXYbvYQj+DtMb9GYluKX2DI7xnmdW3MGuGYT9qQiu5HITLdR3PlMyyhjUCL5lbgM2lJUnOY4OiW/YzgB+KHAruHT0nKE4z3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616776034; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BgrBHwEKE/AzQ6DTDkpb8dgqkglqVRujRvXnU1qRcjc=; b=ZJUm/jslrmGjpJqEgjmJGrizpsnLaXms3w+kWgFZZZiNiNdYB6fpAOM4miPu0IFtrd6C3AbvkV+iYIy7xONk5ABMeNj4x3bR/zSoL3hCIAoJmudKXZeX4E/aARqWSdbQtJLBm5m2KitDdL1q0Xph6V90iV2ths+eDA+BXcGKAD8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1616776033996997.4713152100672; Fri, 26 Mar 2021 09:27:13 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-404-edF-CouhMfaAZCEwaZ6IPg-1; Fri, 26 Mar 2021 12:26:29 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6DCB191220; Fri, 26 Mar 2021 16:26:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6685E5DAA5; Fri, 26 Mar 2021 16:26:22 +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 2C75F4BB7B; Fri, 26 Mar 2021 16:26:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12QGPFSr000303 for ; Fri, 26 Mar 2021 12:25:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id D7E1D2026D48; Fri, 26 Mar 2021 16:25:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D07642026D65 for ; Fri, 26 Mar 2021 16:25:13 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06AEF80A1D2 for ; Fri, 26 Mar 2021 16:25:13 +0000 (UTC) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-556-9UEHusdkMsGi6cMBZQ9QvQ-1; Fri, 26 Mar 2021 12:25:10 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12QGDLGI093765; Fri, 26 Mar 2021 12:25:10 -0400 Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 37hhqvjrfe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Mar 2021 12:25:09 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12QGOK5X025788; Fri, 26 Mar 2021 16:25:08 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma02fra.de.ibm.com with ESMTP id 37h14tgeb0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Mar 2021 16:25:07 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 12QGOkSA12517764 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Mar 2021 16:24:46 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B8D14C04E; Fri, 26 Mar 2021 16:25:05 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0287F4C040; Fri, 26 Mar 2021 16:25:05 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 26 Mar 2021 16:25:04 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id B409DE01DB; Fri, 26 Mar 2021 17:25:04 +0100 (CET) X-MC-Unique: edF-CouhMfaAZCEwaZ6IPg-1 X-MC-Unique: 9UEHusdkMsGi6cMBZQ9QvQ-1 From: Eric Farman To: Pavel Hrdina , libvir-list@redhat.com Subject: [PATCH 1/1] vircgroup: Cleanup nested cgroups Date: Fri, 26 Mar 2021 17:25:03 +0100 Message-Id: <20210326162503.1565199-2-farman@linux.ibm.com> In-Reply-To: <20210326162503.1565199-1-farman@linux.ibm.com> References: <20210326162503.1565199-1-farman@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: U77SNw0ssYAfM9OTg2nwRI4GGFLtPeMB X-Proofpoint-ORIG-GUID: U77SNw0ssYAfM9OTg2nwRI4GGFLtPeMB X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-03-26_06:2021-03-26, 2021-03-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 malwarescore=0 clxscore=1011 impostorscore=0 adultscore=0 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260120 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Boris Fiuczynski , Marc Hartmayer 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The introduction of nested cgroups used a little macro virCgroupGetNested() to retrieve the nested cgroup pointer, if one exists. But this macro isn't used when removing cgroups, resulting in some messages: Mar 25 20:55:17 fedora33 libvirtd[955]: unable to open '/sys/fs/cgroup/ma= chine.slice/machine-qemu\x2d1\x2dguest.scope/': No such file or directory Mar 25 20:55:17 fedora33 libvirtd[955]: Failed to remove cgroup for guest That directory exists while the guest is running, as it was created by systemd/machined, so the code probably meant to open the libvirt/ subdirectory from that point. Similarly, there happen to be BPF-related file descriptors that don't get cleaned up in this process too, because they are anchored off the nested cgroup location: [test@fedora33 ~]# ls /proc/$(pgrep libvirtd)/fd/* | wc -l 35 [test@fedora33 ~]# virsh create guest.xml Domain 'guest' created from guest.xml [test@fedora33 ~]# ls /proc/$(pgrep libvirtd)/fd/* | wc -l 42 [test@fedora33 ~]# virsh shutdown guest Domain 'guest' is being shutdown [test@fedora33 ~]# ls /proc/$(pgrep libvirtd)/fd/* | wc -l 37 [test@fedora33 ~]# virsh create guest.xml Domain 'guest' created from guest.xml [test@fedora33 ~]# ls /proc/$(pgrep libvirtd)/fd/* | wc -l 44 [test@fedora33 ~]# virsh shutdown guest Domain 'guest' is being shutdown [test@fedora33 ~]# ls /proc/$(pgrep libvirtd)/fd/* | wc -l 39 Let's fix this by using the same macro when removing cgroups, so that it picks up the right structure and can remove the associated resources properly. Fixes: 184245f53b94 ("vircgroup: introduce nested cgroup to properly work w= ith systemd") Signed-off-by: Eric Farman --- src/util/vircgroup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 5b6097c335..e606cbfe0b 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -2613,11 +2613,12 @@ virCgroupRemoveRecursively(char *grppath) int virCgroupRemove(virCgroupPtr group) { + virCgroupPtr parent =3D virCgroupGetNested(group); size_t i; =20 for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { - if (group->backends[i]) { - int rc =3D group->backends[i]->remove(group); + if (parent->backends[i]) { + int rc =3D parent->backends[i]->remove(parent); if (rc < 0) return rc; } --=20 2.25.1