From nobody Thu May 2 15:57:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1578320685; cv=none; d=zohomail.com; s=zohoarc; b=FCGb+fG3q3ZdxjDWYCZmPtgLtnNEBewVwXXi3k54R/1/LeC1gJUUxJLEdKSH3bedVqTljcMlNjP44UdjzhtHN8dNoK4hAhmvcRd0YyMBXp82SvzalbwZekXHcUg8+K/yOSHSLVLm4ZQilZiGE0Xvq/rceNoX8ny3mJL6o5FVe24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578320685; h=Content-Type:Content-Transfer-Encoding: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=QnE9a/Dp0nPTBtFVl/sn1HBiQgcQhbup2TWG4WIlQlo=; b=Ml4vHpIaNGo+WEXMS7Jp0Pa24YKag4ijoTi4itVEIx6pqaEtu8US8G+4aq1ECKzBPDZa3oS/nzKqRXrpBuIDPTP5LTQ0oQOofAaQmsSCfuZt91xbNHkNVKEiR4louNSwWtkdiRSn5yiBu7hDwwIQ4NufsbGbyeBHARU2tdDKoS4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1578320685818621.4179396159003; Mon, 6 Jan 2020 06:24:45 -0800 (PST) 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-34-Eohe6_wGO0ef7w21_j5p7Q-1; Mon, 06 Jan 2020 09:24:41 -0500 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 7068C8024DC; Mon, 6 Jan 2020 14:24:36 +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 38E425D9E1; Mon, 6 Jan 2020 14:24:36 +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 D76D781C74; Mon, 6 Jan 2020 14:24:35 +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 006EORhu009606 for ; Mon, 6 Jan 2020 09:24:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id A33845D9E1; Mon, 6 Jan 2020 14:24:27 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C55B5D9CA for ; Mon, 6 Jan 2020 14:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578320684; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QnE9a/Dp0nPTBtFVl/sn1HBiQgcQhbup2TWG4WIlQlo=; b=DVhtRGJAeASdKf2i0Kw4ieT/e+zzbLo8XAWu4hEex5E8xDiYV18rmet7xCcHrGwPBY0Dcx TbUKUedLIHLNLFF8MPt7QpDJY1JS+nDF0ScUN4ENa5dVtUVctTFOgbU9jar6ySJJlNJ/nG gom+nk4VCvuEEwlYBqd6J7xX6S8XiDw= From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 15:24:19 +0100 Message-Id: <0fb9667761c01e7c6c63b5572bb9aea0e9dbe43e.1578320640.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] vircgroupv2devices: Unexport virCgroupV2DevicesAttachProg() 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 X-MC-Unique: Eohe6_wGO0ef7w21_j5p7Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This function is not called outside of the source file where it's defined. There's no need to export it. Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina --- src/libvirt_private.syms | 1 - src/util/vircgroupv2devices.c | 14 +------------- src/util/vircgroupv2devices.h | 5 ----- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 74e3479842..9185e49fda 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1734,7 +1734,6 @@ virCgroupV1Register; virCgroupV2Register; =20 # util/vircgroupv2devices.h -virCgroupV2DevicesAttachProg; virCgroupV2DevicesAvailable; virCgroupV2DevicesCreateProg; virCgroupV2DevicesDetectProg; diff --git a/src/util/vircgroupv2devices.c b/src/util/vircgroupv2devices.c index dcf8925b18..7ea3c70efb 100644 --- a/src/util/vircgroupv2devices.c +++ b/src/util/vircgroupv2devices.c @@ -274,7 +274,7 @@ virCgroupV2DevicesLoadProg(int mapfd) } =20 =20 -int +static int virCgroupV2DevicesAttachProg(virCgroupPtr group, int mapfd, size_t max) @@ -591,18 +591,6 @@ virCgroupV2DevicesAvailable(virCgroupPtr group G_GNUC_= UNUSED) } =20 =20 -int -virCgroupV2DevicesAttachProg(virCgroupPtr group G_GNUC_UNUSED, - int mapfd G_GNUC_UNUSED, - size_t max G_GNUC_UNUSED) -{ - virReportSystemError(ENOSYS, "%s", - _("cgroups v2 BPF devices not supported " - "with this kernel")); - return -1; -} - - int virCgroupV2DevicesDetectProg(virCgroupPtr group G_GNUC_UNUSED) { diff --git a/src/util/vircgroupv2devices.h b/src/util/vircgroupv2devices.h index 7b6cececc1..9d91256120 100644 --- a/src/util/vircgroupv2devices.h +++ b/src/util/vircgroupv2devices.h @@ -28,11 +28,6 @@ bool virCgroupV2DevicesAvailable(virCgroupPtr group) G_GNUC_NO_INLINE; =20 -int -virCgroupV2DevicesAttachProg(virCgroupPtr group, - int mapfd, - size_t max); - int virCgroupV2DevicesDetectProg(virCgroupPtr group); =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 15:57:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1578320691; cv=none; d=zohomail.com; s=zohoarc; b=YJg3AVPOOzLipLJywyDHn7BkGJcO6i/zIWQVBj7QVwKjSiHpNRFYkib/FzLL08oZ8ntOpSb/3HJ15LGpDu3r54AV7QDhJXUZhpqsZxf473U93Ms76c7QXaVVgG7uWmOFp9zWtE+s7vp5bPit/OJW28bV3tapAs4RV6sEYptMpi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578320691; h=Content-Type:Content-Transfer-Encoding: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=C2eAJHtPupjdYOF+Vs3m1S9Ng0hskCu0Ft+IVsVmC0Y=; b=ZT288/2NQdOUODoZEkMaaeio/8OlE7U1vyWpUPpTumzyMhF0f8m2OUooDFlb/mPbRV/KEWdxluQZlDzMqsBVFpv+aY7T0fcgfkvgxvpHmlVq4FMCEKXD7yboPkRG4WYBU2mRoCe5MvvREbd5V2rMPe02j4bNyyRe7UFK7JXMIzQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578320691063402.4596826816487; Mon, 6 Jan 2020 06:24:51 -0800 (PST) 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-17-A4qFAWbwMfG9JQ35mWLBKQ-1; Mon, 06 Jan 2020 09:24:48 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEAA71005514; Mon, 6 Jan 2020 14:24:40 +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 9BF745C6DC; Mon, 6 Jan 2020 14:24:40 +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 5A6241803C32; Mon, 6 Jan 2020 14:24:40 +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 006EOS4T009616 for ; Mon, 6 Jan 2020 09:24:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7319D5D9CA; Mon, 6 Jan 2020 14:24:28 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id F02515D9E1 for ; Mon, 6 Jan 2020 14:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578320689; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=C2eAJHtPupjdYOF+Vs3m1S9Ng0hskCu0Ft+IVsVmC0Y=; b=hEtpQd4SxTob1jooZYbulbA3HFw84X4KGDnMrIQ0wwc1r5EHr8L7IIW91lTPC6uq/wIrD3 wJ4zoMqq4ZGC9vQ+1oICpbOcuV0gLxHcdjv9IK8tOIbOmxgmETh2i1WxF4wwX4knWzFVDb B//ASU8TID7/6xdjjNSJLJDzJ2He3V0= From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 15:24:20 +0100 Message-Id: <90f24cf2ca039d3f709dbeb91484706f5a7c77f0.1578320640.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] vircgroupv2devices: Avoid double close on map FD 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.16 X-MC-Unique: A4qFAWbwMfG9JQ35mWLBKQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When allowing/denying a device in devices CGroupV2 we have to write a BPF program for it. The program we put there is merely static and all it does it looks up a device in a hash table (also known as map in BPF terminology). A map is referenced via an FD which can be acquired via virBPFCreateMap() and like any other FD it should be closed when no longer needed. However, we close it twice: the first time in virCgroupV2DevicesAttachProg() which closes it unconditionally, and the second time in either virCgroupV2DevicesCreateProg() or virCgroupV2DevicesPrepareProg(). Remove the second close. Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina --- src/util/vircgroupv2devices.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/util/vircgroupv2devices.c b/src/util/vircgroupv2devices.c index 7ea3c70efb..402ce3f86f 100644 --- a/src/util/vircgroupv2devices.c +++ b/src/util/vircgroupv2devices.c @@ -494,7 +494,7 @@ virCgroupV2DevicesReallocMap(int mapfd, int virCgroupV2DevicesCreateProg(virCgroupPtr group) { - VIR_AUTOCLOSE mapfd =3D -1; + int mapfd =3D -1; =20 if (group->unified.devices.progfd > 0 && group->unified.devices.mapfd = > 0) return 0; @@ -503,13 +503,8 @@ virCgroupV2DevicesCreateProg(virCgroupPtr group) if (mapfd < 0) return -1; =20 - if (virCgroupV2DevicesAttachProg(group, mapfd, - VIR_CGROUP_V2_INITIAL_BPF_MAP_SIZE) <= 0) { - return -1; - } - - mapfd =3D -1; - return 0; + return virCgroupV2DevicesAttachProg(group, mapfd, + VIR_CGROUP_V2_INITIAL_BPF_MAP_SIZE= ); } =20 =20 @@ -530,10 +525,8 @@ virCgroupV2DevicesPrepareProg(virCgroupPtr group) if (newmapfd < 0) return -1; =20 - if (virCgroupV2DevicesAttachProg(group, newmapfd, max) < 0) { - VIR_FORCE_CLOSE(newmapfd); + if (virCgroupV2DevicesAttachProg(group, newmapfd, max) < 0) return -1; - } } =20 return 0; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list