]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: Try to get limits from /proc
authorAndrea Bolognani <abologna@redhat.com>
Thu, 4 Mar 2021 10:37:36 +0000 (11:37 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 22 Mar 2021 11:05:18 +0000 (12:05 +0100)
commit90fe839f8a0b8301dc72a396be428db397ddf2c0
treea131729d801032d00a4f7be88f79bb4ae53f3661
parentcae268f7b9ed0172cfa8495e3837ab9670445d90
util: Try to get limits from /proc

Calling prlimit() requires elevated privileges, specifically
CAP_SYS_RESOURCE, and getrlimit() only works for the current
process which is too limiting for our needs; /proc/$pid/limits,
on the other hand, can be read by any process, so implement
parsing that file as a fallback for when prlimit() fails.

This is useful in containerized environments.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virprocess.c