]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virCgroupValidateMachineGroup: Reflect change in CGroup struct naming
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 5 May 2016 15:35:38 +0000 (17:35 +0200)
committerCole Robinson <crobinso@redhat.com>
Mon, 27 Jun 2016 18:36:04 +0000 (14:36 -0400)
Fron c3bd0019c0e on instead of creating the following path for
cgroups:

  /sys/fs/cgroupX/$name.libvirt-$driver

we generate rather more verbose one:

  /sys/fs/cgroupX/$driver-$id-$name.libvirt-$driver

where $name is optional and included iff contains allowed chars.
See original commit for more reasoning. Now, problem with the
original commit is that we are unable to start any LXC domain
after it. Because when starting LXC container, the CGroup layout
is created by our lxc_controller process and then detected and
validated by libvirtd. The validation is done by trying to match
detected layout against all the possible patterns for cgroup
paths that we've ever had. And the commit in question forgot to
update this part of the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit fb377701f253559268e903377707ed3d265823cd)

src/util/vircgroup.c

index bffd88f90a44599a228305a8e0c5556a51282009..0b10d7507ab259694ed5e4075fa1f28f61f7896e 100644 (file)
@@ -254,6 +254,7 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
     char *scopename_new = NULL;
     char *machinename = virSystemdMakeMachineName(drivername, id,
                                                   name, privileged);
+    char *partmachinename = NULL;
 
     if (virAsprintf(&partname, "%s.libvirt-%s",
                     name, drivername) < 0)
@@ -262,6 +263,12 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
     if (virCgroupPartitionEscape(&partname) < 0)
         goto cleanup;
 
+    if (machinename &&
+        (virAsprintf(&partmachinename, "%s.libvirt-%s",
+                     machinename, drivername) < 0 ||
+         virCgroupPartitionEscape(&partmachinename) < 0))
+        goto cleanup;
+
     if (!(scopename_old = virSystemdMakeScopeName(name, drivername, true)))
         goto cleanup;
 
@@ -308,6 +315,7 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
         if (STRNEQ(tmp, name) &&
             STRNEQ_NULLABLE(tmp, machinename) &&
             STRNEQ(tmp, partname) &&
+            STRNEQ_NULLABLE(tmp, partmachinename) &&
             STRNEQ(tmp, scopename_old) &&
             STRNEQ_NULLABLE(tmp, scopename_new)) {
             VIR_DEBUG("Name '%s' for controller '%s' does not match "
@@ -322,6 +330,7 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
     valid = true;
 
  cleanup:
+    VIR_FREE(partmachinename);
     VIR_FREE(partname);
     VIR_FREE(scopename_old);
     VIR_FREE(scopename_new);