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

Commit

Permalink
memory: Fix update memory path.
Browse files Browse the repository at this point in the history
When memory is hot added the udevpath is:

 uevent-devpath=/devices/system/memory/memory81

But when the agent checks for the path it expects it
has to check in the /sys filesystem.

Fixes: #388

Signed-off-by: Jose Carlos Venegas Munoz <[email protected]>
  • Loading branch information
jcvenegas committed Sep 29, 2018
1 parent 2fc2fd7 commit e03f7d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const (

var (
// cgroup fs is mounted at /sys/fs when systemd is the init process
cgroupPath = "/sys/fs/cgroup"
sysfsDir = "/sys"
cgroupPath = sysfsDir + "/fs/cgroup"
cgroupCpusetPath = cgroupPath + "/cpuset"
cgroupMemoryPath = cgroupPath + "/memory"
cgroupMemoryUseHierarchyPath = cgroupMemoryPath + "/memory.use_hierarchy"
Expand All @@ -56,7 +57,7 @@ var (

var initRootfsMounts = []initMount{
{"proc", "proc", "/proc", []string{"nosuid", "nodev", "noexec"}},
{"sysfs", "sysfs", "/sys", []string{"nosuid", "nodev", "noexec"}},
{"sysfs", "sysfs", sysfsDir, []string{"nosuid", "nodev", "noexec"}},
{"devtmpfs", "dev", "/dev", []string{"nosuid"}},
{"tmpfs", "tmpfs", "/dev/shm", []string{"nosuid", "nodev"}},
{"devpts", "devpts", "/dev/pts", []string{"nosuid", "noexec"}},
Expand Down Expand Up @@ -541,9 +542,8 @@ func (s *sandbox) listenToUdevEvents() {
}

s.Unlock()
} else if strings.HasPrefix(uEv.DevPath, sysfsMemOnlinePath) {
} else if onlinePath := filepath.Join(sysfsDir, uEv.DevPath, "online"); strings.HasPrefix(onlinePath, 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
10 changes: 5 additions & 5 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ const (
)

const (
rootBusPath = "/devices/pci0000:00"
pciBusRescanFile = "/sys/bus/pci/rescan"
pciBusMode = 0220
rootBusPath = "/devices/pci0000:00"
pciBusMode = 0220
)

var (
sysBusPrefix = "/sys/bus/pci/devices"
sysBusPrefix = sysfsDir + "/bus/pci/devices"
pciBusRescanFile = sysfsDir + "/bus/pci/rescan"
pciBusPathFormat = "%s/%s/pci_bus/"
systemDevPath = "/dev"
)
Expand All @@ -48,7 +48,7 @@ var (
// only one SCSI controller has been plugged, while the second number
// is always 0.
scsiHostChannel = "0:0:"
sysClassPrefix = "/sys/class"
sysClassPrefix = sysfsDir + "/class"
scsiDiskPrefix = filepath.Join(sysClassPrefix, "scsi_disk", scsiHostChannel)
scsiBlockSuffix = "block"
scsiDiskSuffix = filepath.Join("/device", scsiBlockSuffix)
Expand Down

0 comments on commit e03f7d7

Please sign in to comment.