]> git.ipfire.org Git - thirdparty/libvirt.git/commit
libxl: Fix Domain-0 ballooning logic
authorJim Fehlig <jfehlig@suse.com>
Mon, 18 Sep 2023 15:59:39 +0000 (09:59 -0600)
committerJim Fehlig <jfehlig@suse.com>
Tue, 19 Sep 2023 15:56:29 +0000 (09:56 -0600)
commit417197a38feab2bbc1a03395b01fb95be128587e
tree3cad3931d633fba9c094f96172309487a0b12209
parent4096a59e6e450fae40a546487722709e447bbd47
libxl: Fix Domain-0 ballooning logic

When Domain-0 autoballooning is enabled, it's possible that memory may
need to be ballooned down in Domain-0 to accommodate the needs of another
virtual machine. libxlDomainFreeMemory handles this task, but due to a
logic bug is underflowing the variable containing Domain-0 new
target memory. The resulting huge numbers are filtered by
libxlSetMemoryTargetWrapper and memory is not changed.

Under the covers, libxlDomainFreeMemory uses Xen's libxl_set_memory_target
API, which includes a 'relative' parameter for specifying how to set the
target. If true, the target is an increment/decrement value over the
current memory, otherwise target is taken as an absolute value.
libxlDomainFreeMemory sets 'relative' to true, but never allows for
negative values by declaring the target memory variable as an unsigned.
Fix by declaring the variable as signed, which also requried adjusting
libxlSetMemoryTargetWrapper.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/libxl/libxl_api_wrapper.h
src/libxl/libxl_domain.c