|
|
c480ed |
From 094b38a5c13a27f2f48897bd8cf811741a754db7 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <094b38a5c13a27f2f48897bd8cf811741a754db7@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:19 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgrouptest: call virCgroupDetectMounts directly
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Because we can set which files to return for cgroup tests there
|
|
|
c480ed |
is no need to have special function tailored to run tests.
|
|
|
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 4988f4b347d3c56af4bdb9852d1461f08f6cfced)
|
|
|
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: <5b3185e7dd49ac4d9a56532e6d77ad1aa098db95.1561993099.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/libvirt_private.syms | 2 +-
|
|
|
c480ed |
src/util/vircgroup.c | 21 +++++----------------
|
|
|
c480ed |
src/util/vircgrouppriv.h | 4 +---
|
|
|
c480ed |
tests/vircgrouptest.c | 16 ++++++++--------
|
|
|
c480ed |
4 files changed, 15 insertions(+), 28 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
c480ed |
index f8c1a0df16..b66beb7f91 100644
|
|
|
c480ed |
--- a/src/libvirt_private.syms
|
|
|
c480ed |
+++ b/src/libvirt_private.syms
|
|
|
c480ed |
@@ -1528,7 +1528,7 @@ virCgroupDelThread;
|
|
|
c480ed |
virCgroupDenyAllDevices;
|
|
|
c480ed |
virCgroupDenyDevice;
|
|
|
c480ed |
virCgroupDenyDevicePath;
|
|
|
c480ed |
-virCgroupDetectMountsFromFile;
|
|
|
c480ed |
+virCgroupDetectMounts;
|
|
|
c480ed |
virCgroupFree;
|
|
|
c480ed |
virCgroupGetBlkioDeviceReadBps;
|
|
|
c480ed |
virCgroupGetBlkioDeviceReadIops;
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index f08fe3600e..53f5faafd2 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -430,9 +430,7 @@ virCgroupMountOptsMatchController(const char *mntOpts,
|
|
|
c480ed |
* mounted and where
|
|
|
c480ed |
*/
|
|
|
c480ed |
int
|
|
|
c480ed |
-virCgroupDetectMountsFromFile(virCgroupPtr group,
|
|
|
c480ed |
- const char *path,
|
|
|
c480ed |
- bool checkLinks)
|
|
|
c480ed |
+virCgroupDetectMounts(virCgroupPtr group)
|
|
|
c480ed |
{
|
|
|
c480ed |
size_t i;
|
|
|
c480ed |
FILE *mounts = NULL;
|
|
|
c480ed |
@@ -440,9 +438,9 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
|
|
|
c480ed |
char buf[CGROUP_MAX_VAL];
|
|
|
c480ed |
int ret = -1;
|
|
|
c480ed |
|
|
|
c480ed |
- mounts = fopen(path, "r");
|
|
|
c480ed |
+ mounts = fopen("/proc/mounts", "r");
|
|
|
c480ed |
if (mounts == NULL) {
|
|
|
c480ed |
- virReportSystemError(errno, _("Unable to open %s"), path);
|
|
|
c480ed |
+ virReportSystemError(errno, "%s", _("Unable to open /proc/mounts"));
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
@@ -470,8 +468,7 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
|
|
|
c480ed |
|
|
|
c480ed |
/* If it is a co-mount it has a filename like "cpu,cpuacct"
|
|
|
c480ed |
* and we must identify the symlink path */
|
|
|
c480ed |
- if (checkLinks &&
|
|
|
c480ed |
- virCgroupResolveMountLink(entry.mnt_dir, typestr,
|
|
|
c480ed |
+ if (virCgroupResolveMountLink(entry.mnt_dir, typestr,
|
|
|
c480ed |
controller) < 0) {
|
|
|
c480ed |
goto cleanup;
|
|
|
c480ed |
}
|
|
|
c480ed |
@@ -485,12 +482,6 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
|
|
|
c480ed |
return ret;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
-static int
|
|
|
c480ed |
-virCgroupDetectMounts(virCgroupPtr group)
|
|
|
c480ed |
-{
|
|
|
c480ed |
- return virCgroupDetectMountsFromFile(group, "/proc/mounts", true);
|
|
|
c480ed |
-}
|
|
|
c480ed |
-
|
|
|
c480ed |
|
|
|
c480ed |
static int
|
|
|
c480ed |
virCgroupCopyPlacement(virCgroupPtr group,
|
|
|
c480ed |
@@ -4090,9 +4081,7 @@ virCgroupAvailable(void)
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
int
|
|
|
c480ed |
-virCgroupDetectMountsFromFile(virCgroupPtr group ATTRIBUTE_UNUSED,
|
|
|
c480ed |
- const char *path ATTRIBUTE_UNUSED,
|
|
|
c480ed |
- bool checkLinks ATTRIBUTE_UNUSED)
|
|
|
c480ed |
+virCgroupDetectMounts(virCgroupPtr group ATTRIBUTE_UNUSED)
|
|
|
c480ed |
{
|
|
|
c480ed |
virReportSystemError(ENXIO, "%s",
|
|
|
c480ed |
_("Control groups not supported on this platform"));
|
|
|
c480ed |
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
|
|
|
c480ed |
index a0034f3889..f78fe8bb9c 100644
|
|
|
c480ed |
--- a/src/util/vircgrouppriv.h
|
|
|
c480ed |
+++ b/src/util/vircgrouppriv.h
|
|
|
c480ed |
@@ -50,9 +50,7 @@ struct _virCgroup {
|
|
|
c480ed |
virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
-int virCgroupDetectMountsFromFile(virCgroupPtr group,
|
|
|
c480ed |
- const char *path,
|
|
|
c480ed |
- bool checkLinks);
|
|
|
c480ed |
+int virCgroupDetectMounts(virCgroupPtr group);
|
|
|
c480ed |
|
|
|
c480ed |
int virCgroupNewPartition(const char *path,
|
|
|
c480ed |
bool create,
|
|
|
c480ed |
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
|
|
|
c480ed |
index 7968903cad..6a38091a86 100644
|
|
|
c480ed |
--- a/tests/vircgrouptest.c
|
|
|
c480ed |
+++ b/tests/vircgrouptest.c
|
|
|
c480ed |
@@ -164,21 +164,21 @@ testCgroupDetectMounts(const void *args)
|
|
|
c480ed |
{
|
|
|
c480ed |
int result = -1;
|
|
|
c480ed |
const char *file = args;
|
|
|
c480ed |
- char *mounts = NULL;
|
|
|
c480ed |
char *parsed = NULL;
|
|
|
c480ed |
const char *actual;
|
|
|
c480ed |
virCgroupPtr group = NULL;
|
|
|
c480ed |
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
c480ed |
size_t i;
|
|
|
c480ed |
|
|
|
c480ed |
- if (virAsprintf(&mounts, "%s/vircgroupdata/%s.mounts",
|
|
|
c480ed |
- abs_srcdir, file) < 0 ||
|
|
|
c480ed |
- virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed",
|
|
|
c480ed |
- abs_srcdir, file) < 0 ||
|
|
|
c480ed |
- VIR_ALLOC(group) < 0)
|
|
|
c480ed |
+ setenv("VIR_CGROUP_MOCK_FILENAME", file, 1);
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed", abs_srcdir, file) < 0)
|
|
|
c480ed |
goto cleanup;
|
|
|
c480ed |
|
|
|
c480ed |
- if (virCgroupDetectMountsFromFile(group, mounts, false) < 0)
|
|
|
c480ed |
+ if (VIR_ALLOC(group) < 0)
|
|
|
c480ed |
+ goto cleanup;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virCgroupDetectMounts(group) < 0)
|
|
|
c480ed |
goto cleanup;
|
|
|
c480ed |
|
|
|
c480ed |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c480ed |
@@ -196,7 +196,7 @@ testCgroupDetectMounts(const void *args)
|
|
|
c480ed |
result = 0;
|
|
|
c480ed |
|
|
|
c480ed |
cleanup:
|
|
|
c480ed |
- VIR_FREE(mounts);
|
|
|
c480ed |
+ unsetenv("VIR_CGROUP_MOCK_FILENAME");
|
|
|
c480ed |
VIR_FREE(parsed);
|
|
|
c480ed |
virCgroupFree(&group);
|
|
|
c480ed |
virBufferFreeAndReset(&buf;;
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|