Lxc can't create vm container, missing kernel module vhost_vsock

LXC 4.0+ can create containers as virtual machines using the --vm flag. I’m on NixOS 22.05 with lxc 5.1 and am trying to do this using the following command, but get the error shown:

$> sudo lxc launch images:alpine/edge ae-vm --vm 
Creating ae-vm
Error: Failed instance creation: Failed creating instance record: Instance type "virtual-machine" is not supported on this server: vhost_vsock kernel module not loaded

Is there a config setting for this or something else that I’m missing? The virtualization section of my configuration.nix is:

  virtualisation = {
    containers.enable = true;
    containerd.enable = true;
    libvirtd = {
      enable = true;
      onBoot = "ignore";
      onShutdown = "shutdown";
      qemu = {
        ovmf.enable = true;
        runAsRoot = false;
      };
    };
    lxd = {
      enable = true;
      zfsSupport = true;
      recommendedSysctlSettings = true;
    };
    lxc = {
      enable = true;
      lxcfs.enable = true;
      systemConfig = ''
        lxc.lxcpath = /var/lib/lxd/containers
        lxc.bdev.zfs.root = rpool/safe/lxd  
      '';
    };
  };
1 Like

what does

lsmod | grep vhost_vsock

give you? Apparently you need this loaded as a kernel module.

Thanks, looks like I have it already?

$> lsmod | grep vhost_vsock
Module                 Size   Used by
vhost_vsock            24576  0
vmw_vsock_virtio_transport_common    45056  1 vhost_vsock
vhost                  57344  1 vhost_vsock
vsock                  53248  2 vmw_vsock_virtio_transport_common,vhost_vsock

I see the same behaviour in my NixOS 22.05 installation: lsmod shows the vhost_vsock module, and lxc launch fails with the same error message.

1 Like