[libvirt] [PATCH 0/2] [Bug 1760233] Better support for non-systemd distributions

Hi everybody, The following patches try to enhance the support for non-systemd configurations. The first patch just removes the references to the cgroups created by systemd, only leaving the reference to /machine cgroup, created by libvirtd for hosted virtual machines. The second one ensures the creation of that group when using cgroups-v2, as the error message provided in bug report[1] is raised by checking too early the existence of the file cgroup.controllers, before the actual creation of the control group. I tried to solve it at the highest abstraction level, by chaining properly the object construction. Happy hacking! Miguel [1] https://bugzilla.redhat.com/show_bug.cgi?id=1760233 Miguel Ángel Arruga Vivas (2): doc: cgroups: Remove unwanted references to systemd vircgroup: Ensure /machine group is associated with its parent docs/cgroups.html.in | 13 +++---------- src/util/vircgroup.c | 8 +++++--- 2 files changed, 8 insertions(+), 13 deletions(-) -- 2.23.0

The non-systemd configurations do not create system neither user control groups. The title of the diagram referenced systemd too. Signed-off-by: Miguel Ángel Arruga Vivas <rosen644835@gmail.com> --- docs/cgroups.html.in | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/docs/cgroups.html.in b/docs/cgroups.html.in index 081ba2eae1..78dede1bba 100644 --- a/docs/cgroups.html.in +++ b/docs/cgroups.html.in @@ -155,24 +155,17 @@ $ROOT named <code>$VMNAME.libvirt-{qemu,lxc}</code>. Each consumer is associated with exactly one partition, which also have a corresponding cgroup usually named <code>$PARTNAME.partition</code>. The exceptions to this naming rule - are the three top level default partitions, named <code>/system</code> (for - system services), <code>/user</code> (for user login sessions) and - <code>/machine</code> (for virtual machines and containers). By default - every consumer will of course be associated with the <code>/machine</code> - partition. + is the top level default partition for virtual machines and containers + <code>/machine</code>. </p> <p> - Given this, a possible systemd cgroups layout involving 3 qemu guests, + Given this, a possible non-systemd cgroups layout involving 3 qemu guests, 3 lxc containers and 2 custom child slices, would be: </p> <pre> $ROOT - | - +- system - | | - | +- libvirtd.service | +- machine | -- 2.23.0

Call first virCgroupNew on the parent group virCgroupNewPartition if it is available on before the creation of the child group. This ensures that the creation of a first level group on the unified architecture, as the check at virCgroupV2ParseControllersFile as the parent file is there. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1760233 Signed-off-by: Miguel Ángel Arruga Vivas <rosen644835@gmail.com> --- src/util/vircgroup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index b46f20abfd..33c61f2d45 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -855,9 +855,6 @@ virCgroupNewPartition(const char *path, if (virCgroupSetPartitionSuffix(path, &newPath) < 0) goto cleanup; - if (virCgroupNew(-1, newPath, NULL, controllers, group) < 0) - goto cleanup; - if (STRNEQ(newPath, "/")) { char *tmp; parentPath = g_strdup(newPath); @@ -868,7 +865,12 @@ virCgroupNewPartition(const char *path, if (virCgroupNew(-1, parentPath, NULL, controllers, &parent) < 0) goto cleanup; + } + if (virCgroupNew(-1, newPath, parent, controllers, group) < 0) + goto cleanup; + + if (parent) { if (virCgroupMakeGroup(parent, *group, create, VIR_CGROUP_NONE) < 0) goto cleanup; } -- 2.23.0

On 11/4/19 3:55 PM, Miguel Ángel Arruga Vivas wrote:
Hi everybody,
The following patches try to enhance the support for non-systemd configurations.
The first patch just removes the references to the cgroups created by systemd, only leaving the reference to /machine cgroup, created by libvirtd for hosted virtual machines.
The second one ensures the creation of that group when using cgroups-v2, as the error message provided in bug report[1] is raised by checking too early the existence of the file cgroup.controllers, before the actual creation of the control group. I tried to solve it at the highest abstraction level, by chaining properly the object construction.
Happy hacking! Miguel
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1760233
Miguel Ángel Arruga Vivas (2): doc: cgroups: Remove unwanted references to systemd vircgroup: Ensure /machine group is associated with its parent
docs/cgroups.html.in | 13 +++---------- src/util/vircgroup.c | 8 +++++--- 2 files changed, 8 insertions(+), 13 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and pushed. I've tested on my non-systemd machine and everything works just fine. Congratulations on your first libvirt contribution. Michal
participants (2)
-
Michal Privoznik
-
Miguel Ángel Arruga Vivas