-
Notifications
You must be signed in to change notification settings - Fork 933
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
Nested LXD virtualization in peer containers causes vsock ID conflicts #11508
Comments
Yes, this is the track I started to go down with https://github.com/lxc/lxd/pull/10216#issuecomment-1093320228 |
I like where you were going with this, @tomponline. A few thoughts on the commit you referenced:
|
Hello, I am writing to express my interest in working on the issue mentioned in the bug report #11508 for LXD. As a student at the university, I am eager to contribute to open source projects and gain valuable experience in software development. I have experience in Linux systems and I am familiar with virtualization technologies. I believe that my skills and knowledge would be useful in resolving the issue mentioned in the bug report. I am willing to work with the LXD development team to find a solution to the problem and contribute to the project. Thank you for considering my interest in this issue. I look forward to hearing back from you. |
Thanks @Anis-cpu-13 assigned to you! |
I think I have exactly same issue by peer containers causing vsock ID conflict when I try to launch a QEMU VM within containers. What's current stage on the fix? Is there a workaround/hack to fix it for now? |
@stgraber , this issue is one which stops our company to move to LXD, is there any workaround before the fix? |
@kochia7 what is the use case for running VMs inside containers? (it maybe there is a workaround in the short term until this is fixed). |
We have Android Machines (Qemu/CrossVM) running per container, unfortunately we are not able to run VMs directly on the machine, so planning to use LXC containers as lightweight isolation for each Qemu VM. |
Thanks. What is the reason for "we are not able to run VMs directly on the machine"? And are you aware that by passing through non-namespaced devices like /dev/kvm, you are potentially exposing you host to attacks from the containers, so just want to check you are aware that doing that reduces the isolation. I wondered what sort of isolation you are expecting from running VMs inside containers? |
VMM we using create artifacts which interfere each other with other machines, it's how the VMM is build, unable to work with several VM in parallel. So LXC creates just enough isolation to make them work |
You can set
|
I'm not sure though how it will work with LXD's own vsock listener though (as opposed to the lxd-agent's). |
I will give it a try, seems promising! Thanks! |
I used |
Only the last one would have done anything as setting volatile.vsock_id on a container doesn't do anything. |
Didn't really work for LXD: https://github.com/lxc/lxd/issues/11739#issuecomment-1567389272 |
When acquiring a new Context ID for the communication via vsock, pick the first four bytes of the instances UUID (try to get as much randomness as possible out of the 16 bytes) and convert it into an uint32. If there is a collision, try again after adding +1 to the ID. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, pick the first four bytes of the instances UUID (try to get as much randomness as possible out of the 16 bytes) and convert it into an uint32. If there is a collision, try again after adding +1 to the ID. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, pick the first four bytes of the instances UUID (try to get as much randomness as possible out of the 16 bytes) and convert it into an uint32. If there is a collision, try again after adding +1 to the ID. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, pick the first four bytes of the instances UUID (try to get as much randomness as possible out of the 16 bytes) and convert it into an uint32. If there is a collision, try again after adding +1 to the ID. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, pick the first four bytes of the instances UUID (try to get as much randomness as possible out of the 16 bytes) and convert it into an uint32. If there is a collision, try again after adding +1 to the ID. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, pick the first four bytes of the instances UUID (try to get as much randomness as possible out of the 16 bytes) and convert it into an uint32. If there is a collision, try again after adding +1 to the ID. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, pick the first four bytes of the instances UUID (try to get as much randomness as possible out of the 16 bytes) and convert it into an uint32. If there is a collision, try again after adding +1 to the ID. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, use the UUID of the instance as a seed for generating random uint32 candidates. The loop is kept open until a free Context ID is found. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. In case the Context ID of a stopped VM was already acquired again, a new one is now generated. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, use the UUID of the instance as a seed for generating random uint32 candidates. The loop is kept open until a free Context ID is found or the timeout of 5s is reached. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. In case the Context ID of a stopped VM was already acquired again, a new one is now generated. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, use the UUID of the instance as a seed for generating random uint32 candidates. The loop is kept open until a free Context ID is found or the timeout of 5s is reached. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. In case the Context ID of a stopped VM was already acquired again, a new one gets picked. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, use the UUID of the instance as a seed for generating random uint32 candidates. The loop is kept open until a free Context ID is found or the timeout of 5s is reached. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. In case the Context ID of a stopped VM was already acquired again, a new one gets picked. Fixes https://github.com/lxc/lxd/issues/11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, use the UUID of the instance as a seed for generating random uint32 candidates. The loop is kept open until a free Context ID is found or the timeout of 5s is reached. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. In case the Context ID of a stopped VM was already acquired again, a new one gets picked. Fixes lxc#11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, use the UUID of the instance as a seed for generating random uint32 candidates. The loop is kept open until a free Context ID is found or the timeout of 5s is reached. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. In case the Context ID of a stopped VM was already acquired again, a new one gets picked. Removes the `vhost_vsock` feature since the value isn't anymore accessed. Fixes lxc#11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, use the UUID of the instance as a seed for generating random uint32 candidates. The loop is kept open until a free Context ID is found or the timeout of 5s is reached. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. In case the Context ID of a stopped VM was already acquired again, a new one gets picked. Removes the `vhost_vsock` feature since the value isn't anymore accessed. Fixes lxc#11508 Signed-off-by: Julian Pelizäus <[email protected]>
When acquiring a new Context ID for the communication via vsock, use the UUID of the instance as a seed for generating random uint32 candidates. The loop is kept open until a free Context ID is found or the timeout of 5s is reached. The syscall to the vsock returns ENODEV in case the Context ID is not yet assigned. In case the Context ID of a stopped VM was already acquired again, a new one gets picked. Removes the `vhost_vsock` feature since the value isn't anymore accessed. Fixes lxc#11508 Signed-off-by: Julian Pelizäus <[email protected]>
Required information
Ubuntu
22.04 "Jammy"
5.19.0-35-generic
5.12
5.12
zfs
lxc info
outputIssue description
When attempting to use
lxd
to launch virtual machines in multiple peer containers, errors such asvhost-vsock: unable to set guest cid: Address already in use
can be observed when launching VMs, causing the VMs to fail to start.Steps to reproduce
Create a profile allowing nested virtualization, such as:
Launch two or more containers with this profile, such as:
Use
lxc shell
to enter both containers and run:Expected results
Both virtual machines should be created and started.
Actual results
The second VM to be created will fail to start.
lxc info --show-log local:bionic
will display:Additional Information
There was an attempt to address this in PR #10216. However, this fix seems to assume that the vsock IDs are only shared with the parent, not peer containers.
libvirt
seems to avoid this problem by iterating over usable IDs until a free ID is found.The text was updated successfully, but these errors were encountered: