virtcontainers: Add function supportGuestMemoryHotplug

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 <afrosi@de.ibm.com>
This commit is contained in:
Alice Frosi 2018-11-15 15:04:39 +00:00
parent d73f27c612
commit 0796f2e5a0
2 changed files with 11 additions and 0 deletions

View File

@ -1070,6 +1070,10 @@ func (q *qemu) hotplugRemoveCPUs(amount uint32) (uint32, error) {
} }
func (q *qemu) hotplugMemory(memDev *memoryDevice, op operation) (int, 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 { if memDev.sizeMB < 0 {
return 0, fmt.Errorf("cannot hotplug negative size (%d) memory", memDev.sizeMB) return 0, fmt.Errorf("cannot hotplug negative size (%d) memory", memDev.sizeMB)
} }

View File

@ -93,6 +93,9 @@ type qemuArch interface {
// handleImagePath handles the Hypervisor Config image path // handleImagePath handles the Hypervisor Config image path
handleImagePath(config HypervisorConfig) handleImagePath(config HypervisorConfig)
// supportGuestMemoryHotplug returns if the guest supports memory hotplug
supportGuestMemoryHotplug() bool
} }
type qemuArchBase struct { type qemuArchBase struct {
@ -559,3 +562,7 @@ func (q *qemuArchBase) handleImagePath(config HypervisorConfig) {
q.kernelParamsDebug = append(q.kernelParamsDebug, kernelParamsSystemdDebug...) q.kernelParamsDebug = append(q.kernelParamsDebug, kernelParamsSystemdDebug...)
} }
} }
func (q *qemuArchBase) supportGuestMemoryHotplug() bool {
return true
}