Skip to content

Commit

Permalink
agent: auto-online hotplug memory
Browse files Browse the repository at this point in the history
Kata agent does not wait for memory hotplug, and kata-runtime
does not wait on cpu/memory online. As a temporary fix, let's
make sure memory are onlined by the uevent listener at least.

Fixes: kata-containers#363

Signed-off-by: Peng Tao <bergwolf@gmail.com>
  • Loading branch information
bergwolf committed Sep 12, 2018
1 parent e3eb9ce commit 9cf56c0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ func (s *sandbox) listenToUdevEvents() {
continue
}

// We only care about add event
if uEv.Action != "add" {
continue
}

fieldLogger = fieldLogger.WithFields(logrus.Fields{
"uevent-action": uEv.Action,
"uevent-devpath": uEv.DevPath,
Expand All @@ -495,7 +500,7 @@ func (s *sandbox) listenToUdevEvents() {
})

// Check if device hotplug event results in a device node being created.
if uEv.DevName != "" && uEv.Action == "add" && strings.HasPrefix(uEv.DevPath, rootBusPath) {
if uEv.DevName != "" && strings.HasPrefix(uEv.DevPath, rootBusPath) {
// Lock is needed to safey read and modify the pciDeviceMap and deviceWatchers.
// This makes sure that watchers do not access the map while it is being updated.
s.Lock()
Expand All @@ -514,6 +519,12 @@ func (s *sandbox) listenToUdevEvents() {
}

s.Unlock()
} else if strings.HasPrefix(uEv.DevPath, sysfsMemOnlinePath) {
// Check memory hotplug and online if possible
onlinePath := filepath.Join("sys", uEv.DevPath, "online")
if err := ioutil.WriteFile(onlinePath, []byte("1"), 0600); err != nil {
fieldLogger.WithError(err).Error("failed online device")
}
}
}
}
Expand Down

0 comments on commit 9cf56c0

Please sign in to comment.