forked from canonical/snapd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the first part of the normalization done for test tools. The idea is to keep as similar as possible all the test tools regarding imlpementation and usage.
- Loading branch information
1 parent
69efd8e
commit 10588ad
Showing
9 changed files
with
637 additions
and
590 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,53 @@ | ||
#!/bin/sh -e | ||
case "${1:-}" in | ||
-h|--help|'') | ||
echo "usage: lxd-state [-h] {undo-mount-changes} ..." | ||
;; | ||
undo-mount-changes) | ||
# Vanilla systems have /sys/fs/cgroup/cpuset without clone_children option. | ||
# Using LXD to create a container enables this option, as can be seen here: | ||
# | ||
# -37 32 0:32 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,cpuset | ||
# +37 32 0:32 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,cpuset,clone_children | ||
# | ||
# To restore vanilla state, disable the option now. | ||
if [ "$(mountinfo.query /sys/fs/cgroup/cpuset .fs_type)" = cgroup ]; then | ||
echo 0 > /sys/fs/cgroup/cpuset/cgroup.clone_children | ||
fi | ||
#!/bin/bash -e | ||
|
||
# Vanilla system have /sys/fs/cgroup/unified mounted with the nsdelegate | ||
# option which is available since kernel 4.13 Using LXD to create a | ||
# container disables this options, as can be seen here: | ||
# | ||
# -32 31 0:27 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:10 - cgroup2 cgroup rw,nsdelegate | ||
# +32 31 0:27 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:10 - cgroup2 cgroup rw | ||
# | ||
# To restore vanilla state, enable the option now, but only if the kernel supports that. | ||
# https://lore.kernel.org/patchwork/patch/803265/ | ||
# https://github.com/systemd/systemd/commit/4095205ecccdfddb822ee8fdc44d11f2ded9be24 | ||
# The kernel version must be made compatible with the strict version | ||
# comparison. I chose to cut at the "-" and take the stuff before it. | ||
if [ "$(mountinfo.query /sys/fs/cgroup/unified .fs_type)" = cgroup2 ] && "$TESTSTOOLS"/version-compare --strict "$(uname -r | cut -d- -f 1)" -ge 4.13; then | ||
mount -o remount,nsdelegate /sys/fs/cgroup/unified | ||
fi | ||
;; | ||
*) | ||
echo "lxd-state: unknown command $*" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
show_help() { | ||
echo "usage: lxd-state [-h] {undo-mount-changes} ..." | ||
} | ||
|
||
main() { | ||
if [ $# -eq 0 ]; then | ||
show_help | ||
exit 0 | ||
fi | ||
|
||
case "${1:-}" in | ||
-h|--help) | ||
show_help | ||
exit 0 | ||
;; | ||
undo-mount-changes) | ||
# Vanilla systems have /sys/fs/cgroup/cpuset without clone_children option. | ||
# Using LXD to create a container enables this option, as can be seen here: | ||
# | ||
# -37 32 0:32 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,cpuset | ||
# +37 32 0:32 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,cpuset,clone_children | ||
# | ||
# To restore vanilla state, disable the option now. | ||
if [ "$(mountinfo.query /sys/fs/cgroup/cpuset .fs_type)" = cgroup ]; then | ||
echo 0 > /sys/fs/cgroup/cpuset/cgroup.clone_children | ||
fi | ||
|
||
# Vanilla system have /sys/fs/cgroup/unified mounted with the nsdelegate | ||
# option which is available since kernel 4.13 Using LXD to create a | ||
# container disables this options, as can be seen here: | ||
# | ||
# -32 31 0:27 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:10 - cgroup2 cgroup rw,nsdelegate | ||
# +32 31 0:27 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:10 - cgroup2 cgroup rw | ||
# | ||
# To restore vanilla state, enable the option now, but only if the kernel supports that. | ||
# https://lore.kernel.org/patchwork/patch/803265/ | ||
# https://github.com/systemd/systemd/commit/4095205ecccdfddb822ee8fdc44d11f2ded9be24 | ||
# The kernel version must be made compatible with the strict version | ||
# comparison. I chose to cut at the "-" and take the stuff before it. | ||
if [ "$(mountinfo.query /sys/fs/cgroup/unified .fs_type)" = cgroup2 ] && "$TESTSTOOLS"/version-compare --strict "$(uname -r | cut -d- -f 1)" -ge 4.13; then | ||
mount -o remount,nsdelegate /sys/fs/cgroup/unified | ||
fi | ||
;; | ||
*) | ||
echo "lxd-state: unknown command $*" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
main "$@" |
Oops, something went wrong.