lxc: seek errors reading from /proc/meminfo inside container
Software environment
- Operating system: Debian Bookworm
- Architecture: amd64
- kernel version:
6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08)
- libvirt version: 9.0.0-4
- Hypervisor and version: libvirt-lxc
Description of problem
Trying to run free
or other commands that try to read from /proc/meminfo
via library calls results in errors. Running these commands under strace
shows that they all try to seek to the start of the file immediately after opening it, and get an error from that:
openat(AT_FDCWD, "/proc/meminfo", O_RDONLY) = 3
lseek(3, 0, SEEK_SET) = -1 ESPIPE (Illegal seek)
close(3) = 0
Looking in the commit history, I found 76649550 which sounds like it was attempting to fix this very issue, and that fix is still present in the code for 9.0.0, so I'm a bit puzzled what's going on.
Steps to reproduce
- Use
lxc-create
to create a new Debian Bookworm container - Configure libvirtd to run that rootfs and start it
- Inside the container, run
free