virtcontainers: Don't fail memory hotplug

Architectures that do not support memory hotplugging will fail when
memory limits are set because that amount is hotplugged. Issue a warning
instead. The long-term solution is virtio-mem.

Fixes: #1412
Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
This commit is contained in:
Jakob Naucke 2021-06-16 11:55:13 +02:00
parent 5a22e0e3b1
commit 8310a3d70a
No known key found for this signature in database
GPG Key ID: 45FA1C7D310C0EBE
2 changed files with 8 additions and 2 deletions

View File

@ -126,6 +126,8 @@ const (
qemuStopSandboxTimeoutSecs = 15
)
var noGuestMemHotplugErr error = errors.New("guest memory hotplug not supported")
// agnostic list of kernel parameters
var defaultKernelParameters = []Param{
{"panic", "1"},
@ -1742,7 +1744,7 @@ func (q *qemu) hotplugRemoveCPUs(amount uint32) (uint32, error) {
func (q *qemu) hotplugMemory(memDev *memoryDevice, op operation) (int, error) {
if !q.arch.supportGuestMemoryHotplug() {
return 0, fmt.Errorf("guest memory hotplug not supported")
return 0, noGuestMemHotplugErr
}
if memDev.sizeMB < 0 {
return 0, fmt.Errorf("cannot hotplug negative size (%d) memory", memDev.sizeMB)

View File

@ -1845,7 +1845,11 @@ func (s *Sandbox) updateResources(ctx context.Context) error {
s.Logger().WithField("memory-sandbox-size-byte", sandboxMemoryByte).Debugf("Request to hypervisor to update memory")
newMemory, updatedMemoryDevice, err := s.hypervisor.resizeMemory(ctx, uint32(sandboxMemoryByte>>utils.MibToBytesShift), s.state.GuestMemoryBlockSizeMB, s.state.GuestMemoryHotplugProbe)
if err != nil {
return err
if err == noGuestMemHotplugErr {
s.Logger().Warnf("%s, memory specifications cannot be guaranteed", err)
} else {
return err
}
}
s.Logger().Debugf("Sandbox memory size: %d MB", newMemory)
if s.state.GuestMemoryHotplugProbe && updatedMemoryDevice.addr != 0 {