Hello, iam currently trying to run LXC Containers with libvirt but the memory limit doesn't want to work in the container i see the full 32GB from the Host OS iam pretty sure that iam missing a configline in the xml lxc-template ~ # free -m total used free shared buff/cache available Mem: 32108 626 31396 249 85 31396 Swap: 0 0 0 lxc-template ~ # the host is running debian 9 with default repos hv1 ~ # dpkg -l | grep virt ii libgovirt-common 0.3.4-2 all GObject-based library to access oVirt REST API (common files) ii libgovirt2:amd64 0.3.4-2 amd64 GObject-based library to access oVirt REST API ii libvirt-clients 3.0.0-4+deb9u3 amd64 Programs for the libvirt library ii libvirt-daemon 3.0.0-4+deb9u3 amd64 Virtualization daemon ii libvirt-daemon-system 3.0.0-4+deb9u3 amd64 Libvirt daemon configuration files ii libvirt-glib-1.0-0:amd64 1.0.0-1 amd64 libvirt GLib and GObject mapping library ii libvirt0 3.0.0-4+deb9u3 amd64 library for interfacing with different virtualization systems ii python-libvirt 3.0.0-2 amd64 libvirt Python bindings ii qemu-kvm 1:2.8+dfsg-6+deb9u4 amd64 QEMU Full virtualization on x86 hardware ii virt-viewer 5.0-1 amd64 Displaying the graphical console of a virtual machine ii virtinst 1:1.4.0-5 all Programs to create and clone virtual machines -- best regards Markus Raps -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: deb4.xml URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20180801/c6b010d0/attachment.ksh>
Ok somehow the processes bypasses the group/namespace under libvirt the cgroups.procs file ( /sys/fs/cgroup/memory/machine/lxc-4296-deb4.libvirt-lxc/cgroup.procs ) shows only one process with the lxc tools the cgroups.procs file ( /sys/fs/cgroup/memory/lxc/debian/cgroup.procs ) shows up to all 11 processes -- Mit freundlichen Gr??en / best regards Markus Raps -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: libvirt.txt URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20180801/f1fef45e/attachment.txt> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: lxc.txt URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20180801/f1fef45e/attachment-0001.txt>
On Wed, Aug 01, 2018 at 12:53:58PM +0200, Markus Raps wrote:> Hello, > > iam currently trying to run LXC Containers with libvirt > but the memory limit doesn't want to work > > in the container i see the full 32GB from the Host OS > iam pretty sure that iam missing a configline in the xml > > lxc-template ~ # free -m > total used free shared buff/cache > available > Mem: 32108 626 31396 249 85 > 31396 > Swap: 0 0 0 > lxc-template ~ #The 'free' command reports what is present in the host, which is distinct from what's made available to the container. This isn't unique to libvirt LXC containers - in fact any command that is runnning in a cgroup with memory controller limits applied will see the same behaviour. Apps can't assume that 'free' reflects the amount of memory that is available to them. Instead they need to look at cgroups memory controller that they are placed under (/proc/self/cgroups tells you where) Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
On 06.08.2018 10:35, Daniel P. Berrangé wrote:> The 'free' command reports what is present in the host, which is distinct > from what's made available to the container. This isn't unique to libvirt > LXC containers - in fact any command that is runnning in a cgroup with > memory controller limits applied will see the same behaviour. Apps can't > assume that 'free' reflects the amount of memory that is available to > them. Instead they need to look at cgroups memory controller that they > are placed under (/proc/self/cgroups tells you where)I think this is not completely true... I had a similiar problem in the past, and I could get it fixed by using e.g. this in the domains XML: <memtune> <hard_limit unit='KiB'>4194304</hard_limit> <soft_limit unit='KiB'>4194304</soft_limit> <swap_hard_limit unit='KiB'>4194304</swap_hard_limit> </memtune> `free` then reports the correct values. Maybe you can give that a try @Markus Raps? Of course make sure to check out the documentation[1] of these config elements to make sure you really want what they do. Regards Rene [1] = https://libvirt.org/formatdomain.html#elementsMemoryTuning