Skip to content

Commit

Permalink
node-labeller.sh: Consider AppArmor restrictions
Browse files Browse the repository at this point in the history
Even though the virt-handler pod is privileged, on the systems with
AppArmor there might be a host profile which will be automatically
picked for the /usr/sbin/libvirtd binary. That may block the execution
of /usr/libexec/qemu-kvm. In such a case, try moving the qemu executable
to a location, which is more common for AppArmor-enabled Linux distros.

Signed-off-by: Vasiliy Ulyanov <vulyanov@suse.de>
  • Loading branch information
vasiliy-ul committed Oct 28, 2022
1 parent 7594c5a commit 940c9b2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/virt-launcher/node-labeller/node-labeller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ fi

libvirtd -d

# If the below command fails, then probably we run under AppArmor restrictions
# and the active profile denies exec of /usr/libexec/qemu-kvm for libvirtd. In
# such case, move the binary to a more common location and try again.
if ! virsh domcapabilities --machine q35 --arch x86_64 --virttype $VIRTTYPE > /dev/null; then
[ -f /usr/libexec/qemu-kvm ] && mv /usr/libexec/qemu-kvm /usr/bin/qemu-system-x86_64
fi

virsh domcapabilities --machine q35 --arch x86_64 --virttype $VIRTTYPE > /var/lib/kubevirt-node-labeller/virsh_domcapabilities.xml

cp -r /usr/share/libvirt/cpu_map /var/lib/kubevirt-node-labeller
Expand Down

0 comments on commit 940c9b2

Please sign in to comment.