I am running FreeBSD in a Linux/KVM environment with the -balloon virtio flag passed to qemu. The virtio-balloon kernel module gets loaded: jan@vm03 ~ $ kldstat -v | grep virtio 460 virtio_pci/virtio_scsi 459 virtio_pci/virtio_balloon 458 virtio_pci/virtio_blk 457 virtio_pci/vtnet 456 pci/virtio_pci 455 virtio But there is no ballooning at all. The VM allocates all the memory up to the specified maximum from the host, no matter how much memory is actually in use inside FreeBSD. Expected result would be that the VM only allocates as much memory from the host as it actually uses right now. This works with Linux guests, but not FreeBSD ones. For reference the complete qemu command line: qemu-system-x86_64 -enable-kvm \ -cpu host \ -smp cores=4,threads=2 \-drive file=/var/kvm/disks/vm03.img,if=virtio \-net tap,ifname=tap_br1_3,script=no,downscript=no -net nic,model=virtio,macaddr=0e:77:77:0e:0e:03 \ -m 4G \ -balloon virtio \ -vga std \ -display vnc=:3 \ -monitor stdio \ -name "VM 03" \ -usbdevice tablet \ -k de
The guest balloon inflation and deflation is a manual process. IIRC, it can be controlled by either the qemu monitor or virsh setmem commands.
(In reply to Bryan Venteicher from comment #1) As explained in the initial report that is not the case with Linux guest, there it is automatic and needs no user intervention. If it is currently manual in FreeBSD, please add an automatic mode.
I observe this as well (FreeBSD 10.2), except the freebsd guest does not allocate all the allowed memory at start; it will grow up to the max memory then never shrink. Linux VM's shrink to allow better utilization of the host RAM.
With 10.2 I see the same behaviour as Vick. The FreeBSD no longer allocates up to the maximum at boot, but it does not release unused memory either. Would be nice to implement full ballooning in FreeBSD.
It looks like this might be at least partially addressed in r267858. Trying to get it MFCed for 10.3.
I'm currently running a tinderbox with a backport of r267858, if everything goes fine I will commit it.
It looks like this should be fixed in this MFC: https://svnweb.freebsd.org/base/stable/10/sys/dev/virtio/balloon/virtio_balloon.c?view=log Can someone test 10.3 and let us know?
Created attachment 169998 [details] graph of memory usage of my VM I've been watching my 10.3 VM for a while now, and I finally found evidence that it did release some memory. The VM environment is Proxmox VE, which is basically a fancy pants GUI on top of Debian linux + KVM. The memory usage graph is attached.
Assign to committer that resolved (royger, r267858, MFC 10-STABLE: r292906)