Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
agent: add memory hotplug probe interface check in GetGuestDetails
Browse files Browse the repository at this point in the history
There are 2 phases in Memory Hotplug. 1) Physical Memory Hotplug phase.
2) Logical Memory Hotplug phase.
The First phase is to communicate hardware/firmware and make/erase
environment for hotplugged memory.
If firmware supports notification of connection of new memory to OS,
this phase is triggered automatically. ACPI can notify this event.
This also what kata supports on amd64, memory hotplug via acpi-driven.
But if not, there is another option, probe operation by hand.
And since memory hotplug via acpi is missing on qemu-system-aarch64,
we hope to support the other probe solution.
This whole implementation of memory hotplug via probe interface is
divided into two phases, the first is to check if guest kernel
is capable of memory hot-add via probe interface, which is located at
/sys/devices/system/memory/probe.

Fixes: #442

Signed-off-by: Penny Zheng <[email protected]>
  • Loading branch information
Pennyzct committed Jan 29, 2019
1 parent a581aeb commit 6007523
Show file tree
Hide file tree
Showing 3 changed files with 276 additions and 171 deletions.
21 changes: 16 additions & 5 deletions grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ const (
)

var (
sysfsCPUOnlinePath = "/sys/devices/system/cpu"
sysfsMemOnlinePath = "/sys/devices/system/memory"
sysfsMemoryBlockSizePath = "/sys/devices/system/memory/block_size_bytes"
sysfsConnectedCPUsPath = filepath.Join(sysfsCPUOnlinePath, "online")
containersRootfsPath = "/run"
sysfsCPUOnlinePath = "/sys/devices/system/cpu"
sysfsMemOnlinePath = "/sys/devices/system/memory"
sysfsMemoryBlockSizePath = "/sys/devices/system/memory/block_size_bytes"
sysfsMemoryHotplugProbePath = "/sys/devices/system/memory/probe"
sysfsConnectedCPUsPath = filepath.Join(sysfsCPUOnlinePath, "online")
containersRootfsPath = "/run"
)

type onlineResource struct {
Expand Down Expand Up @@ -1414,6 +1415,16 @@ func (a *agentGRPC) GetGuestDetails(ctx context.Context, req *pb.GuestDetailsReq
}
}

if req.MemHotplugProbe {
if _, err := os.Stat(sysfsMemoryHotplugProbePath); os.IsNotExist(err) {
details.SupportMemHotplugProbe = false
} else if err != nil {
return nil, err
} else {
details.SupportMemHotplugProbe = true
}
}

details.AgentDetails = a.getAgentDetails(ctx)

return &details, nil
Expand Down
Loading

0 comments on commit 6007523

Please sign in to comment.