提交 fd9a0368 编写于 作者: P Pavel Hrdina

vircgroup: extract virCgroupV1(Allow|Deny)AllDevices

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 8cbb0c76
......@@ -1818,10 +1818,7 @@ virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus)
int
virCgroupDenyAllDevices(virCgroupPtr group)
{
return virCgroupSetValueStr(group,
VIR_CGROUP_CONTROLLER_DEVICES,
"devices.deny",
"a");
VIR_CGROUP_BACKEND_CALL(group, denyAllDevices, -1);
}
/**
......@@ -1841,18 +1838,7 @@ virCgroupDenyAllDevices(virCgroupPtr group)
int
virCgroupAllowAllDevices(virCgroupPtr group, int perms)
{
int ret = -1;
if (virCgroupAllowDevice(group, 'b', -1, -1, perms) < 0)
goto cleanup;
if (virCgroupAllowDevice(group, 'c', -1, -1, perms) < 0)
goto cleanup;
ret = 0;
cleanup:
return ret;
VIR_CGROUP_BACKEND_CALL(group, allowAllDevices, -1, perms);
}
......
......@@ -269,6 +269,13 @@ typedef int
int minor,
int perms);
typedef int
(*virCgroupAllowAllDevicesCB)(virCgroupPtr group,
int perms);
typedef int
(*virCgroupDenyAllDevicesCB)(virCgroupPtr group);
struct _virCgroupBackend {
virCgroupBackendType type;
......@@ -321,6 +328,8 @@ struct _virCgroupBackend {
virCgroupAllowDeviceCB allowDevice;
virCgroupDenyDeviceCB denyDevice;
virCgroupAllowAllDevicesCB allowAllDevices;
virCgroupDenyAllDevicesCB denyAllDevices;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
......
......@@ -1736,6 +1736,35 @@ virCgroupV1DenyDevice(virCgroupPtr group,
}
static int
virCgroupV1AllowAllDevices(virCgroupPtr group,
int perms)
{
int ret = -1;
if (virCgroupV1AllowDevice(group, 'b', -1, -1, perms) < 0)
goto cleanup;
if (virCgroupV1AllowDevice(group, 'c', -1, -1, perms) < 0)
goto cleanup;
ret = 0;
cleanup:
return ret;
}
static int
virCgroupV1DenyAllDevices(virCgroupPtr group)
{
return virCgroupSetValueStr(group,
VIR_CGROUP_CONTROLLER_DEVICES,
"devices.deny",
"a");
}
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
......@@ -1786,6 +1815,8 @@ virCgroupBackend virCgroupV1Backend = {
.allowDevice = virCgroupV1AllowDevice,
.denyDevice = virCgroupV1DenyDevice,
.allowAllDevices = virCgroupV1AllowAllDevices,
.denyAllDevices = virCgroupV1DenyAllDevices,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册