]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
sysfs: cpuinfo: show cgroup cpuset value
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 28 Apr 2020 08:35:26 +0000 (10:35 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 28 Apr 2020 08:57:12 +0000 (10:57 +0200)
To stop the immediate bleeding.

Closes #401.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/sysfs_fuse.c
tests/test_proc

index 5bdb2cea79156002cf098d408c3a074135d9cf26..06073c498e7dca293a02cdb479680232ae07a1aa 100644 (file)
@@ -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");
 
index fbb38d42f5fcdbb1669bb2fe0a18e263e6bb0550..9e168782b74397943f074af230f484696d157567 100755 (executable)
@@ -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" ]