From 7375e560b423a6805eefc4c98ca297bffbe323c8 Mon Sep 17 00:00:00 2001 From: RouxAntoine Date: Mon, 26 Apr 2021 23:24:36 +0200 Subject: [PATCH] Adapt libvirtd to work with cgroupv2 --- Makefile | 5 +++-- libvirtd.sh | 14 ++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 6ea7374..74da2e1 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ .PHONY: imageLibvirtd test REGISTRY_IP=docker.registry +DOCKER_BUILDKIT=1 ## build -shell_build_image = docker build -t $(REGISTRY_IP):5000/$(1) .; \ +shell_build_image = docker build --platform=linux/amd64 -t $(REGISTRY_IP):5000/$(1) .; \ docker push $(REGISTRY_IP):5000/$(1); imageLibvirtd: @@ -29,4 +30,4 @@ download_centos: ## management status: - @curl -s $(REGISTRY_IP):5000/v2/_catalog | jq \ No newline at end of file + @curl -s $(REGISTRY_IP):5000/v2/_catalog | jq diff --git a/libvirtd.sh b/libvirtd.sh index c279672..f2c8552 100644 --- a/libvirtd.sh +++ b/libvirtd.sh @@ -36,12 +36,14 @@ modprobe kvm_intel nested=1 -d /host # If no cpuacct,cpu is present, symlink it to cpu,cpuacct # Otherwise libvirt and our emulator get confused -if [ ! -d "/host/sys/fs/cgroup/cpuacct,cpu" ]; then - echo "Creating cpuacct,cpu cgroup symlink" - mount -o remount,rw /host/sys/fs/cgroup - cd /host/sys/fs/cgroup - ln -s cpu,cpuacct cpuacct,cpu - mount -o remount,ro /host/sys/fs/cgroup +if [ ! -f "/host/sys/fs/cgroup/cgroup.controllers" ]; then + if [ ! -d "/host/sys/fs/cgroup/cpuacct,cpu" ]; then + echo "Creating cpuacct,cpu cgroup symlink" + mount -o remount,rw /host/sys/fs/cgroup + cd /host/sys/fs/cgroup + ln -s cpu,cpuacct cpuacct,cpu + mount -o remount,ro /host/sys/fs/cgroup + fi fi mount --rbind /host/sys/fs/cgroup /sys/fs/cgroup