From e4ccafee732ad9afd55b205a10e1b95f157ba16f Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Sep 2023 15:42:28 -0400 Subject: [PATCH] Add cgroup delegation override Required to solve the occasional libvirt: QEMU Driver error : Requested operation is not valid: cgroup CPUACCT controller is not mounted problem, as per: https://answers.launchpad.net/ubuntu/+question/665132 --- roles/pvc/tasks/libvirt/main.yml | 20 ++++++++++++++++++- .../libvirt/cgroup-delegation.conf.j2 | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 roles/pvc/templates/libvirt/cgroup-delegation.conf.j2 diff --git a/roles/pvc/tasks/libvirt/main.yml b/roles/pvc/tasks/libvirt/main.yml index e6ec10f..2b203e5 100644 --- a/roles/pvc/tasks/libvirt/main.yml +++ b/roles/pvc/tasks/libvirt/main.yml @@ -24,7 +24,7 @@ append: yes with_items: "{{ admin_users }}" -- name: install libvirt configuration +- name: install libvirt configurations template: src: libvirt/{{ item }}.j2 dest: /etc/libvirt/{{ item }} @@ -66,6 +66,24 @@ command: systemctl daemon-reload when: systemd.changed +- name: create unit override configuration directory + file: + dest: /etc/systemd/system/libvirtd.service.d + state: directory + +- name: install libvirt cgroup delegation configuration + template: + src: libvirt/{{ item }}.j2 + dest: /etc/systemd/system/libvirtd.service.d/{{ item }} + with_items: + - cgroup-delegation.conf + register: systemd + notify: restart libvirtd + +- name: reload systemd to apply changes + command: systemctl daemon-reload + when: systemd.changed + - name: start and enable services (not managed by PVC) service: name: "{{ item }}" diff --git a/roles/pvc/templates/libvirt/cgroup-delegation.conf.j2 b/roles/pvc/templates/libvirt/cgroup-delegation.conf.j2 new file mode 100644 index 0000000..7e409de --- /dev/null +++ b/roles/pvc/templates/libvirt/cgroup-delegation.conf.j2 @@ -0,0 +1,2 @@ +[Service] +Delegate=yes