diff options
| author | Xiangyu Chen <xiangyu.chen@windriver.com> | 2024-03-26 17:42:58 +0800 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2024-04-09 14:08:26 +0000 |
| commit | 8410846c0b986e2e506a6457a58ef12fbe7c3485 (patch) | |
| tree | 3da199130141020f7bad6dcc67f7cb4b27ceb87f | |
| parent | 415cc454d08c0151e51bb987233c30052bb663a4 (diff) | |
| download | meta-virtualization-8410846c0b986e2e506a6457a58ef12fbe7c3485.tar.gz | |
lxc: fix broken test cases
Upstream dropped cgroup handling in lxc-test-usernic lxc-test-unpriv and
lxc-test-apparmor-mount to fix the broken cases.
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
3 files changed, 166 insertions, 0 deletions
diff --git a/recipes-containers/lxc/files/0001-lxc-test-usernic-drop-cgroup-handling.patch b/recipes-containers/lxc/files/0001-lxc-test-usernic-drop-cgroup-handling.patch new file mode 100644 index 00000000..162e8f9d --- /dev/null +++ b/recipes-containers/lxc/files/0001-lxc-test-usernic-drop-cgroup-handling.patch | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | From ec85e5ca4953292c4341497704ce738669a79b64 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Serge Hallyn <serge@hallyn.com> | ||
| 3 | Date: Fri, 2 Feb 2024 10:41:11 -0600 | ||
| 4 | Subject: [PATCH] lxc-test-usernic: drop cgroup handling | ||
| 5 | |||
| 6 | This stuff is not needed in a modern systemd based system, and in fact | ||
| 7 | breaks. It would probably be better to detect such a system so that a | ||
| 8 | non-systemd box can still run this test. But I'm not sure what would be | ||
| 9 | reliable. | ||
| 10 | |||
| 11 | Upstream-Status: Backport from | ||
| 12 | [https://github.com/lxc/lxc/commit/ec85e5ca4953292c4341497704ce738669a79b64] | ||
| 13 | |||
| 14 | Signed-off-by: Serge Hallyn <serge@hallyn.com> | ||
| 15 | Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> | ||
| 16 | --- | ||
| 17 | src/tests/lxc-test-usernic.in | 28 ---------------------------- | ||
| 18 | 1 file changed, 28 deletions(-) | ||
| 19 | |||
| 20 | diff --git a/src/tests/lxc-test-usernic.in b/src/tests/lxc-test-usernic.in | ||
| 21 | index 9af8678f3..49fd5e3f7 100755 | ||
| 22 | --- a/src/tests/lxc-test-usernic.in | ||
| 23 | +++ b/src/tests/lxc-test-usernic.in | ||
| 24 | @@ -80,34 +80,6 @@ lxc.idmap = u 0 910000 10000 | ||
| 25 | lxc.idmap = g 0 910000 10000 | ||
| 26 | EOF | ||
| 27 | |||
| 28 | -if command -v cgm >/dev/null 2>&1; then | ||
| 29 | - cgm create all usernic-user | ||
| 30 | - cgm chown all usernic-user $(id -u usernic-user) $(id -g usernic-user) | ||
| 31 | - cgm movepid all usernic-user $$ | ||
| 32 | -elif [ -e /sys/fs/cgroup/cgmanager/sock ]; then | ||
| 33 | - for d in $(cut -d : -f 2 /proc/self/cgroup); do | ||
| 34 | - dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \ | ||
| 35 | - --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \ | ||
| 36 | - string:$d string:usernic-user >/dev/null | ||
| 37 | - | ||
| 38 | - dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \ | ||
| 39 | - --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Chown \ | ||
| 40 | - string:$d string:usernic-user int32:$(id -u usernic-user) int32:$(id -g usernic-user) >/dev/null | ||
| 41 | - | ||
| 42 | - dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \ | ||
| 43 | - --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.MovePid \ | ||
| 44 | - string:$d string:usernic-user int32:$$ >/dev/null | ||
| 45 | - done | ||
| 46 | -else | ||
| 47 | - for d in /sys/fs/cgroup/*; do | ||
| 48 | - [ "$d" = "/sys/fs/cgroup/unified" ] && continue | ||
| 49 | - [ -f $d/cgroup.clone_children ] && echo 1 > $d/cgroup.clone_children | ||
| 50 | - [ ! -d $d/lxctest ] && mkdir $d/lxctest | ||
| 51 | - chown -R usernic-user: $d/lxctest | ||
| 52 | - echo $$ > $d/lxctest/tasks | ||
| 53 | - done | ||
| 54 | -fi | ||
| 55 | - | ||
| 56 | mkdir -p /run/user/$(id -u usernic-user) | ||
| 57 | chown -R usernic-user: /run/user/$(id -u usernic-user) /home/usernic-user | ||
| 58 | |||
| 59 | -- | ||
| 60 | 2.35.5 | ||
| 61 | |||
diff --git a/recipes-containers/lxc/files/0001-tests-remove-old-and-broken-cgroup-handling-code-fro.patch b/recipes-containers/lxc/files/0001-tests-remove-old-and-broken-cgroup-handling-code-fro.patch new file mode 100644 index 00000000..bf8df795 --- /dev/null +++ b/recipes-containers/lxc/files/0001-tests-remove-old-and-broken-cgroup-handling-code-fro.patch | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | From 8f9733d756361ff8f8d8d589f286c0e064b1195d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com> | ||
| 3 | Date: Thu, 15 Feb 2024 18:13:05 +0100 | ||
| 4 | Subject: [PATCH] tests: remove old and broken cgroup handling code from tests | ||
| 5 | |||
| 6 | We have removed the same piece of code in | ||
| 7 | ec85e5ca495 ("lxc-test-usernic: drop cgroup handling") | ||
| 8 | let's do the same for two other tests. | ||
| 9 | |||
| 10 | This fixes autopkgtests. | ||
| 11 | |||
| 12 | Upstream-Status: Backport from | ||
| 13 | [https://github.com/lxc/lxc/commit/8f9733d756361ff8f8d8d589f286c0e064b1195d] | ||
| 14 | |||
| 15 | Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com> | ||
| 16 | Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> | ||
| 17 | --- | ||
| 18 | src/tests/lxc-test-apparmor-mount | 29 ----------------------------- | ||
| 19 | src/tests/lxc-test-unpriv | 28 ---------------------------- | ||
| 20 | 2 files changed, 57 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/src/tests/lxc-test-apparmor-mount b/src/tests/lxc-test-apparmor-mount | ||
| 23 | index 7c9d9ad50..ddf783d4b 100755 | ||
| 24 | --- a/src/tests/lxc-test-apparmor-mount | ||
| 25 | +++ b/src/tests/lxc-test-apparmor-mount | ||
| 26 | @@ -119,35 +119,6 @@ chown -R $TUSER: /run/user/$(id -u $TUSER) | ||
| 27 | |||
| 28 | cd $HDIR | ||
| 29 | |||
| 30 | -if command -v cgm >/dev/null 2>&1; then | ||
| 31 | - cgm create all $TUSER | ||
| 32 | - cgm chown all $TUSER $(id -u $TUSER) $(id -g $TUSER) | ||
| 33 | - cgm movepid all $TUSER $$ | ||
| 34 | -elif [ -e /sys/fs/cgroup/cgmanager/sock ]; then | ||
| 35 | - for d in $(cut -d : -f 2 /proc/self/cgroup); do | ||
| 36 | - dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \ | ||
| 37 | - --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \ | ||
| 38 | - string:$d string:$TUSER >/dev/null | ||
| 39 | - | ||
| 40 | - dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \ | ||
| 41 | - --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Chown \ | ||
| 42 | - string:$d string:$TUSER int32:$(id -u $TUSER) int32:$(id -g $TUSER) >/dev/null | ||
| 43 | - | ||
| 44 | - dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \ | ||
| 45 | - --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.MovePid \ | ||
| 46 | - string:$d string:$TUSER int32:$$ >/dev/null | ||
| 47 | - done | ||
| 48 | -else | ||
| 49 | - for d in /sys/fs/cgroup/*; do | ||
| 50 | - [ "$d" = "/sys/fs/cgroup/unified" ] && continue | ||
| 51 | - [ -f $d/cgroup.clone_children ] && echo 1 > $d/cgroup.clone_children | ||
| 52 | - [ ! -d $d/lxctest ] && mkdir $d/lxctest | ||
| 53 | - chown -R $TUSER: $d/lxctest | ||
| 54 | - echo $$ > $d/lxctest/tasks | ||
| 55 | - done | ||
| 56 | -fi | ||
| 57 | - | ||
| 58 | - | ||
| 59 | run_cmd lxc-create -t busybox -n $cname | ||
| 60 | |||
| 61 | echo "test default confined container" | ||
| 62 | diff --git a/src/tests/lxc-test-unpriv b/src/tests/lxc-test-unpriv | ||
| 63 | index 8fb9106d6..426add9da 100755 | ||
| 64 | --- a/src/tests/lxc-test-unpriv | ||
| 65 | +++ b/src/tests/lxc-test-unpriv | ||
| 66 | @@ -130,34 +130,6 @@ chown -R $TUSER: /run/user/$(id -u $TUSER) | ||
| 67 | |||
| 68 | cd $HDIR | ||
| 69 | |||
| 70 | -if command -v cgm >/dev/null 2>&1; then | ||
| 71 | - cgm create all $TUSER | ||
| 72 | - cgm chown all $TUSER $(id -u $TUSER) $(id -g $TUSER) | ||
| 73 | - cgm movepid all $TUSER $$ | ||
| 74 | -elif [ -e /sys/fs/cgroup/cgmanager/sock ]; then | ||
| 75 | - for d in $(cut -d : -f 2 /proc/self/cgroup); do | ||
| 76 | - dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \ | ||
| 77 | - --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \ | ||
| 78 | - string:$d string:$TUSER >/dev/null | ||
| 79 | - | ||
| 80 | - dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \ | ||
| 81 | - --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Chown \ | ||
| 82 | - string:$d string:$TUSER int32:$(id -u $TUSER) int32:$(id -g $TUSER) >/dev/null | ||
| 83 | - | ||
| 84 | - dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \ | ||
| 85 | - --type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.MovePid \ | ||
| 86 | - string:$d string:$TUSER int32:$$ >/dev/null | ||
| 87 | - done | ||
| 88 | -else | ||
| 89 | - for d in /sys/fs/cgroup/*; do | ||
| 90 | - [ "$d" = "/sys/fs/cgroup/unified" ] && continue | ||
| 91 | - [ -f $d/cgroup.clone_children ] && echo 1 > $d/cgroup.clone_children | ||
| 92 | - [ ! -d $d/lxctest ] && mkdir $d/lxctest | ||
| 93 | - chown -R $TUSER: $d/lxctest | ||
| 94 | - echo $$ > $d/lxctest/tasks | ||
| 95 | - done | ||
| 96 | -fi | ||
| 97 | - | ||
| 98 | run_cmd lxc-create -t busybox -n c1 -l trace -o "${UNPRIV_LOG}" | ||
| 99 | |||
| 100 | # Make sure we can start it - twice | ||
| 101 | -- | ||
| 102 | 2.35.5 | ||
| 103 | |||
diff --git a/recipes-containers/lxc/lxc_git.bb b/recipes-containers/lxc/lxc_git.bb index 33ea4ee7..ee0e442f 100644 --- a/recipes-containers/lxc/lxc_git.bb +++ b/recipes-containers/lxc/lxc_git.bb | |||
| @@ -47,6 +47,8 @@ SRC_URI = "git://github.com/lxc/lxc.git;branch=stable-5.0;protocol=https \ | |||
| 47 | file://0001-template-if-busybox-contains-init-use-it-in-containe.patch \ | 47 | file://0001-template-if-busybox-contains-init-use-it-in-containe.patch \ |
| 48 | file://dnsmasq.conf \ | 48 | file://dnsmasq.conf \ |
| 49 | file://lxc-net \ | 49 | file://lxc-net \ |
| 50 | file://0001-lxc-test-usernic-drop-cgroup-handling.patch \ | ||
| 51 | file://0001-tests-remove-old-and-broken-cgroup-handling-code-fro.patch \ | ||
| 50 | " | 52 | " |
| 51 | 53 | ||
| 52 | SRCREV = "cb8e38aca27a23964941f0f011a8919aab8bebab" | 54 | SRCREV = "cb8e38aca27a23964941f0f011a8919aab8bebab" |
