[lxc-users] unable to start qemu-kvm inside lxc container (the host freezes)

Serge Hallyn serge.hallyn at ubuntu.com
Wed Apr 15 14:28:05 UTC 2015


Quoting Syraxes (syraxes at gmail.com):
> Hello,
> 
> I am trying to start a qemu virtual machine inside a LXC container
> 
> (one might wonder why exactly would I want to do this.  The idea is
> that I have a complex environment with 6 virtual machines + network
> bridges + mysql + some proprietary software ,    and the goal is to
> start multiple environments on a computer .  We need processes and
> network isolation between the environments.    So starting one qemu is
> only the first step ... )
> 
> 
> The host is a CentOS 6.6 ,  and the container is also CentOS 6.6 .
> 
> Inside the container,  the qemu complained that there is no  /dev/kvm
> and  /dev/net/tun  .
> So I've created them with mknod   and also added into the container config :
> lxc.cgroup.devices.allow = c 10:232 rwm          #   the /dev/kvm
> lxc.cgroup.devices.allow = c 10:200 rwm          #   the /dev/net/tun
> 
> 
> After these changes,  when I try to start the qemu vm   the host
> computer freezes .
> 
> Any idea about what am I doing wrong ?
> I guess that it's incorrect to give the container access to those
> devices.

No, it's fine.

> But is there another way to make the qemu work inside the
> lxc container ?

Yes.  I've done it many times.  The host freezing suggests you
have a problem with the kvm binary - kvm runs fine outside of
a container?  You're sure you have the same arch in the container
as on the host?  If you strace kvm in the container, does it
give you any clues?


More information about the lxc-users mailing list