From 884479b42b857dc3dce6b3bd1dec4d8e971dee3c Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Fri, 11 Jan 2019 14:56:48 +0100 Subject: [PATCH] vircgroup: introduce virCgroupV2DenyAllDevices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we want to deny all devices we just need to replace any existing program with new program with empty map. Signed-off-by: Pavel Hrdina Reviewed-by: Ján Tomko --- src/util/vircgroupv2.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 109b64f1c2..84d8e38a59 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -1824,6 +1824,16 @@ virCgroupV2AllowAllDevices(virCgroupPtr group, } +static int +virCgroupV2DenyAllDevices(virCgroupPtr group) +{ + if (virCgroupV2DevicesDetectProg(group) < 0) + return -1; + + return virCgroupV2DevicesCreateProg(group); +} + + virCgroupBackend virCgroupV2Backend = { .type = VIR_CGROUP_BACKEND_TYPE_V2, @@ -1876,6 +1886,7 @@ virCgroupBackend virCgroupV2Backend = { .allowDevice = virCgroupV2AllowDevice, .denyDevice = virCgroupV2DenyDevice, .allowAllDevices = virCgroupV2AllowAllDevices, + .denyAllDevices = virCgroupV2DenyAllDevices, .setCpuShares = virCgroupV2SetCpuShares, .getCpuShares = virCgroupV2GetCpuShares,