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;
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;

View File

@ -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;
}