Merge pull request #9641 from cmaf/runtime-resize-mem-1

runtime: Add missing check in ResizeMemory for CH
This commit is contained in:
Alex Lyn 2024-05-22 14:05:30 +08:00 committed by GitHub
commit ce030d1804
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1042,12 +1042,15 @@ func (clh *cloudHypervisor) ResizeMemory(ctx context.Context, reqMemMB uint32, m
newMem = alignedRequest
}
// Check if memory is the same as requested, a second Check is done
// to consider the memory request now that is updated to be memory aligned
// Post-alignment checks
if currentMem == newMem {
clh.Logger().WithFields(log.Fields{"current-memory": currentMem, "new-memory": newMem}).Debug("VM already has requested memory(after alignment)")
return uint32(currentMem.ToMiB()), MemoryDevice{}, nil
}
// Check for aligned memory exceeding max hotplug size
if newMem > (utils.MemUnit(uint32(maxHotplugSize.ToMiB())) * utils.MiB) {
newMem = utils.MemUnit(uint32(maxHotplugSize.ToMiB())) * utils.MiB
}
cl := clh.client()
ctx, cancelResize := context.WithTimeout(ctx, clh.getClhAPITimeout()*time.Second)