KVM inside LXC container

Discussion in 'Proxmox VE: Installation and configuration' started by aodtorusan, May 10, 2019.

  1. aodtorusan

    aodtorusan New Member

    Joined:
    May 10, 2019
    Messages:
    3
    Likes Received:
    0
    I would like to use plain kvm virtualization inside a container created in proxmox.
    Using plain LXC/LXD this is possible by running (see github.com/lxc/lxd/issues/2718):

    Code:
    lxc config device add CONTAINER kvm unix-char path=/dev/kvm
    I noticed that in my unprivileged container, the device /dev/kvm is missing. Would it be possible to create a similar device in LXC under proxmox.
     
  2. LnxBil

    LnxBil Well-Known Member

    Joined:
    Feb 21, 2015
    Messages:
    3,696
    Likes Received:
    331
    If you have to corresponding setting in the lxc config file that will be generated by the command above, sure. Just add it to your LXC configuration file like here for OpenVPN with another device file:

    https://forum.proxmox.com/threads/openvpn-in-the-lxc.41889/#post-206450
     
  3. aodtorusan

    aodtorusan New Member

    Joined:
    May 10, 2019
    Messages:
    3
    Likes Received:
    0
    After adding to /etc/pve/lxc/{vmid}.conf the correct cgroups rule, it qemu was able to start correctly;
    Code:
    # /dev/kvm
    lxc.cgroup.devices.allow = c 10:232 rwm
    The container did have the be a privileged one.
     
  4. oguz

    oguz Proxmox Staff Member
    Staff Member

    Joined:
    Nov 19, 2018
    Messages:
    505
    Likes Received:
    50
    Just out of curiosity, why would you want to run KVM in a CT, when you can just create a VM on Proxmox?
    What kind of advantages or use case does this have?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    BobhWasatch likes this.
  5. aodtorusan

    aodtorusan New Member

    Joined:
    May 10, 2019
    Messages:
    3
    Likes Received:
    0
    In this case it’s for running gns3. It spins up its own managed VM's for simulating network devices and topologies.
    Running it in a container separates the GNS3 managed instances in a dedicated context.
    I was previously running in a dedicated VM, so it uses nested virtualization for the vm's it creates. However, its simulated devices seem to be running faster launched directly from the container and not using nested virtualization.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice