From nobody Fri May 3 06:11:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1666182198; cv=none; d=zohomail.com; s=zohoarc; b=Y+Tlheiw2APQbmLuVYNgDRooYVuNYkSAYwMrCpMhle5FdjESnjKg7ntj3xzgIfmkUIW04HnVYlaUoubXAP0dJknd9PD4vZDi6oWWgSb7MqAObk1t15Ck76dShwL+wkxcHhhzoBkq8yJ6ML6f3VeLCmZp4LnV9K5K21kUq6I1u8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666182198; 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=b6+nRwdUj7kd5Q6sZ9PwfqsVF0uIT4p4/hOUObDk2EI=; b=IaIF2j2nigX+t0IcK9qmCkNnHWDLx+uRNw9ulCZPjCqBGsR3F5iPyfe4HP1Vte61d01gx3DUKaES+RPvUqNc0FPA3yHgaTNYID5mtt5fHS+q2b57rkx7v3FW4VdW65VdU0DwykhQYJB8O4vd5odMVyqU52Mqoic8jR8N3hTDpbo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1666182198576412.4019254929941; Wed, 19 Oct 2022 05:23:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-kSEp3xv6MGS9nP2F4Xg0XA-1; Wed, 19 Oct 2022 08:23:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A718110726CD; Wed, 19 Oct 2022 12:22:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FABD4081B61; Wed, 19 Oct 2022 12:22:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 709C01946595; Wed, 19 Oct 2022 12:22:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E59441946587 for ; Wed, 19 Oct 2022 12:13:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BBB98111E3F8; Wed, 19 Oct 2022 12:13:48 +0000 (UTC) Received: from antique-laptop.redhat.com (ovpn-208-13.brq.redhat.com [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AE07111E3F2 for ; Wed, 19 Oct 2022 12:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666182196; 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=b6+nRwdUj7kd5Q6sZ9PwfqsVF0uIT4p4/hOUObDk2EI=; b=MUGsTBCP6+E1f5Xt67DZ4jIubSSO8OBu5YnhtJR7PFRsJ674Ef3i2oeYojxBEgKhH1Yn9H iOVY+8/3/hyFoL/rWM4QvltqGq8jPrHBP0pDwc0rqz91IH9UP5m7sUiBDYzqYXkyoY8h6w pUO4sjf84nOjHu++gM911zUTyt6i98Q= X-MC-Unique: kSEp3xv6MGS9nP2F4Xg0XA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] vircgroupmock: fix cgroup v1 mocking Date: Wed, 19 Oct 2022 14:13:45 +0200 Message-Id: <5fdf6118f6c2ece519a5de97863f1f4f2a0d6110.1666181550.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666182199894100003 Content-Type: text/plain; charset="utf-8"; x-default="true" The `legacy` mode is also valid so we need to take it into account as well. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- tests/vircgroupmock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index 8a0e3aec0f..777d60b152 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -317,7 +317,7 @@ static int make_controller(const char *path, mode_t mod= e) unified =3D true; } else if (STREQ(mock, "hybrid")) { hybrid =3D true; - } else { + } else if (STRNEQ(mock, "legacy")) { fprintf(stderr, "invalid mode '%s'\n", mock); abort(); } @@ -355,7 +355,7 @@ static void init_sysfs(void) unified =3D true; } else if (STREQ(mock, "hybrid")) { hybrid =3D true; - } else { + } else if (STRNEQ(mock, "legacy")) { fprintf(stderr, "invalid mode '%s'\n", mock); abort(); } --=20 2.37.3 From nobody Fri May 3 06:11:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1666181883; cv=none; d=zohomail.com; s=zohoarc; b=ETsAT0OQZWjTSpHw226icrSipczG5/fwGZ38vVSwUDGvhbQ+i0aGqI2WaG7xZBoX22ve82O6QAyIVhpdNA9DfkPVdFdKnD3qUH13hByZQPwQO4MLs0FqhRcfxexYORZdFNu8gEqD3RKrSkUxok+dg44pnjLEpDf0BgAJL6PDzno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666181883; 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=Sbia5TdeeJC6sJYmooIw12oaaUw+dKKlOjWtKF5CGe0=; b=RXz5i8nxsGWjU/h7j5+qxoEGkvyrHpnUMXO28P2le488gp8qnG45yYKZNB41JTc1wfggMOm1xBcU/Rm/zdrUCqd5eNY2PARk4KUGhT4IjyrbmvsKY7B7vRbo3SPmPeU7JBfirVcPtbLaCSZnvCJL88e8PEhc+c0iAcCsQ8eyLbU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1666181883468747.5341043243042; Wed, 19 Oct 2022 05:18:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-375-sgqPMKVrOv2zjvCyuyH8xw-1; Wed, 19 Oct 2022 08:17:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B964E3C32C6A; Wed, 19 Oct 2022 12:17:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AA5D200BA83; Wed, 19 Oct 2022 12:17:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0C0E91946595; Wed, 19 Oct 2022 12:17:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BDDCD1946587 for ; Wed, 19 Oct 2022 12:13:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A14F1111E3F8; Wed, 19 Oct 2022 12:13:49 +0000 (UTC) Received: from antique-laptop.redhat.com (ovpn-208-13.brq.redhat.com [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CA6A111E3F2 for ; Wed, 19 Oct 2022 12:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666181882; 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=Sbia5TdeeJC6sJYmooIw12oaaUw+dKKlOjWtKF5CGe0=; b=WxtvHRP+O3NVBhrjt6XjxNr5g2Ew9ciOFy8+nTTj9bt0NCIOrHxyvTQgfYgoTOdVBkPFdl EwiCZRUZhxFkkBAM9H1IL4fc/YwbqwMvOUmof7g7yhR74F9WBygdFlkHLQbFC81+TwczkF /GeC6pbTMwM9iLTK3VaV5j0bDaZ2uRQ= X-MC-Unique: sgqPMKVrOv2zjvCyuyH8xw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] vircgroup: rework virCgroupNewSelf Date: Wed, 19 Oct 2022 14:13:46 +0200 Message-Id: <4a092b22b487cb7077b62fc954ff5a55a72fb3d9.1666181550.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666181884581100001 Content-Type: text/plain; charset="utf-8"; x-default="true" With the introduction of `libvirt` sub-directory to the cgroup topology some of the cgroup configuration was moved into that sub-directory together with the VM processes. LXC uses virCgroupNewSelf() in the container process to detect cgroups in order to report various data from cgroups inside the container. We need to properly detect the new `libvirt` sub-directory here otherwise LXC will report incorrect data. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- src/util/vircgroup.c | 15 ++++++++++++++- tests/vircgrouptest.c | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 9918430cca..a6a409af3d 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1024,7 +1024,20 @@ virCgroupNewNested(virCgroup *parent, int virCgroupNewSelf(virCgroup **group) { - return virCgroupNewDetect(-1, -1, group); + g_autoptr(virCgroup) newGroup =3D NULL; + g_autoptr(virCgroup) nested =3D NULL; + + if (virCgroupNewDetect(-1, -1, &newGroup) < 0) + return -1; + + if (virCgroupNewNested(newGroup, -1, false, -1, &nested) < 0) + return -1; + + if (virCgroupExists(nested)) + newGroup->nested =3D g_steal_pointer(&nested); + + *group =3D g_steal_pointer(&newGroup); + return 0; } =20 =20 diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index e29bc094b1..848a9c7bb0 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -1019,7 +1019,9 @@ mymain(void) DETECT_MOUNTS("cgroups1"); DETECT_MOUNTS("cgroups2"); DETECT_MOUNTS("cgroups3"); + fakerootdir =3D initFakeFS(NULL, "all-in-one"); DETECT_MOUNTS("all-in-one"); + cleanupFakeFS(fakerootdir); DETECT_MOUNTS_FAIL("no-cgroups"); DETECT_MOUNTS("kubevirt"); fakerootdir =3D initFakeFS("unified", NULL); --=20 2.37.3