From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 00CA3BC0E; Fri, 31 Jul 2026 22:00:52 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 1AFC0B9F9; Fri, 31 Jul 2026 22:00:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_PASS,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by atuin.qyliss.net (Postfix) with ESMTPS id CA80FBA2A for ; Fri, 31 Jul 2026 22:00:38 +0000 (UTC) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-81e6f2ee60bso34086497b3.1 for ; Fri, 31 Jul 2026 15:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785535237; x=1786140037; darn=spectrum-os.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9ZySXyO8VTbB7JfP3YdHfN2HYkECNw8lNiaVaw98b+0=; b=OwYA0wx04rY57/bnuKGBoEP5ApKONkQgBvJR6ESFjzwvPikBEsAqQ3JC4qLEXzr/lV C0wYPZgTJfIlKQwY1BFFpog/dEJ1FdgKycwLM0Sj4OtLIIfSf23vIQCiIACZF3icOO5p 8n4xXZ9MmYHabmIQZSzqpJ9WvI0+dtirXJxuLdN4N3S4Z+VDKnbQIHTNducS38b5rxS7 iNr7vOLTIVwykmQumL1po/EImEbpvRwHd7xls/OxDk6VTLsNiA4tjhvSFPkxCqivGpL6 JYUAy81M4XxhIi+wHbEKrM09ctRRHJDq4Xnk0Xsb6MO6eB4ce42hrAInVWUQoKFwrJzX 0a3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785535237; x=1786140037; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9ZySXyO8VTbB7JfP3YdHfN2HYkECNw8lNiaVaw98b+0=; b=j+Q60RoGn0/3FuxMm3Ff8KO06p/UR/jJWVyJFuwOPIqsoqPQbp+ffE6YkcFpCwB/b5 2hTYYvtA4TchGTJA1XJ8m1g5gG+/yhzGrG9J0AACP+rCOE6L4MmO5JAy39g8e97pb02a 7SN5w0NWlSYrKWKavCU0AT6yIZyt9Z1x8X5MhxLzFMZfxP2ZHuFiaeCEf+TswO1UNk93 JiFnNY/a5Txx89QllYLa0pfjtft5CSsA/KGmX36ypnPxrAkPibHLfvvfhTD1G6kATnPC G3ciOsP2DD5T2TqOqAKK2ExM9Tv9iqMd5B7Jr7hgW2Kt8W2sDG+RK2Fn8fV4udQX+2eY gfew== X-Gm-Message-State: AOJu0YyHvXxYveHyatMY1MU0J1XGxXkdVuSaLUWWfu0XA5oe1deVl1NK LIO5wSYB//LMC1g9vvoBDnTewDQtVMW4ggVfCbO3IDaxWQ+KGNBSYxrVnNVhSA== X-Gm-Gg: AR+sD10jfUTfOxzO8ZvPeq+eb9VPC9lvUM/ZXE8FGgOXdqdZ8QR4a3y9dBVZKy/l2aa s0CN1ltOG2VrnF835sPHdSuGrP1gWa2kdlirILi5lkEV1EV9GtVGYSa0yS8x6QCtLW9yHaPW3De Iyw7E9a0Y1jrcOGHG8zvzfvRAxeGZHuxY95BDTQOtEwtu67b88lnbT1ol0B8bZ3DRCqnEvGGfH2 vJraOjSsBo3O8JBm9NoceSRMH3E19qGKzZwfVP6kDL5CwOCRIcwd4xun1a2M6Ld0f3QY1fwuHTo 2wGlz+fAEsUXQTwy9V5H5LS+5W68hyl59Y6z6wJ5gOZYouUBJO+GHPQ0/fDzPqsUX2O2nGyNO8l OCfkxv6yiqyANb2j9TV9YFnInO1N/HvZEg3APdBCoSd5ATNCo+8iCpOkfCPMh/2YXHQ7+nVmZqA EOc7ZKDbEKOmWK7GovXKctD8PszFB6No2TTjFcJR7tOqUNhyAPDMFa1MlMV8Sh2UJPEuibeW0g1 Q== X-Received: by 2002:a05:690c:6d83:b0:7f0:38f7:6ca6 with SMTP id 00721157ae682-81fcbbd5cefmr33427767b3.5.1785535237319; Fri, 31 Jul 2026 15:00:37 -0700 (PDT) Received: from localhost.localdomain ([185.98.168.14]) by smtp.gmail.com with UTF8SMTPSA id 00721157ae682-81fccf8d82esm15188547b3.19.2026.07.31.15.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2026 15:00:36 -0700 (PDT) From: Demi Marie Obenour Date: Fri, 31 Jul 2026 17:54:52 -0400 Subject: [PATCH v5 12/19] host/rootfs: run-vmm: Create per-VM cgroup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260731-cgroups-v5-12-b325bac9d34f@gmail.com> References: <20260731-cgroups-v5-0-b325bac9d34f@gmail.com> In-Reply-To: <20260731-cgroups-v5-0-b325bac9d34f@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1785534880; l=3225; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=/kyOFDu9ux6YcMwfWiHYgQZ/EaFXsRP/JYA6JkjFYAY=; b=/RWm2T9gz20XDg0SZC0iFij/l4xX7Ds5cvSCH7v6DhY6oyppDYL5Jj8ret2ATeOTcXSIpDJfo 25r+v0p8zrLDptmckat80UgJS+YuCbRvR/Qe1MegyxhcO6GqPtokxLi X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: PTPKENPD76PTS323PRGDWU5OVPLR4MMN X-Message-ID-Hash: PTPKENPD76PTS323PRGDWU5OVPLR4MMN X-MailFrom: demiobenour@gmail.com X-Mailman-Rule-Hits: member-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; emergency CC: Demi Marie Obenour , Alyssa Ross X-Mailman-Version: 3.3.10 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Demi Marie Obenour --- host/rootfs/file-list.mk | 1 + .../image/etc/s6-linux-init/run-image/service/vmm/template/finish | 5 +++++ host/rootfs/image/usr/bin/run-vmm | 4 ++++ host/rootfs/image/usr/bin/vm-stop | 5 ++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/host/rootfs/file-list.mk b/host/rootfs/file-list.mk index 36f508962c0515b2132aa9ab30cde929e2de100e..5f7b0c3fc1d7d7f8dc184ecc991126a793e316c6 100644 --- a/host/rootfs/file-list.mk +++ b/host/rootfs/file-list.mk @@ -44,6 +44,7 @@ FILES = \ image/etc/s6-linux-init/run-image/service/vm-services/template/run \ image/etc/s6-linux-init/run-image/service/vmm/notification-fd \ image/etc/s6-linux-init/run-image/service/vmm/run \ + image/etc/s6-linux-init/run-image/service/vmm/template/finish \ image/etc/s6-linux-init/run-image/service/vmm/template/notification-fd \ image/etc/s6-linux-init/scripts/rc.init \ image/etc/s6-linux-init/scripts/rc.shutdown \ diff --git a/host/rootfs/image/etc/s6-linux-init/run-image/service/vmm/template/finish b/host/rootfs/image/etc/s6-linux-init/run-image/service/vmm/template/finish new file mode 100755 index 0000000000000000000000000000000000000000..6f6e549f6d95915138e53b8d406fb246d2968ccc --- /dev/null +++ b/host/rootfs/image/etc/s6-linux-init/run-image/service/vmm/template/finish @@ -0,0 +1,5 @@ +#!/usr/bin/execlineb -WS3 +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2026 Demi Marie Obenour + +cgroup-purge /vm-services.slice/vm-${3}.slice/vmm diff --git a/host/rootfs/image/usr/bin/run-vmm b/host/rootfs/image/usr/bin/run-vmm index 6967dc5586335d999f8030371fe0f38502409919..12896c276fbffa024fa0f89f42a2967506b1cb74 100755 --- a/host/rootfs/image/usr/bin/run-vmm +++ b/host/rootfs/image/usr/bin/run-vmm @@ -5,6 +5,7 @@ if { backtick -D "" mnt { importas -Siu 1 + if { cgroup-setup --no-wait /vm-services.slice/vm-${1}.slice } nsenter --mount=/run/vm/by-id/${1}/ns/mnt findmnt -no FSTYPE,SOURCE /run/fs/${1}/disk } @@ -33,6 +34,8 @@ if { elgetpositionals +if { rm -f /run/vsock/${1}/vsock } + s6-ipcserver-socketbinder -B /run/vm/by-id/${1}/vmm getpid -E vmm_pid @@ -86,6 +89,7 @@ redirfd -r 0 /dev/null s6-softlimit -H -l 18446744073709551615 if { udevadm wait /dev/kvm } +cgroup-setup --leaf /vm-services.slice/vm-${1}.slice/vmm s6-envuidgid vmm-${1} s6-applyuidgid -Uz bwrap diff --git a/host/rootfs/image/usr/bin/vm-stop b/host/rootfs/image/usr/bin/vm-stop index 6fb6aaed46de684eb035243e4f7c79111e93bf8c..23a815c0c260452ff9b1bcce7a091519b7420196 100755 --- a/host/rootfs/image/usr/bin/vm-stop +++ b/host/rootfs/image/usr/bin/vm-stop @@ -2,4 +2,7 @@ # SPDX-License-Identifier: EUPL-1.2+ # SPDX-FileCopyrightText: 2023 Alyssa Ross -ch-remote --api-socket /run/vm/by-id/${1}/vmm shutdown +foreground { ch-remote --api-socket /run/vm/by-id/${1}/vmm shutdown } +if { cgroup-purge /vm-services.slice/vm-${1}.slice/vmm } +importas -iS ? +exit $? -- 2.55.0