mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
vircgroupmock: mock virCgroupV2DevicesAvailable
We need to mock virCgroupV2DevicesAvailable() in order to remove any dependency on kernel as BPF devices might not be available. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c359cb9aee
commit
8addef2bef
@ -20,10 +20,13 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
#include "vircgroup.h"
|
#include "vircgroup.h"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
virCgroupV2DevicesAvailable(virCgroupPtr group);
|
virCgroupV2DevicesAvailable(virCgroupPtr group)
|
||||||
|
G_GNUC_NO_INLINE;
|
||||||
|
|
||||||
int
|
int
|
||||||
virCgroupV2DevicesAttachProg(virCgroupPtr group,
|
virCgroupV2DevicesAttachProg(virCgroupPtr group,
|
||||||
|
@ -2,7 +2,7 @@ cpu <null>
|
|||||||
cpuacct <null>
|
cpuacct <null>
|
||||||
cpuset /not/really/sys/fs/cgroup/cpuset
|
cpuset /not/really/sys/fs/cgroup/cpuset
|
||||||
memory <null>
|
memory <null>
|
||||||
devices /not/really/sys/fs/cgroup/devices
|
devices <null>
|
||||||
freezer /not/really/sys/fs/cgroup/freezer
|
freezer /not/really/sys/fs/cgroup/freezer
|
||||||
blkio <null>
|
blkio <null>
|
||||||
net_cls /not/really/sys/fs/cgroup/net_cls
|
net_cls /not/really/sys/fs/cgroup/net_cls
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
# include "virstring.h"
|
# include "virstring.h"
|
||||||
# include "virfile.h"
|
# include "virfile.h"
|
||||||
# include "viralloc.h"
|
# include "viralloc.h"
|
||||||
|
# include "vircgroupv2devices.h"
|
||||||
|
|
||||||
static int (*real_open)(const char *path, int flags, ...);
|
static int (*real_open)(const char *path, int flags, ...);
|
||||||
static FILE *(*real_fopen)(const char *path, const char *mode);
|
static FILE *(*real_fopen)(const char *path, const char *mode);
|
||||||
@ -597,6 +598,12 @@ int open(const char *path, int flags, ...)
|
|||||||
free(newpath);
|
free(newpath);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
virCgroupV2DevicesAvailable(virCgroupPtr group G_GNUC_UNUSED)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Nothing to override on non-__linux__ platforms */
|
/* Nothing to override on non-__linux__ platforms */
|
||||||
#endif
|
#endif
|
||||||
|
@ -582,6 +582,7 @@ static int testCgroupNewForSelfUnified(const void *args G_GNUC_UNUSED)
|
|||||||
(1 << VIR_CGROUP_CONTROLLER_CPU) |
|
(1 << VIR_CGROUP_CONTROLLER_CPU) |
|
||||||
(1 << VIR_CGROUP_CONTROLLER_CPUACCT) |
|
(1 << VIR_CGROUP_CONTROLLER_CPUACCT) |
|
||||||
(1 << VIR_CGROUP_CONTROLLER_MEMORY) |
|
(1 << VIR_CGROUP_CONTROLLER_MEMORY) |
|
||||||
|
(1 << VIR_CGROUP_CONTROLLER_DEVICES) |
|
||||||
(1 << VIR_CGROUP_CONTROLLER_BLKIO);
|
(1 << VIR_CGROUP_CONTROLLER_BLKIO);
|
||||||
|
|
||||||
if (virCgroupNewSelf(&cgroup) < 0) {
|
if (virCgroupNewSelf(&cgroup) < 0) {
|
||||||
@ -604,14 +605,12 @@ static int testCgroupNewForSelfHybrid(const void *args G_GNUC_UNUSED)
|
|||||||
const char *empty[VIR_CGROUP_CONTROLLER_LAST] = { 0 };
|
const char *empty[VIR_CGROUP_CONTROLLER_LAST] = { 0 };
|
||||||
const char *mounts[VIR_CGROUP_CONTROLLER_LAST] = {
|
const char *mounts[VIR_CGROUP_CONTROLLER_LAST] = {
|
||||||
[VIR_CGROUP_CONTROLLER_CPUSET] = "/not/really/sys/fs/cgroup/cpuset",
|
[VIR_CGROUP_CONTROLLER_CPUSET] = "/not/really/sys/fs/cgroup/cpuset",
|
||||||
[VIR_CGROUP_CONTROLLER_DEVICES] = "/not/really/sys/fs/cgroup/devices",
|
|
||||||
[VIR_CGROUP_CONTROLLER_FREEZER] = "/not/really/sys/fs/cgroup/freezer",
|
[VIR_CGROUP_CONTROLLER_FREEZER] = "/not/really/sys/fs/cgroup/freezer",
|
||||||
[VIR_CGROUP_CONTROLLER_NET_CLS] = "/not/really/sys/fs/cgroup/net_cls",
|
[VIR_CGROUP_CONTROLLER_NET_CLS] = "/not/really/sys/fs/cgroup/net_cls",
|
||||||
[VIR_CGROUP_CONTROLLER_PERF_EVENT] = "/not/really/sys/fs/cgroup/perf_event",
|
[VIR_CGROUP_CONTROLLER_PERF_EVENT] = "/not/really/sys/fs/cgroup/perf_event",
|
||||||
};
|
};
|
||||||
const char *placement[VIR_CGROUP_CONTROLLER_LAST] = {
|
const char *placement[VIR_CGROUP_CONTROLLER_LAST] = {
|
||||||
[VIR_CGROUP_CONTROLLER_CPUSET] = "/",
|
[VIR_CGROUP_CONTROLLER_CPUSET] = "/",
|
||||||
[VIR_CGROUP_CONTROLLER_DEVICES] = "/",
|
|
||||||
[VIR_CGROUP_CONTROLLER_FREEZER] = "/",
|
[VIR_CGROUP_CONTROLLER_FREEZER] = "/",
|
||||||
[VIR_CGROUP_CONTROLLER_NET_CLS] = "/",
|
[VIR_CGROUP_CONTROLLER_NET_CLS] = "/",
|
||||||
[VIR_CGROUP_CONTROLLER_PERF_EVENT] = "/",
|
[VIR_CGROUP_CONTROLLER_PERF_EVENT] = "/",
|
||||||
@ -620,6 +619,7 @@ static int testCgroupNewForSelfHybrid(const void *args G_GNUC_UNUSED)
|
|||||||
(1 << VIR_CGROUP_CONTROLLER_CPU) |
|
(1 << VIR_CGROUP_CONTROLLER_CPU) |
|
||||||
(1 << VIR_CGROUP_CONTROLLER_CPUACCT) |
|
(1 << VIR_CGROUP_CONTROLLER_CPUACCT) |
|
||||||
(1 << VIR_CGROUP_CONTROLLER_MEMORY) |
|
(1 << VIR_CGROUP_CONTROLLER_MEMORY) |
|
||||||
|
(1 << VIR_CGROUP_CONTROLLER_DEVICES) |
|
||||||
(1 << VIR_CGROUP_CONTROLLER_BLKIO);
|
(1 << VIR_CGROUP_CONTROLLER_BLKIO);
|
||||||
|
|
||||||
if (virCgroupNewSelf(&cgroup) < 0) {
|
if (virCgroupNewSelf(&cgroup) < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user