Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use nested virtualization with LXC container #11674

Closed
Gio2241 opened this issue May 13, 2023 · 3 comments
Closed

Unable to use nested virtualization with LXC container #11674

Gio2241 opened this issue May 13, 2023 · 3 comments
Labels
Incomplete Waiting on more information from reporter

Comments

@Gio2241
Copy link

Gio2241 commented May 13, 2023

Required information

  • Distribution: Ubuntu
  • Distribution version: 22.04.2 LTS
  • The output of "lxc info" or if that fails:
    • Kernel version: 5.15.0-71-generic
    • LXC version: 5.13
    • LXD version: 5.13
    • Storage backend in use: zfs | dir

Issue description

Unable to run LXD VM inside a LXD VM image (nested virtualization)

Steps to reproduce

on host:

lxc launch images:ubuntu/22.04 u22 -c security.nesting=true
lxc config device add u22 kvm unix-char source=/dev/kvm
lxc config device add u22 vhost-net unix-char source=/dev/vhost-net
lxc config device add u22 vhost-vsock unix-char source=/dev/vhost-vsock

lxc exec u22 bash

on VM:

...install snap and lxd

root@u22:~# kvm-ok
> INFO: /dev/kvm exists
> KVM acceleration can be used

lxc --version # 5.13
lxd init --auto

lxc launch images:ubuntu/22.04 u22 --vm

Getting this error:

Error: Failed instance creation: Failed creating instance record: Instance type "virtual-machine" is not supported on this server: Vsock support is missing (no /dev/vsock)
@Gio2241 Gio2241 closed this as completed May 13, 2023
@Gio2241 Gio2241 reopened this May 16, 2023
@tomponline
Copy link
Member

Please show lxc config show <container> --expanded

@tomponline tomponline added the Incomplete Waiting on more information from reporter label May 17, 2023
@Gio2241
Copy link
Author

Gio2241 commented May 17, 2023

If there is another LXC container running with a LXC VM inside, launch a VM inside a new LXC causes this error:

Error: Failed to run: forklimits fd=3 -- /snap/lxd/24846/bin/qemu-system-x86_64 -S -name u22 -uuid f09540b7-8133-425e-a68d-e69de6338a6e -daemonize -cpu host,hv_passthrough -nographic -serial chardev:console -nodefaults -no-user-config -sandbox on,obsolete=deny,elevateprivileges=allow,spawn=allow,resourcecontrol=deny -readconfig /var/snap/lxd/common/lxd/logs/u22/qemu.conf -spice unix=on,disable-ticketing=on,addr=/var/snap/lxd/common/lxd/logs/u22/qemu.spice -pidfile /var/snap/lxd/common/lxd/logs/u22/qemu.pid -D /var/snap/lxd/common/lxd/logs/u22/qemu.log -smbios type=2,manufacturer=Canonical Ltd.,product=LXD -runas lxd: : Process exited with non-zero value 1
Try `lxc info --show-log local:u22` for more info

--show log result:

Name: u22
Status: STOPPED
Type: virtual-machine
Architecture: x86_64
Created: 2023/05/17 11:09 UTC

Log:

qemu-system-x86_64:/var/snap/lxd/common/lxd/logs/u22/qemu.conf:115: vhost-vsock: unable to set guest cid: Address already in use

lxc config show u22 --expanded

architecture: x86_64
config:
  image.architecture: amd64
  image.description: Ubuntu jammy amd64 (20230517_07:42)
  image.os: Ubuntu
  image.release: jammy
  image.serial: "20230517_07:42"
  image.type: disk-kvm.img
  image.variant: default
  volatile.base_image: 2827820539fec451e353579dea6ee5a8fbead380e055c7e5700c019a751bdd76
  volatile.cloud-init.instance-id: 2b85d2a7-ec5e-4233-872d-4a3e7513a930
  volatile.eth0.hwaddr: 00:16:3e:05:de:19
  volatile.uuid: f09540b7-8133-425e-a68d-e69de6338a6e
  volatile.uuid.generation: f09540b7-8133-425e-a68d-e69de6338a6e
  volatile.vsock_id: "4"
devices:
  eth0:
    name: eth0
    network: lxdbr0
    type: nic
  root:
    path: /
    pool: default
    type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""

output for the another LXC VM:

architecture: x86_64
config:
  image.architecture: amd64
  image.description: Ubuntu jammy amd64 (20230517_07:42)
  image.os: Ubuntu
  image.release: jammy
  image.serial: "20230517_07:42"
  image.type: disk-kvm.img
  image.variant: default
  volatile.base_image: 2827820539fec451e353579dea6ee5a8fbead380e055c7e5700c019a751bdd76
  volatile.cloud-init.instance-id: 1b0874b0-4739-43d2-9dbe-f4ff99af6cd8
  volatile.eth0.host_name: tap628ed6fe
  volatile.eth0.hwaddr: 00:16:3e:03:fc:3e
  volatile.last_state.power: RUNNING
  volatile.uuid: b7783b4c-6b1d-4803-9f39-071c99841cc8
  volatile.uuid.generation: b7783b4c-6b1d-4803-9f39-071c99841cc8
  volatile.vsock_id: "4"
devices:
  eth0:
    name: eth0
    network: lxdbr0
    type: nic
  root:
    path: /
    pool: default
    type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""

I guess the reason is that both VMs within these LXC containers using same vsock_id volatile.vsock_id: "4"
The one gets first runs, the other failes

Race condition bug?

@tomponline
Copy link
Member

Its a duplicate of https://github.com/lxc/lxd/issues/11508 in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Incomplete Waiting on more information from reporter
Projects
None yet
Development

No branches or pull requests

2 participants