]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
lxcfs: add --disable-cfs
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 3 Mar 2020 16:16:23 +0000 (17:16 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 3 Mar 2020 16:22:06 +0000 (17:22 +0100)
Closes #298.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
bindings.h
lxcfs.c
proc_cpuview.c

index d995518b67d39e35b4aae9e17a372d1c8688b2cb..64a9be573d6e4940637f53a4bc76e1284d3edb55 100644 (file)
@@ -66,6 +66,7 @@ struct file_info {
 struct lxcfs_opts {
        bool swap_off;
        bool use_pidfd;
+       bool use_cfs;
 };
 
 extern pid_t lookup_initpid_in_store(pid_t qpid);
diff --git a/lxcfs.c b/lxcfs.c
index 880aa9495a77115fea6a0078d196e4c0e23ff74d..1f4d902861db5740b59db045b882eff3aa81ec24 100644 (file)
--- a/lxcfs.c
+++ b/lxcfs.c
@@ -963,6 +963,7 @@ static void usage()
        fprintf(stderr, "\n");
        fprintf(stderr, "Options :\n");
        fprintf(stderr, "-d, --debug            Run lxcfs with debugging enabled\n");
+       fprintf(stderr, "--disable-cfs          Disable cpu virtualization via cpu shares\n");
        fprintf(stderr, "-f, --foreground       Run lxcfs in the foreground\n");
        fprintf(stderr, "-n, --help             Print help\n");
        fprintf(stderr, "-l, --enable-loadavg   Enable loadavg virtualization\n");
@@ -1088,6 +1089,7 @@ int main(int argc, char *argv[])
        }
        opts->swap_off = false;
        opts->use_pidfd = false;
+       opts->use_cfs = true;
 
        /* accomodate older init scripts */
        swallow_arg(&argc, argv, "-s");
@@ -1118,6 +1120,10 @@ int main(int argc, char *argv[])
        /* --enable-pidfd */
        opts->use_pidfd = swallow_arg(&argc, argv, "--enable-pidfd");
 
+       /* --disable-cfs */
+       if (swallow_arg(&argc, argv, "--disable-cfs"))
+               opts->use_cfs = false;
+
        if (swallow_option(&argc, argv, "-o", &v)) {
                /* Parse multiple values */
                for (; (token = strtok_r(v, ",", &saveptr)); v = NULL) {
index c25b4f5b97ad7bd6eb9d603698290271d4b103a8..83218404435641953f1bcad3e1c242c4d3b3a5ac 100644 (file)
@@ -869,6 +869,7 @@ int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
        __do_free void *fopen_cache = NULL;
        __do_fclose FILE *f = NULL;
        struct fuse_context *fc = fuse_get_context();
+       struct lxcfs_opts *opts = (struct lxcfs_opts *)fc->private_data;
        struct file_info *d = INTTYPE_TO_PTR(fi->fh);
        size_t linelen = 0, total_len = 0;
        bool am_printing = false, firstline = true, is_s390x = false;
@@ -905,7 +906,9 @@ int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
        if (!cpuset)
                return 0;
 
-       use_view = cgroup_ops->can_use_cpuview(cgroup_ops);
+       if (cgroup_ops->can_use_cpuview(cgroup_ops) && opts->use_cfs)
+               use_view = true;
+
        if (use_view)
                max_cpus = max_cpu_count(cg);