[libvirt] [PATCH 9/9] vircgrouptest: call virCgroupNewSelf instead virCgroupDetectMounts
Fabiano Fidêncio
fidencio at redhat.com
Wed Sep 19 11:37:00 UTC 2018
On Tue, Sep 18, 2018 at 2:18 PM, Pavel Hrdina <phrdina at redhat.com> wrote:
> This will be required once cgroup v2 is introduced. The cgroup
> detection is not simple and we will have multiple backends so we
> should not just jump into the middle of the detection code.
>
> In order to use virCgroupNewSelf we need to create all the remaining
> data files.
>
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
> src/libvirt_private.syms | 1 -
> src/util/vircgroup.c | 11 +----------
> src/util/vircgrouppriv.h | 2 --
> tests/vircgroupdata/cgroups1.cgroups | 11 +++++++++++
> tests/vircgroupdata/cgroups1.self.cgroup | 11 +++++++++++
> tests/vircgroupdata/cgroups2.cgroups | 10 ++++++++++
> tests/vircgroupdata/cgroups2.self.cgroup | 10 ++++++++++
> tests/vircgroupdata/cgroups3.cgroups | 12 ++++++++++++
> tests/vircgroupdata/cgroups3.self.cgroup | 12 ++++++++++++
> tests/vircgroupdata/fedora-18.cgroups | 10 ++++++++++
> tests/vircgroupdata/fedora-18.self.cgroup | 9 +++++++++
> tests/vircgroupdata/fedora-21.cgroups | 12 ++++++++++++
> tests/vircgroupdata/fedora-21.self.cgroup | 10 ++++++++++
> tests/vircgroupdata/kubevirt.cgroups | 10 ++++++++++
> tests/vircgroupdata/kubevirt.self.cgroup | 10 ++++++++++
> tests/vircgroupdata/ovirt-node-6.6.cgroups | 9 +++++++++
> tests/vircgroupdata/ovirt-node-6.6.self.cgroup | 8 ++++++++
> tests/vircgroupdata/ovirt-node-7.1.cgroups | 11 +++++++++++
> tests/vircgroupdata/ovirt-node-7.1.self.cgroup | 10 ++++++++++
> tests/vircgroupdata/rhel-7.1.cgroups | 11 +++++++++++
> tests/vircgroupdata/rhel-7.1.self.cgroup | 10 ++++++++++
> tests/vircgrouptest.c | 6 +-----
> 22 files changed, 188 insertions(+), 18 deletions(-)
> create mode 100644 tests/vircgroupdata/cgroups1.cgroups
> create mode 100644 tests/vircgroupdata/cgroups1.self.cgroup
> create mode 100644 tests/vircgroupdata/cgroups2.cgroups
> create mode 100644 tests/vircgroupdata/cgroups2.self.cgroup
> create mode 100644 tests/vircgroupdata/cgroups3.cgroups
> create mode 100644 tests/vircgroupdata/cgroups3.self.cgroup
> create mode 100644 tests/vircgroupdata/fedora-18.cgroups
> create mode 100644 tests/vircgroupdata/fedora-18.self.cgroup
> create mode 100644 tests/vircgroupdata/fedora-21.cgroups
> create mode 100644 tests/vircgroupdata/fedora-21.self.cgroup
> create mode 100644 tests/vircgroupdata/kubevirt.cgroups
> create mode 100644 tests/vircgroupdata/kubevirt.self.cgroup
> create mode 100644 tests/vircgroupdata/ovirt-node-6.6.cgroups
> create mode 100644 tests/vircgroupdata/ovirt-node-6.6.self.cgroup
> create mode 100644 tests/vircgroupdata/ovirt-node-7.1.cgroups
> create mode 100644 tests/vircgroupdata/ovirt-node-7.1.self.cgroup
> create mode 100644 tests/vircgroupdata/rhel-7.1.cgroups
> create mode 100644 tests/vircgroupdata/rhel-7.1.self.cgroup
>
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 7f3b5738c4..75c59fbf89 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1513,7 +1513,6 @@ virCgroupDelThread;
> virCgroupDenyAllDevices;
> virCgroupDenyDevice;
> virCgroupDenyDevicePath;
> -virCgroupDetectMounts;
> virCgroupFree;
> virCgroupGetBlkioDeviceReadBps;
> virCgroupGetBlkioDeviceReadIops;
> diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
> index f8ef76136b..e85e0bde24 100644
> --- a/src/util/vircgroup.c
> +++ b/src/util/vircgroup.c
> @@ -429,7 +429,7 @@ virCgroupMountOptsMatchController(const char *mntOpts,
> * Process /proc/mounts figuring out what controllers are
> * mounted and where
> */
> -int
> +static int
> virCgroupDetectMounts(virCgroupPtr group)
> {
> size_t i;
> @@ -4072,15 +4072,6 @@ virCgroupAvailable(void)
> }
>
>
> -int
> -virCgroupDetectMounts(virCgroupPtr group ATTRIBUTE_UNUSED)
> -{
> - virReportSystemError(ENXIO, "%s",
> - _("Control groups not supported on this
> platform"));
> - return -1;
> -}
> -
> -
> int
> virCgroupNewPartition(const char *path ATTRIBUTE_UNUSED,
> bool create ATTRIBUTE_UNUSED,
> diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
> index f78fe8bb9c..046c96c52c 100644
> --- a/src/util/vircgrouppriv.h
> +++ b/src/util/vircgrouppriv.h
> @@ -50,8 +50,6 @@ struct _virCgroup {
> virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
> };
>
> -int virCgroupDetectMounts(virCgroupPtr group);
> -
> int virCgroupNewPartition(const char *path,
> bool create,
> int controllers,
> diff --git a/tests/vircgroupdata/cgroups1.cgroups
> b/tests/vircgroupdata/cgroups1.cgroups
> new file mode 100644
> index 0000000000..a03c290a98
> --- /dev/null
> +++ b/tests/vircgroupdata/cgroups1.cgroups
> @@ -0,0 +1,11 @@
> +#subsys_name hierarchy num_cgroups enabled
> +cpuset 1 1 1
> +cpu 2 1 1
> +cpuacct 3 1 1
> +blkio 8 1 1
> +memory 4 1 1
> +devices 5 1 1
> +freezer 6 1 1
> +net_cls 7 1 1
> +net_prio 9 1 1
> +hugetlb 10 1 1
> diff --git a/tests/vircgroupdata/cgroups1.self.cgroup
> b/tests/vircgroupdata/cgroups1.self.cgroup
> new file mode 100644
> index 0000000000..181f0c22f8
> --- /dev/null
> +++ b/tests/vircgroupdata/cgroups1.self.cgroup
> @@ -0,0 +1,11 @@
> +10:hugetlb:/
> +9:net_prio:/
> +8:blkio:/
> +7:net_cls:/
> +6:freezer:/
> +5:devices:/
> +4:memory:/
> +3:cpuacct:/
> +2:cpu:/
> +1:cpuset:/
> +0:name=openrc:/
> diff --git a/tests/vircgroupdata/cgroups2.cgroups
> b/tests/vircgroupdata/cgroups2.cgroups
> new file mode 100644
> index 0000000000..f0a7699559
> --- /dev/null
> +++ b/tests/vircgroupdata/cgroups2.cgroups
> @@ -0,0 +1,10 @@
> +#subsys_name hierarchy num_cgroups enabled
> +cpuset 1 1 1
> +cpu 2 1 1
> +cpuacct 3 1 1
> +blkio 7 1 1
> +memory 4 1 1
> +devices 5 1 1
> +freezer 6 1 1
> +perf_event 8 1 1
> +hugetlb 9 1 1
> diff --git a/tests/vircgroupdata/cgroups2.self.cgroup
> b/tests/vircgroupdata/cgroups2.self.cgroup
> new file mode 100644
> index 0000000000..3d0e793e5a
> --- /dev/null
> +++ b/tests/vircgroupdata/cgroups2.self.cgroup
> @@ -0,0 +1,10 @@
> +9:hugetlb:/
> +8:perf_event:/
> +7:blkio:/
> +6:freezer:/
> +5:devices:/
> +4:memory:/
> +3:cpuacct:/
> +2:cpu:/
> +1:cpuset:/
> +0:name=openrc:/
> diff --git a/tests/vircgroupdata/cgroups3.cgroups
> b/tests/vircgroupdata/cgroups3.cgroups
> new file mode 100644
> index 0000000000..294d95dedf
> --- /dev/null
> +++ b/tests/vircgroupdata/cgroups3.cgroups
> @@ -0,0 +1,12 @@
> +#subsys_name hierarchy num_cgroups enabled
> +cpuset 1 1 1
> +cpu 2 1 1
> +cpuacct 3 1 1
> +blkio 8 1 1
> +memory 4 1 1
> +devices 5 1 1
> +freezer 6 1 1
> +net_cls 7 1 1
> +perf_event 9 1 1
> +net_prio 10 1 1
> +hugetlb 11 1 1
> diff --git a/tests/vircgroupdata/cgroups3.self.cgroup
> b/tests/vircgroupdata/cgroups3.self.cgroup
> new file mode 100644
> index 0000000000..bf346abdf9
> --- /dev/null
> +++ b/tests/vircgroupdata/cgroups3.self.cgroup
> @@ -0,0 +1,12 @@
> +11:hugetlb:/
> +10:net_prio:/
> +9:perf_event:/
> +8:blkio:/
> +7:net_cls:/
> +6:freezer:/
> +5:devices:/
> +4:memory:/
> +3:cpuacct:/
> +2:cpu:/
> +1:cpuset:/
> +0:name=openrc:/
> diff --git a/tests/vircgroupdata/fedora-18.cgroups
> b/tests/vircgroupdata/fedora-18.cgroups
> new file mode 100644
> index 0000000000..8eb41087f3
> --- /dev/null
> +++ b/tests/vircgroupdata/fedora-18.cgroups
> @@ -0,0 +1,10 @@
> +#subsys_name hierarchy num_cgroups enabled
> +cpuset 1 1 1
> +cpu 2 1 1
> +cpuacct 2 1 1
> +blkio 7 1 1
> +memory 3 1 1
> +devices 4 1 1
> +freezer 5 1 1
> +net_cls 6 1 1
> +perf_event 8 1 1
> diff --git a/tests/vircgroupdata/fedora-18.self.cgroup
> b/tests/vircgroupdata/fedora-18.self.cgroup
> new file mode 100644
> index 0000000000..da9ad8ad4d
> --- /dev/null
> +++ b/tests/vircgroupdata/fedora-18.self.cgroup
> @@ -0,0 +1,9 @@
> +8:perf_event:/
> +7:blkio:/
> +6:net_cls:/
> +5:freezer:/
> +4:devices:/
> +3:memory:/
> +2:cpu,cpuacct:/
> +1:cpuset:/
> +0:name=systemd:/
> diff --git a/tests/vircgroupdata/fedora-21.cgroups
> b/tests/vircgroupdata/fedora-21.cgroups
> new file mode 100644
> index 0000000000..3e1401ee98
> --- /dev/null
> +++ b/tests/vircgroupdata/fedora-21.cgroups
> @@ -0,0 +1,12 @@
> +#subsys_name hierarchy num_cgroups enabled
> +cpuset 1 1 1
> +cpu 2 1 1
> +cpuacct 2 1 1
> +blkio 7 1 1
> +memory 3 1 1
> +devices 4 1 1
> +freezer 5 1 1
> +net_cls 6 1 1
> +perf_event 8 1 1
> +net_prio 6 1 1
> +hugetlb 9 1 1
> diff --git a/tests/vircgroupdata/fedora-21.self.cgroup
> b/tests/vircgroupdata/fedora-21.self.cgroup
> new file mode 100644
> index 0000000000..4c666bd59e
> --- /dev/null
> +++ b/tests/vircgroupdata/fedora-21.self.cgroup
> @@ -0,0 +1,10 @@
> +9:hugetlb:/
> +8:perf_event:/
> +7:blkio:/
> +6:net_cls,net_prio:/
> +5:freezer:/
> +4:devices:/
> +3:memory:/
> +2:cpu,cpuacct:/
> +1:cpuset:/
> +0:name=systemd:/
> diff --git a/tests/vircgroupdata/kubevirt.cgroups
> b/tests/vircgroupdata/kubevirt.cgroups
> new file mode 100644
> index 0000000000..f0a7699559
> --- /dev/null
> +++ b/tests/vircgroupdata/kubevirt.cgroups
> @@ -0,0 +1,10 @@
> +#subsys_name hierarchy num_cgroups enabled
> +cpuset 1 1 1
> +cpu 2 1 1
> +cpuacct 3 1 1
> +blkio 7 1 1
> +memory 4 1 1
> +devices 5 1 1
> +freezer 6 1 1
> +perf_event 8 1 1
> +hugetlb 9 1 1
> diff --git a/tests/vircgroupdata/kubevirt.self.cgroup
> b/tests/vircgroupdata/kubevirt.self.cgroup
> new file mode 100644
> index 0000000000..3d0e793e5a
> --- /dev/null
> +++ b/tests/vircgroupdata/kubevirt.self.cgroup
> @@ -0,0 +1,10 @@
> +9:hugetlb:/
> +8:perf_event:/
> +7:blkio:/
> +6:freezer:/
> +5:devices:/
> +4:memory:/
> +3:cpuacct:/
> +2:cpu:/
> +1:cpuset:/
> +0:name=openrc:/
> diff --git a/tests/vircgroupdata/ovirt-node-6.6.cgroups
> b/tests/vircgroupdata/ovirt-node-6.6.cgroups
> new file mode 100644
> index 0000000000..aaabf11a44
> --- /dev/null
> +++ b/tests/vircgroupdata/ovirt-node-6.6.cgroups
> @@ -0,0 +1,9 @@
> +#subsys_name hierarchy num_cgroups enabled
> +cpuset 0 1 1
> +cpu 1 1 1
> +cpuacct 2 1 1
> +blkio 7 1 1
> +memory 3 1 1
> +devices 4 1 1
> +freezer 5 1 1
> +net_cls 6 1 1
> diff --git a/tests/vircgroupdata/ovirt-node-6.6.self.cgroup
> b/tests/vircgroupdata/ovirt-node-6.6.self.cgroup
> new file mode 100644
> index 0000000000..dadc8155fa
> --- /dev/null
> +++ b/tests/vircgroupdata/ovirt-node-6.6.self.cgroup
> @@ -0,0 +1,8 @@
> +7:blkio:/
> +6:net_cls:/
> +5:freezer:/
> +4:devices:/
> +3:memory:/
> +2:cpuacct:/
> +1:cpu:/
> +0:cpuset:/
> diff --git a/tests/vircgroupdata/ovirt-node-7.1.cgroups
> b/tests/vircgroupdata/ovirt-node-7.1.cgroups
> new file mode 100644
> index 0000000000..687297ad4a
> --- /dev/null
> +++ b/tests/vircgroupdata/ovirt-node-7.1.cgroups
> @@ -0,0 +1,11 @@
> +#subsys_name hierarchy num_cgroups enabled
> +cpuset 1 1 1
> +cpu 2 1 1
> +cpuacct 2 1 1
> +blkio 7 1 1
> +memory 3 1 1
> +devices 4 1 1
> +freezer 5 1 1
> +net_cls 6 1 1
> +perf_event 8 1 1
> +hugetlb 9 1 1
> diff --git a/tests/vircgroupdata/ovirt-node-7.1.self.cgroup
> b/tests/vircgroupdata/ovirt-node-7.1.self.cgroup
> new file mode 100644
> index 0000000000..f07e8e20f5
> --- /dev/null
> +++ b/tests/vircgroupdata/ovirt-node-7.1.self.cgroup
> @@ -0,0 +1,10 @@
> +9:hugetlb:/
> +8:perf_event:/
> +7:blkio:/
> +6:net_cls:/
> +5:freezer:/
> +4:devices:/
> +3:memory:/
> +2:cpu,cpuacct:/
> +1:cpuset:/
> +0:name=systemd:/
> diff --git a/tests/vircgroupdata/rhel-7.1.cgroups
> b/tests/vircgroupdata/rhel-7.1.cgroups
> new file mode 100644
> index 0000000000..687297ad4a
> --- /dev/null
> +++ b/tests/vircgroupdata/rhel-7.1.cgroups
> @@ -0,0 +1,11 @@
> +#subsys_name hierarchy num_cgroups enabled
> +cpuset 1 1 1
> +cpu 2 1 1
> +cpuacct 2 1 1
> +blkio 7 1 1
> +memory 3 1 1
> +devices 4 1 1
> +freezer 5 1 1
> +net_cls 6 1 1
> +perf_event 8 1 1
> +hugetlb 9 1 1
> diff --git a/tests/vircgroupdata/rhel-7.1.self.cgroup
> b/tests/vircgroupdata/rhel-7.1.self.cgroup
> new file mode 100644
> index 0000000000..f07e8e20f5
> --- /dev/null
> +++ b/tests/vircgroupdata/rhel-7.1.self.cgroup
> @@ -0,0 +1,10 @@
> +9:hugetlb:/
> +8:perf_event:/
> +7:blkio:/
> +6:net_cls:/
> +5:freezer:/
> +4:devices:/
> +3:memory:/
> +2:cpu,cpuacct:/
> +1:cpuset:/
> +0:name=systemd:/
> diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
> index 6a38091a86..bbbe6ffbe5 100644
> --- a/tests/vircgrouptest.c
> +++ b/tests/vircgrouptest.c
> @@ -175,10 +175,7 @@ testCgroupDetectMounts(const void *args)
> if (virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed", abs_srcdir,
> file) < 0)
> goto cleanup;
>
> - if (VIR_ALLOC(group) < 0)
> - goto cleanup;
> -
> - if (virCgroupDetectMounts(group) < 0)
> + if (virCgroupNewSelf(&group) < 0)
> goto cleanup;
>
> for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
> @@ -887,7 +884,6 @@ mymain(void)
> DETECT_MOUNTS("cgroups2");
> DETECT_MOUNTS("cgroups3");
> DETECT_MOUNTS("all-in-one");
> - DETECT_MOUNTS("no-cgroups");
>
I've talked to Pavel and sems that this change should not be part of this
patch.
However, if the tests is not removed, vircgrouptest will fail.
Maybe a way to go is adding the files which are missing for no-cgroups
tests and mark the test as expected to fail? (Maybe through a new macro
...)?
> DETECT_MOUNTS("kubevirt");
>
> setenv("VIR_CGROUP_MOCK_FILENAME", "systemd", 1);
> --
> 2.17.1
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180919/05a021c1/attachment-0001.htm>
More information about the libvir-list
mailing list