Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: Add function supportGuestMemoryHotplug
Browse files Browse the repository at this point in the history
This PR defines a new function supportGuestMemoryHotplug that
clearly defines if the architecture supports memory hotplug. The function
can be reimplemented in virtcontainers/qemu_$arch.go file for each
architecture.

Fixes: #910

Signed-off-by: Alice Frosi <[email protected]>
  • Loading branch information
Alice Frosi committed Nov 19, 2018
1 parent d73f27c commit 0796f2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,10 @@ 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")
}
if memDev.sizeMB < 0 {
return 0, fmt.Errorf("cannot hotplug negative size (%d) memory", memDev.sizeMB)
}
Expand Down
7 changes: 7 additions & 0 deletions virtcontainers/qemu_arch_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ type qemuArch interface {

// handleImagePath handles the Hypervisor Config image path
handleImagePath(config HypervisorConfig)

// supportGuestMemoryHotplug returns if the guest supports memory hotplug
supportGuestMemoryHotplug() bool
}

type qemuArchBase struct {
Expand Down Expand Up @@ -559,3 +562,7 @@ func (q *qemuArchBase) handleImagePath(config HypervisorConfig) {
q.kernelParamsDebug = append(q.kernelParamsDebug, kernelParamsSystemdDebug...)
}
}

func (q *qemuArchBase) supportGuestMemoryHotplug() bool {
return true
}

0 comments on commit 0796f2e

Please sign in to comment.