diff --git a/virtcontainers/qemu.go b/virtcontainers/qemu.go index 18bed3558a..e73e936991 100644 --- a/virtcontainers/qemu.go +++ b/virtcontainers/qemu.go @@ -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) } diff --git a/virtcontainers/qemu_arch_base.go b/virtcontainers/qemu_arch_base.go index b8fb5cd20c..a0f8f84e78 100644 --- a/virtcontainers/qemu_arch_base.go +++ b/virtcontainers/qemu_arch_base.go @@ -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 +}