Skip to content

Commit

Permalink
Merge pull request kata-containers#1810 from ganeshmaharaj/virtiofs-h…
Browse files Browse the repository at this point in the history
…otplug

virtiofs: Allow memory hotplug with virtiofs
  • Loading branch information
chavafg authored Jul 17, 2019
2 parents bc15e44 + d392b22 commit e89195e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,9 @@ func (q *qemu) hotplugMemory(memDev *memoryDevice, op operation) (int, error) {

func (q *qemu) hotplugAddMemory(memDev *memoryDevice) (int, error) {
memoryDevices, err := q.qmpMonitorCh.qmp.ExecQueryMemoryDevices(q.qmpMonitorCh.ctx)
share := false
target := ""
memoryBack := "memory-backend-ram"
if err != nil {
return 0, fmt.Errorf("failed to query memory devices: %v", err)
}
Expand All @@ -1368,7 +1371,20 @@ func (q *qemu) hotplugAddMemory(memDev *memoryDevice) (int, error) {
}
memDev.slot = maxSlot + 1
}
err = q.qmpMonitorCh.qmp.ExecHotplugMemory(q.qmpMonitorCh.ctx, "memory-backend-ram", "mem"+strconv.Itoa(memDev.slot), "", memDev.sizeMB, false)
if q.qemuConfig.Knobs.HugePages {
// we are setting all the bits that govmm sets when hugepages are enabled.
// https://github.com/intel/govmm/blob/master/qemu/qemu.go#L1677
target = "/dev/hugepages"
memoryBack = "memory-backend-file"
share = true
} else if q.config.SharedFS == config.VirtioFS || q.config.FileBackedMemRootDir != "" {
target = q.qemuConfig.Memory.Path
memoryBack = "memory-backend-file"
}
if q.qemuConfig.Knobs.FileBackedMemShared {
share = true
}
err = q.qmpMonitorCh.qmp.ExecHotplugMemory(q.qmpMonitorCh.ctx, memoryBack, "mem"+strconv.Itoa(memDev.slot), target, memDev.sizeMB, share)
if err != nil {
q.Logger().WithError(err).Error("hotplug memory")
return 0, err
Expand Down

0 comments on commit e89195e

Please sign in to comment.