[PATCH] libxl: Fix Domain-0 ballooning logic

Jim Fehlig jfehlig at suse.com
Tue Sep 19 16:05:31 UTC 2023


On 9/19/23 06:50, Michal Prívozník wrote:
> On 9/18/23 19:16, Jim Fehlig wrote:
>> 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 at suse.com>
>> ---
>>   src/libxl/libxl_api_wrapper.h | 16 ++++++----------
>>   src/libxl/libxl_domain.c      |  2 +-
>>   2 files changed, 7 insertions(+), 11 deletions(-)
> 
> Reviewed-by: Michal Privoznik <mprivozn at redhat.com>

Thanks! Before pushing I also ensured the autoballoon logic is working as 
expected. I don't have any automated tests for that since autoballoon has not 
been enabled in SUSE distros for years.

Regards,
Jim



More information about the libvir-list mailing list