https://bugzilla.redhat.com/show_bug.cgi?id=1591732
On kernels without device mapper support there won't be
/dev/mapper/control. Therefore it doesn't make much sense to
put it into devices CGroup.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_cgroup.c | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index c8fba7f9e6..43e17d786e 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -129,6 +129,7 @@ qemuSetupImageCgroupInternal(virDomainObjPtr vm,
}
if (virStoragePRDefIsManaged(src->pr) &&
+ virFileExists(DEVICE_MAPPER_CONTROL_PATH) &&
qemuSetupImagePathCgroup(vm, DEVICE_MAPPER_CONTROL_PATH, false) < 0)
return -1;
@@ -163,28 +164,29 @@ qemuTeardownImageCgroup(virDomainObjPtr vm,
return 0;
}
- for (i = 0; i < vm->def->ndisks; i++) {
- virStorageSourcePtr diskSrc = vm->def->disks[i]->src;
+ if (virFileExists(DEVICE_MAPPER_CONTROL_PATH)) {
+ for (i = 0; i < vm->def->ndisks; i++) {
+ virStorageSourcePtr diskSrc = vm->def->disks[i]->src;
- if (src == diskSrc)
- continue;
+ if (src == diskSrc)
+ continue;
- if (virStoragePRDefIsManaged(diskSrc->pr))
- break;
- }
+ if (virStoragePRDefIsManaged(diskSrc->pr))
+ break;
+ }
- if (i == vm->def->ndisks) {
- VIR_DEBUG("Disabling device mapper control");
- ret = virCgroupDenyDevicePath(priv->cgroup,
- DEVICE_MAPPER_CONTROL_PATH, perms, true);
- virDomainAuditCgroupPath(vm, priv->cgroup, "deny",
- DEVICE_MAPPER_CONTROL_PATH,
- virCgroupGetDevicePermsString(perms), ret);
- if (ret < 0)
- return ret;
+ if (i == vm->def->ndisks) {
+ VIR_DEBUG("Disabling device mapper control");
+ ret = virCgroupDenyDevicePath(priv->cgroup,
+ DEVICE_MAPPER_CONTROL_PATH, perms, true);
+ virDomainAuditCgroupPath(vm, priv->cgroup, "deny",
+ DEVICE_MAPPER_CONTROL_PATH,
+ virCgroupGetDevicePermsString(perms), ret);
+ if (ret < 0)
+ return ret;
+ }
}
-
VIR_DEBUG("Deny path %s", src->path);
ret = virCgroupDenyDevicePath(priv->cgroup, src->path, perms, true);
--
2.16.4