]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Avoid hidden cgroup mount points
authorJuan Hernandez <jhernand@redhat.com>
Thu, 6 Jul 2017 15:03:31 +0000 (17:03 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 13 Jul 2017 07:37:52 +0000 (09:37 +0200)
commitdacd160d7479e0ec2d8a63f102145fd30636a1c8
tree51837dc9c38ee942f6f98814db886ae154a26140
parent3d52a8444bc01d8d3d1b7a38976633fcbc645d21
Avoid hidden cgroup mount points

Currently the scan of the /proc/mounts file used to find cgroup mount
points doesn't take into account that mount points may hidden by other
mount points. For, example in certain Kubernetes environments the
/proc/mounts contains the following lines:

  cgroup /sys/fs/cgroup/net_prio,net_cls cgroup ...
  tmpfs /sys/fs/cgroup tmpfs ...
  cgroup /sys/fs/cgroup/net_cls,net_prio cgroup ...

In this particular environment the first mount point is hidden by the
second one. The correct mount point is the third one, but libvirt will
never process it because it only checks the first mount point for each
controller (net_cls in this case). So libvirt will try to use the first
mount point, which doesn't actually exist, and the complete detection
process will fail.

To avoid that issue this patch changes the virCgroupDetectMountsFromFile
function so that when there are duplicates it takes the information from
the last line in /proc/mounts. This requires removing the previous
explicit condition to skip duplicates, and adding code to free the
memory used by the processing of duplicated lines.

Related-To: https://bugzilla.redhat.com/1468214
Related-To: https://github.com/kubevirt/libvirt/issues/4
Signed-off-by: Juan Hernandez <jhernand@redhat.com>
src/util/vircgroup.c
tests/vircgroupdata/kubevirt.mounts [new file with mode: 0644]
tests/vircgroupdata/kubevirt.parsed [new file with mode: 0644]
tests/vircgrouptest.c