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 <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Pavel Hrdina 2020-11-02 23:06:19 +01:00
parent 6f0aa96f41
commit 457877eae4
2 changed files with 23 additions and 28 deletions

View File

@ -190,26 +190,24 @@ virCgroupV1CopyPlacement(virCgroupPtr group,
{ {
size_t i; size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
bool delim;
if (!group->legacy[i].mountPoint) if (!group->legacy[i].mountPoint)
continue; continue;
if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) if (i == VIR_CGROUP_CONTROLLER_SYSTEMD)
continue; continue;
if (path[0] == '/') { delim = STREQ(parent->legacy[i].placement, "/") || STREQ(path, "");
group->legacy[i].placement = g_strdup(path); /*
} else { * parent == "/" + path="" => "/"
bool delim = STREQ(parent->legacy[i].placement, "/") || STREQ(path, ""); * parent == "/libvirt.service" + path == "" => "/libvirt.service"
/* * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo"
* parent == "/" + path="" => "/" */
* parent == "/libvirt.service" + path == "" => "/libvirt.service" group->legacy[i].placement = g_strdup_printf("%s%s%s",
* parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo" parent->legacy[i].placement,
*/ delim ? "" : "/",
group->legacy[i].placement = g_strdup_printf("%s%s%s", path);
parent->legacy[i].placement,
delim ? "" : "/",
path);
}
} }
return 0; return 0;

View File

@ -149,22 +149,19 @@ virCgroupV2CopyPlacement(virCgroupPtr group,
const char *path, const char *path,
virCgroupPtr parent) virCgroupPtr parent)
{ {
bool delim = STREQ(parent->unified.placement, "/") || STREQ(path, "");
VIR_DEBUG("group=%p path=%s parent=%p", group, path, parent); VIR_DEBUG("group=%p path=%s parent=%p", group, path, parent);
if (path[0] == '/') { /*
group->unified.placement = g_strdup(path); * parent == "/" + path="" => "/"
} else { * parent == "/libvirt.service" + path == "" => "/libvirt.service"
bool delim = STREQ(parent->unified.placement, "/") || STREQ(path, ""); * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo"
/* */
* parent == "/" + path="" => "/" group->unified.placement = g_strdup_printf("%s%s%s",
* parent == "/libvirt.service" + path == "" => "/libvirt.service" parent->unified.placement,
* parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo" delim ? "" : "/",
*/ path);
group->unified.placement = g_strdup_printf("%s%s%s",
parent->unified.placement,
delim ? "" : "/",
path);
}
return 0; return 0;
} }