mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: cgroup: Extract guts of qemuSetupImageCgroupInternal
They will later be reused for setting cgroup for other image backed devices.
This commit is contained in:
parent
2b15f2a196
commit
d6c91b3c03
@ -52,38 +52,47 @@ static const char *const defaultDeviceACL[] = {
|
|||||||
#define DEVICE_PTY_MAJOR 136
|
#define DEVICE_PTY_MAJOR 136
|
||||||
#define DEVICE_SND_MAJOR 116
|
#define DEVICE_SND_MAJOR 116
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuSetupImageCgroupInternal(virDomainObjPtr vm,
|
qemuSetupImagePathCgroup(virDomainObjPtr vm,
|
||||||
virStorageSourcePtr src,
|
const char *path,
|
||||||
bool forceReadonly)
|
bool readonly)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
int perms = VIR_CGROUP_DEVICE_READ;
|
int perms = VIR_CGROUP_DEVICE_READ;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!virCgroupHasController(priv->cgroup,
|
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES))
|
||||||
VIR_CGROUP_CONTROLLER_DEVICES))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (readonly)
|
||||||
|
perms |= VIR_CGROUP_DEVICE_WRITE;
|
||||||
|
|
||||||
|
VIR_DEBUG("Allow path %s, perms: %s",
|
||||||
|
path, virCgroupGetDevicePermsString(perms));
|
||||||
|
|
||||||
|
ret = virCgroupAllowDevicePath(priv->cgroup, path, perms, true);
|
||||||
|
|
||||||
|
virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path,
|
||||||
|
virCgroupGetDevicePermsString(perms),
|
||||||
|
ret == 0);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuSetupImageCgroupInternal(virDomainObjPtr vm,
|
||||||
|
virStorageSourcePtr src,
|
||||||
|
bool forceReadonly)
|
||||||
|
{
|
||||||
if (!src->path || !virStorageSourceIsLocalStorage(src)) {
|
if (!src->path || !virStorageSourceIsLocalStorage(src)) {
|
||||||
VIR_DEBUG("Not updating cgroups for disk path '%s', type: %s",
|
VIR_DEBUG("Not updating cgroups for disk path '%s', type: %s",
|
||||||
NULLSTR(src->path), virStorageTypeToString(src->type));
|
NULLSTR(src->path), virStorageTypeToString(src->type));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!src->readonly && !forceReadonly)
|
return qemuSetupImagePathCgroup(vm, src->path, src->readonly || forceReadonly);
|
||||||
perms |= VIR_CGROUP_DEVICE_WRITE;
|
|
||||||
|
|
||||||
VIR_DEBUG("Allow path %s, perms: %s",
|
|
||||||
src->path, virCgroupGetDevicePermsString(perms));
|
|
||||||
|
|
||||||
ret = virCgroupAllowDevicePath(priv->cgroup, src->path, perms, true);
|
|
||||||
|
|
||||||
virDomainAuditCgroupPath(vm, priv->cgroup, "allow", src->path,
|
|
||||||
virCgroupGetDevicePermsString(perms),
|
|
||||||
ret == 0);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user