Blame SOURCES/libvirt-vircgrouptest-call-virCgroupNewSelf-instead-virCgroupDetectMounts.patch

c313de
From e3b6a0736a5b8e23041006ac004cccf1e48ae528 Mon Sep 17 00:00:00 2001
c313de
Message-Id: <e3b6a0736a5b8e23041006ac004cccf1e48ae528@dist-git>
c313de
From: Pavel Hrdina <phrdina@redhat.com>
c313de
Date: Mon, 1 Jul 2019 17:06:20 +0200
c313de
Subject: [PATCH] vircgrouptest: call virCgroupNewSelf instead
c313de
 virCgroupDetectMounts
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
This will be required once cgroup v2 is introduced.  The cgroup
c313de
detection is not simple and we will have multiple backends so we
c313de
should not just jump into the middle of the detection code.
c313de
c313de
In order to use virCgroupNewSelf we need to create all the remaining
c313de
data files:
c313de
c313de
    - {name}.cgroups represents /proc/cgroups, it is a list of cgroup
c313de
      controllers compiled into kernel
c313de
c313de
    - {name}.self.cgroup represents /proc/self/cgroup, it describes
c313de
      cgroups to which the process belongs
c313de
c313de
For "no-cgroups" we need to modify the expected behavior because
c313de
virCgroupNewSelf() will fail if there are no controllers available.
c313de
c313de
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
(cherry picked from commit 8b62008d2bc5442f7755e579ea754ffd5e3f9691)
c313de
c313de
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c313de
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
Message-Id: <3d1ddcca1a1e323e607445c5d1089698122efdd8.1561993099.git.phrdina@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
---
c313de
 src/libvirt_private.syms                      |  1 -
c313de
 src/util/vircgroup.c                          | 11 +------
c313de
 src/util/vircgrouppriv.h                      |  2 --
c313de
 tests/vircgroupdata/cgroups1.cgroups          | 11 +++++++
c313de
 tests/vircgroupdata/cgroups1.self.cgroup      | 11 +++++++
c313de
 tests/vircgroupdata/cgroups2.cgroups          | 10 +++++++
c313de
 tests/vircgroupdata/cgroups2.self.cgroup      | 10 +++++++
c313de
 tests/vircgroupdata/cgroups3.cgroups          | 12 ++++++++
c313de
 tests/vircgroupdata/cgroups3.self.cgroup      | 12 ++++++++
c313de
 tests/vircgroupdata/fedora-18.cgroups         | 10 +++++++
c313de
 tests/vircgroupdata/fedora-18.self.cgroup     |  9 ++++++
c313de
 tests/vircgroupdata/fedora-21.cgroups         | 12 ++++++++
c313de
 tests/vircgroupdata/fedora-21.self.cgroup     | 10 +++++++
c313de
 tests/vircgroupdata/kubevirt.cgroups          | 10 +++++++
c313de
 tests/vircgroupdata/kubevirt.self.cgroup      | 10 +++++++
c313de
 tests/vircgroupdata/no-cgroups.cgroups        |  8 +++++
c313de
 tests/vircgroupdata/no-cgroups.parsed         | 10 -------
c313de
 tests/vircgroupdata/no-cgroups.self.cgroup    |  0
c313de
 tests/vircgroupdata/ovirt-node-6.6.cgroups    |  9 ++++++
c313de
 .../vircgroupdata/ovirt-node-6.6.self.cgroup  |  8 +++++
c313de
 tests/vircgroupdata/ovirt-node-7.1.cgroups    | 11 +++++++
c313de
 .../vircgroupdata/ovirt-node-7.1.self.cgroup  | 10 +++++++
c313de
 tests/vircgroupdata/rhel-7.1.cgroups          | 11 +++++++
c313de
 tests/vircgroupdata/rhel-7.1.self.cgroup      | 10 +++++++
c313de
 tests/vircgrouptest.c                         | 30 ++++++++++++++-----
c313de
 25 files changed, 217 insertions(+), 31 deletions(-)
c313de
 create mode 100644 tests/vircgroupdata/cgroups1.cgroups
c313de
 create mode 100644 tests/vircgroupdata/cgroups1.self.cgroup
c313de
 create mode 100644 tests/vircgroupdata/cgroups2.cgroups
c313de
 create mode 100644 tests/vircgroupdata/cgroups2.self.cgroup
c313de
 create mode 100644 tests/vircgroupdata/cgroups3.cgroups
c313de
 create mode 100644 tests/vircgroupdata/cgroups3.self.cgroup
c313de
 create mode 100644 tests/vircgroupdata/fedora-18.cgroups
c313de
 create mode 100644 tests/vircgroupdata/fedora-18.self.cgroup
c313de
 create mode 100644 tests/vircgroupdata/fedora-21.cgroups
c313de
 create mode 100644 tests/vircgroupdata/fedora-21.self.cgroup
c313de
 create mode 100644 tests/vircgroupdata/kubevirt.cgroups
c313de
 create mode 100644 tests/vircgroupdata/kubevirt.self.cgroup
c313de
 create mode 100644 tests/vircgroupdata/no-cgroups.cgroups
c313de
 delete mode 100644 tests/vircgroupdata/no-cgroups.parsed
c313de
 create mode 100644 tests/vircgroupdata/no-cgroups.self.cgroup
c313de
 create mode 100644 tests/vircgroupdata/ovirt-node-6.6.cgroups
c313de
 create mode 100644 tests/vircgroupdata/ovirt-node-6.6.self.cgroup
c313de
 create mode 100644 tests/vircgroupdata/ovirt-node-7.1.cgroups
c313de
 create mode 100644 tests/vircgroupdata/ovirt-node-7.1.self.cgroup
c313de
 create mode 100644 tests/vircgroupdata/rhel-7.1.cgroups
c313de
 create mode 100644 tests/vircgroupdata/rhel-7.1.self.cgroup
c313de
c313de
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
c313de
index b66beb7f91..8c4be84fd5 100644
c313de
--- a/src/libvirt_private.syms
c313de
+++ b/src/libvirt_private.syms
c313de
@@ -1528,7 +1528,6 @@ virCgroupDelThread;
c313de
 virCgroupDenyAllDevices;
c313de
 virCgroupDenyDevice;
c313de
 virCgroupDenyDevicePath;
c313de
-virCgroupDetectMounts;
c313de
 virCgroupFree;
c313de
 virCgroupGetBlkioDeviceReadBps;
c313de
 virCgroupGetBlkioDeviceReadIops;
c313de
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
c313de
index 53f5faafd2..d55f411daa 100644
c313de
--- a/src/util/vircgroup.c
c313de
+++ b/src/util/vircgroup.c
c313de
@@ -429,7 +429,7 @@ virCgroupMountOptsMatchController(const char *mntOpts,
c313de
  * Process /proc/mounts figuring out what controllers are
c313de
  * mounted and where
c313de
  */
c313de
-int
c313de
+static int
c313de
 virCgroupDetectMounts(virCgroupPtr group)
c313de
 {
c313de
     size_t i;
c313de
@@ -4080,15 +4080,6 @@ virCgroupAvailable(void)
c313de
 }
c313de
 
c313de
 
c313de
-int
c313de
-virCgroupDetectMounts(virCgroupPtr group ATTRIBUTE_UNUSED)
c313de
-{
c313de
-    virReportSystemError(ENXIO, "%s",
c313de
-                         _("Control groups not supported on this platform"));
c313de
-    return -1;
c313de
-}
c313de
-
c313de
-
c313de
 int
c313de
 virCgroupNewPartition(const char *path ATTRIBUTE_UNUSED,
c313de
                       bool create ATTRIBUTE_UNUSED,
c313de
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
c313de
index f78fe8bb9c..046c96c52c 100644
c313de
--- a/src/util/vircgrouppriv.h
c313de
+++ b/src/util/vircgrouppriv.h
c313de
@@ -50,8 +50,6 @@ struct _virCgroup {
c313de
     virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
c313de
 };
c313de
 
c313de
-int virCgroupDetectMounts(virCgroupPtr group);
c313de
-
c313de
 int virCgroupNewPartition(const char *path,
c313de
                           bool create,
c313de
                           int controllers,
c313de
diff --git a/tests/vircgroupdata/cgroups1.cgroups b/tests/vircgroupdata/cgroups1.cgroups
c313de
new file mode 100644
c313de
index 0000000000..a03c290a98
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/cgroups1.cgroups
c313de
@@ -0,0 +1,11 @@
c313de
+#subsys_name    hierarchy       num_cgroups     enabled
c313de
+cpuset      1       1       1
c313de
+cpu         2       1       1
c313de
+cpuacct     3       1       1
c313de
+blkio       8       1       1
c313de
+memory      4       1       1
c313de
+devices     5       1       1
c313de
+freezer     6       1       1
c313de
+net_cls     7       1       1
c313de
+net_prio    9       1       1
c313de
+hugetlb     10      1       1
c313de
diff --git a/tests/vircgroupdata/cgroups1.self.cgroup b/tests/vircgroupdata/cgroups1.self.cgroup
c313de
new file mode 100644
c313de
index 0000000000..181f0c22f8
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/cgroups1.self.cgroup
c313de
@@ -0,0 +1,11 @@
c313de
+10:hugetlb:/
c313de
+9:net_prio:/
c313de
+8:blkio:/
c313de
+7:net_cls:/
c313de
+6:freezer:/
c313de
+5:devices:/
c313de
+4:memory:/
c313de
+3:cpuacct:/
c313de
+2:cpu:/
c313de
+1:cpuset:/
c313de
+0:name=openrc:/
c313de
diff --git a/tests/vircgroupdata/cgroups2.cgroups b/tests/vircgroupdata/cgroups2.cgroups
c313de
new file mode 100644
c313de
index 0000000000..f0a7699559
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/cgroups2.cgroups
c313de
@@ -0,0 +1,10 @@
c313de
+#subsys_name    hierarchy       num_cgroups     enabled
c313de
+cpuset      1       1       1
c313de
+cpu         2       1       1
c313de
+cpuacct     3       1       1
c313de
+blkio       7       1       1
c313de
+memory      4       1       1
c313de
+devices     5       1       1
c313de
+freezer     6       1       1
c313de
+perf_event  8       1       1
c313de
+hugetlb     9       1       1
c313de
diff --git a/tests/vircgroupdata/cgroups2.self.cgroup b/tests/vircgroupdata/cgroups2.self.cgroup
c313de
new file mode 100644
c313de
index 0000000000..3d0e793e5a
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/cgroups2.self.cgroup
c313de
@@ -0,0 +1,10 @@
c313de
+9:hugetlb:/
c313de
+8:perf_event:/
c313de
+7:blkio:/
c313de
+6:freezer:/
c313de
+5:devices:/
c313de
+4:memory:/
c313de
+3:cpuacct:/
c313de
+2:cpu:/
c313de
+1:cpuset:/
c313de
+0:name=openrc:/
c313de
diff --git a/tests/vircgroupdata/cgroups3.cgroups b/tests/vircgroupdata/cgroups3.cgroups
c313de
new file mode 100644
c313de
index 0000000000..294d95dedf
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/cgroups3.cgroups
c313de
@@ -0,0 +1,12 @@
c313de
+#subsys_name    hierarchy       num_cgroups     enabled
c313de
+cpuset      1       1       1
c313de
+cpu         2       1       1
c313de
+cpuacct     3       1       1
c313de
+blkio       8       1       1
c313de
+memory      4       1       1
c313de
+devices     5       1       1
c313de
+freezer     6       1       1
c313de
+net_cls     7       1       1
c313de
+perf_event  9       1       1
c313de
+net_prio    10      1       1
c313de
+hugetlb     11      1       1
c313de
diff --git a/tests/vircgroupdata/cgroups3.self.cgroup b/tests/vircgroupdata/cgroups3.self.cgroup
c313de
new file mode 100644
c313de
index 0000000000..bf346abdf9
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/cgroups3.self.cgroup
c313de
@@ -0,0 +1,12 @@
c313de
+11:hugetlb:/
c313de
+10:net_prio:/
c313de
+9:perf_event:/
c313de
+8:blkio:/
c313de
+7:net_cls:/
c313de
+6:freezer:/
c313de
+5:devices:/
c313de
+4:memory:/
c313de
+3:cpuacct:/
c313de
+2:cpu:/
c313de
+1:cpuset:/
c313de
+0:name=openrc:/
c313de
diff --git a/tests/vircgroupdata/fedora-18.cgroups b/tests/vircgroupdata/fedora-18.cgroups
c313de
new file mode 100644
c313de
index 0000000000..8eb41087f3
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/fedora-18.cgroups
c313de
@@ -0,0 +1,10 @@
c313de
+#subsys_name    hierarchy       num_cgroups     enabled
c313de
+cpuset      1       1       1
c313de
+cpu         2       1       1
c313de
+cpuacct     2       1       1
c313de
+blkio       7       1       1
c313de
+memory      3       1       1
c313de
+devices     4       1       1
c313de
+freezer     5       1       1
c313de
+net_cls     6       1       1
c313de
+perf_event  8       1       1
c313de
diff --git a/tests/vircgroupdata/fedora-18.self.cgroup b/tests/vircgroupdata/fedora-18.self.cgroup
c313de
new file mode 100644
c313de
index 0000000000..da9ad8ad4d
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/fedora-18.self.cgroup
c313de
@@ -0,0 +1,9 @@
c313de
+8:perf_event:/
c313de
+7:blkio:/
c313de
+6:net_cls:/
c313de
+5:freezer:/
c313de
+4:devices:/
c313de
+3:memory:/
c313de
+2:cpu,cpuacct:/
c313de
+1:cpuset:/
c313de
+0:name=systemd:/
c313de
diff --git a/tests/vircgroupdata/fedora-21.cgroups b/tests/vircgroupdata/fedora-21.cgroups
c313de
new file mode 100644
c313de
index 0000000000..3e1401ee98
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/fedora-21.cgroups
c313de
@@ -0,0 +1,12 @@
c313de
+#subsys_name    hierarchy       num_cgroups     enabled
c313de
+cpuset      1       1       1
c313de
+cpu         2       1       1
c313de
+cpuacct     2       1       1
c313de
+blkio       7       1       1
c313de
+memory      3       1       1
c313de
+devices     4       1       1
c313de
+freezer     5       1       1
c313de
+net_cls     6       1       1
c313de
+perf_event  8       1       1
c313de
+net_prio    6       1       1
c313de
+hugetlb     9       1       1
c313de
diff --git a/tests/vircgroupdata/fedora-21.self.cgroup b/tests/vircgroupdata/fedora-21.self.cgroup
c313de
new file mode 100644
c313de
index 0000000000..4c666bd59e
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/fedora-21.self.cgroup
c313de
@@ -0,0 +1,10 @@
c313de
+9:hugetlb:/
c313de
+8:perf_event:/
c313de
+7:blkio:/
c313de
+6:net_cls,net_prio:/
c313de
+5:freezer:/
c313de
+4:devices:/
c313de
+3:memory:/
c313de
+2:cpu,cpuacct:/
c313de
+1:cpuset:/
c313de
+0:name=systemd:/
c313de
diff --git a/tests/vircgroupdata/kubevirt.cgroups b/tests/vircgroupdata/kubevirt.cgroups
c313de
new file mode 100644
c313de
index 0000000000..f0a7699559
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/kubevirt.cgroups
c313de
@@ -0,0 +1,10 @@
c313de
+#subsys_name    hierarchy       num_cgroups     enabled
c313de
+cpuset      1       1       1
c313de
+cpu         2       1       1
c313de
+cpuacct     3       1       1
c313de
+blkio       7       1       1
c313de
+memory      4       1       1
c313de
+devices     5       1       1
c313de
+freezer     6       1       1
c313de
+perf_event  8       1       1
c313de
+hugetlb     9       1       1
c313de
diff --git a/tests/vircgroupdata/kubevirt.self.cgroup b/tests/vircgroupdata/kubevirt.self.cgroup
c313de
new file mode 100644
c313de
index 0000000000..3d0e793e5a
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/kubevirt.self.cgroup
c313de
@@ -0,0 +1,10 @@
c313de
+9:hugetlb:/
c313de
+8:perf_event:/
c313de
+7:blkio:/
c313de
+6:freezer:/
c313de
+5:devices:/
c313de
+4:memory:/
c313de
+3:cpuacct:/
c313de
+2:cpu:/
c313de
+1:cpuset:/
c313de
+0:name=openrc:/
c313de
diff --git a/tests/vircgroupdata/no-cgroups.cgroups b/tests/vircgroupdata/no-cgroups.cgroups
c313de
new file mode 100644
c313de
index 0000000000..3ed1d4e45e
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/no-cgroups.cgroups
c313de
@@ -0,0 +1,8 @@
c313de
+#subsys_name    hierarchy       num_cgroups     enabled
c313de
+cpuset      0       1       1
c313de
+cpu         0       1       1
c313de
+cpuacct     0       1       1
c313de
+memory      0       1       1
c313de
+devices     0       1       1
c313de
+freezer     0       1       1
c313de
+blkio       0       1       1
c313de
diff --git a/tests/vircgroupdata/no-cgroups.parsed b/tests/vircgroupdata/no-cgroups.parsed
c313de
deleted file mode 100644
c313de
index bf4eea085f..0000000000
c313de
--- a/tests/vircgroupdata/no-cgroups.parsed
c313de
+++ /dev/null
c313de
@@ -1,10 +0,0 @@
c313de
-cpu          <null>
c313de
-cpuacct      <null>
c313de
-cpuset       <null>
c313de
-memory       <null>
c313de
-devices      <null>
c313de
-freezer      <null>
c313de
-blkio        <null>
c313de
-net_cls      <null>
c313de
-perf_event   <null>
c313de
-name=systemd <null>
c313de
diff --git a/tests/vircgroupdata/no-cgroups.self.cgroup b/tests/vircgroupdata/no-cgroups.self.cgroup
c313de
new file mode 100644
c313de
index 0000000000..e69de29bb2
c313de
diff --git a/tests/vircgroupdata/ovirt-node-6.6.cgroups b/tests/vircgroupdata/ovirt-node-6.6.cgroups
c313de
new file mode 100644
c313de
index 0000000000..aaabf11a44
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/ovirt-node-6.6.cgroups
c313de
@@ -0,0 +1,9 @@
c313de
+#subsys_name    hierarchy       num_cgroups     enabled
c313de
+cpuset      0       1       1
c313de
+cpu         1       1       1
c313de
+cpuacct     2       1       1
c313de
+blkio       7       1       1
c313de
+memory      3       1       1
c313de
+devices     4       1       1
c313de
+freezer     5       1       1
c313de
+net_cls     6       1       1
c313de
diff --git a/tests/vircgroupdata/ovirt-node-6.6.self.cgroup b/tests/vircgroupdata/ovirt-node-6.6.self.cgroup
c313de
new file mode 100644
c313de
index 0000000000..dadc8155fa
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/ovirt-node-6.6.self.cgroup
c313de
@@ -0,0 +1,8 @@
c313de
+7:blkio:/
c313de
+6:net_cls:/
c313de
+5:freezer:/
c313de
+4:devices:/
c313de
+3:memory:/
c313de
+2:cpuacct:/
c313de
+1:cpu:/
c313de
+0:cpuset:/
c313de
diff --git a/tests/vircgroupdata/ovirt-node-7.1.cgroups b/tests/vircgroupdata/ovirt-node-7.1.cgroups
c313de
new file mode 100644
c313de
index 0000000000..687297ad4a
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/ovirt-node-7.1.cgroups
c313de
@@ -0,0 +1,11 @@
c313de
+#subsys_name    hierarchy       num_cgroups     enabled
c313de
+cpuset      1       1       1
c313de
+cpu         2       1       1
c313de
+cpuacct     2       1       1
c313de
+blkio       7       1       1
c313de
+memory      3       1       1
c313de
+devices     4       1       1
c313de
+freezer     5       1       1
c313de
+net_cls     6       1       1
c313de
+perf_event  8       1       1
c313de
+hugetlb     9       1       1
c313de
diff --git a/tests/vircgroupdata/ovirt-node-7.1.self.cgroup b/tests/vircgroupdata/ovirt-node-7.1.self.cgroup
c313de
new file mode 100644
c313de
index 0000000000..f07e8e20f5
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/ovirt-node-7.1.self.cgroup
c313de
@@ -0,0 +1,10 @@
c313de
+9:hugetlb:/
c313de
+8:perf_event:/
c313de
+7:blkio:/
c313de
+6:net_cls:/
c313de
+5:freezer:/
c313de
+4:devices:/
c313de
+3:memory:/
c313de
+2:cpu,cpuacct:/
c313de
+1:cpuset:/
c313de
+0:name=systemd:/
c313de
diff --git a/tests/vircgroupdata/rhel-7.1.cgroups b/tests/vircgroupdata/rhel-7.1.cgroups
c313de
new file mode 100644
c313de
index 0000000000..687297ad4a
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/rhel-7.1.cgroups
c313de
@@ -0,0 +1,11 @@
c313de
+#subsys_name    hierarchy       num_cgroups     enabled
c313de
+cpuset      1       1       1
c313de
+cpu         2       1       1
c313de
+cpuacct     2       1       1
c313de
+blkio       7       1       1
c313de
+memory      3       1       1
c313de
+devices     4       1       1
c313de
+freezer     5       1       1
c313de
+net_cls     6       1       1
c313de
+perf_event  8       1       1
c313de
+hugetlb     9       1       1
c313de
diff --git a/tests/vircgroupdata/rhel-7.1.self.cgroup b/tests/vircgroupdata/rhel-7.1.self.cgroup
c313de
new file mode 100644
c313de
index 0000000000..f07e8e20f5
c313de
--- /dev/null
c313de
+++ b/tests/vircgroupdata/rhel-7.1.self.cgroup
c313de
@@ -0,0 +1,10 @@
c313de
+9:hugetlb:/
c313de
+8:perf_event:/
c313de
+7:blkio:/
c313de
+6:net_cls:/
c313de
+5:freezer:/
c313de
+4:devices:/
c313de
+3:memory:/
c313de
+2:cpu,cpuacct:/
c313de
+1:cpuset:/
c313de
+0:name=systemd:/
c313de
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
c313de
index 6a38091a86..5031a2973d 100644
c313de
--- a/tests/vircgrouptest.c
c313de
+++ b/tests/vircgrouptest.c
c313de
@@ -159,26 +159,37 @@ const char *linksLogind[VIR_CGROUP_CONTROLLER_LAST] = {
c313de
 };
c313de
 
c313de
 
c313de
+struct _detectMountsData {
c313de
+    const char *file;
c313de
+    bool fail;
c313de
+};
c313de
+
c313de
+
c313de
 static int
c313de
 testCgroupDetectMounts(const void *args)
c313de
 {
c313de
     int result = -1;
c313de
-    const char *file = args;
c313de
+    const struct _detectMountsData *data = args;
c313de
     char *parsed = NULL;
c313de
     const char *actual;
c313de
     virCgroupPtr group = NULL;
c313de
     virBuffer buf = VIR_BUFFER_INITIALIZER;
c313de
     size_t i;
c313de
 
c313de
-    setenv("VIR_CGROUP_MOCK_FILENAME", file, 1);
c313de
+    setenv("VIR_CGROUP_MOCK_FILENAME", data->file, 1);
c313de
 
c313de
-    if (virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed", abs_srcdir, file) < 0)
c313de
+    if (virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed",
c313de
+                    abs_srcdir, data->file) < 0) {
c313de
         goto cleanup;
c313de
+    }
c313de
 
c313de
-    if (VIR_ALLOC(group) < 0)
c313de
+    if (virCgroupNewSelf(&group) < 0) {
c313de
+        if (data->fail)
c313de
+            result = 0;
c313de
         goto cleanup;
c313de
+    }
c313de
 
c313de
-    if (virCgroupDetectMounts(group) < 0)
c313de
+    if (data->fail)
c313de
         goto cleanup;
c313de
 
c313de
     for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
c313de
@@ -870,13 +881,16 @@ mymain(void)
c313de
 
c313de
     setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
c313de
 
c313de
-# define DETECT_MOUNTS(file) \
c313de
+# define DETECT_MOUNTS_FULL(file, fail) \
c313de
     do { \
c313de
+        struct _detectMountsData data = { file, fail }; \
c313de
         if (virTestRun("Detect cgroup mounts for " file, \
c313de
                        testCgroupDetectMounts, \
c313de
-                       file) < 0) \
c313de
+                       &data) < 0) \
c313de
             ret = -1; \
c313de
     } while (0)
c313de
+# define DETECT_MOUNTS(file) DETECT_MOUNTS_FULL(file, false);
c313de
+# define DETECT_MOUNTS_FAIL(file) DETECT_MOUNTS_FULL(file, true);
c313de
 
c313de
     DETECT_MOUNTS("ovirt-node-6.6");
c313de
     DETECT_MOUNTS("ovirt-node-7.1");
c313de
@@ -887,7 +901,7 @@ mymain(void)
c313de
     DETECT_MOUNTS("cgroups2");
c313de
     DETECT_MOUNTS("cgroups3");
c313de
     DETECT_MOUNTS("all-in-one");
c313de
-    DETECT_MOUNTS("no-cgroups");
c313de
+    DETECT_MOUNTS_FAIL("no-cgroups");
c313de
     DETECT_MOUNTS("kubevirt");
c313de
 
c313de
     setenv("VIR_CGROUP_MOCK_FILENAME", "systemd", 1);
c313de
-- 
c313de
2.22.0
c313de