mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-20 15:54:19 +01:00
hypervisor: Add GetTotalMemoryMB to interface
It'll be useful to get the total memory provided to the guest (hotplugged + coldplugged). We'll use this information when calcualting how much memory we can add at a time when utilizing ACPI hotplug. Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
@@ -2166,6 +2166,10 @@ func (q *qemu) Disconnect(ctx context.Context) {
|
||||
q.qmpShutdown()
|
||||
}
|
||||
|
||||
func (q *qemu) GetTotalMemoryMB(ctx context.Context) uint32 {
|
||||
return q.config.MemorySize + uint32(q.state.HotpluggedMemory)
|
||||
}
|
||||
|
||||
// ResizeMemory gets a request to update the VM memory to reqMemMB
|
||||
// Memory update is managed with two approaches
|
||||
// Add memory to VM:
|
||||
@@ -2179,7 +2183,7 @@ func (q *qemu) Disconnect(ctx context.Context) {
|
||||
// A longer term solution is evaluate solutions like virtio-mem
|
||||
func (q *qemu) ResizeMemory(ctx context.Context, reqMemMB uint32, memoryBlockSizeMB uint32, probe bool) (uint32, MemoryDevice, error) {
|
||||
|
||||
currentMemory := q.config.MemorySize + uint32(q.state.HotpluggedMemory)
|
||||
currentMemory := q.GetTotalMemoryMB(ctx)
|
||||
if err := q.qmpSetup(); err != nil {
|
||||
return 0, MemoryDevice{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user