]> git.proxmox.com Git - mirror_lxcfs.git/log
mirror_lxcfs.git
3 years agoproc_fuse: cleanup proc_uptime_read() a little
Christian Brauner [Fri, 5 Jun 2020 13:42:41 +0000 (15:42 +0200)]
proc_fuse: cleanup proc_uptime_read() a little

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_fuse: move get_reaper_busy() down
Christian Brauner [Fri, 5 Jun 2020 12:53:54 +0000 (14:53 +0200)]
proc_fuse: move get_reaper_busy() down

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_loadavg: avoid needless memory allocation
Christian Brauner [Fri, 5 Jun 2020 11:24:33 +0000 (13:24 +0200)]
proc_loadavg: avoid needless memory allocation

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_loadavg: remove dummy variable
Christian Brauner [Fri, 5 Jun 2020 11:23:31 +0000 (13:23 +0200)]
proc_loadavg: remove dummy variable

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_loadavg: use must_* alloc helpers
Christian Brauner [Fri, 5 Jun 2020 11:11:39 +0000 (13:11 +0200)]
proc_loadavg: use must_* alloc helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_fuse: use zalloc()
Christian Brauner [Fri, 5 Jun 2020 11:11:27 +0000 (13:11 +0200)]
proc_fuse: use zalloc()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxcfs: free opts on lxcfs binary exit
Christian Brauner [Fri, 5 Jun 2020 10:59:05 +0000 (12:59 +0200)]
lxcfs: free opts on lxcfs binary exit

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobindings: avoid dynamic stack allocations in clone()
Christian Brauner [Fri, 5 Jun 2020 10:52:12 +0000 (12:52 +0200)]
bindings: avoid dynamic stack allocations in clone()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobindings: wipe initpid cache on library reload
Christian Brauner [Fri, 5 Jun 2020 10:41:00 +0000 (12:41 +0200)]
bindings: wipe initpid cache on library reload

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_loadavg: simplify calc_pid()
Christian Brauner [Fri, 5 Jun 2020 10:24:15 +0000 (12:24 +0200)]
proc_loadavg: simplify calc_pid()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_loadavg(): use strdup() in calc_pid()
Christian Brauner [Fri, 5 Jun 2020 10:13:01 +0000 (12:13 +0200)]
proc_loadavg(): use strdup() in calc_pid()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agomacro: use ISO C compatible __typeof__
Christian Brauner [Fri, 5 Jun 2020 10:12:32 +0000 (12:12 +0200)]
macro: use ISO C compatible __typeof__

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_loadavg: replace malloc() with asprintf() in calc_pid()
Christian Brauner [Fri, 5 Jun 2020 09:44:56 +0000 (11:44 +0200)]
proc_loadavg: replace malloc() with asprintf() in calc_pid()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_loadavg: don't leak getline() memory
Christian Brauner [Fri, 5 Jun 2020 09:44:37 +0000 (11:44 +0200)]
proc_loadavg: don't leak getline() memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_loadavg: ensure pointer is NULL when passing to calc_pid()
Christian Brauner [Fri, 5 Jun 2020 09:43:10 +0000 (11:43 +0200)]
proc_loadavg: ensure pointer is NULL when passing to calc_pid()

We passed down an uninitialized pointer that we then pass to realloc()
which is problematic since it contains garbage.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoproc_loadavg: don't leak getline() memory in calc_pid()
Christian Brauner [Fri, 5 Jun 2020 09:42:31 +0000 (11:42 +0200)]
proc_loadavg: don't leak getline() memory in calc_pid()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobindings: s/get_init_pid_for_task()/scm_init_pid()/g
Christian Brauner [Thu, 4 Jun 2020 18:14:49 +0000 (20:14 +0200)]
bindings: s/get_init_pid_for_task()/scm_init_pid()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocpuview: fix /proc/stat virtualization
Christian Brauner [Tue, 2 Jun 2020 14:10:20 +0000 (16:10 +0200)]
cpuview: fix /proc/stat virtualization

Closes: #406.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobindings: cleanup init pid verification
Christian Brauner [Thu, 28 May 2020 12:24:06 +0000 (14:24 +0200)]
bindings: cleanup init pid verification

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobindings: cleanup cache locking
Christian Brauner [Thu, 28 May 2020 12:07:09 +0000 (14:07 +0200)]
bindings: cleanup cache locking

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobindings: use brackets to make logic clearer
Christian Brauner [Thu, 28 May 2020 11:31:59 +0000 (13:31 +0200)]
bindings: use brackets to make logic clearer

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobindings: make opts pointer const
Christian Brauner [Thu, 28 May 2020 11:27:37 +0000 (13:27 +0200)]
bindings: make opts pointer const

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobindings: fix init pid hashing
Christian Brauner [Thu, 28 May 2020 09:03:05 +0000 (11:03 +0200)]
bindings: fix init pid hashing

We were stupidly always hashing entry->ino where entry was just freshly
allocated zeroed-memory so we effectively added stuff to the cache
forever but this meant:
- we never found a match when we hashed the actual inode
- we kept growing the cache
- we leaked memory

Closes: #407.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocoverity: Use build custom build script
Stéphane Graber [Fri, 22 May 2020 17:01:40 +0000 (13:01 -0400)]
coverity: Use build custom build script

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoFix https://github.com/lxc/lxcfs/issues/404
Joseph Moore [Wed, 6 May 2020 20:23:35 +0000 (13:23 -0700)]
Fix https://github.com/lxc/lxcfs/issues/404

reset  read_pos=0 after building usage_str

Signed-off-by: Joseph Moore <joemoore1123@gmail.com>
4 years agosysfs_fuse: remove logically dead code
Christian Brauner [Tue, 28 Apr 2020 11:24:00 +0000 (13:24 +0200)]
sysfs_fuse: remove logically dead code

Fixes: Coverity 357808.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agosysfs: cpuinfo: show cgroup cpuset value
Christian Brauner [Tue, 28 Apr 2020 08:35:26 +0000 (10:35 +0200)]
sysfs: cpuinfo: show cgroup cpuset value

To stop the immediate bleeding.

Closes #401.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoproc_fuse: silence error when we find no memlimit
Wolfgang Bumiller [Fri, 24 Apr 2020 07:17:06 +0000 (09:17 +0200)]
proc_fuse: silence error when we find no memlimit

We get a positive result with an empty string if we do not
encounter any limits while walking up the cgroup.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoRelease LXCFS 4.0.3 lxcfs-4.0.3
Stéphane Graber [Fri, 17 Apr 2020 20:14:26 +0000 (16:14 -0400)]
Release LXCFS 4.0.3

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoproc_fuse: improve swap calculation
Stéphane Graber [Fri, 17 Apr 2020 19:59:53 +0000 (21:59 +0200)]
proc_fuse: improve swap calculation

Stéphane has been running into issues with wrong sawp limits. The logic
he suggested does:
- if memory == memory+swap, we list both at the memlimit for total size
- if memory+swap is larger than memory, then we add the extra amount to
  total swap but still cap to physical swap limit

We came to the conclusion that this is currently the best approach as we
show the mem limit as both Memory and Swap so advertising twice as much
as allowed but there's no way around that really or we'd need to
dynamically update both MemTotal and SwapTotal based on what's used to
keep MemTotal+SwapTotal == limit that's certainly doable but it will be
somewhat racy and also likely confused userspace more than mis-reporting
swap.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: simplify cgroup_walkup_to_root()
Christian Brauner [Fri, 17 Apr 2020 15:50:56 +0000 (17:50 +0200)]
cgroups: simplify cgroup_walkup_to_root()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: please Coverity
Christian Brauner [Fri, 17 Apr 2020 13:33:01 +0000 (15:33 +0200)]
cgroups: please Coverity

Fixes: Coverity 355759.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotests: correctly skip readdir test
Christian Brauner [Fri, 17 Apr 2020 11:20:52 +0000 (13:20 +0200)]
tests: correctly skip readdir test

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: more cgroup2 fun
Christian Brauner [Fri, 17 Apr 2020 10:20:55 +0000 (12:20 +0200)]
cgroups: more cgroup2 fun

Try too read a valid value from a given cgroup file. If it is a legacy
cgroup hierarchy and we fail to find a valid value we terminate early
and report an error.
The cgroup2 hierarchy however, has different semantics. In a few
controller files it will show the value "max" or simply leave it
completely empty thereby indicating that no limit has been set for this
particular cgroup.  However, that doesn't mean that there's no limit. A
cgroup further up the hierarchy could have a limit set that also applies
to the cgroup we are interested in. So for the unified cgroup hierarchy
we need to keep walking towards the cgroup2 root cgroup and try to parse
a valid value.

Fixes: #389.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobindings: use zalloc()
Christian Brauner [Thu, 16 Apr 2020 17:12:34 +0000 (19:12 +0200)]
bindings: use zalloc()

Fixes: Coverity 355747.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoutils: fix recv_creds()
Christian Brauner [Thu, 16 Apr 2020 15:58:37 +0000 (17:58 +0200)]
utils: fix recv_creds()

Fixes: Coverity 355704.
Fixes: Coverity 355718.
Fixes: Coverity 355738.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxcfs: don't cause a uaf
Christian Brauner [Thu, 16 Apr 2020 15:45:04 +0000 (17:45 +0200)]
lxcfs: don't cause a uaf

Fixes: Coverity 355711.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: be cautios when dereferencing d->controller
Christian Brauner [Thu, 16 Apr 2020 15:43:00 +0000 (17:43 +0200)]
cgroup_fuse: be cautios when dereferencing d->controller

Fixes: Coverity 355712.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobindings: do not falsely return
Christian Brauner [Thu, 16 Apr 2020 15:39:05 +0000 (17:39 +0200)]
bindings: do not falsely return

This may also explain some of the performance regressions that Blub\0
reported.

Fixes: Coverity 355716.
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: s/clone/lxcfs_clone/g
Christian Brauner [Thu, 16 Apr 2020 15:34:42 +0000 (17:34 +0200)]
cgroup_fuse: s/clone/lxcfs_clone/g

Fixes: Coverity 355713.
Fixes: Coverity 355723.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxcfs: remove fl.* prefix
Christian Brauner [Thu, 16 Apr 2020 15:31:12 +0000 (17:31 +0200)]
lxcfs: remove fl.* prefix

Fixes: Coverity 355708.
Fixes: Coverity 355702.
Fixes: Coverity 355729.
Fixes: Coverity 355735.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: do not double-close
Christian Brauner [Thu, 16 Apr 2020 15:27:58 +0000 (17:27 +0200)]
cgroup_fuse: do not double-close

Fixes: Coverity 355703.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years ago.travis: fix coverity
Christian Brauner [Thu, 16 Apr 2020 16:51:03 +0000 (18:51 +0200)]
.travis: fix coverity

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomemory_utils: make it easier for Coverity
Christian Brauner [Wed, 15 Apr 2020 13:32:44 +0000 (15:32 +0200)]
memory_utils: make it easier for Coverity

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotravis: enable coverity integration
Christian Brauner [Wed, 15 Apr 2020 13:15:02 +0000 (15:15 +0200)]
travis: enable coverity integration

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agorelax init pid store locking a bit
Wolfgang Bumiller [Wed, 15 Apr 2020 08:41:01 +0000 (10:41 +0200)]
relax init pid store locking a bit

So we don't keep holding it throughout the expensive the
fork/clone/send cycle of figuring out a namespace's init
pid.

Also change some functions to pass the init namespace inode
instead of the process' struct stat, so that it is obvious
that we don't use other parts of the stat info. The reason
is that we previously acquired the store lock before doing
the call to `stat()` and therefore it may not be immediately
obvious that things such as the timestamps found inside the
`struct stat` are not contributing to any race between the
multiple acquisitions of the store lock.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoFix #387. Include `:` in matching of lines in /proc/meminfo
Dmitry Petrashko [Thu, 9 Apr 2020 01:27:06 +0000 (18:27 -0700)]
Fix #387. Include `:` in matching of lines in /proc/meminfo

Some lines of /proc/meminfo can be prefixes of the other,
e.g. `Writeback:` and `WritebackTmp:`

This means that in order to to precise match, the code should always match up until `:`

Signed-off-by: Dmitry Petrashko <dark@d-d.me>
4 years agoRelease LXCFS 4.0.2 lxcfs-4.0.2
Stéphane Graber [Tue, 7 Apr 2020 18:14:03 +0000 (14:14 -0400)]
Release LXCFS 4.0.2

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agotests: Handle different lib paths
Stéphane Graber [Wed, 25 Mar 2020 14:55:51 +0000 (10:55 -0400)]
tests: Handle different lib paths

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoproc_fuse: fix swap calculations
Christian Brauner [Tue, 24 Mar 2020 09:03:06 +0000 (10:03 +0100)]
proc_fuse: fix swap calculations

The sscanf() line got removed on accident.

Closes #384.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: add and use syscall_numbers.h
Christian Brauner [Fri, 20 Mar 2020 17:42:37 +0000 (18:42 +0100)]
tree-wide: add and use syscall_numbers.h

The same thing that I did for LXC.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoproc_fuse: improve /proc/uptime virtualization
Christian Brauner [Fri, 20 Mar 2020 10:22:46 +0000 (11:22 +0100)]
proc_fuse: improve /proc/uptime virtualization

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoproc_fuse: memory virtualization improvements
Christian Brauner [Fri, 20 Mar 2020 10:07:16 +0000 (11:07 +0100)]
proc_fuse: memory virtualization improvements

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoproc_fuse: improve /proc/meminfo
Christian Brauner [Fri, 20 Mar 2020 09:46:40 +0000 (10:46 +0100)]
proc_fuse: improve /proc/meminfo

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoRelease LXCFS 4.0.1 lxcfs-4.0.1
Stéphane Graber [Thu, 19 Mar 2020 14:20:44 +0000 (10:20 -0400)]
Release LXCFS 4.0.1

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agocgroup_fuse: actually make asz check mean something
Christian Brauner [Wed, 18 Mar 2020 14:35:43 +0000 (15:35 +0100)]
cgroup_fuse: actually make asz check mean something

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotests: Silence build output
Stéphane Graber [Wed, 18 Mar 2020 16:14:43 +0000 (12:14 -0400)]
tests: Silence build output

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agocgroup_utils: remove dot_or_empty()
Christian Brauner [Tue, 17 Mar 2020 09:41:17 +0000 (10:41 +0100)]
cgroup_utils: remove dot_or_empty()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: rework cgfs_iterate_cgroup()
Christian Brauner [Tue, 17 Mar 2020 09:40:47 +0000 (10:40 +0100)]
cgroup_fuse: rework cgfs_iterate_cgroup()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: rework cgfs_set_value()
Christian Brauner [Tue, 17 Mar 2020 09:34:39 +0000 (10:34 +0100)]
cgroup_fuse: rework cgfs_set_value()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: rework open_pids_file()
Christian Brauner [Tue, 17 Mar 2020 09:29:40 +0000 (10:29 +0100)]
cgroup_fuse: rework open_pids_file()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: rework cgfs_chown_file()
Christian Brauner [Tue, 17 Mar 2020 09:23:57 +0000 (10:23 +0100)]
cgroup_fuse: rework cgfs_chown_file()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: rework cgfs_chmod_file()
Christian Brauner [Tue, 17 Mar 2020 09:18:05 +0000 (10:18 +0100)]
cgroup_fuse: rework cgfs_chmod_file()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: rework cgfs_remove()
Christian Brauner [Tue, 17 Mar 2020 09:16:45 +0000 (10:16 +0100)]
cgroup_fuse: rework cgfs_remove()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: rework cgfs_create()
Christian Brauner [Tue, 17 Mar 2020 09:15:12 +0000 (10:15 +0100)]
cgroup_fuse: rework cgfs_create()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: rework cgfs_get_key()
Christian Brauner [Tue, 17 Mar 2020 09:13:49 +0000 (10:13 +0100)]
cgroup_fuse: rework cgfs_get_key()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: rework is_child_cgroup()
Christian Brauner [Tue, 17 Mar 2020 09:08:21 +0000 (10:08 +0100)]
cgroup_fuse: rework is_child_cgroup()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: remove is_relative() and use must_make_path_relative()
Christian Brauner [Tue, 17 Mar 2020 09:05:53 +0000 (10:05 +0100)]
tree-wide: remove is_relative() and use must_make_path_relative()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: add and use must_make_path_relative()
Christian Brauner [Mon, 16 Mar 2020 21:16:51 +0000 (22:16 +0100)]
tree-wide: add and use must_make_path_relative()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoproc_cpuview: fix compiler warning
Christian Brauner [Mon, 16 Mar 2020 19:59:41 +0000 (20:59 +0100)]
proc_cpuview: fix compiler warning

proc_cpuview.c: In function ‘read_cpu_cfs_param’:
proc_cpuview.c:440:39: error: use of assignment suppression and length modifier together in gnu_scanf format [-Werror=format=]
  440 |  if (sscanf(str, first ? "%" PRId64 : "%*" PRId64 " %" PRId64, value) != 1)
      |                                       ^~~~

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoproc_loadvg: fixes
Christian Brauner [Mon, 16 Mar 2020 19:24:59 +0000 (20:24 +0100)]
proc_loadvg: fixes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoutils: shut up compiler
Christian Brauner [Mon, 16 Mar 2020 17:55:09 +0000 (18:55 +0100)]
utils: shut up compiler

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: remove unused function
Christian Brauner [Mon, 16 Mar 2020 16:46:57 +0000 (17:46 +0100)]
cgroups: remove unused function

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: fix dot_or_empty()
Christian Brauner [Mon, 16 Mar 2020 16:34:34 +0000 (17:34 +0100)]
tree-wide: fix dot_or_empty()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: memory utils improvements
Christian Brauner [Mon, 16 Mar 2020 13:05:11 +0000 (14:05 +0100)]
tree-wide: memory utils improvements

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroup_fuse: fix cgroupfs virtualization needed on non-cgns systems
Christian Brauner [Mon, 16 Mar 2020 12:31:58 +0000 (13:31 +0100)]
cgroup_fuse: fix cgroupfs virtualization needed on non-cgns systems

This also removes "default_permissions" again.
We can't use default_permissions since we still support systems that
don't have kernels with cgroup namespace support. On such kernels lxcfs
will provide a namespaced cgroup view and needs explicit access helpers
to make that work.
Another reason that came to me is that we can't or at least shouldn't
guarantee that we don't need more complicated access helpers for proc
and sys virtualization in the future.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobindings: introduce set_signal_handler
Christian Brauner [Sat, 14 Mar 2020 23:39:17 +0000 (00:39 +0100)]
bindings: introduce set_signal_handler

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotest_sigusr2: improve tests
Christian Brauner [Sat, 14 Mar 2020 20:27:02 +0000 (21:27 +0100)]
test_sigusr2: improve tests

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoproc_fuse: remove unused variable
Christian Brauner [Sat, 14 Mar 2020 18:43:17 +0000 (19:43 +0100)]
proc_fuse: remove unused variable

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotest_proc: add SIGUSR2 virtualization switch tests
Christian Brauner [Sat, 14 Mar 2020 17:35:45 +0000 (18:35 +0100)]
test_proc: add SIGUSR2 virtualization switch tests

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobindings: allow users to switch between virtualization and non-virtualization mode
Christian Brauner [Sat, 14 Mar 2020 17:25:46 +0000 (18:25 +0100)]
bindings: allow users to switch between virtualization and non-virtualization mode

When LXCFS has a bug and provides wrong or inconsistent values user
often want to turn off virtualization until we have figured out a fix
and rollout an upgrade to reload the shared library. Allow them to
toggle between virtualization mode and non-virtualization mode by
sending SIGUSR2 to lxcfs:

 Kernel supports pidfds
 api_extensions:
 - cgroups
 - sys_cpu_online
 - proc_cpuinfo
 - proc_diskstats
 - proc_loadavg
 - proc_meminfo
 - proc_stat
 - proc_swaps
 - proc_uptime
 - shared_pidns
 - cpuview_daemon
 - loadavg_daemon
 - pidfds
 Switched into non-virtualization mode
 Switched into virtualization mode
 Switched into non-virtualization mode
 Switched into virtualization mode
 Switched into non-virtualization mode

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: use {u}int64_t types
Christian Brauner [Sat, 14 Mar 2020 17:04:38 +0000 (18:04 +0100)]
tree-wide: use {u}int64_t types

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoproc_fuse: port to uint64_t
Christian Brauner [Sat, 14 Mar 2020 11:54:55 +0000 (12:54 +0100)]
proc_fuse: port to uint64_t

Using unsigned long and uint64_t is problematic on 32bit.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agousage: Fix lxcfs description
Stéphane Graber [Fri, 13 Mar 2020 23:22:26 +0000 (19:22 -0400)]
usage: Fix lxcfs description

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agousage: Fix cfs help
Stéphane Graber [Fri, 13 Mar 2020 23:07:35 +0000 (19:07 -0400)]
usage: Fix cfs help

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoliblxcfs: handle broken upgrade gracefully
Christian Brauner [Fri, 13 Mar 2020 12:24:59 +0000 (13:24 +0100)]
liblxcfs: handle broken upgrade gracefully

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobindings: make constructor failures non-fatal
Christian Brauner [Fri, 13 Mar 2020 11:24:41 +0000 (12:24 +0100)]
bindings: make constructor failures non-fatal

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: mark lxcfs fuse ops
Christian Brauner [Fri, 13 Mar 2020 11:22:26 +0000 (12:22 +0100)]
tree-wide: mark lxcfs fuse ops

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobindings: handle current working directory on upgrade
Christian Brauner [Fri, 13 Mar 2020 10:34:37 +0000 (11:34 +0100)]
bindings: handle current working directory on upgrade

Recenly I've made failures to run the constructor or destructor fatal.
Mostly, because we can't guarantee correct functionality if they fail.
In fact we can't do anything useful at all (Maybe I can come up with
something more useful soon.)
In any case, this surfaced a bug where on systems that replace/delete
the current workding directory of lxcfs will cause the constructor to
crash on reload because the path that getcwd() returns does not exist
anymore. Fix this by always escaping to root after the construtor has
run but also make it optional in case someone is messing with chroot()s
or other things.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: add missing O_CLOEXEC
Christian Brauner [Fri, 13 Mar 2020 10:12:14 +0000 (11:12 +0100)]
tree-wide: add missing O_CLOEXEC

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconfigure: add -Wvla and -std=gnu11
Christian Brauner [Wed, 11 Mar 2020 02:10:09 +0000 (03:10 +0100)]
configure: add -Wvla and -std=gnu11

Both are standard in LXC for a long time now. And gcc-4.8 which is the
minimal compiler version we require (same as the Linux kernel) deals
with this.

Closes #362.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoproc_fuse: fix meminfo with unified cgroup layout
Jonathan Calmels [Sat, 7 Mar 2020 10:50:41 +0000 (02:50 -0800)]
proc_fuse: fix meminfo with unified cgroup layout

Signed-off-by: Jonathan Calmels <jbjcalmels@gmail.com>
4 years agoproc_cpuview: add minimal support for unified cgroup layout
Jonathan Calmels [Sat, 7 Mar 2020 10:48:14 +0000 (02:48 -0800)]
proc_cpuview: add minimal support for unified cgroup layout

Signed-off-by: Jonathan Calmels <jbjcalmels@gmail.com>
4 years agoRelease LXCFS 4.0.0 lxcfs-4.0.0
Stéphane Graber [Fri, 6 Mar 2020 13:43:40 +0000 (14:43 +0100)]
Release LXCFS 4.0.0

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoMerge pull request #358 from stgraber/master
Christian Brauner [Fri, 6 Mar 2020 13:36:48 +0000 (14:36 +0100)]
Merge pull request #358 from stgraber/master

travis: Enable all architectures

4 years agotests: Append to LD_LIBRARY_PATH
Stéphane Graber [Fri, 6 Mar 2020 13:33:35 +0000 (14:33 +0100)]
tests: Append to LD_LIBRARY_PATH

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agotravis: Pass env through sudo
Stéphane Graber [Fri, 6 Mar 2020 12:57:46 +0000 (13:57 +0100)]
travis: Pass env through sudo

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agotravis: Add uuid-runtime
Stéphane Graber [Fri, 6 Mar 2020 11:34:27 +0000 (12:34 +0100)]
travis: Add uuid-runtime

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agotests: Don't overwrite LD_LIBRARY_PATH
Stéphane Graber [Fri, 6 Mar 2020 11:33:13 +0000 (12:33 +0100)]
tests: Don't overwrite LD_LIBRARY_PATH

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agogitignore: Add dirstamp
Stéphane Graber [Fri, 6 Mar 2020 11:24:55 +0000 (12:24 +0100)]
gitignore: Add dirstamp

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>