From: Pavel Hrdina Date: Mon, 2 Nov 2020 22:06:19 +0000 (+0100) Subject: vircgroup: drop condition for absolute path from copyPlacement callbacks X-Git-Tag: v6.10.0-rc1~353 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=457877eae48d5cf3dc1ff687a8cc69def557a570;p=thirdparty%2Flibvirt.git vircgroup: drop condition for absolute path from copyPlacement callbacks Now that every caller to copyPlacement doesn't pass absolute path there is no need to have a condition to handle that case. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index ed4b0813f2..731e9d61d4 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -190,26 +190,24 @@ virCgroupV1CopyPlacement(virCgroupPtr group, { size_t i; for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { + bool delim; + if (!group->legacy[i].mountPoint) continue; if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) continue; - if (path[0] == '/') { - group->legacy[i].placement = g_strdup(path); - } else { - bool delim = STREQ(parent->legacy[i].placement, "/") || STREQ(path, ""); - /* - * parent == "/" + path="" => "/" - * parent == "/libvirt.service" + path == "" => "/libvirt.service" - * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo" - */ - group->legacy[i].placement = g_strdup_printf("%s%s%s", - parent->legacy[i].placement, - delim ? "" : "/", - path); - } + delim = STREQ(parent->legacy[i].placement, "/") || STREQ(path, ""); + /* + * parent == "/" + path="" => "/" + * parent == "/libvirt.service" + path == "" => "/libvirt.service" + * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo" + */ + group->legacy[i].placement = g_strdup_printf("%s%s%s", + parent->legacy[i].placement, + delim ? "" : "/", + path); } return 0; diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 8e058ca9c6..2b32f614e4 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -149,22 +149,19 @@ virCgroupV2CopyPlacement(virCgroupPtr group, const char *path, virCgroupPtr parent) { + bool delim = STREQ(parent->unified.placement, "/") || STREQ(path, ""); + VIR_DEBUG("group=%p path=%s parent=%p", group, path, parent); - if (path[0] == '/') { - group->unified.placement = g_strdup(path); - } else { - bool delim = STREQ(parent->unified.placement, "/") || STREQ(path, ""); - /* - * parent == "/" + path="" => "/" - * parent == "/libvirt.service" + path == "" => "/libvirt.service" - * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo" - */ - group->unified.placement = g_strdup_printf("%s%s%s", - parent->unified.placement, - delim ? "" : "/", - path); - } + /* + * parent == "/" + path="" => "/" + * parent == "/libvirt.service" + path == "" => "/libvirt.service" + * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo" + */ + group->unified.placement = g_strdup_printf("%s%s%s", + parent->unified.placement, + delim ? "" : "/", + path); return 0; }