Merge pull request #1361 from darfux/fix-mem-id

vc:qemu: Fix id calculation of memory hotplug
This commit is contained in:
James O. D. Hunt 2019-03-13 18:10:47 +00:00 committed by GitHub
commit 71fc406381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1220,7 +1220,13 @@ func (q *qemu) hotplugAddMemory(memDev *memoryDevice) (int, error) {
}
if len(memoryDevices) != 0 {
memDev.slot = memoryDevices[len(memoryDevices)-1].Data.Slot + 1
maxSlot := -1
for _, device := range memoryDevices {
if maxSlot < device.Data.Slot {
maxSlot = device.Data.Slot
}
}
memDev.slot = maxSlot + 1
}
err = q.qmpMonitorCh.qmp.ExecHotplugMemory(q.qmpMonitorCh.ctx, "memory-backend-ram", "mem"+strconv.Itoa(memDev.slot), "", memDev.sizeMB)
if err != nil {