The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxcfs/pull/402

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
To stop the immediate bleeding.

Closes #401.
Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From b3c85f5d1af413ffef992b272beb676f95becf19 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Tue, 28 Apr 2020 10:35:26 +0200
Subject: [PATCH] sysfs: cpuinfo: show cgroup cpuset value

To stop the immediate bleeding.

Closes #401.
Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 src/sysfs_fuse.c | 14 +++++++++-----
 tests/test_proc  |  3 +++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/sysfs_fuse.c b/src/sysfs_fuse.c
index 5bdb2ce..06073c4 100644
--- a/src/sysfs_fuse.c
+++ b/src/sysfs_fuse.c
@@ -96,12 +96,16 @@ static int sys_devices_system_cpu_online_read(char *buf, 
size_t size,
        if (use_view)
                max_cpus = max_cpu_count(cg);
 
-       if (max_cpus == 0)
+       if (use_view) {
+               if (max_cpus > 1)
+                       total_len = snprintf(d->buf, d->buflen, "0-%d\n", 
max_cpus - 1);
+               else
+                       total_len = snprintf(d->buf, d->buflen, "0\n");
+       } else if (cpuset) {
+               total_len = snprintf(d->buf, d->buflen, "%s\n", cpuset);
+       } else {
                return read_file_fuse("/sys/devices/system/cpu/online", buf, 
size, d);
-       if (max_cpus > 1)
-               total_len = snprintf(d->buf, d->buflen, "0-%d\n", max_cpus - 1);
-       else
-               total_len = snprintf(d->buf, d->buflen, "0\n");
+       }
        if (total_len < 0 || total_len >= d->buflen)
                return log_error(0, "Failed to write to cache");
 
diff --git a/tests/test_proc b/tests/test_proc
index fbb38d4..9e16878 100755
--- a/tests/test_proc
+++ b/tests/test_proc
@@ -49,6 +49,9 @@ echo "==> Testing /proc/cpuinfo"
 [ "$(grep "^processor" ${LXCFSDIR}/proc/cpuinfo | wc -l)" = "1" ]
 grep -q "^processor.*0$" ${LXCFSDIR}/proc/cpuinfo || grep -q "^processor 0:.*" 
${LXCFSDIR}/proc/cpuinfo
 
+echo "==> Testing /sys/devices/system/cpu/online"
+[ "$(cat ${LXCFSDIR}/sys/devices/system/cpu/online)" = "$(cat 
${cpupath}/lxcfs_test_proc/cpuset.cpus)" ]
+
 # Test stat
 echo "==> Testing /proc/stat"
 [ "$(grep "^cpu" ${LXCFSDIR}/proc/stat | wc -l)" = "2" ]
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to