Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com> --- host/rootfs/file-list.mk | 1 + .../etc/s6-linux-init/run-image/service/vm-services/template/finish | 4 ++-- .../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 ++++- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/host/rootfs/file-list.mk b/host/rootfs/file-list.mk index 498c699c459515c1c7b6139aa07a89fd904509b3..33b7f869da7dfdb8bde6c70ebd9acd5e0f2856c1 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/vm-services/template/finish b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/finish index 4d5b454e97c3584d0644c2d738514f13b1c53957..72d071291f5235e17b9a94c15bd2c0a287e5cbfb 100755 --- a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/finish +++ b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/finish @@ -1,5 +1,5 @@ #!/usr/bin/execlineb -WS3 -# SPDX-License-Identifier: EUPL-1.2+ # SPDX-FileCopyrightText: 2026 Demi Marie Obenour <demiobenour@gmail.com> +# SPDX-License-Identifier: EUPL-1.2+ -cgroup-s6-finish $@ +cgroup-s6-finish $1 $2 /vm-services.slice/vm-${3}.slice 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..bb9647c0f4a501a83874adfba8765954438d0b11 --- /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 <demiobenour@gmail.com> + +cgroup-s6-finish $1 $2 /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 <hi@alyssa.is> -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