Skip to content

Commit

Permalink
Merge pull request #85 from arighi/support-cgroup-v1
Browse files Browse the repository at this point in the history
init: allow to mount legacy cgroupfs (v1)
  • Loading branch information
arighi committed Mar 2, 2024
2 parents 259c1dd + 768e591 commit f709cd6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,19 @@ Troubleshooting
$ udevadm trigger --subsystem-match --action=change
```

- To mount the legacy cgroup filesystem (v1) layout, add
`SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE=1` to the kernel boot options:
```
$ vng -r --append "SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE=1" -- 'df -T /sys/fs/cgroup/*'
Filesystem Type 1K-blocks Used Available Use% Mounted on
blkio cgroup 0 0 0 - /sys/fs/cgroup/blkio
cpu cgroup 0 0 0 - /sys/fs/cgroup/cpu
cpuacct cgroup 0 0 0 - /sys/fs/cgroup/cpuacct
devices cgroup 0 0 0 - /sys/fs/cgroup/devices
memory cgroup 0 0 0 - /sys/fs/cgroup/memory
pids cgroup 0 0 0 - /sys/fs/cgroup/pids
```

Contributing
============

Expand Down
16 changes: 15 additions & 1 deletion virtme/guest/virtme-init
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,21 @@ mount -t tracefs tracefs /sys/kernel/tracing &>/dev/null
mount -t securityfs securityfs /sys/kernel/security &>/dev/null

# Set up cgroup mount points (mount cgroupv2 hierarchy by default)
mount -t cgroup2 cgroup2 /sys/fs/cgroup
#
# If SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE=1 is passed we can mimic systemd's
# behavior and mount the legacy cgroup v1 layout.
if cat /proc/cmdline |grep -q -E '(^| )SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE=1($| )'; then
mount -t tmpfs cgroup /sys/fs/cgroup
sybsys=(cpu cpuacct blkio memory devices pids)
for s in "${sybsys[@]}"; do
mkdir -p "/sys/fs/cgroup/${s}"
# Don't treat failure as critical here, since the kernel may not
# support all the legacy cgroups.
mount -t cgroup "${s}" -o "${s}" "/sys/fs/cgroup/${s}" || true
done
else
mount -t cgroup2 cgroup2 /sys/fs/cgroup
fi

# Set up filesystems that live in /dev
mkdir -p -m 0755 /dev/shm /dev/pts
Expand Down
2 changes: 1 addition & 1 deletion virtme_ng_init
Submodule virtme_ng_init updated 1 files
+20 −7 src/main.rs

0 comments on commit f709cd6

Please sign in to comment.