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