Copies the value of 'cpuset.cpus' and 'cpuset.mems' from a parent cgroup to a child cgroup so the child cgroup can actually run tasks (otherwise it gets the error 'Device or resource busy'). @param hierarchy Path to hierarchy root. @param parentCgroup Path to parent cgroup relative to the hierarchy root. @param childCgroup Path to child cgroup relative to the hierarchy root. @return
| 237 | // @return Some if the operation succeeds. |
| 238 | // Error if the operation fails. |
| 239 | static Try<Nothing> cloneCpusetCpusMems( |
| 240 | const string& hierarchy, |
| 241 | const string& parentCgroup, |
| 242 | const string& childCgroup) |
| 243 | { |
| 244 | Try<string> cpus = cgroups::read(hierarchy, parentCgroup, "cpuset.cpus"); |
| 245 | if (cpus.isError()) { |
| 246 | return Error("Failed to read control 'cpuset.cpus': " + cpus.error()); |
| 247 | } |
| 248 | |
| 249 | Try<string> mems = cgroups::read(hierarchy, parentCgroup, "cpuset.mems"); |
| 250 | if (mems.isError()) { |
| 251 | return Error("Failed to read control 'cpuset.mems': " + mems.error()); |
| 252 | } |
| 253 | |
| 254 | Try<Nothing> write = |
| 255 | cgroups::write(hierarchy, childCgroup, "cpuset.cpus", cpus.get()); |
| 256 | if (write.isError()) { |
| 257 | return Error("Failed to write control 'cpuset.cpus': " + write.error()); |
| 258 | } |
| 259 | |
| 260 | write = cgroups::write(hierarchy, childCgroup, "cpuset.mems", mems.get()); |
| 261 | if (write.isError()) { |
| 262 | return Error("Failed to write control 'cpuset.mems': " + write.error()); |
| 263 | } |
| 264 | |
| 265 | return Nothing(); |
| 266 | } |
| 267 | |
| 268 | |
| 269 | // Removes a cgroup from a given hierachy. |