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
In order to support memory hotplug br probe interface, firstly, we
need to verify whether guest kernel is capable of that. Typically
we will check if the path /sys/devices/system/memory/probe exists

Fixes: #442

Signed-off-by: Penny Zheng <[email protected]>
  • Loading branch information
Pennyzct committed Jan 23, 2019
1 parent 91a87bc commit 34b3caa
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 34b3caa

Please sign in to comment.