mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-15 16:11:32 +00:00
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>