mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
vircgrouptest: call virCgroupDetectMounts directly
Because we can set which files to return for cgroup tests there is no need to have special function tailored to run tests. Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
5cf1b25708
commit
4988f4b347
@ -1513,7 +1513,7 @@ virCgroupDelThread;
|
|||||||
virCgroupDenyAllDevices;
|
virCgroupDenyAllDevices;
|
||||||
virCgroupDenyDevice;
|
virCgroupDenyDevice;
|
||||||
virCgroupDenyDevicePath;
|
virCgroupDenyDevicePath;
|
||||||
virCgroupDetectMountsFromFile;
|
virCgroupDetectMounts;
|
||||||
virCgroupFree;
|
virCgroupFree;
|
||||||
virCgroupGetBlkioDeviceReadBps;
|
virCgroupGetBlkioDeviceReadBps;
|
||||||
virCgroupGetBlkioDeviceReadIops;
|
virCgroupGetBlkioDeviceReadIops;
|
||||||
|
@ -426,9 +426,7 @@ virCgroupMountOptsMatchController(const char *mntOpts,
|
|||||||
* mounted and where
|
* mounted and where
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virCgroupDetectMountsFromFile(virCgroupPtr group,
|
virCgroupDetectMounts(virCgroupPtr group)
|
||||||
const char *path,
|
|
||||||
bool checkLinks)
|
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
FILE *mounts = NULL;
|
FILE *mounts = NULL;
|
||||||
@ -436,9 +434,9 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
|
|||||||
char buf[CGROUP_MAX_VAL];
|
char buf[CGROUP_MAX_VAL];
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
mounts = fopen(path, "r");
|
mounts = fopen("/proc/mounts", "r");
|
||||||
if (mounts == NULL) {
|
if (mounts == NULL) {
|
||||||
virReportSystemError(errno, _("Unable to open %s"), path);
|
virReportSystemError(errno, "%s", _("Unable to open /proc/mounts"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,8 +464,7 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
|
|||||||
|
|
||||||
/* If it is a co-mount it has a filename like "cpu,cpuacct"
|
/* If it is a co-mount it has a filename like "cpu,cpuacct"
|
||||||
* and we must identify the symlink path */
|
* and we must identify the symlink path */
|
||||||
if (checkLinks &&
|
if (virCgroupResolveMountLink(entry.mnt_dir, typestr,
|
||||||
virCgroupResolveMountLink(entry.mnt_dir, typestr,
|
|
||||||
controller) < 0) {
|
controller) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -481,12 +478,6 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
virCgroupDetectMounts(virCgroupPtr group)
|
|
||||||
{
|
|
||||||
return virCgroupDetectMountsFromFile(group, "/proc/mounts", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virCgroupCopyPlacement(virCgroupPtr group,
|
virCgroupCopyPlacement(virCgroupPtr group,
|
||||||
@ -4086,9 +4077,7 @@ virCgroupAvailable(void)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virCgroupDetectMountsFromFile(virCgroupPtr group ATTRIBUTE_UNUSED,
|
virCgroupDetectMounts(virCgroupPtr group ATTRIBUTE_UNUSED)
|
||||||
const char *path ATTRIBUTE_UNUSED,
|
|
||||||
bool checkLinks ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
virReportSystemError(ENXIO, "%s",
|
virReportSystemError(ENXIO, "%s",
|
||||||
_("Control groups not supported on this platform"));
|
_("Control groups not supported on this platform"));
|
||||||
|
@ -50,9 +50,7 @@ struct _virCgroup {
|
|||||||
virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
|
virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
|
||||||
};
|
};
|
||||||
|
|
||||||
int virCgroupDetectMountsFromFile(virCgroupPtr group,
|
int virCgroupDetectMounts(virCgroupPtr group);
|
||||||
const char *path,
|
|
||||||
bool checkLinks);
|
|
||||||
|
|
||||||
int virCgroupNewPartition(const char *path,
|
int virCgroupNewPartition(const char *path,
|
||||||
bool create,
|
bool create,
|
||||||
|
@ -163,21 +163,21 @@ testCgroupDetectMounts(const void *args)
|
|||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
const char *file = args;
|
const char *file = args;
|
||||||
char *mounts = NULL;
|
|
||||||
char *parsed = NULL;
|
char *parsed = NULL;
|
||||||
const char *actual;
|
const char *actual;
|
||||||
virCgroupPtr group = NULL;
|
virCgroupPtr group = NULL;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (virAsprintf(&mounts, "%s/vircgroupdata/%s.mounts",
|
setenv("VIR_CGROUP_MOCK_FILENAME", file, 1);
|
||||||
abs_srcdir, file) < 0 ||
|
|
||||||
virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed",
|
if (virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed", abs_srcdir, file) < 0)
|
||||||
abs_srcdir, file) < 0 ||
|
|
||||||
VIR_ALLOC(group) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCgroupDetectMountsFromFile(group, mounts, false) < 0)
|
if (VIR_ALLOC(group) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virCgroupDetectMounts(group) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
||||||
@ -195,7 +195,7 @@ testCgroupDetectMounts(const void *args)
|
|||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(mounts);
|
unsetenv("VIR_CGROUP_MOCK_FILENAME");
|
||||||
VIR_FREE(parsed);
|
VIR_FREE(parsed);
|
||||||
virCgroupFree(&group);
|
virCgroupFree(&group);
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user