mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-07 04:19:58 +00:00
Merge pull request #911 from alicefr/memory_hotplug
virtcontainers: Add function supportGuestMemoryHotplug
This commit is contained in:
commit
ccc41d7363
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
@ -350,6 +350,7 @@ func TestHotplugRemoveMemory(t *testing.T) {
|
|||||||
qemuConfig := newQemuConfig()
|
qemuConfig := newQemuConfig()
|
||||||
fs := &filesystem{}
|
fs := &filesystem{}
|
||||||
q := &qemu{
|
q := &qemu{
|
||||||
|
arch: &qemuArchBase{},
|
||||||
config: qemuConfig,
|
config: qemuConfig,
|
||||||
storage: fs,
|
storage: fs,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user