Merge pull request #11822 from BbolroC/runtime-no-hotplug-ibm-sel-s390x

runtime: Set maxmem to initialmem on s390x when memory hotplug is disabled
This commit is contained in:
Hyounggyu Choi
2025-09-18 17:31:01 +02:00
committed by GitHub
2 changed files with 24 additions and 0 deletions

View File

@@ -424,3 +424,21 @@ func (q *qemuS390x) qomGetPciPath(qemuID string, qmpCh *qmpChannel) (types.PciPa
hvLogger.Warnf("qomGetPciPath not implemented for s390x")
return types.PciPath{}, nil
}
func (q *qemuS390x) memoryTopology(memoryMb, hostMemoryMb uint64, slots uint8) govmmQemu.Memory {
// For no hotplug memory, set hostMemoryMb to memoryMb, otherwise will cause
// `invalid value of maxmem: maximum memory size (0x0) must be at least the initial memory size`
if hostMemoryMb == 0 {
hostMemoryMb = memoryMb
}
memMax := fmt.Sprintf("%dM", hostMemoryMb)
mem := fmt.Sprintf("%dM", memoryMb)
memory := govmmQemu.Memory{
Size: mem,
Slots: slots,
MaxMem: memMax,
}
return memory
}

View File

@@ -56,6 +56,12 @@ func TestQemuS390xMemoryTopology(t *testing.T) {
m := s390x.memoryTopology(mem, hostMem, slots)
assert.Equal(expectedMemory, m)
// test when hostMem is set to 0 (no hotplug memory)
hostMem = 0
expectedMemory.MaxMem = fmt.Sprintf("%dM", mem)
m = s390x.memoryTopology(mem, hostMem, slots)
assert.Equal(expectedMemory, m)
}
func TestQemuS390xAppendVhostUserDevice(t *testing.T) {