From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407317; cv=none; d=zohomail.com; s=zohoarc; b=PmVFbEKnlBSzC89EcmRpxeOpMxZ4suJ70eyMCLT49DqY5Xm2afm4DESoPn9VVHuOuXzm1K4biHqU8svugZt8+rqv0wDJICa4Mhk/lA9FOp0c+acNf1CIxUnHsN8gwrwa4cwUs3Q9GVpw/zBkBXPLYZ6Iz3preQJq2+PSt8NbtfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407317; 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=MXmk5phNZHAb48LiTChu0taEhwgyJ33Jy+WIOIEJkak=; b=UsFKPtWC5t8COvsVhKsz1hiKgmtexfmgMzApTrKTQ/DG7TgQm+pz0Fx8zP+mE2A3ANIdnMjMmxUnCyrw6HUaezipgofAWrv2H/dUcOc+yrHTKMckmKuQFSpdc1qZpSK74chaEgUwoZNc5NAftNSiRzStXxd9modDVVjDnPPE8vo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 160440731781879.10599213116302; Tue, 3 Nov 2020 04:41:57 -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-46-3AvwpuQ-P2GFS6I49k1PRg-1; Tue, 03 Nov 2020 07:41:54 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 363B880B70A; Tue, 3 Nov 2020 12:41:49 +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 0C8205B4AE; Tue, 3 Nov 2020 12:41:48 +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 148A744A43; Tue, 3 Nov 2020 12:41:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cfh59015826 for ; Tue, 3 Nov 2020 07:41:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 27B8573661; Tue, 3 Nov 2020 12:41:43 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95BBE1C4 for ; Tue, 3 Nov 2020 12:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407316; 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=MXmk5phNZHAb48LiTChu0taEhwgyJ33Jy+WIOIEJkak=; b=Xvbvmc+5ewwzvVUbyT7MNjumFL1eI0E3Z56VyyDUb+2L4diFaqmE2G7ji8hgs+fJ+wZ9dm sIc9jJ2FC8KajMrf2sF1gYMJLJy631PqIX9wB9lYqhgzjltEyg1yMIBiB82N1iJWFRKPMk whv8SvPmz3FZRygC38WuOcH/2q9LjAQ= X-MC-Unique: 3AvwpuQ-P2GFS6I49k1PRg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 01/25] qemu_cgroup: remove unused @empty variable Date: Tue, 3 Nov 2020 13:41:13 +0100 Message-Id: <3a72c93395748bdb4f33c83c3cf3089f3187f41d.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/qemu/qemu_cgroup.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 210cac9866..10fdc7444d 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -988,7 +988,6 @@ static void qemuRestoreCgroupState(virDomainObjPtr vm) { g_autofree char *mem_mask =3D NULL; - int empty =3D -1; qemuDomainObjPrivatePtr priv =3D vm->privateData; size_t i =3D 0; g_autoptr(virBitmap) all_nodes =3D NULL; @@ -1003,8 +1002,8 @@ qemuRestoreCgroupState(virDomainObjPtr vm) if (!(mem_mask =3D virBitmapFormat(all_nodes))) goto error; =20 - if ((empty =3D virCgroupHasEmptyTasks(priv->cgroup, - VIR_CGROUP_CONTROLLER_CPUSET)) <= =3D 0) + if (virCgroupHasEmptyTasks(priv->cgroup, + VIR_CGROUP_CONTROLLER_CPUSET) <=3D 0) goto error; =20 if (virCgroupSetCpusetMems(priv->cgroup, mem_mask) < 0) --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407384; cv=none; d=zohomail.com; s=zohoarc; b=YtdbeTyyph+Dml46GZc3QUbxXBEshVqTmwaeXvIHVZgLp2MEw2WRdRoiKbgS1/PeOigqXwRxXrSrjULEJCis2ch4TmJbliagLfesbgOkX/buS9YGL//TFXt31Bp60ljJuK1Uw9B/wh3RWF4VkpZ87sWwZslAYzkjViR74DXvXOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407384; 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=oXS5lESctdQZI36OCyQKUKY1c7l2WwMS0pokbBd8hGs=; b=cDOrgm2JwwkaQ8wp9nyfyjYVGlR9LdGQ7xe3/dLUoyyGlG7vjm1B3qtWoiJfC7slR7bEC4o3UsYDIP97VHDpCA8wln/jaLCJ07upMqykJmVdMYsznsFyis12yIRYKM73tVt92Sv2IKB53ez1XxohtbrTuY+zBhB6obU1GSW3NB0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604407384049324.76733242636556; Tue, 3 Nov 2020 04:43:04 -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-425-yXtit-I-Pn6vwXmUuP9ShQ-1; Tue, 03 Nov 2020 07:42:08 -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 2B625186841A; Tue, 3 Nov 2020 12:42:02 +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 082F45D9CC; Tue, 3 Nov 2020 12:42:02 +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 C38B71800B70; Tue, 3 Nov 2020 12:42:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cfix8015838 for ; Tue, 3 Nov 2020 07:41:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 10DDA73661; Tue, 3 Nov 2020 12:41:44 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DBE41C4 for ; Tue, 3 Nov 2020 12:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407382; 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=oXS5lESctdQZI36OCyQKUKY1c7l2WwMS0pokbBd8hGs=; b=EwD/oVssfiuTYP1eUd5dza+dwgp2SMAH+Xv1j2Lgln+0c8YZVPxyQBGrmPZYJHJ2levp12 AD1UdKi9agUlWUg/ovvdd7tuRmS7qsmaCm12RA3vRw8oooxvwpowgoL6pLksj2CYDztfpR JANgSkZtq9Ub/trPbMpd0CJDN8Qsa5Y= X-MC-Unique: yXtit-I-Pn6vwXmUuP9ShQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 02/25] qemu: remove dead code that setup cgroups for helper processes Date: Tue, 3 Nov 2020 13:41:14 +0100 Message-Id: <6f1003498ae51e360432c66cfbc6c0cb01a80f6c.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In both cases priv->cgroup will always be NULL because it is called before the QEMU process is started and cgroups are configured. In qemuProcessLaunch() the call order is following: qemuExtDevicesStart() ... virCommandRun() ... qemuSetupCgroup() where qemuDBusStart() is called from qemuExtDevicesStart() but we cgroups are created in qemuSetupCgroup(). Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/qemu/qemu_dbus.c | 4 ---- src/qemu/qemu_slirp.c | 4 ---- 2 files changed, 8 deletions(-) diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index 81042876fe..a0567e55a3 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -268,10 +268,6 @@ qemuDBusStart(virQEMUDriverPtr driver, goto cleanup; } =20 - if (priv->cgroup && - virCgroupAddProcess(priv->cgroup, cpid) < 0) - goto cleanup; - if (qemuSecurityDomainSetPathLabel(driver, vm, sockpath, false) < 0) goto cleanup; =20 diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c index dfb36125f0..4c4949f88b 100644 --- a/src/qemu/qemu_slirp.c +++ b/src/qemu/qemu_slirp.c @@ -251,7 +251,6 @@ qemuSlirpStart(qemuSlirpPtr slirp, virDomainNetDefPtr net, bool incoming) { - qemuDomainObjPrivatePtr priv =3D vm->privateData; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virCommand) cmd =3D NULL; g_autofree char *pidfile =3D NULL; @@ -356,9 +355,6 @@ qemuSlirpStart(qemuSlirpPtr slirp, =20 slirp->pid =3D pid; =20 - if (priv->cgroup && qemuSlirpSetupCgroup(slirp, priv->cgroup) < 0) - goto error; - return 0; =20 error: --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407318; cv=none; d=zohomail.com; s=zohoarc; b=CavTh4BBXyYfJIxwx1uRqMYbhY6L1SeHqR2dknq1ic8FJ09upRKFRUbZO6NUvoT3jMwHAy3KCpsfN5xZqbM5gGlmOka8tKbUTH7IejuRlhdNhN12MvUK/BS4Swou5scNL1mGLu5ZVpzdCGh712MluC3NTqZ4UE2E3cXecVeLBn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407318; 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=qWTYjgD0Bkrfjmrwu7jEaXXBrvhU5RDWzoZy/6iLsmM=; b=XGJvgrcPzniiVVurcXPu40ILqsoqHDtJRv+JORiZoB0smUDi7+oWQx/R8/eFLUUVwpMrlAvXCrMl3pyBW8KSRl9wgHXAhE7t5sshenIfNKyInEiuwxYSoDcvkyv4jM5goxn6W6T99gwJi8d6VzS9Xr3H+Hl9S0H4a+RdopkAgCw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407318659852.0678698450234; Tue, 3 Nov 2020 04:41:58 -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-565-VubRQEpQMS20zr9igd-1Lg-1; Tue, 03 Nov 2020 07:41:55 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D7031868412; Tue, 3 Nov 2020 12:41:49 +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 F1B6110013C1; Tue, 3 Nov 2020 12:41:48 +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 581FC180BACB; Tue, 3 Nov 2020 12:41:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3CfjI9015846 for ; Tue, 3 Nov 2020 07:41:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id F34F71C4; Tue, 3 Nov 2020 12:41:44 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D2C273667 for ; Tue, 3 Nov 2020 12:41:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407317; 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=qWTYjgD0Bkrfjmrwu7jEaXXBrvhU5RDWzoZy/6iLsmM=; b=f+eMJItnU8HcKsHjzU/0iNlwJ4brcSve3WHArix2tSsJJ6VJ7yBdHXfAhyx0R8dM+SzQUY H1ANpMjVnhX1pvtw/le9nYIbFZ9iJ4SURfVoZ+kAcMOpV1E6M6c0U7KD+bJ1eMroEhIp4T 6l2I0Naf4XtGaCxe0qpjpTtp4j4hErI= X-MC-Unique: VubRQEpQMS20zr9igd-1Lg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 03/25] qemu_dbus: use emulator cgroup for dbus-daemon Date: Tue, 3 Nov 2020 13:41:15 +0100 Message-Id: <13872ec8c8deb1d0743cd7b1cbbf4e55891e6eea.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.22 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" All other helper processes are moved to cgroup with QEMU emulator thread as we keep the root VM cgroup without any processes. This assumption is validated in qemuRestoreCgroupState() which is called when libvirtd is restarted and reconnected to all running VMs. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/qemu/qemu_dbus.c | 5 +++-- src/qemu/qemu_dbus.h | 3 ++- src/qemu/qemu_extdevice.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index a0567e55a3..ffcf83e5da 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -148,7 +148,8 @@ qemuDBusStop(virQEMUDriverPtr driver, =20 int qemuDBusSetupCgroup(virQEMUDriverPtr driver, - virDomainObjPtr vm) + virDomainObjPtr vm, + virCgroupPtr cgroup) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv =3D vm->privateData; @@ -167,7 +168,7 @@ qemuDBusSetupCgroup(virQEMUDriverPtr driver, return -1; } =20 - return virCgroupAddProcess(priv->cgroup, cpid); + return virCgroupAddProcess(cgroup, cpid); } =20 int diff --git a/src/qemu/qemu_dbus.h b/src/qemu/qemu_dbus.h index 3c2145a223..e3ce1330fd 100644 --- a/src/qemu/qemu_dbus.h +++ b/src/qemu/qemu_dbus.h @@ -35,4 +35,5 @@ int qemuDBusVMStateAdd(virDomainObjPtr vm, const char *id= ); void qemuDBusVMStateRemove(virDomainObjPtr vm, const char *id); =20 int qemuDBusSetupCgroup(virQEMUDriverPtr driver, - virDomainObjPtr vm); + virDomainObjPtr vm, + virCgroupPtr cgroup); diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 2fb71dd334..8fe7ceaa10 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -280,7 +280,7 @@ qemuExtDevicesSetupCgroup(virQEMUDriverPtr driver, virDomainDefPtr def =3D vm->def; size_t i; =20 - if (qemuDBusSetupCgroup(driver, vm) < 0) + if (qemuDBusSetupCgroup(driver, vm, cgroup) < 0) return -1; =20 for (i =3D 0; i < def->nvideos; i++) { --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407390; cv=none; d=zohomail.com; s=zohoarc; b=CCG9xHkL44KTXwfmwPmsBaOoWcPqsDw2B6iB7GIlC/gO7TDV32NARUJ1RWW3WxqW4YhM/6sZKTmUSqZBWlN8XaxPLkz7dGG6g3CDhTYXgd9ggvo6KbqhYFpBjQqjx6iUonwiDS+VRb7Irmaqa0xE5Mx0y7OrmM/AdNi/Kus3iB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407390; 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=I2J0jWI2t4vWmA4pNf38X/aM5fjK3oFt4sz/opXAz08=; b=KCrqOlkun8m7WE3Obi9alaF8chITWCPZYgtnDEr6wMnaBgXMtOKXOuhLO+dW80/vNagzIoujP0Ss/NihKH7ZRblSrZzsIRrZD/zeNdxfqViTTWHxuvPfMbc2UfDGVnYicRc9VJDLkdwGBUyxOpD0KfQoy3YWbzQsFh1uitjmAyg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604407390338459.7456190205569; Tue, 3 Nov 2020 04:43:10 -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-451-C60h1dmbPJaTLizmpPbEzw-1; Tue, 03 Nov 2020 07:42:10 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A15C803F49; Tue, 3 Nov 2020 12:42:02 +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 169D37512E; Tue, 3 Nov 2020 12:42:02 +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 C38E78C7C9; Tue, 3 Nov 2020 12:42:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3CfjdR015854 for ; Tue, 3 Nov 2020 07:41:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id DB95A73661; Tue, 3 Nov 2020 12:41:45 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55F5B1C4 for ; Tue, 3 Nov 2020 12:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407389; 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=I2J0jWI2t4vWmA4pNf38X/aM5fjK3oFt4sz/opXAz08=; b=aKLp4Rir46pKqWZw/rqqhwOch6kl7+LXAG9zX/x8bL0V5JFfSevtEVMMxo0ODS4Ch/2lOK cB5wlHCyu31u8SHIhiqtzFTZofSSbeSk6Jotv+BMivv6Qft1MOMKogATRg3ZmAzJNLUeZm 2Pkd4OSlB36xu6IZHnHQepiM4kbUM58= X-MC-Unique: C60h1dmbPJaTLizmpPbEzw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 04/25] vircgroupv2: properly detect empty tasks Date: Tue, 3 Nov 2020 13:41:16 +0100 Message-Id: <779e0df0e5408364ff0e22189dbe7001e0c2eba2.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.15 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" With cgroups v2 the file cgroup.procs will never be empty if threading is enabled as it will always have ID of all processes even if all threads of the processes are moved to sub-cgroups. If that happens the file cgroup.threads will be empty. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroupv2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 285b7675d9..65f5cc6bd0 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -521,7 +521,7 @@ virCgroupV2HasEmptyTasks(virCgroupPtr cgroup, int ret =3D -1; g_autofree char *content =3D NULL; =20 - ret =3D virCgroupGetValueStr(cgroup, controller, "cgroup.procs", &cont= ent); + ret =3D virCgroupGetValueStr(cgroup, controller, "cgroup.threads", &co= ntent); =20 if (ret =3D=3D 0 && content[0] =3D=3D '\0') ret =3D 1; --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407334; cv=none; d=zohomail.com; s=zohoarc; b=fPmAEhLt5zQ/3mjyCjFG0fHn3obwUMNiLq+/xv2D1Jhc4NnSZZ52pRiwcxsgHxDYFeIe36otoXcILpYXBGoGAHGVKNNOyPoUk27Z6sZToz/sw50Qxtux52ISyiGMEt6cVMARYYTgvzf6zey2TOqfGucXHMLMdOvcmiHgNzoMVkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407334; 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=KGZ23UDi/H4TSPPrquy5AqtHZ5MfRd2ZeluZ1r/7vas=; b=JSKWiziQXd+RqzooTVGyYjT6TALq9DsQFbwElNeUB/J9eiq1jITLa66MNfm2+QwqWwKH5FugacTJlW0FEb59H3CK6i+/QX1DwRxnHTM2lkaTDwaHUqXmhrSx6WmXf0FXLlRP4b5X4vP3fPgRbtBTo2nc9JS5b4/+rLz2nsUwFd8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160440733426168.82581169518471; Tue, 3 Nov 2020 04:42:14 -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-385-YDuhOH3FP7i4sgZzQmq9tQ-1; Tue, 03 Nov 2020 07:42:10 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E60ED800597; Tue, 3 Nov 2020 12:42:04 +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 C344D7512C; Tue, 3 Nov 2020 12:42:04 +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 8BC088C7CD; Tue, 3 Nov 2020 12:42:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3CfkqO015871 for ; Tue, 3 Nov 2020 07:41:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id C22C01C4; Tue, 3 Nov 2020 12:41:46 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DB7373667 for ; Tue, 3 Nov 2020 12:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407333; 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=KGZ23UDi/H4TSPPrquy5AqtHZ5MfRd2ZeluZ1r/7vas=; b=SgRlWPkJ6ggNvFUnES6ITXD+/ofjyQ55vcY6FhziwmJu8ASSGD6p8eBruccByvbuAin4sw VdY0PIITuO0PaJ7xrFPHuHJZHaIu1FkIbWnmXP2kOPKHQ1IlAHGkYLRSQeg2Fiun9Hf+if imBnTg/CbvsokMMRzAk4UQ3F0D3prdQ= X-MC-Unique: YDuhOH3FP7i4sgZzQmq9tQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 05/25] vircgroupv2: properly detect placement of running VM Date: Tue, 3 Nov 2020 13:41:17 +0100 Message-Id: <89ff8c8c1a0ab6739f5a007cf47a0649731b7683.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.15 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When libvirtd starts a VM it internally stores a path to the main cgroup. When we restart libvirtd we should get to the same state. When we start a VM on host with systemd the cgroup is created for us and the process is already placed into that cgroup and we detect the path created by systemd using /proc/$PID/cgroup. After that we create sub-cgroups and move all threads there. Once libvirtd is restarted we again detect the cgroup path using /proc/$PID/cgroup, but in this case we will get a different path because the main thread was moved to a "emulator" cgroup. Instead of ignoring the "emulator" directory when validating cgroups remove it completely when detecting cgroup otherwise cgroups will not work properly when libvirtd is restarted. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroupv2.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 65f5cc6bd0..fb97b7fd2a 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -122,12 +122,6 @@ virCgroupV2ValidateMachineGroup(virCgroupPtr group, if (!(tmp =3D strrchr(group->unified.placement, '/'))) return false; =20 - if (STREQ(tmp, "/emulator")) { - *tmp =3D '\0'; - - if (!(tmp =3D strrchr(group->unified.placement, '/'))) - return false; - } tmp++; =20 if (STRNEQ(tmp, partmachinename) && @@ -198,6 +192,9 @@ virCgroupV2DetectPlacement(virCgroupPtr group, const char *controllers, const char *selfpath) { + g_autofree char *placement =3D g_strdup(selfpath); + char *tmp =3D NULL; + if (group->unified.placement) return 0; =20 @@ -208,12 +205,18 @@ virCgroupV2DetectPlacement(virCgroupPtr group, if (STRNEQ(controllers, "")) return 0; =20 + /* Running VM will have the main thread placed in emulator cgroup + * but we need to get the main cgroup. */ + tmp =3D g_strrstr(placement, "/emulator"); + if (tmp) + *tmp =3D '\0'; + /* * selfpath =3D=3D "/" + path=3D"" -> "/" * selfpath =3D=3D "/libvirt.service" + path =3D=3D "" -> "/libvirt.se= rvice" * selfpath =3D=3D "/libvirt.service" + path =3D=3D "foo" -> "/libvirt= .service/foo" */ - group->unified.placement =3D g_strdup_printf("%s%s%s", selfpath, + group->unified.placement =3D g_strdup_printf("%s%s%s", placement, (STREQ(selfpath, "/") || ST= REQ(path, "") ? "" : "/"), path); =20 return 0; --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407331; cv=none; d=zohomail.com; s=zohoarc; b=U6z94DmbYXR1ejX2mL2gfjwc2+XMDWGQ2AzOCnsDu1GFaX2gB/Qh1ps/BLDysVJeB8bdj1q4Gz1Kj1984LQRtfStCJew1KBbBz86FLgxOQprNhU1YzXwr56RjptrU9+7RcxVbcB+KttRVNon+KSN8TE2TD9KdypvRN3bCmTiUOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407331; 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=KdVfjaZoSpZMZStWtiXAqiH1lpBzggIafNz57pEXotI=; b=ccfOmb0kbGp0sKpRPKR2zqMLeQtkafuyXecb2nJ1Xe77vJ9BhY/7M4d1Yv5or4wZRGYSM+8uZc+EDCwUGoF8w9cqcjtNn+ZPwSMxTwVGS5q5OCcmbVlUzymTZFdOE/5+H9vBvDiG6OoHoqjK5Pic37Z9piqp50nQhCFiTxkSc0c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604407331975312.4240558519016; Tue, 3 Nov 2020 04:42:11 -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-2-chOIHB5nPF2TUK4j-oGYJg-1; Tue, 03 Nov 2020 07:42:07 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 352365708A; Tue, 3 Nov 2020 12:42:02 +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 070E421E9D; Tue, 3 Nov 2020 12:42:02 +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 C4C758C7CA; Tue, 3 Nov 2020 12:42:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3CfllC015879 for ; Tue, 3 Nov 2020 07:41:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id AA99073661; Tue, 3 Nov 2020 12:41:47 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 241481C4 for ; Tue, 3 Nov 2020 12:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407330; 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=KdVfjaZoSpZMZStWtiXAqiH1lpBzggIafNz57pEXotI=; b=TsEYHVcgym6IE5MM7MySsHzdCG4vDTQb3F5ag9nWlyWAzuTWPCwccMCBwY2FE0P9Lgf4EX m6gqyd3+62JguzCnJJfCnQVKwGYxchkhEdKYwI81M8DyZ/Yhtyt4k87jmf9kQ44Z4fEgIo hslmEsK1LhyQn2sw4CIaTyWd1BbY0mY= X-MC-Unique: chOIHB5nPF2TUK4j-oGYJg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 06/25] vircgroupv2: detect controllers enabled in parent cgroup Date: Tue, 3 Nov 2020 13:41:18 +0100 Message-Id: <374ea88fe567f4a25cd1b3fb17a3dba865b8133b.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" With cgroups v2 working with controllers is a bit more complicated then with cgroups v1 where the controller had to be mounted. There are two files, cgroups.controllers and cgroup.subtree_control. The file cgroup.controllers lists all controllers enabled in the current cgroup and cgroups.subtree_control, as the name suggest, controls which controllers are enabled for a subtree of cgroups. Now the issue here is that the current code doesn't make any difference if the @parent variable is NULL or not because ../cgroup.subtree_control will list the same controllers as ./cgroup.controllers. The whole point of the @parent variable is when we are building the cgroup topology ourselves without systemd help we need to detect which controllers are enabled in the parent cgroup in order to enable them for the current cgroup as well and for that we need to check cgroup.controllers of the parent group. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroupv2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index fb97b7fd2a..530e5d2ce9 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -255,7 +255,7 @@ virCgroupV2ParseControllersFile(virCgroupPtr group, char **tmp; =20 if (parent) { - contFile =3D g_strdup_printf("%s%s/cgroup.subtree_control", + contFile =3D g_strdup_printf("%s%s/cgroup.controllers", parent->unified.mountPoint, NULLSTR_EMPTY(parent->unified.placement= )); } else { --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407624; cv=none; d=zohomail.com; s=zohoarc; b=RUDELQ+FoWdU4OUjHyceTmE0UQWiFUcWdjSpukWeY90D/gMD5h0SAK2yhBmxlaYFifv6TYxcg/EUKTz7mfgGzVDA4/0TJ3gkowjYHci3s5ULqOwH8nEx4lFyOsWtSZAs4uGwP67m/iXkMPQapzFihKlhf/GKspNRtPSyliHgl3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407624; 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=X0CaoNLhj5Rt96jphoBCbK1DboZD3d6RrWMQYak5oEA=; b=H9nStcOTq9acR5wWzVmzT2b5yiQ8bM79OmtmtN/2XFRYDOCM1EAHz38c2jN44HzEG6vq4G8ZLe/rYDSJRfD2YjW9KhK3VebhrjolBXMxPEPrK+d+sW3WxkR4xSuuZQHhrT2O9w2bvjeqolsR4hsOOZ7x3XCDQHGfQfzbcYXOVuE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604407624107191.03847848890325; Tue, 3 Nov 2020 04:47:04 -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-414-ZqGXCQHiPXOWU6q4o9ijbA-1; Tue, 03 Nov 2020 07:42:13 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F1A5803F76; Tue, 3 Nov 2020 12:42:07 +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 7F01573667; Tue, 3 Nov 2020 12:42:07 +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 4A9DC181A07C; Tue, 3 Nov 2020 12:42:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3CfmKR015886 for ; Tue, 3 Nov 2020 07:41:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 92E2373661; Tue, 3 Nov 2020 12:41:48 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C1BB1C4 for ; Tue, 3 Nov 2020 12:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407623; 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=X0CaoNLhj5Rt96jphoBCbK1DboZD3d6RrWMQYak5oEA=; b=e4p3rGzeJDeYmjCqRfGeZrgxl3NeMUZlnIoxIdF+x7/b6bl5e0PQAJC/8SOlK7LvWMMIsE KIKrD0Vm2F3TR6ohiVFa1dYZmuUrfy8d2xjUGC2uICMUUL1YEKnAv24xuk/S8oHjyAV/+A Ong/Yn1mrMxUHtqwgqofAaf6TSnEoNg= X-MC-Unique: ZqGXCQHiPXOWU6q4o9ijbA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 07/25] vircgroup: remove useless cgroup->path variable Date: Tue, 3 Nov 2020 13:41:19 +0100 Message-Id: <33286e83c4bc89faedd6f761fe31b6465ad8b33b.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.13 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It is only used for debug and error purposes which can be easily replaced by @placement. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 20 ++++++-------------- src/util/vircgrouppriv.h | 2 -- src/util/vircgroupv1.c | 8 +++----- src/util/vircgroupv2.c | 4 +--- tests/vircgrouptest.c | 29 ++++++++++------------------- 5 files changed, 20 insertions(+), 43 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index e3c45e93cb..7ff23e1218 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -669,13 +669,6 @@ virCgroupNew(pid_t pid, *group =3D NULL; newGroup =3D g_new0(virCgroup, 1); =20 - if (path[0] =3D=3D '/' || !parent) { - newGroup->path =3D g_strdup(path); - } else { - newGroup->path =3D g_strdup_printf("%s%s%s", parent->path, - STREQ(parent->path, "") ? "" : "/= ", path); - } - if (virCgroupDetect(newGroup, pid, controllers, path, parent) < 0) return -1; =20 @@ -2388,8 +2381,8 @@ virCgroupKillInternal(virCgroupPtr group, g_autofree char *keypath =3D NULL; bool done =3D false; FILE *fp =3D NULL; - VIR_DEBUG("group=3D%p path=3D%s signum=3D%d pids=3D%p", - group, group->path, signum, pids); + VIR_DEBUG("group=3D%p signum=3D%d pids=3D%p", + group, signum, pids); =20 if (virCgroupPathOfController(group, controller, taskFile, &keypath) <= 0) return -1; @@ -2471,8 +2464,8 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, g_autoptr(DIR) dp =3D NULL; struct dirent *ent; int direrr; - VIR_DEBUG("group=3D%p path=3D%s signum=3D%d pids=3D%p", - group, group->path, signum, pids); + VIR_DEBUG("group=3D%p signum=3D%d pids=3D%p", + group, signum, pids); =20 if (virCgroupPathOfController(group, controller, "", &keypath) < 0) return -1; @@ -2532,7 +2525,7 @@ virCgroupKillRecursive(virCgroupPtr group, int signum) virCgroupBackendPtr *backends =3D virCgroupBackendGetAll(); g_autoptr(GHashTable) pids =3D g_hash_table_new_full(g_int64_hash, g_i= nt64_equal, g_free, NULL); =20 - VIR_DEBUG("group=3D%p path=3D%s signum=3D%d", group, group->path, sign= um); + VIR_DEBUG("group=3D%p signum=3D%d", group, signum); =20 for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { if (backends && backends[i] && backends[i]->available()) { @@ -2563,7 +2556,7 @@ virCgroupKillPainfully(virCgroupPtr group) { size_t i; int ret; - VIR_DEBUG("cgroup=3D%p path=3D%s", group, group->path); + VIR_DEBUG("cgroup=3D%p", group); for (i =3D 0; i < 15; i++) { int signum; if (i =3D=3D 0) @@ -3491,7 +3484,6 @@ virCgroupFree(virCgroupPtr group) VIR_FREE(group->unified.mountPoint); VIR_FREE(group->unified.placement); =20 - VIR_FREE(group->path); VIR_FREE(group); } =20 diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index f85a36efdb..af8bf99888 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -60,8 +60,6 @@ typedef struct _virCgroupV2Controller virCgroupV2Controll= er; typedef virCgroupV2Controller *virCgroupV2ControllerPtr; =20 struct _virCgroup { - char *path; - virCgroupBackendPtr backends[VIR_CGROUP_BACKEND_TYPE_LAST]; =20 virCgroupV1Controller legacy[VIR_CGROUP_CONTROLLER_LAST]; diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 61fb359f8d..6bb819410b 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -545,7 +545,9 @@ virCgroupV1CpuSetInherit(virCgroupPtr parent, "cpuset.memory_migrate", }; =20 - VIR_DEBUG("Setting up inheritance %s -> %s", parent->path, group->path= ); + VIR_DEBUG("Setting up inheritance %s -> %s", + parent->legacy[VIR_CGROUP_CONTROLLER_CPUSET].placement, + group->legacy[VIR_CGROUP_CONTROLLER_CPUSET].placement); for (i =3D 0; i < G_N_ELEMENTS(inherit_values); i++) { g_autofree char *value =3D NULL; =20 @@ -583,7 +585,6 @@ virCgroupV1SetMemoryUseHierarchy(virCgroupPtr group) if (value =3D=3D 1) return 0; =20 - VIR_DEBUG("Setting up %s/%s", group->path, filename); if (virCgroupSetValueU64(group, VIR_CGROUP_CONTROLLER_MEMORY, filename, 1) < 0) @@ -601,7 +602,6 @@ virCgroupV1MakeGroup(virCgroupPtr parent, { size_t i; =20 - VIR_DEBUG("Make group %s", group->path); for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { g_autofree char *path =3D NULL; =20 @@ -671,7 +671,6 @@ virCgroupV1Remove(virCgroupPtr group) int rc =3D 0; size_t i; =20 - VIR_DEBUG("Removing cgroup %s", group->path); for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { g_autofree char *grppath =3D NULL; =20 @@ -697,7 +696,6 @@ virCgroupV1Remove(virCgroupPtr group) VIR_DEBUG("Removing cgroup %s and all child cgroups", grppath); rc =3D virCgroupRemoveRecursively(grppath); } - VIR_DEBUG("Done removing cgroup %s", group->path); =20 return rc; } diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 530e5d2ce9..0467a72566 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -413,8 +413,6 @@ virCgroupV2MakeGroup(virCgroupPtr parent, return 0; } =20 - VIR_DEBUG("Make group %s", group->path); - controller =3D virCgroupV2GetAnyController(group); if (virCgroupV2PathOfController(group, controller, "", &path) < 0) return -1; @@ -424,7 +422,7 @@ virCgroupV2MakeGroup(virCgroupPtr parent, if (!virFileExists(path) && (!create || (mkdir(path, 0755) < 0 && errno !=3D EEXIST))) { virReportSystemError(errno, _("Failed to create v2 cgroup '%s'"), - group->path); + path); return -1; } =20 diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 6c1a766fa2..0dd5e3f0b4 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -38,7 +38,6 @@ VIR_LOG_INIT("tests.cgrouptest"); =20 static int validateCgroup(virCgroupPtr cgroup, - const char *expectPath, const char **expectMountPoint, const char **expectLinkPoint, const char **expectPlacement, @@ -48,12 +47,6 @@ static int validateCgroup(virCgroupPtr cgroup, { size_t i; =20 - if (STRNEQ(cgroup->path, expectPath)) { - fprintf(stderr, "Wrong path '%s', expected '%s'\n", - cgroup->path, expectPath); - return -1; - } - for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { if (STRNEQ_NULLABLE(expectMountPoint[i], cgroup->legacy[i].mountPoint)) { @@ -240,7 +233,7 @@ static int testCgroupNewForSelf(const void *args G_GNUC= _UNUSED) return -1; } =20 - return validateCgroup(cgroup, "", mountsFull, links, placement, NULL, = NULL, 0); + return validateCgroup(cgroup, mountsFull, links, placement, NULL, NULL= , 0); } =20 =20 @@ -314,14 +307,14 @@ static int testCgroupNewForPartition(const void *args= G_GNUC_UNUSED) fprintf(stderr, "Cannot create /virtualmachines cgroup: %d\n", -rv= ); return -1; } - rv =3D validateCgroup(cgroup, "/virtualmachines.partition", mountsSmal= l, links, placementSmall, NULL, NULL, 0); + rv =3D validateCgroup(cgroup, mountsSmall, links, placementSmall, NULL= , NULL, 0); virCgroupFree(cgroup); =20 if ((rv =3D virCgroupNewPartition("/virtualmachines", true, -1, &cgrou= p)) !=3D 0) { fprintf(stderr, "Cannot create /virtualmachines cgroup: %d\n", -rv= ); return -1; } - return validateCgroup(cgroup, "/virtualmachines.partition", mountsFull= , links, placementFull, NULL, NULL, 0); + return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, = NULL, 0); } =20 =20 @@ -365,8 +358,7 @@ static int testCgroupNewForPartitionNested(const void *= args G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(cgroup, "/deployment.partition/production.partit= ion", - mountsFull, links, placementFull, NULL, NULL, 0); + return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, = NULL, 0); } =20 =20 @@ -416,8 +408,7 @@ static int testCgroupNewForPartitionNestedDeep(const vo= id *args G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(cgroup, "/user/berrange.user/production.partitio= n", - mountsFull, links, placementFull, NULL, NULL, 0); + return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, = NULL, 0); } =20 =20 @@ -448,7 +439,7 @@ static int testCgroupNewForPartitionDomain(const void *= args G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(domaincgroup, "/production.partition/foo.libvirt= -lxc", mountsFull, links, placement, NULL, NULL, 0); + return validateCgroup(domaincgroup, mountsFull, links, placement, NULL= , NULL, 0); } =20 static int testCgroupNewForPartitionDomainEscaped(const void *args G_GNUC_= UNUSED) @@ -493,7 +484,7 @@ static int testCgroupNewForPartitionDomainEscaped(const= void *args G_GNUC_UNUSED * since our fake /proc/cgroups pretends this controller * isn't compiled into the kernel */ - return validateCgroup(domaincgroup, "/_cgroup.evil/net_cls.evil/__evil= .evil/_cpu.foo.libvirt-lxc", mountsFull, links, placement, NULL, NULL, 0); + return validateCgroup(domaincgroup, mountsFull, links, placement, NULL= , NULL, 0); } =20 static int testCgroupNewForSelfAllInOne(const void *args G_GNUC_UNUSED) @@ -514,7 +505,7 @@ static int testCgroupNewForSelfAllInOne(const void *arg= s G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(cgroup, "", mountsAllInOne, linksAllInOne, place= ment, NULL, NULL, 0); + return validateCgroup(cgroup, mountsAllInOne, linksAllInOne, placement= , NULL, NULL, 0); } =20 =20 @@ -547,7 +538,7 @@ static int testCgroupNewForSelfUnified(const void *args= G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(cgroup, "", empty, empty, empty, + return validateCgroup(cgroup, empty, empty, empty, "/not/really/sys/fs/cgroup", "/", controllers); } =20 @@ -580,7 +571,7 @@ static int testCgroupNewForSelfHybrid(const void *args = G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(cgroup, "", mounts, empty, placement, + return validateCgroup(cgroup, mounts, empty, placement, "/not/really/sys/fs/cgroup/unified", "/", contro= llers); } =20 --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407334; cv=none; d=zohomail.com; s=zohoarc; b=j7W2TXZ8A/9oyUYLcURZJ7Vn2C8XahlAAExNPJcXfkoKGh7cVLxNJBZ0u+Xbf4qGwR07GJJuKPuKWoFRRc0HBzC+cNM3Eax/9DfEuEMr0iWEsvsZwfcKJylCkZNfBhRmB6iOfzEyG/RlkXzLEbRo5fZY1W9VrD8KsoXtLNm4xJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407334; 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=rT3YiOWOnH+IrH9FqtCBHMnkNSuCx7ESg5ZktvPGT6A=; b=a/fIkTGDnVd85f0V+hGx9xc1UgNYBvwy7LEBLtAe+tLejiZqd2adYDo5M9+9Fa9Jf284CtVR1JW+EPRbUZkC3qL70aRloEIwgT3UVud/6kayPe0B+YcJ+1tdpRG7CwxOaeJvsoP6F0ZivOFD0DyduQ7wTGctWcgnXkD7dj5s3UM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160440733405962.46530337503748; Tue, 3 Nov 2020 04:42:14 -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-27-DEm9VoT0OgKypveuGZ359A-1; Tue, 03 Nov 2020 07:42:10 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E500F1006CAE; Tue, 3 Nov 2020 12:42:04 +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 C0D8F1002C3E; Tue, 3 Nov 2020 12:42:04 +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 88CD41819AC1; Tue, 3 Nov 2020 12:42:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cfnob015903 for ; Tue, 3 Nov 2020 07:41:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7A8AF1C4; Tue, 3 Nov 2020 12:41:49 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id E975773667 for ; Tue, 3 Nov 2020 12:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407333; 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=rT3YiOWOnH+IrH9FqtCBHMnkNSuCx7ESg5ZktvPGT6A=; b=A4fmtlmDSq8/4XxSlkMVvsRGoPido8AAlL/4x3mChm+c4aNT48VPQsowznMMlwWUQsT7i+ cgL0sSa4T8Osf3ZyVcgkqChJXVNDr1j//tMC7gLD2POKt76fWeBF7t8LnqJk8/h0QI3Kab z6o1Oo6jDaXp3JXVfTctl7t2UjmW+08= X-MC-Unique: DEm9VoT0OgKypveuGZ359A-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 08/25] vircgroup: introduce virCgroupSetBackends helper Date: Tue, 3 Nov 2020 13:41:20 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.22 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 7ff23e1218..3db20ed262 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -212,6 +212,33 @@ virCgroupPartitionEscape(char **path) } =20 =20 +static int +virCgroupSetBackends(virCgroupPtr group) +{ + virCgroupBackendPtr *backends =3D virCgroupBackendGetAll(); + bool backendAvailable =3D false; + size_t i; + + if (!backends) + return -1; + + for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { + if (backends[i] && backends[i]->available()) { + group->backends[i] =3D backends[i]; + backendAvailable =3D true; + } + } + + if (!backendAvailable) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("no cgroup backend available")); + return -1; + } + + return 0; +} + + /* * Process /proc/mounts figuring out what controllers are * mounted and where @@ -339,29 +366,14 @@ virCgroupDetect(virCgroupPtr group, virCgroupPtr parent) { size_t i; - bool backendAvailable =3D false; int controllersAvailable =3D 0; - virCgroupBackendPtr *backends =3D virCgroupBackendGetAll(); =20 VIR_DEBUG("group=3D%p controllers=3D%d path=3D%s parent=3D%p", group, controllers, path, parent); =20 - if (!backends) + if (virCgroupSetBackends(group) < 0) return -1; =20 - for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { - if (backends[i] && backends[i]->available()) { - group->backends[i] =3D backends[i]; - backendAvailable =3D true; - } - } - - if (!backendAvailable) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("no cgroup backend available")); - return -1; - } - if (parent) { for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { if (group->backends[i] && --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407341; cv=none; d=zohomail.com; s=zohoarc; b=bx6tXc7pfbXVSRaXZhWYWAGU5YcYk/wL7CyEjzO1aF5aedAb7m81EDm3dlhCW6IU5d04DNXmwz6xIi6Gp7AYdV+6raJ36T6vtDA71Qbho35ihKhpPAFxAQdDMiHIiso5laZsdDDmLFTvLsgvPvzkR+mxNNfV/7TjN7380zZvg78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407341; 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=UoZKCfnz0BGbrlUFatnxChF9dYNPZAnl1Ua9/AM8EKw=; b=MmId1X4sRRqMK4SQLEDB7ME7Z+dK5vuqozUK7+9WaN75A3J6bqm4zKvFCjD6PFEk7E3p1QOhd+JYzZAbhecCRCgiufROlU+rcMMpDHVjWcihMiPVt+adc/rNWoFqU6d1uExIRJm3C+jyTXSDAv1b2nGGu8RzJaWrzH0A3UhYFpQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407341946445.3682405264566; Tue, 3 Nov 2020 04:42:21 -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-157-2HeqA_4VPWCN1EL3TLujUg-1; Tue, 03 Nov 2020 07:42:18 -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 9AEE68049E7; Tue, 3 Nov 2020 12:42:10 +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 764265D990; Tue, 3 Nov 2020 12:42:10 +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 4369A8C7D8; Tue, 3 Nov 2020 12:42:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3CfoBB015911 for ; Tue, 3 Nov 2020 07:41:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6244573661; Tue, 3 Nov 2020 12:41:50 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1BCA1C4 for ; Tue, 3 Nov 2020 12:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407340; 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=UoZKCfnz0BGbrlUFatnxChF9dYNPZAnl1Ua9/AM8EKw=; b=gVdbuptWj5O1EjqR8YgvMdJ3vR8Q/dcS2MknzFGNpKu5Uz6Qs3GmajeZOhMY/ZpmB5NrZf jShMAXUXYwNGwkiuFAeT1uw/5b7lCs29xHfd36cQ5DZ/Uc7tb/qAwe2aob2U7EzrsEbqtB PYCocyvSdZKsS2TO2+lAD5us8ABbyKU= X-MC-Unique: 2HeqA_4VPWCN1EL3TLujUg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 09/25] vircgroup: introduce virCgroupCopyMounts helper Date: Tue, 3 Nov 2020 13:41:21 +0100 Message-Id: <41cd051ff19261b49e3f77d2d4dcaeebf3ffdbe9.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 3db20ed262..a30aec4e5e 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -239,6 +239,23 @@ virCgroupSetBackends(virCgroupPtr group) } =20 =20 +static int +virCgroupCopyMounts(virCgroupPtr group, + virCgroupPtr parent) +{ + size_t i; + + for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { + if (group->backends[i] && + group->backends[i]->copyMounts(group, parent) < 0) { + return -1; + } + } + + return 0; +} + + /* * Process /proc/mounts figuring out what controllers are * mounted and where @@ -375,12 +392,8 @@ virCgroupDetect(virCgroupPtr group, return -1; =20 if (parent) { - for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { - if (group->backends[i] && - group->backends[i]->copyMounts(group, parent) < 0) { - return -1; - } - } + if (virCgroupCopyMounts(group, parent) < 0) + return -1; } else { if (virCgroupDetectMounts(group) < 0) return -1; --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407337; cv=none; d=zohomail.com; s=zohoarc; b=KPlrxJTWpmPbmY9rgRHyhBFaX2tLdmqFa2Pg0dluiT2EfEgOeKQoJqSCeN0XinwxR0ABFypfurMLUNuzvmGdEeNBz1FYKke6wG17Tg73EHmT6yiLbKmVRIQGQLTRp17JrpD0DFwYfUaBxY8hp3Wa6uU7CMbSItEqPSsOunmxp70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407337; 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=kd/ZUkMECgDAIEXhWhT8RHk7Je3zuSiud3aplfKZ3yQ=; b=EPxKE5ovCe+JJ0PIVQFLlErsP6EqWZ508RNwZfYiRxDMTFOun2N9SEBgv5Eb2ynYxtjxn9p23/M4YTngL6KcahlRz4/wjkdrGOpRN48voQPpCIV/n3bCsFPDUy7K3ZbF30iDQulSZPCt94cd98xkKrvPNEL+5/QpEFQBR8YYp/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407337656196.46799350790116; Tue, 3 Nov 2020 04:42:17 -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-351-halkwuWMNS6a5hiBScq8Dw-1; Tue, 03 Nov 2020 07:42:14 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6C3457208; Tue, 3 Nov 2020 12:42:07 +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 A54C273664; Tue, 3 Nov 2020 12:42:07 +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 6EA528C7D2; Tue, 3 Nov 2020 12:42:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cfpfg015928 for ; Tue, 3 Nov 2020 07:41:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4A95C73661; Tue, 3 Nov 2020 12:41:51 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id B94C71C4 for ; Tue, 3 Nov 2020 12:41:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407336; 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=kd/ZUkMECgDAIEXhWhT8RHk7Je3zuSiud3aplfKZ3yQ=; b=azGBZ/nLmm3EQqR69emy7ETTMFDLPRdfGO6TkojnUvNrTlIIIv+FCZuXq/qmQzlOWrmfTf Etx220Knuhl48eejftqcEvgSHRpw6ifYkQ7vnDi+upinCuBMb3ETLKcfy1n46jxSAvri/a r0P4D8uEyBLnKalIRqIv4WO0zb+d5CM= X-MC-Unique: halkwuWMNS6a5hiBScq8Dw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 10/25] vircgroup: introduce virCgroupCopyPlacement helper Date: Tue, 3 Nov 2020 13:41:22 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.13 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index a30aec4e5e..b5f38210fb 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -294,6 +294,24 @@ virCgroupDetectMounts(virCgroupPtr group) } =20 =20 +static int +virCgroupCopyPlacement(virCgroupPtr group, + const char *path, + virCgroupPtr parent) +{ + size_t i; + + for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { + if (group->backends[i] && + group->backends[i]->copyPlacement(group, path, parent) < 0) { + return -1; + } + } + + return 0; +} + + /* * virCgroupDetectPlacement: * @group: the group to process @@ -403,12 +421,8 @@ virCgroupDetect(virCgroupPtr group, * based on the parent cgroup... */ if (parent || path[0] =3D=3D '/') { - for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { - if (group->backends[i] && - group->backends[i]->copyPlacement(group, path, parent) < 0= ) { - return -1; - } - } + if (virCgroupCopyPlacement(group, path, parent) < 0) + return -1; } =20 /* ... but use /proc/cgroups to fill in the rest */ --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407336; cv=none; d=zohomail.com; s=zohoarc; b=ePe27OYv3cgXtAxPZYGU+vA+Ifn+tJsOMxZF3F19pAxLsAldMHC1AUT2Q4Ss3nbLUMhiyuoFyqXnO9sSansYV/DHMfsZK1QpqtGNpaXVRnrM9Dt+Me2osIdm2LXGD6adoDsvGht+jQ1UpWMGWXBROjay++KOGg6sk7PvdD27SRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407336; 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=MYXbtmo2D3+AtPSprQkgR4ih87/XSvDJRQe6tVD+uYs=; b=DAzSgv8xqVMJd93QhFZ0uxVfua03nuqnL00TM8oaPhDlvIy8XtsyuwHRxdrlBewR3WyQz8n6FVZhS81O1/+Gpzkf8nvxu+czQzCbqMW0MXlyYlKRB62xC2b0n/zzu64QHK+4djI9Nc4c1opMrFqDrmnyjB6VPLe4BMMON2TXfLU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407336651700.8571921767701; Tue, 3 Nov 2020 04:42:16 -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-217-JTgDEEU9NMeatxM13mfpYA-1; Tue, 03 Nov 2020 07:42:13 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6687F1006CBB; Tue, 3 Nov 2020 12:42:07 +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 47043672C0; Tue, 3 Nov 2020 12:42:07 +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 15DDD8C7D0; Tue, 3 Nov 2020 12:42:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cfq6w015934 for ; Tue, 3 Nov 2020 07:41:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3191D73661; Tue, 3 Nov 2020 12:41:52 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id A09B91C4 for ; Tue, 3 Nov 2020 12:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407335; 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=MYXbtmo2D3+AtPSprQkgR4ih87/XSvDJRQe6tVD+uYs=; b=FQg0PCkMDozPZUSsGFrn22K75ogXBIWyLI/Iv8f53SotkabXJ8B23IGZDlyezHCcv2gWla 6ANymA+bG/iZ/d+03Um6drITzI5YEDyNyMWQUT2HVax2v/MIkwss2XGA75N4kGG5GpTWLU r0ut3eTeIyCiOaEX2L9yM5dyA30/uOU= X-MC-Unique: JTgDEEU9NMeatxM13mfpYA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 11/25] vircgroup: introduce virCgroupValidatePlacement helper Date: Tue, 3 Nov 2020 13:41:23 +0100 Message-Id: <9ddda9a43d6c9fa66f6e1e473a9b3f079e788599.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.12 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index b5f38210fb..55fa49a398 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -393,6 +393,23 @@ virCgroupDetectPlacement(virCgroupPtr group, } =20 =20 +static int +virCgroupValidatePlacement(virCgroupPtr group, + pid_t pid) +{ + size_t i; + + for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { + if (group->backends[i] && + group->backends[i]->validatePlacement(group, pid) < 0) { + return -1; + } + } + + return 0; +} + + static int virCgroupDetect(virCgroupPtr group, pid_t pid, @@ -430,12 +447,8 @@ virCgroupDetect(virCgroupPtr group, return -1; =20 /* Check that for every mounted controller, we found our placement */ - for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { - if (group->backends[i] && - group->backends[i]->validatePlacement(group, pid) < 0) { - return -1; - } - } + if (virCgroupValidatePlacement(group, pid) < 0) + return -1; =20 for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { if (group->backends[i]) { --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407437; cv=none; d=zohomail.com; s=zohoarc; b=nsd2BC1duNZF6Z1hn+jadFJQQW672dtw81kB7F0GY9+6P4O7OfIY/1968WvEgTgmGadZveNvKthN675fLjsCcV53W7lOlx4vIV0HBu5jZXWoXay10glK2W72jcOTX/hBy9yQf9lPes4c8lsy/LlipnoR5EdUsQS9Rxa0alPgLuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407437; 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=Sf7MSNsiJm375gYXW8rKjIxTt2YnxysTFt0HN5xmLnw=; b=hp1Wev5C7hR1ZwUne4Bf9NJRodeMMqgcy7Nwcbp6Dmvn/223GtTeOILd7HpEduZyvYByNo0yKHS8v1rDkb9BrBeO9BA47JF4JuVkA+r+xcetxFoajz2X5CSflBFjLhAIt8HpXzHdIpudW35bPmn1VMZ8Uh15rqeoPsfGVx/f4k8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604407437256910.8373531384135; Tue, 3 Nov 2020 04:43:57 -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-137-3SIyLM5YMyGGK_m3f1qwhA-1; Tue, 03 Nov 2020 07:42:18 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C32B31007468; Tue, 3 Nov 2020 12:42:10 +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 9BD3E1002D4A; Tue, 3 Nov 2020 12:42:10 +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 651F0181A270; Tue, 3 Nov 2020 12:42:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3CfrcZ015949 for ; Tue, 3 Nov 2020 07:41:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1A38473661; Tue, 3 Nov 2020 12:41:53 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88E4D73667 for ; Tue, 3 Nov 2020 12:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407436; 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=Sf7MSNsiJm375gYXW8rKjIxTt2YnxysTFt0HN5xmLnw=; b=KSCwzCzVvFILgBw7HNIoj7DX3k3wGSheAx6Kw+pNVDcK/IFA/Vtoge6q0ImW6bgEuP8QlZ 6xEXzckmjuWiowgNuIwnf3jQ0CZ661WlR3tc8kHxI2y2+qVZEhRWQM7aePLBDyPVuikhNg o+m1JRcho5qlzMSFl+7DBCUtXxEUvk8= X-MC-Unique: 3SIyLM5YMyGGK_m3f1qwhA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 12/25] vircgroup: introduce virCgroupDetectControllers helper Date: Tue, 3 Nov 2020 13:41:24 +0100 Message-Id: <4890b04ecd6d63dbfbf093970cb66ae776728761.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.22 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 51 ++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 55fa49a398..f21a581946 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -410,6 +410,38 @@ virCgroupValidatePlacement(virCgroupPtr group, } =20 =20 +static int +virCgroupDetectControllers(virCgroupPtr group, + int controllers, + virCgroupPtr parent) +{ + size_t i; + int controllersAvailable =3D 0; + + for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { + int rc; + + if (!group->backends[i]) + continue; + + rc =3D group->backends[i]->detectControllers(group, controllers, p= arent, + controllersAvailable); + if (rc < 0) + return -1; + controllersAvailable |=3D rc; + } + + /* Check that at least 1 controller is available */ + if (controllersAvailable =3D=3D 0) { + virReportSystemError(ENXIO, "%s", + _("At least one cgroup controller is required= ")); + return -1; + } + + return 0; +} + + static int virCgroupDetect(virCgroupPtr group, pid_t pid, @@ -417,9 +449,6 @@ virCgroupDetect(virCgroupPtr group, const char *path, virCgroupPtr parent) { - size_t i; - int controllersAvailable =3D 0; - VIR_DEBUG("group=3D%p controllers=3D%d path=3D%s parent=3D%p", group, controllers, path, parent); =20 @@ -450,22 +479,8 @@ virCgroupDetect(virCgroupPtr group, if (virCgroupValidatePlacement(group, pid) < 0) return -1; =20 - for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { - if (group->backends[i]) { - int rc =3D group->backends[i]->detectControllers(group, contro= llers, parent, - controllersAvai= lable); - if (rc < 0) - return -1; - controllersAvailable |=3D rc; - } - } - - /* Check that at least 1 controller is available */ - if (controllersAvailable =3D=3D 0) { - virReportSystemError(ENXIO, "%s", - _("At least one cgroup controller is required= ")); + if (virCgroupDetectControllers(group, controllers, parent) < 0) return -1; - } =20 return 0; } --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407343; cv=none; d=zohomail.com; s=zohoarc; b=SNSczyKoPWVFy8i6ctcayGUkhCnxJWOwA/LV9O+6gjjF+FDtdL/knWiouD4w5q5vS3F9Q6SUA3xw0RzR45X8pF1Is8HIUbPlJrsaOjNUc03/kSC4wN97t3IVYzYuhfdW5QLixTtuypinSG5hkw2HQpL0MYzNv47DyjDg+nfdBoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407343; 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=yadB5VgpHs5atg0pa9r0zvVCZ+rNNGXN8zdNvusYbg8=; b=g6YqJXMlSpE4dwxb+uwtnNXgAtYYRnVvet63YOsOaxrNZehRhbqdda8WIneJtDWUneQrPndwqVe5RyV4xzjO4ToS0niLTUXKx5yrYGekHMPSlmrMJkRKDLaheyVT2uG33u21g0MB2Jm8HbViiTlHtXyX7uVpQ9E86c3zj7YkgtY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407343223328.90688101800754; Tue, 3 Nov 2020 04:42:23 -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-543-oTPaqGdVN6mc9Ixg_dNtLw-1; Tue, 03 Nov 2020 07:42:19 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 789F010866B2; Tue, 3 Nov 2020 12:42:13 +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 55A7B7512C; Tue, 3 Nov 2020 12:42:13 +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 1AC65181A71F; Tue, 3 Nov 2020 12:42:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cfs6V015958 for ; Tue, 3 Nov 2020 07:41:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0165F73661; Tue, 3 Nov 2020 12:41:54 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 704A11C4 for ; Tue, 3 Nov 2020 12:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407342; 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=yadB5VgpHs5atg0pa9r0zvVCZ+rNNGXN8zdNvusYbg8=; b=WsLXdSqC2RRnz36JYBy0PgD4WXgJxT9gtrk6o4P7tN71f+oi0MpgCVooN2VzwiRZhtzv9n w4nTkem+0N4wYMCby2VGkWCo6f+RL0s4ERoDXbRlaFcxI6vRd/l66SHfDsZ4+FgPnFlRBI 45pAEpuXx+v9rrJU4gog9ryoHSaU6xU= X-MC-Unique: oTPaqGdVN6mc9Ixg_dNtLw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 13/25] vircgroup: extract virCgroupNewDetect from virCgroupNew Date: Tue, 3 Nov 2020 13:41:25 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.15 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The current code uses virCgroupNew() as a single point of entry and calls into virCgroupDetect() as well. Both have logic for several paths which is difficult to figure out. Extract the actually used code path from the two functions to make it obvious what's happening in this case. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index f21a581946..97e15c0ab3 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1048,7 +1048,28 @@ virCgroupNewDetect(pid_t pid, int controllers, virCgroupPtr *group) { - return virCgroupNew(pid, "", NULL, controllers, group); + g_autoptr(virCgroup) new =3D g_new0(virCgroup, 1); + + VIR_DEBUG("pid=3D%lld controllers=3D%d group=3D%p", + (long long) pid, controllers, group); + + if (virCgroupSetBackends(new) < 0) + return -1; + + if (virCgroupDetectMounts(new) < 0) + return -1; + + if (virCgroupDetectPlacement(new, pid, "") < 0) + return -1; + + if (virCgroupValidatePlacement(new, pid) < 0) + return -1; + + if (virCgroupDetectControllers(new, controllers, NULL) < 0) + return -1; + + *group =3D g_steal_pointer(&new); + return 0; } =20 =20 --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407344; cv=none; d=zohomail.com; s=zohoarc; b=USZNEhC47nQOvsaxpn8PvmOxNv6ZyIABg4pp4ObN+Gadv0MK6yrbUrSf3SVVf5Zrdfy6uadNxs3RwyxhruePPeONt9GqnwGU9HrXsJVimEaGYffPbu3MDFqkZESir64/6XG0du2gg5BXfaTftFVEpvOHWCGxwdGN1N6krJOPNqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407344; 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=1h1D3s+njEq4l/l3nOJzHXJzA46YkZgm/WvxGFgs4y0=; b=CA3v7W3J9VGayCBYNwlUE9t4zpsY1NpjrUTdwFziSW70t5X6tsGke7XMhlDilzJBDj4NUpQs6B67iYAR5LryUQPMJNH2lMyLv2dtJq2ntefLAQXupj+/i7Jq6ZgBfr5jsaSX2MzNoEAo1sQz0jYjSKlIkxxoVELLE6NWM3scbso= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407344112185.3300296613304; Tue, 3 Nov 2020 04:42:24 -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-475-F2D9mzy3Mzq2jBHC1YthtA-1; Tue, 03 Nov 2020 07:42:17 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 650E7803F4D; Tue, 3 Nov 2020 12:42:10 +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 432567366D; Tue, 3 Nov 2020 12:42:10 +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 F0BEA181A07E; Tue, 3 Nov 2020 12:42:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cfsos015964 for ; Tue, 3 Nov 2020 07:41:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id DF04973661; Tue, 3 Nov 2020 12:41:54 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 596011C4 for ; Tue, 3 Nov 2020 12:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407343; 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=1h1D3s+njEq4l/l3nOJzHXJzA46YkZgm/WvxGFgs4y0=; b=FRlpYapl1cqKHgGEaPaMXjsWP5IrdPCYIJayhgKGGBlJYiyOfJVPTacIHb3Hjyb70NwZUS rkCV7OjdeerQ71g4dJDlX4vW+R0M2xuC+cP9JJOIM55HgJqSlW1jo8wbz2XYy2rgjft6BD 6S5Ifmuhu1HEf1+QvfEngia6Yt75v5E= X-MC-Unique: F2D9mzy3Mzq2jBHC1YthtA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 14/25] vircgroup: introduce virCgroupNewParent Date: Tue, 3 Nov 2020 13:41:26 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.13 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The current code uses virCgroupNew() as a single point of entry and calls into virCgroupDetect() as well. Both have logic for several paths which is difficult to figure out. Extract the actually used code path from the two functions to make it obvious what's happening in this case. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 51 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 97e15c0ab3..b11139bef1 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -861,6 +861,40 @@ virCgroupSetPartitionSuffix(const char *path, char **r= es) } =20 =20 +static int +virCgroupNewFromParent(virCgroupPtr parent, + const char *path, + int controllers, + virCgroupPtr *group) +{ + g_autoptr(virCgroup) new =3D g_new0(virCgroup, 1); + + VIR_DEBUG("parent=3D%p path=3D%s controllers=3D%d group=3D%p", + parent, path, controllers, group); + + if (virCgroupSetBackends(new) < 0) + return -1; + + if (virCgroupCopyMounts(new, parent) < 0) + return -1; + + if (virCgroupCopyPlacement(new, path, parent) < 0) + return -1; + + if (virCgroupDetectPlacement(new, -1, path) < 0) + return -1; + + if (virCgroupValidatePlacement(new, -1) < 0) + return -1; + + if (virCgroupDetectControllers(new, controllers, parent) < 0) + return -1; + + *group =3D g_steal_pointer(&new); + return 0; +} + + /** * virCgroupNewPartition: * @path: path for the partition @@ -910,7 +944,7 @@ virCgroupNewPartition(const char *path, return -1; } =20 - if (virCgroupNew(-1, newPath, parent, controllers, &newGroup) < 0) + if (virCgroupNewFromParent(parent, newPath, controllers, &newGroup) < = 0) return -1; =20 if (parent) { @@ -965,7 +999,7 @@ virCgroupNewDomainPartition(virCgroupPtr partition, if (virCgroupPartitionEscape(&grpname) < 0) return -1; =20 - if (virCgroupNew(-1, grpname, partition, -1, &newGroup) < 0) + if (virCgroupNewFromParent(partition, grpname, -1, &newGroup) < 0) return -1; =20 /* @@ -1032,7 +1066,7 @@ virCgroupNewThread(virCgroupPtr domain, (1 << VIR_CGROUP_CONTROLLER_CPUACCT) | (1 << VIR_CGROUP_CONTROLLER_CPUSET)); =20 - if (virCgroupNew(-1, name, domain, controllers, &newGroup) < 0) + if (virCgroupNewFromParent(domain, name, controllers, &newGroup) < 0) return -1; =20 if (virCgroupMakeGroup(domain, newGroup, create, VIR_CGROUP_THREAD) < = 0) @@ -1133,11 +1167,10 @@ virCgroupEnableMissingControllers(char *path, if (t) *t =3D '\0'; =20 - if (virCgroupNew(pidleader, - path, - parent, - controllers, - &tmp) < 0) + if (virCgroupNewFromParent(parent, + path, + controllers, + &tmp) < 0) return -1; =20 if (virCgroupMakeGroup(parent, tmp, true, VIR_CGROUP_SYSTEMD) < 0) @@ -2583,7 +2616,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, =20 VIR_DEBUG("Process subdir %s", ent->d_name); =20 - if (virCgroupNew(-1, ent->d_name, group, -1, &subgroup) < 0) + if (virCgroupNewFromParent(group, ent->d_name, -1, &subgroup) < 0) return -1; =20 if ((rc =3D virCgroupKillRecursiveInternal(subgroup, signum, pids, --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407510; cv=none; d=zohomail.com; s=zohoarc; b=FuA7GNob8l5ctCtaX5GhqoDLJF+ywAhywb1qjgcnvqJBoh18bejnuOyJs+f/tT13abfbvllU+FXU2A26FSX2tL8TBUT4htqeqeudRSb4f83/Pxzd7mV10O8Hxx1NWtItuqPpKk/LMuY6xFopJhe3MHFA6RsED0D8NmrYBVu3i+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407510; 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=jhHmUBKTbMVK+yhj080S1hbOtmCnIFsm5GvSnVgnQ1Y=; b=EfZ/1H6zByjPlzhhXiypLmalue7RRlUfll2PZSLm7fy+Jg2vXo5vUQl1Tw9ZRdb/+HHTC63WbS18Ujvkcg5vq6pRSZlHyikhh1wzjtZUZGedRjF9RM2t5/0qgxCFBi9zgfQO8PScW0XdCjdGqApt4d4Gg+reXWC5D/YGCSCxyTk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604407510267297.09468711706154; Tue, 3 Nov 2020 04:45:10 -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-519-v0-xooB2PJq6cMK02jsUBQ-1; Tue, 03 Nov 2020 07:42:21 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38F4F1868424; Tue, 3 Nov 2020 12:42:13 +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 F01C421E96; Tue, 3 Nov 2020 12:42:12 +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 AEE37181A3EC; Tue, 3 Nov 2020 12:42:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3CftIT015974 for ; Tue, 3 Nov 2020 07:41:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id C6F3D1C4; Tue, 3 Nov 2020 12:41:55 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41DCD73667 for ; Tue, 3 Nov 2020 12:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407508; 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=jhHmUBKTbMVK+yhj080S1hbOtmCnIFsm5GvSnVgnQ1Y=; b=hq1hmxZJ42QN1yqyMFaU2rpj2Ksy1Ge6ygiZoCFlBB0BVNU8XCa58UnARQRISqn37TXCeD hAQi14kfKSTzOqpUBtQZbZXitiWOaKetLnrHP/3mwsK6Oruh9cTVf3hiN3HCooKDE1zpjc xK4WJHAN/HOGuEiSESfuA05VNJdT2vI= X-MC-Unique: v0-xooB2PJq6cMK02jsUBQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 15/25] vircgroup: drop @parent from virCgroupNew Date: Tue, 3 Nov 2020 13:41:27 +0100 Message-Id: <66453bc623bc57ab3883e833685db2ecd38c437b.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now it is always NULL. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 40 +++++++++++++--------------------------- src/util/vircgrouppriv.h | 1 - src/util/vircgroupv1.c | 2 +- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index b11139bef1..56aa9cc064 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -446,28 +446,19 @@ static int virCgroupDetect(virCgroupPtr group, pid_t pid, int controllers, - const char *path, - virCgroupPtr parent) + const char *path) { - VIR_DEBUG("group=3D%p controllers=3D%d path=3D%s parent=3D%p", - group, controllers, path, parent); + VIR_DEBUG("group=3D%p controllers=3D%d path=3D%s", + group, controllers, path); =20 if (virCgroupSetBackends(group) < 0) return -1; =20 - if (parent) { - if (virCgroupCopyMounts(group, parent) < 0) - return -1; - } else { - if (virCgroupDetectMounts(group) < 0) - return -1; - } + if (virCgroupDetectMounts(group) < 0) + return -1; =20 - /* In some cases we can copy part of the placement info - * based on the parent cgroup... - */ - if (parent || path[0] =3D=3D '/') { - if (virCgroupCopyPlacement(group, path, parent) < 0) + if (path[0] =3D=3D '/') { + if (virCgroupCopyPlacement(group, path, NULL) < 0) return -1; } =20 @@ -479,7 +470,7 @@ virCgroupDetect(virCgroupPtr group, if (virCgroupValidatePlacement(group, pid) < 0) return -1; =20 - if (virCgroupDetectControllers(group, controllers, parent) < 0) + if (virCgroupDetectControllers(group, controllers, NULL) < 0) return -1; =20 return 0; @@ -708,15 +699,12 @@ virCgroupMakeGroup(virCgroupPtr parent, /** * virCgroupNew: * @path: path for the new group - * @parent: parent group, or NULL * @controllers: bitmask of controllers to activate * * Create a new cgroup storing it in @group. * * If @path starts with a '/' it is treated as an - * absolute path, and @parent is ignored. Otherwise - * it is treated as being relative to @parent. If - * @parent is NULL, then the placement of the current + * absolute path. Otherwise then the placement of the current * process is used. * * Returns 0 on success, -1 on error @@ -724,19 +712,18 @@ virCgroupMakeGroup(virCgroupPtr parent, int virCgroupNew(pid_t pid, const char *path, - virCgroupPtr parent, int controllers, virCgroupPtr *group) { g_autoptr(virCgroup) newGroup =3D NULL; =20 - VIR_DEBUG("pid=3D%lld path=3D%s parent=3D%p controllers=3D%d group=3D%= p", - (long long) pid, path, parent, controllers, group); + VIR_DEBUG("pid=3D%lld path=3D%s controllers=3D%d group=3D%p", + (long long) pid, path, controllers, group); =20 *group =3D NULL; newGroup =3D g_new0(virCgroup, 1); =20 - if (virCgroupDetect(newGroup, pid, controllers, path, parent) < 0) + if (virCgroupDetect(newGroup, pid, controllers, path) < 0) return -1; =20 *group =3D g_steal_pointer(&newGroup); @@ -940,7 +927,7 @@ virCgroupNewPartition(const char *path, tmp++; *tmp =3D '\0'; =20 - if (virCgroupNew(-1, parentPath, NULL, controllers, &parent) < 0) + if (virCgroupNew(-1, parentPath, controllers, &parent) < 0) return -1; } =20 @@ -1156,7 +1143,6 @@ virCgroupEnableMissingControllers(char *path, =20 if (virCgroupNew(pidleader, "/", - NULL, controllers, &parent) < 0) return -1; diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index af8bf99888..0ac62882a5 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -112,7 +112,6 @@ int virCgroupGetValueForBlkDev(const char *str, =20 int virCgroupNew(pid_t pid, const char *path, - virCgroupPtr parent, int controllers, virCgroupPtr *group); =20 diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 6bb819410b..b3e0f733b9 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -1468,7 +1468,7 @@ virCgroupV1MemoryOnceInit(void) g_autoptr(virCgroup) group =3D NULL; unsigned long long int mem_unlimited =3D 0ULL; =20 - if (virCgroupNew(-1, "/", NULL, -1, &group) < 0) + if (virCgroupNew(-1, "/", -1, &group) < 0) return; =20 if (!virCgroupV1HasController(group, VIR_CGROUP_CONTROLLER_MEMORY)) --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407346; cv=none; d=zohomail.com; s=zohoarc; b=LgbTg248SZDxQJRRIw0E1stVqy4XZ9deEshs7uuh0szIgX12X2/DBmzQLjrj6pqq+aeJG2CYof0X6d1jU3/VKpMFcAkAFb5zoitWG8n94zXzLypxRvYqqolnltweQU+xc4VlDd+Q0ljPTZxZ17ouAs8G4D5kZVPMkAmGODTNi8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407346; 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=QaZCI8wtRFLX7+U7Baxh1SNB6c7ZNkyBtKsEnOy34iE=; b=aLUv8+zjG/t5EuT/Vrzn6/2laHTJo026NBHX41tHDS3/AzDgU3oj2mqvneOBhfORHgC0W9s1/VNGGyzTqnt0Yo8pmWG/po7tzkQEjWb0unuandTxb9HVR5JduLKK6guDJQ30VLzIJVHzR8cN9PdJbDajR4jzqQYdS1tGtv+tlbw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407346132197.3647324024787; Tue, 3 Nov 2020 04:42:26 -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-565-kz9FACuMPwW9m3SmXbZEng-1; Tue, 03 Nov 2020 07:42:22 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A001910866B9; Tue, 3 Nov 2020 12:42:16 +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 079AA5B4BB; Tue, 3 Nov 2020 12:42:16 +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 C40C5922E1; Tue, 3 Nov 2020 12:42:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3CfuPL015988 for ; Tue, 3 Nov 2020 07:41:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id AE5DA73661; Tue, 3 Nov 2020 12:41:56 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28F371C4 for ; Tue, 3 Nov 2020 12:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407345; 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=QaZCI8wtRFLX7+U7Baxh1SNB6c7ZNkyBtKsEnOy34iE=; b=CEnpPdFPkNL80AYdj8B7iNse8y77t9ENykotIwxxreVF80sod8RJtrCN31YE8G9z9z9Si7 1nACglfNVNc+bx+4AHymCrfdT81IfRm/csGL/ar3ld3UpWdFvuDwdl4/Ljftf0OM+jX3Tl Eop6klK2VgGCBiX275jm9RJok6Vp/zQ= X-MC-Unique: kz9FACuMPwW9m3SmXbZEng-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 16/25] vircgroup: virCgroupNew is now always called with absolute path Date: Tue, 3 Nov 2020 13:41:28 +0100 Message-Id: <701e4bf9a04050a4c731707a3ca732d0fb051e53.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 56aa9cc064..794680d696 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -457,10 +457,8 @@ virCgroupDetect(virCgroupPtr group, if (virCgroupDetectMounts(group) < 0) return -1; =20 - if (path[0] =3D=3D '/') { - if (virCgroupCopyPlacement(group, path, NULL) < 0) - return -1; - } + if (virCgroupCopyPlacement(group, path, NULL) < 0) + return -1; =20 /* ... but use /proc/cgroups to fill in the rest */ if (virCgroupDetectPlacement(group, pid, path) < 0) @@ -703,10 +701,6 @@ virCgroupMakeGroup(virCgroupPtr parent, * * Create a new cgroup storing it in @group. * - * If @path starts with a '/' it is treated as an - * absolute path. Otherwise then the placement of the current - * process is used. - * * Returns 0 on success, -1 on error */ int --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407385; cv=none; d=zohomail.com; s=zohoarc; b=E4G8ji3bxAnJPIH0vMF8pnhGxuORowKGot9+SRXfGUmYsaSMEdpVfk9vPPXujT9GK6jxR8A0fK4wxaii+guTTlUelDfjWqpOgt6LpfvI8Nate8wgfUqdESdLIuW1DmrUYZJJQCuGP10USPONO0w/2SyhP6xFHKsbTlOlODUW6oU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407385; 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=vg3+4nUMCsovD2NBWGuKV6OyTT/cKZfrYA3SWZ438Fo=; b=hQJJeReZlNrYWwwf1dv0IE6sgQ/WanA3zoTOu4NnLBQbByzGdnvVpqu+qf2wiMDo2UQvOOIKoeBl300geMEEG32aPcU4HUCYnKQ6sr1trHeNlya0Znf9StNq8xU63Vk7JmLyEUsoCQbLD4P0YB4WlWdCNTke8DO+AkvbpikBHwc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407385923306.0887860435132; Tue, 3 Nov 2020 04:43:05 -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-122-kNeuYaRRNkS5nH1be-Ig6w-1; Tue, 03 Nov 2020 07:42:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C4D6010082EA; Tue, 3 Nov 2020 12:42:15 +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 A619B73667; Tue, 3 Nov 2020 12:42: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 738058C7DE; Tue, 3 Nov 2020 12:42:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cg1qQ016047 for ; Tue, 3 Nov 2020 07:42:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 130E573664; Tue, 3 Nov 2020 12:42:01 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8042E1C4 for ; Tue, 3 Nov 2020 12:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407384; 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=vg3+4nUMCsovD2NBWGuKV6OyTT/cKZfrYA3SWZ438Fo=; b=HAF22HRxbSFTemv52lvv8TyFu2Vi0AbbO2Ev1wBrIkqGDUhQouJdiBeoKln3Ym9cSzTUso VG8jhMOSR1fjb+PiidKUoewX/V4T1EYckQ+IOvP6AeoKIzugdNWqBvAQ6MicEZyiQ4iOvZ 2Jj3IGpdaBUn/XhMzFLFKIWkT+QHNWY= X-MC-Unique: kNeuYaRRNkS5nH1be-Ig6w-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 17/25] vircgroup: expand virCgroupDetect into virCgroupNew Date: Tue, 3 Nov 2020 13:41:29 +0100 Message-Id: <9fd88498e7a44267d07bfb7a150ce60594dbacca.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.13 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 52 +++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 794680d696..81aa3ee791 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -442,39 +442,6 @@ virCgroupDetectControllers(virCgroupPtr group, } =20 =20 -static int -virCgroupDetect(virCgroupPtr group, - pid_t pid, - int controllers, - const char *path) -{ - VIR_DEBUG("group=3D%p controllers=3D%d path=3D%s", - group, controllers, path); - - if (virCgroupSetBackends(group) < 0) - return -1; - - if (virCgroupDetectMounts(group) < 0) - return -1; - - if (virCgroupCopyPlacement(group, path, NULL) < 0) - return -1; - - /* ... but use /proc/cgroups to fill in the rest */ - if (virCgroupDetectPlacement(group, pid, path) < 0) - return -1; - - /* Check that for every mounted controller, we found our placement */ - if (virCgroupValidatePlacement(group, pid) < 0) - return -1; - - if (virCgroupDetectControllers(group, controllers, NULL) < 0) - return -1; - - return 0; -} - - char * virCgroupGetBlockDevString(const char *path) { @@ -717,7 +684,24 @@ virCgroupNew(pid_t pid, *group =3D NULL; newGroup =3D g_new0(virCgroup, 1); =20 - if (virCgroupDetect(newGroup, pid, controllers, path) < 0) + if (virCgroupSetBackends(newGroup) < 0) + return -1; + + if (virCgroupDetectMounts(newGroup) < 0) + return -1; + + if (virCgroupCopyPlacement(newGroup, path, NULL) < 0) + return -1; + + /* ... but use /proc/cgroups to fill in the rest */ + if (virCgroupDetectPlacement(newGroup, pid, path) < 0) + return -1; + + /* Check that for every mounted controller, we found our placement */ + if (virCgroupValidatePlacement(newGroup, pid) < 0) + return -1; + + if (virCgroupDetectControllers(newGroup, controllers, NULL) < 0) return -1; =20 *group =3D g_steal_pointer(&newGroup); --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407349; cv=none; d=zohomail.com; s=zohoarc; b=M75dPjH+MuwSww3NMHUbu3qvWdH8Clr05fkvsDo1HAR9ZnD2kieB20KOZdTiWLWhoGxZExN80l95srTecOlCIjPjo8/ObcaD4L/dJ+sqyl7YFWNVJ2Qr7pCiYJFR94X8+jGisQ3LfhQpF46kIqR4gwP83cz2MY0EjlffApRZ8+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407349; 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=bPx2Sd6Hul5lRpYYOtAKWDaEx81JRoIaRQYsktrHtDU=; b=je2aphVhx5/HxcgWVcyH/xnvyCuVTzRlgqqqB92qQdDfE3PVItt3fyaWU2Eo5PhAArHy0OutmXT1h1JbLvd5VanDqM7qJoFo2q3u4Nh2zzHYDduoFs96niCiKzXMZTtGa+6EkJGuhWOET+lDx8lxJTAlGJB8u3jgZC4uGairxYc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604407349086858.8888950573394; Tue, 3 Nov 2020 04:42:29 -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-270-BICDrjORM9ChH6MpEee3UQ-1; Tue, 03 Nov 2020 07:42:25 -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 99555809DF2; Tue, 3 Nov 2020 12:42:18 +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 72A4B4DA7F; Tue, 3 Nov 2020 12:42:18 +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 3B84D181A870; Tue, 3 Nov 2020 12:42:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cg1AW016211 for ; Tue, 3 Nov 2020 07:42:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id EE6B11C4; Tue, 3 Nov 2020 12:42:01 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68DDA7366C for ; Tue, 3 Nov 2020 12:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407347; 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=bPx2Sd6Hul5lRpYYOtAKWDaEx81JRoIaRQYsktrHtDU=; b=VXWKcNRWETuwkdOApR84QLbG1pSKCxxM/AMXlQsqHe+EWo2F28YUfhwH+lq/eJbDYRA+L9 qWsR0MPQTs99msoAS4hLzwcVEPBw//THiDfllKU7/DyZVBFxzGIxfnAE2tIjb5KUgm26Tg 0gELkfxG4jrG3B7+/Q0/55cwrgwBusY= X-MC-Unique: BICDrjORM9ChH6MpEee3UQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 18/25] vircgroup: no need to use PID in virCgroupEnableMissingControllers Date: Tue, 3 Nov 2020 13:41:30 +0100 Message-Id: <983a640fb0dd7afa4deea4a8babc4c1977923b48.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This function is relevant only with cgroups v1 where it creates hierarchy for controllers that are not managed by systemd. PID is used to detect a placement of current process but in this situation we are building the hierarchy for already known placement. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 81aa3ee791..2c1d6f9f01 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1112,14 +1112,13 @@ virCgroupNewDetectMachine(const char *name, =20 static int virCgroupEnableMissingControllers(char *path, - pid_t pidleader, int controllers, virCgroupPtr *group) { g_autoptr(virCgroup) parent =3D NULL; char *offset =3D path; =20 - if (virCgroupNew(pidleader, + if (virCgroupNew(-1, "/", controllers, &parent) < 0) @@ -1213,10 +1212,8 @@ virCgroupNewMachineSystemd(const char *name, return -2; } =20 - if (virCgroupEnableMissingControllers(path, pidleader, - controllers, &newGroup) < 0) { + if (virCgroupEnableMissingControllers(path, controllers, &newGroup) < = 0) return -1; - } =20 if (virCgroupAddProcess(newGroup, pidleader) < 0) { virErrorPtr saved; --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407350; cv=none; d=zohomail.com; s=zohoarc; b=ffsC4RlezlXuQtj1d2PUGXfJCpINqIZweihKH9+1zXi+NwiGhirbdEvt6/9J2QWEVQJKeH+jipnMQDuVU4qve8jA1lvShUb1ZgiWisPFPbkhG3opYhHaZgjWLDJKOvaoSC3RPLMX3PaB/UrCptDNsjp2jnOm9f4g6w+DvnZel3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407350; 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=Gjy2ZLintx0NKU0mgI1teJBeUnJJnLkwo5qOIXxlFGs=; b=EfvCDNbTVeOZ9pTwdqXLVYY11M0FYfRgIcAMG/DExmCDf7WtNMFpER5lM7F2X/3YD9yVcicif5KblFpl6Sqg4BZ73/T/UcUkaGnpI1R1Vg9Dp6j7sHYZdt3izwd48jsFveLF4qG32uZIhdYB/mrgiqSRb3B1+KZlNXWeU4FEyRs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604407350072204.37634471162607; Tue, 3 Nov 2020 04:42:30 -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-116-WQ-5NrwGP8elyeqipdYmrA-1; Tue, 03 Nov 2020 07:42:27 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A1E8100963E; Tue, 3 Nov 2020 12:42:19 +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 3AEA375129; Tue, 3 Nov 2020 12:42:19 +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 F412F181A884; Tue, 3 Nov 2020 12:42:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cg3tc016268 for ; Tue, 3 Nov 2020 07:42:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id D5F021C4; Tue, 3 Nov 2020 12:42:02 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50A5B7366C for ; Tue, 3 Nov 2020 12:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407348; 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=Gjy2ZLintx0NKU0mgI1teJBeUnJJnLkwo5qOIXxlFGs=; b=g5ZyEv+E5cXACblQBQ6enQd5/WkyzkaX/hOgRcOEQd6OyD5JdkYf+SkcEMAVOo32MDmUgA Qso9EJ9YK407EUafxG5+ycaZ5MJTKJ/q6/IGwF1qyLxjPuI2iPxoqSSgng3opBlg4K0pgP bSE5kFcxc7LGsEaF7ukPMZAJVGkZPRk= X-MC-Unique: WQ-5NrwGP8elyeqipdYmrA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 19/25] vircgroup: drop @pid argument from virCgroupNew Date: Tue, 3 Nov 2020 13:41:31 +0100 Message-Id: <3e9d5d231c7888a1e3963a26cadcf2c76636d5dd.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.15 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now it is always -1. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 16 +++++++--------- src/util/vircgrouppriv.h | 3 +-- src/util/vircgroupv1.c | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 2c1d6f9f01..6a34eb4037 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -671,15 +671,14 @@ virCgroupMakeGroup(virCgroupPtr parent, * Returns 0 on success, -1 on error */ int -virCgroupNew(pid_t pid, - const char *path, +virCgroupNew(const char *path, int controllers, virCgroupPtr *group) { g_autoptr(virCgroup) newGroup =3D NULL; =20 - VIR_DEBUG("pid=3D%lld path=3D%s controllers=3D%d group=3D%p", - (long long) pid, path, controllers, group); + VIR_DEBUG("path=3D%s controllers=3D%d group=3D%p", + path, controllers, group); =20 *group =3D NULL; newGroup =3D g_new0(virCgroup, 1); @@ -694,11 +693,11 @@ virCgroupNew(pid_t pid, return -1; =20 /* ... but use /proc/cgroups to fill in the rest */ - if (virCgroupDetectPlacement(newGroup, pid, path) < 0) + if (virCgroupDetectPlacement(newGroup, -1, path) < 0) return -1; =20 /* Check that for every mounted controller, we found our placement */ - if (virCgroupValidatePlacement(newGroup, pid) < 0) + if (virCgroupValidatePlacement(newGroup, -1) < 0) return -1; =20 if (virCgroupDetectControllers(newGroup, controllers, NULL) < 0) @@ -905,7 +904,7 @@ virCgroupNewPartition(const char *path, tmp++; *tmp =3D '\0'; =20 - if (virCgroupNew(-1, parentPath, controllers, &parent) < 0) + if (virCgroupNew(parentPath, controllers, &parent) < 0) return -1; } =20 @@ -1118,8 +1117,7 @@ virCgroupEnableMissingControllers(char *path, g_autoptr(virCgroup) parent =3D NULL; char *offset =3D path; =20 - if (virCgroupNew(-1, - "/", + if (virCgroupNew("/", controllers, &parent) < 0) return -1; diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index 0ac62882a5..7248bc1d35 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -110,8 +110,7 @@ int virCgroupGetValueForBlkDev(const char *str, const char *devPath, char **value); =20 -int virCgroupNew(pid_t pid, - const char *path, +int virCgroupNew(const char *path, int controllers, virCgroupPtr *group); =20 diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index b3e0f733b9..98b5aa047d 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -1468,7 +1468,7 @@ virCgroupV1MemoryOnceInit(void) g_autoptr(virCgroup) group =3D NULL; unsigned long long int mem_unlimited =3D 0ULL; =20 - if (virCgroupNew(-1, "/", -1, &group) < 0) + if (virCgroupNew("/", -1, &group) < 0) return; =20 if (!virCgroupV1HasController(group, VIR_CGROUP_CONTROLLER_MEMORY)) --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407444; cv=none; d=zohomail.com; s=zohoarc; b=SQluoEqtKzmwV70457lLOn8g2mvqFk5sl+v2HNbYLQ+EO0h+Yv5v8kSGSwRB+/ol/EVvtbm08mr6KmsQZDGSBjNtLVg+4WhsldrwoD7xHHkFAFQ9TJndZpb3IRp2bI1N6LEcEMr+xVUSt+1J5To743+RcXranJ8vsSH0Rgi0aI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407444; 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=PD8OtCtjyCty3Fz1wmVUjh4IwI+zrLK39ECqecFHj84=; b=fn7Vp77SjPl9PDp5fEfnwn6+dRG99YllT/u7wnCO5R8TKFc+HFXxK/l0ul84JhEr5DI3T7N4qYpRtGKqfCWkeadM+eDSKbG9qRnKanKFQja4nbk7Uh3UzWtjnNtYBQzgDO88JrcP0EqsathJZrKWYafd+Sd+miQAy9yQBksszQ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604407444094420.90152359363594; Tue, 3 Nov 2020 04:44:04 -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-171-3jLsLTdJPVSJjTwkFy3nWA-1; Tue, 03 Nov 2020 07:42:27 -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 822F5186DD31; Tue, 3 Nov 2020 12:42:21 +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 5FEC65DA33; Tue, 3 Nov 2020 12:42:21 +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 2FED0181A89B; Tue, 3 Nov 2020 12:42:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cg3Rk016262 for ; Tue, 3 Nov 2020 07:42:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id BE3FE73667; Tue, 3 Nov 2020 12:42:03 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 382FF73664 for ; Tue, 3 Nov 2020 12:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407443; 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=PD8OtCtjyCty3Fz1wmVUjh4IwI+zrLK39ECqecFHj84=; b=VO+ReiQG9/URx3k0W4CJ/X49gQoADbWroev2qLOCKdVUzbXjiDQEIC3GKG2bCNrNEgv32n Tp9BbxL7/eChgf6iU7C5ppXWgPtrDHgdzxhy7JqLk9ELHF4xTWtWQgmkZ5lThWeB2ezkP0 GwWaCC0g4kcZWgYE/HmXPjogHTZezX0= X-MC-Unique: 3jLsLTdJPVSJjTwkFy3nWA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 20/25] vircgroup: introduce virCgroupSetPlacement Date: Tue, 3 Nov 2020 13:41:32 +0100 Message-Id: <144f9fdf53d91e2453cbc00dce8ffce5e5e07c68.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Currently this task is done by virCgroupCopyPlacement when the @path starts with "/". virCgroupNew is always called with @path starting with "/" and there is no parent to copy path from. To make it obvious what the code is doing introduce new helper. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 19 ++++++++++++++++++- src/util/vircgroupbackend.h | 5 +++++ src/util/vircgroupv1.c | 21 +++++++++++++++++++++ src/util/vircgroupv2.c | 11 +++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 6a34eb4037..00967ea5fa 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -393,6 +393,23 @@ virCgroupDetectPlacement(virCgroupPtr group, } =20 =20 +static int +virCgroupSetPlacement(virCgroupPtr group, + const char *path) +{ + size_t i; + + for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { + if (group->backends[i] && + group->backends[i]->setPlacement(group, path) < 0) { + return -1; + } + } + + return 0; +} + + static int virCgroupValidatePlacement(virCgroupPtr group, pid_t pid) @@ -689,7 +706,7 @@ virCgroupNew(const char *path, if (virCgroupDetectMounts(newGroup) < 0) return -1; =20 - if (virCgroupCopyPlacement(newGroup, path, NULL) < 0) + if (virCgroupSetPlacement(newGroup, path) < 0) return -1; =20 /* ... but use /proc/cgroups to fill in the rest */ diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index f677157a91..4ca2e38af2 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -88,6 +88,10 @@ typedef int const char *controllers, const char *selfpath); =20 +typedef int +(*virCgroupSetPlacementCB)(virCgroupPtr group, + const char *path); + typedef int (*virCgroupValidatePlacementCB)(virCgroupPtr group, pid_t pid); @@ -369,6 +373,7 @@ struct _virCgroupBackend { virCgroupCopyPlacementCB copyPlacement; virCgroupDetectMountsCB detectMounts; virCgroupDetectPlacementCB detectPlacement; + virCgroupSetPlacementCB setPlacement; virCgroupValidatePlacementCB validatePlacement; virCgroupStealPlacementCB stealPlacement; virCgroupDetectControllersCB detectControllers; diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 98b5aa047d..ed4b0813f2 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -364,6 +364,26 @@ virCgroupV1DetectPlacement(virCgroupPtr group, } =20 =20 +static int +virCgroupV1SetPlacement(virCgroupPtr group, + const char *path) +{ + size_t i; + + for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { + if (!group->legacy[i].mountPoint) + continue; + + if (i =3D=3D VIR_CGROUP_CONTROLLER_SYSTEMD) + continue; + + group->legacy[i].placement =3D g_strdup(path); + } + + return 0; +} + + static int virCgroupV1ValidatePlacement(virCgroupPtr group, pid_t pid) @@ -2101,6 +2121,7 @@ virCgroupBackend virCgroupV1Backend =3D { .copyPlacement =3D virCgroupV1CopyPlacement, .detectMounts =3D virCgroupV1DetectMounts, .detectPlacement =3D virCgroupV1DetectPlacement, + .setPlacement =3D virCgroupV1SetPlacement, .validatePlacement =3D virCgroupV1ValidatePlacement, .stealPlacement =3D virCgroupV1StealPlacement, .detectControllers =3D virCgroupV1DetectControllers, diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 0467a72566..8e058ca9c6 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -223,6 +223,16 @@ virCgroupV2DetectPlacement(virCgroupPtr group, } =20 =20 +static int +virCgroupV2SetPlacement(virCgroupPtr group, + const char *path) +{ + group->unified.placement =3D g_strdup(path); + + return 0; +} + + static int virCgroupV2ValidatePlacement(virCgroupPtr group, pid_t pid G_GNUC_UNUSED) @@ -1845,6 +1855,7 @@ virCgroupBackend virCgroupV2Backend =3D { .copyPlacement =3D virCgroupV2CopyPlacement, .detectMounts =3D virCgroupV2DetectMounts, .detectPlacement =3D virCgroupV2DetectPlacement, + .setPlacement =3D virCgroupV2SetPlacement, .validatePlacement =3D virCgroupV2ValidatePlacement, .stealPlacement =3D virCgroupV2StealPlacement, .detectControllers =3D virCgroupV2DetectControllers, --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407396; cv=none; d=zohomail.com; s=zohoarc; b=Q9nBlfuzQdj1rHYvIlBMI3OSP7HT3r9YeOoouLdJ6q/FfERLsLQRflCjIuVbNdXuU6NknE31BNNqyqzMNIVzlUoY0UI9TGjlHHzgEMbJkdghGRJ1oId02pVBDvaa2056qKk04+ru1JRpz6QDDDkO3ePQxbIs+wCjUWtzNRI0jqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407396; 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=m5F6g98Qk8wt3Eqxmhwd7aAfKc0/nnoPPRMdtR4vejU=; b=kanOqbbwu2S+Sv1lm/YxWo86fIM6zs8V/QWemV3nxcB39NhPb+sJUc3mtk0Erg/1t/NTXudlixzMAaStH5BJ0puhkRlxAu/3xRKHvAen2FpmxSa7OpBBLFz9u9BtzRGbozZlp6GpGG9bnpQTd5kfXCDet3DFd6lnmxb4oXRTEnE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407396140734.9923583989496; Tue, 3 Nov 2020 04:43:16 -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-269-64U4GsJDOxStQ4tstrXBMA-1; Tue, 03 Nov 2020 07:42:28 -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 3305C10866A2; Tue, 3 Nov 2020 12:42:22 +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 11D9B5DA33; Tue, 3 Nov 2020 12:42: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 CFF32922EB; Tue, 3 Nov 2020 12:42:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cg4l7016278 for ; Tue, 3 Nov 2020 07:42:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id A68747366D; Tue, 3 Nov 2020 12:42:04 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 210CB1C4 for ; Tue, 3 Nov 2020 12:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407394; 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=m5F6g98Qk8wt3Eqxmhwd7aAfKc0/nnoPPRMdtR4vejU=; b=Zo+grKWQc/TUiH1D8JMLQifNcbxeOJ8xmYDFSm74fWGZF4e/lZY8IG/IA37A9TH9QLWYGi b5lt9fHGwme0u8Mv+D0PQ9NJcIwLwzWfVriviFOticruH28AUqJEfunEZDwNQgCdoJU5aT XUVyGfnCqXUJoZvrmzinhF/qAKiCvYI= X-MC-Unique: 64U4GsJDOxStQ4tstrXBMA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 21/25] vircgroup: drop @create from virCgroupNewDomainPartition Date: Tue, 3 Nov 2020 13:41:33 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" All callers pass true. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 5 +---- src/util/vircgrouppriv.h | 1 - tests/vircgrouptest.c | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 00967ea5fa..1e18b84b54 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -969,7 +969,6 @@ int virCgroupNewDomainPartition(virCgroupPtr partition, const char *driver, const char *name, - bool create, virCgroupPtr *group) { g_autofree char *grpname =3D NULL; @@ -993,7 +992,7 @@ virCgroupNewDomainPartition(virCgroupPtr partition, * a group for driver, is to avoid overhead to track * cumulative usage that we don't need. */ - if (virCgroupMakeGroup(partition, newGroup, create, + if (virCgroupMakeGroup(partition, newGroup, true, VIR_CGROUP_MEM_HIERACHY) < 0) { return -1; } @@ -1278,7 +1277,6 @@ virCgroupNewMachineManual(const char *name, if (virCgroupNewDomainPartition(parent, drivername, name, - true, &newGroup) < 0) return -1; =20 @@ -2836,7 +2834,6 @@ int virCgroupNewDomainPartition(virCgroupPtr partition G_GNUC_UNUSED, const char *driver G_GNUC_UNUSED, const char *name G_GNUC_UNUSED, - bool create G_GNUC_UNUSED, virCgroupPtr *group G_GNUC_UNUSED) { virReportSystemError(ENXIO, "%s", diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index 7248bc1d35..77e01519b0 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -123,7 +123,6 @@ int virCgroupNewPartition(const char *path, int virCgroupNewDomainPartition(virCgroupPtr partition, const char *driver, const char *name, - bool create, virCgroupPtr *group) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5); =20 diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 0dd5e3f0b4..1baa71e61c 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -434,7 +434,7 @@ static int testCgroupNewForPartitionDomain(const void *= args G_GNUC_UNUSED) return -1; } =20 - if ((rv =3D virCgroupNewDomainPartition(partitioncgroup, "lxc", "foo",= true, &domaincgroup)) !=3D 0) { + if ((rv =3D virCgroupNewDomainPartition(partitioncgroup, "lxc", "foo",= &domaincgroup)) !=3D 0) { fprintf(stderr, "Cannot create LXC cgroup: %d\n", -rv); return -1; } @@ -475,7 +475,7 @@ static int testCgroupNewForPartitionDomainEscaped(const= void *args G_GNUC_UNUSED return -1; } =20 - if ((rv =3D virCgroupNewDomainPartition(partitioncgroup3, "lxc", "cpu.= foo", true, &domaincgroup)) !=3D 0) { + if ((rv =3D virCgroupNewDomainPartition(partitioncgroup3, "lxc", "cpu.= foo", &domaincgroup)) !=3D 0) { fprintf(stderr, "Cannot create LXC cgroup: %d\n", -rv); return -1; } --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407446; cv=none; d=zohomail.com; s=zohoarc; b=Ac6QkmwdfqR24rj5gmkIA9d4fbCwYoCJlQ6g9W57NcU+NHFJSid8QBVbBiUkW9swe06LsN7Ovl5CxThs2ey6HVFgltbL0Bf5suN8qMcMeUr/7slB0pnrVqMycwOJRYz+J6PWkL5gAe/IGtJGrxvkqUW5/9qb9XzviiMamr3TqFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407446; 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=6h9w2F4VI327F4HgOLijj+Apr0gT5wBbj4rqromKiEk=; b=R4r7Xmv8+be+S2WDtAO65wbceio48duuBydr8K2I5asKimRCptGvnmn8tE3u4PzOC6jl+LUj3guYg3352alNzhs+BoWsx2fOqRhNF058kkpuBy4rggLSjBiQ4u1HHk/TsvKE5GJ20IOJBqxzBfERh4AKSirUhTdcjZllngwQF/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604407446818807.1171145784092; Tue, 3 Nov 2020 04:44:06 -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-547-MJaIG3cENFeEqu2dgajECw-1; Tue, 03 Nov 2020 07:42:20 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C6C4805F12; Tue, 3 Nov 2020 12:42:13 +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 1AAF97366D; Tue, 3 Nov 2020 12:42:13 +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 DB7638C7DC; Tue, 3 Nov 2020 12:42:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cg5HK016302 for ; Tue, 3 Nov 2020 07:42:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8FF9073667; Tue, 3 Nov 2020 12:42:05 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09B0073664 for ; Tue, 3 Nov 2020 12:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407445; 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=6h9w2F4VI327F4HgOLijj+Apr0gT5wBbj4rqromKiEk=; b=U/pAjLSvroLDNcrj8+4KlcuEb5NUbNtzNfLRWsmTJlcA3C9hIjxCn1HNlzZ1G9fWUtLDLk Sl5LGMWouMkSkNpOvvaXVkVQfBaUh97oyVnaSduBUHAOtJS/WwziAblhG9yYbGUaQ6fd35 IfzKqtLPFBHJ/wkb4qV361o5WBdmGVY= X-MC-Unique: MJaIG3cENFeEqu2dgajECw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 22/25] vircgroup: refactor virCgroupEnableMissingControllers Date: Tue, 3 Nov 2020 13:41:34 +0100 Message-Id: <224d1d6584227af3ea2719d65fc17e6bcc01ecd6.1604407065.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.13 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use virStringSplit() to get the list of directories needed to be created. This improves readability of the code and stops passing absolute path to virCgroupNewFromParent(). Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 1e18b84b54..f4c1623567 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1131,21 +1131,18 @@ virCgroupEnableMissingControllers(char *path, virCgroupPtr *group) { g_autoptr(virCgroup) parent =3D NULL; - char *offset =3D path; + VIR_AUTOSTRINGLIST tokens =3D virStringSplit(path, "/", 0); + size_t i; =20 - if (virCgroupNew("/", - controllers, - &parent) < 0) + if (virCgroupNew("/", controllers, &parent) < 0) return -1; =20 - for (;;) { + /* Skip the first token as it is empty string. */ + for (i =3D 1; tokens[i]; i++) { g_autoptr(virCgroup) tmp =3D NULL; - char *t =3D strchr(offset + 1, '/'); - if (t) - *t =3D '\0'; =20 if (virCgroupNewFromParent(parent, - path, + tokens[i], controllers, &tmp) < 0) return -1; @@ -1153,17 +1150,10 @@ virCgroupEnableMissingControllers(char *path, if (virCgroupMakeGroup(parent, tmp, true, VIR_CGROUP_SYSTEMD) < 0) return -1; =20 - if (t) { - *t =3D '/'; - offset =3D t; - virCgroupFree(parent); - parent =3D g_steal_pointer(&tmp); - } else { - *group =3D g_steal_pointer(&tmp); - break; - } + parent =3D g_steal_pointer(&tmp); } =20 + *group =3D g_steal_pointer(&parent); return 0; } =20 --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407409; cv=none; d=zohomail.com; s=zohoarc; b=e6CNUtCDON7JH9atUX11sUcihUeopgnAjh3I8CmJ1sOCzgwB6ZDh4MbLv83+/xkPBTC1i5iz663i0tXodKywY4nJFteQbt8v+v4mQOfe8jF5tC9ixLImvC0TuNDdgHuCzuoRAKVyPP7ySI+c++3aQ87hDlRGt5tjX88qauDGrz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407409; 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=zsBp1T13vT2E9Cbe5aPfMUExGPtIR9qpJlMODRJrWcI=; b=OG2WwNWeFDOYJUcEZDBgFi+xQvdOj0JL3xughkqKYqCAvgPfNBAaE6fgwBG7rRo7H/iKit9nVBso6EY0LRLEdXKr4GVwIuCts7FI1cWR/ERo4HHjrC1m4ZrQNrbpGjq0lGdHFSlAgDapC9tTpwrF7kA2tBl2zng4up/YkC+Vr1s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407409797401.84846484620493; Tue, 3 Nov 2020 04:43:29 -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-233-xP6VQlQxMp6-9L_omFEhnQ-1; Tue, 03 Nov 2020 07:42:30 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 34FDA186DD29; Tue, 3 Nov 2020 12:42:24 +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 099911002D47; Tue, 3 Nov 2020 12:42:24 +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 C84C61826D36; Tue, 3 Nov 2020 12:42:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cg6o9016310 for ; Tue, 3 Nov 2020 07:42:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7831473667; Tue, 3 Nov 2020 12:42:06 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5CF673664 for ; Tue, 3 Nov 2020 12:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407408; 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=zsBp1T13vT2E9Cbe5aPfMUExGPtIR9qpJlMODRJrWcI=; b=UKM7tag5F1j4C1jAPMf2agv+QxGqNeXNmau1f/Qsbl62FrvZsmFzUKdd8o6gWHzvNAFOfL ghgPMls5cYTEZI2Ism+GI8UllPUVEg/1KpCmsDQrII0WcZ4k/VjlyjVl8SeMXwldTsRBc5 V01qQQHvriHW6SUMmFnzxsmR1bxrVf0= X-MC-Unique: xP6VQlQxMp6-9L_omFEhnQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 23/25] vircgroup: move parentPath declaration Date: Tue, 3 Nov 2020 13:41:35 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.22 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It's used only inside the if condition. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index f4c1623567..6caeb2d7f4 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -893,7 +893,6 @@ virCgroupNewPartition(const char *path, int controllers, virCgroupPtr *group) { - g_autofree char *parentPath =3D NULL; g_autofree char *newPath =3D NULL; g_autoptr(virCgroup) parent =3D NULL; g_autoptr(virCgroup) newGroup =3D NULL; @@ -915,7 +914,7 @@ virCgroupNewPartition(const char *path, =20 if (STRNEQ(newPath, "/")) { char *tmp; - parentPath =3D g_strdup(newPath); + g_autofree char *parentPath =3D g_strdup(newPath); =20 tmp =3D strrchr(parentPath, '/'); tmp++; --=20 2.26.2 From nobody Mon May 6 10:30:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1604407384; cv=none; d=zohomail.com; s=zohoarc; b=G9wB70iTdPnMWKW9tV+M+UyWHTHZyp6kZe7bn+bx6la7xQIzjSYpTFzcbN8uuTLkfTw6laOCZSegaAUdBgzqfshfU8PXgMxbfMRniJ363y2H0hbQqNaqbdEcm31ZaedWbhRY/BAwVGgdH9lhjMp1WIveZMNCng7FTpVQNyj8DWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407384; 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=ZJoJx8w0DpzgMDQbp1gZgpR8+y64HjznLqKqajtNI6o=; b=GKXwTZeP+s3xHnCxFZPLKPLT7N74HmimT2qzcNKG5JGGuJfj1bI6+dUZF9gu1ECXzuCCM8VEWEeNuRS4QjS63lcUMD2f83KfmndFf0SbH/8F8aK12FnhHvkAmWYWGCXZQGLLHPlLo2Xsm5hDqxzbJSzfrZ3iuS9Qw2dAI+B5uwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604407384397560.3099066805469; Tue, 3 Nov 2020 04:43:04 -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-460-tb_LcZ-JM3WF1dnYBsiwWw-1; Tue, 03 Nov 2020 07:42:22 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E882510866A9; Tue, 3 Nov 2020 12:42:15 +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 BB0E021E8C; Tue, 3 Nov 2020 12:42: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 82FB08C7DD; Tue, 3 Nov 2020 12:42:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cg7NL016318 for ; Tue, 3 Nov 2020 07:42:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5F81273667; Tue, 3 Nov 2020 12:42:07 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id CECF173664 for ; Tue, 3 Nov 2020 12:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407383; 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=ZJoJx8w0DpzgMDQbp1gZgpR8+y64HjznLqKqajtNI6o=; b=Gd/dgRy8ujgcCf2CAO0DiEpWKFcChz1d0MlZAmeNHW5Fpy7JEx9UaV3vozozZPMVJzzYSB dCL0mKWTz4tUVKSDJK2bEcKp8oH8qIsj2QEOmUTm0OydL1bbCfcW4hzMJMWEMFBPP5KTZ1 9ZYY9r8eVdTHqiIfQwF1AFCThWAn2do= X-MC-Unique: tb_LcZ-JM3WF1dnYBsiwWw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 24/25] vircgroup: refactor virCgroupNewPartition Date: Tue, 3 Nov 2020 13:41:36 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The old code passed an absolute path to virCgroupNewFromParent() which is not necessary. The code can take the current placement of parent cgroup and append a relative path. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroup.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 6caeb2d7f4..e0fe1dbf3e 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -896,6 +896,7 @@ virCgroupNewPartition(const char *path, g_autofree char *newPath =3D NULL; g_autoptr(virCgroup) parent =3D NULL; g_autoptr(virCgroup) newGroup =3D NULL; + char *partition =3D NULL; =20 VIR_DEBUG("path=3D%s create=3D%d controllers=3D%x", path, create, controllers); @@ -914,17 +915,26 @@ virCgroupNewPartition(const char *path, =20 if (STRNEQ(newPath, "/")) { char *tmp; - g_autofree char *parentPath =3D g_strdup(newPath); + const char *parentPath; =20 - tmp =3D strrchr(parentPath, '/'); - tmp++; + tmp =3D strrchr(newPath, '/'); *tmp =3D '\0'; =20 + if (tmp =3D=3D newPath) { + parentPath =3D "/"; + } else { + parentPath =3D newPath; + } + if (virCgroupNew(parentPath, controllers, &parent) < 0) return -1; + + partition =3D tmp + 1; + } else { + partition =3D newPath; } =20 - if (virCgroupNewFromParent(parent, newPath, controllers, &newGroup) < = 0) + if (virCgroupNewFromParent(parent, partition, controllers, &newGroup) = < 0) return -1; =20 if (parent) { --=20 2.26.2 From nobody Mon May 6 10:30:03 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1604407387; cv=none; d=zohomail.com; s=zohoarc; b=dQyiqpDjZ49tE7D+df5Svn2nXpivO51BxneqmYOeZKGk+VW+S+iK38LnLW7X1xIlxoGaf9vyv6Rhy0OLOz5rAJ84Og7ZNTxPN6i4OQW9yllnuWAQJVWLmf42URTAcSrbyQzCEQjb8fstjfqE/wppJWrT/KCyZICrk/INMqBNSGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407387; 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=sNrxsijX8jGh/RCR4Yg/pIdaltBnY4iTDjCLNhAa/fw=; b=E7ifFD9b1yEVrLTqnTCnUuxZtJU4u0Mf4Totv5PeY0M0T5dttHWAkSSn6TxR6TdLoYuTUDZrmn1qIEJK9JRcyDbuUPZQ97+ezLLgtDBGeN2h62xb6Oo0z4Yo+ZCzkbize8IUq6ptK6hALxdNNQZEWHqVh2XoJLia1RaFtpZGYYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 160440738718420.653636007848604; Tue, 3 Nov 2020 04:43:07 -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-326-w_U_CvoaPTetOQ764rRiMw-1; Tue, 03 Nov 2020 07:42:30 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6CB764163; Tue, 3 Nov 2020 12:42:24 +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 9FAE47512A; Tue, 3 Nov 2020 12:42:24 +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 6EA61922F0; Tue, 3 Nov 2020 12:42:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cg8gZ016349 for ; Tue, 3 Nov 2020 07:42:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id 476F47366C; Tue, 3 Nov 2020 12:42:08 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id B503573667 for ; Tue, 3 Nov 2020 12:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407386; 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=sNrxsijX8jGh/RCR4Yg/pIdaltBnY4iTDjCLNhAa/fw=; b=EY08HpMTd8Pf/twyd0JT2RcDOK2flKbUASK0k53TaCWf//d7CKmtU4hmNexbjvGnkZaWyl Cu4xJzDotCizWuIJYxcdlABKiZz89qmkKs9PGWwDDyG0CUH0H5qOMEhNXN/vOsUFLdPsh2 QmZxSJnfJO31Cy1vdMumvReMPtNLkx0= X-MC-Unique: w_U_CvoaPTetOQ764rRiMw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 25/25] vircgroup: drop condition for absolute path from copyPlacement callbacks Date: Tue, 3 Nov 2020 13:41:37 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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.15 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now that every caller to copyPlacement doesn't pass absolute path there is no need to have a condition to handle that case. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik Reviewed-by: Neal Gompa --- src/util/vircgroupv1.c | 26 ++++++++++++-------------- src/util/vircgroupv2.c | 25 +++++++++++-------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index ed4b0813f2..731e9d61d4 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -190,26 +190,24 @@ virCgroupV1CopyPlacement(virCgroupPtr group, { size_t i; for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { + bool delim; + if (!group->legacy[i].mountPoint) continue; =20 if (i =3D=3D VIR_CGROUP_CONTROLLER_SYSTEMD) continue; =20 - if (path[0] =3D=3D '/') { - group->legacy[i].placement =3D g_strdup(path); - } else { - bool delim =3D STREQ(parent->legacy[i].placement, "/") || STRE= Q(path, ""); - /* - * parent =3D=3D "/" + path=3D"" =3D> "/" - * parent =3D=3D "/libvirt.service" + path =3D=3D "" =3D> "/li= bvirt.service" - * parent =3D=3D "/libvirt.service" + path =3D=3D "foo" =3D> "= /libvirt.service/foo" - */ - group->legacy[i].placement =3D g_strdup_printf("%s%s%s", - parent->legacy[i]= .placement, - delim ? "" : "/", - path); - } + delim =3D STREQ(parent->legacy[i].placement, "/") || STREQ(path, "= "); + /* + * parent =3D=3D "/" + path=3D"" =3D> "/" + * parent =3D=3D "/libvirt.service" + path =3D=3D "" =3D> "/libvir= t.service" + * parent =3D=3D "/libvirt.service" + path =3D=3D "foo" =3D> "/lib= virt.service/foo" + */ + group->legacy[i].placement =3D g_strdup_printf("%s%s%s", + parent->legacy[i].pla= cement, + delim ? "" : "/", + path); } =20 return 0; diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 8e058ca9c6..2b32f614e4 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -149,22 +149,19 @@ virCgroupV2CopyPlacement(virCgroupPtr group, const char *path, virCgroupPtr parent) { + bool delim =3D STREQ(parent->unified.placement, "/") || STREQ(path, ""= ); + VIR_DEBUG("group=3D%p path=3D%s parent=3D%p", group, path, parent); =20 - if (path[0] =3D=3D '/') { - group->unified.placement =3D g_strdup(path); - } else { - bool delim =3D STREQ(parent->unified.placement, "/") || STREQ(path= , ""); - /* - * parent =3D=3D "/" + path=3D"" =3D> "/" - * parent =3D=3D "/libvirt.service" + path =3D=3D "" =3D> "/libvir= t.service" - * parent =3D=3D "/libvirt.service" + path =3D=3D "foo" =3D> "/lib= virt.service/foo" - */ - group->unified.placement =3D g_strdup_printf("%s%s%s", - parent->unified.placeme= nt, - delim ? "" : "/", - path); - } + /* + * parent =3D=3D "/" + path=3D"" =3D> "/" + * parent =3D=3D "/libvirt.service" + path =3D=3D "" =3D> "/libvirt.se= rvice" + * parent =3D=3D "/libvirt.service" + path =3D=3D "foo" =3D> "/libvirt= .service/foo" + */ + group->unified.placement =3D g_strdup_printf("%s%s%s", + parent->unified.placement, + delim ? "" : "/", + path); =20 return 0; } --=20 2.26.2