On 08/09/2018 03:44 PM, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/vircgroup.c | 85 +++++++++++++++++++++++++-------------------
1 file changed, 48 insertions(+), 37 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 5144b33d43..fd58ba154f 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -356,6 +356,51 @@ virCgroupCopyMounts(virCgroupPtr group,
}
+static int
+virCgroupResolveMountLink(const char *mntDir,
@mntDir shouldn't be const char. You're changing it in the function,
even though not directly rather than via @dirName.
+ const char *typeStr,
+ virCgroupControllerPtr controller)
+{
+ VIR_AUTOFREE(char *) linkSrc = NULL;
+ char *dirName;
+ struct stat sb;
+
+ dirName = strrchr(mntDir, '/');
+ if (!dirName) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Missing '/' separator in cgroup mount
'%s'"), mntDir);
+ return -1;
+ }
+
+ if (!strchr(dirName + 1, ','))
+ return 0;
+
+ *dirName = '\0';
+ if (virAsprintf(&linkSrc, "%s/%s", mntDir, typeStr) < 0)
+ return -1;
+ *dirName = '/';
Pre-existing and probably doesn't matter, but if above virAsprintf()
fails, @dirName is not written back and thus @mntDir is left mangled.
+
+ if (lstat(linkSrc, &sb) < 0) {
+ if (errno == ENOENT) {
+ VIR_WARN("Controller %s co-mounted at %s is missing symlink at
%s",
+ typeStr, mntDir, linkSrc);
+ } else {
+ virReportSystemError(errno, _("Cannot stat %s"), linkSrc);
+ return -1;
+ }
+ } else {
+ if (!S_ISLNK(sb.st_mode)) {
+ VIR_WARN("Expecting a symlink at %s for controller %s",
+ linkSrc, typeStr);
+ } else {
+ VIR_STEAL_PTR(controller->linkPoint, linkSrc);
+ }
+ }
+
+ return 0;
+}
Michal