Libvirt broken in Ubuntu in Docker Hub? libvirtError: cannot set CPU affinity on process 594: Operation not permitted

I’m trying to setup an image for CI tests on a KVM/Qemu opensource project. But the container doesn’t allow creation of kvm images in the Ubuntu 16.04 base image. I need to create the kvm/qemu images in the container so that I can automate the tests of the kvm/qemu backup scripts.

The error is

libvirtError: cannot set CPU affinity on process 594: Operation not permitted

I’ve tried several things and found the following:

  • /dev/kvm is not setup in the container

  • the command RUN mknod /dev/kvm c 10 232 does not create /dev/kvm

  • The directories /sys/module/kvm and /sys/modules/kvm_X (where X=intel or amd) do not exist

  • It does not matter if you use tcp instead of sockets for libvirt to connect/listen - you still get the same error regarding CPUs.

I know the script I’m using has worked before with TravisCI in the past.

I know others have gotten libvirtd to work in containers (http://www.projectatomic.io/blog/2014/10/libvirtd_in_containers/ )

I stuck on why it fails in Docker and the fact that /dev/kvm and //sys/module/kvm* don’t exist and can’t be created I think might be a bug.

You can see my latest test here: https://hub.docker.com/r/000a/libvirtkvm-scripts/builds/bei6zehf9jc6fbjxrttkeda/