mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 12:44:39 +00:00
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:
parent
5a22e0e3b1
commit
8310a3d70a
@ -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)
|
||||
|
@ -1845,8 +1845,12 @@ 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 {
|
||||
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 {
|
||||
// notify the guest kernel about memory hot-add event, before onlining them
|
||||
|
Loading…
Reference in New Issue
Block a user