Merge pull request #911 from alicefr/memory_hotplug

virtcontainers: Add function supportGuestMemoryHotplug
This commit is contained in:
Sebastien Boeuf 2018-11-19 20:17:32 +00:00 committed by GitHub
commit ccc41d7363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 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) {
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)
}

View File

@ -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 {
@ -559,3 +562,7 @@ func (q *qemuArchBase) handleImagePath(config HypervisorConfig) {
q.kernelParamsDebug = append(q.kernelParamsDebug, kernelParamsSystemdDebug...)
}
}
func (q *qemuArchBase) supportGuestMemoryHotplug() bool {
return true
}

View File

@ -350,6 +350,7 @@ func TestHotplugRemoveMemory(t *testing.T) {
qemuConfig := newQemuConfig()
fs := &filesystem{}
q := &qemu{
arch: &qemuArchBase{},
config: qemuConfig,
storage: fs,
}