-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
MicroVMs with QEMU can conflict in vsock port space on the host side #311
Comments
It feels like one could solve this problem by binding to port -1 and then somehow divining the port number assigned. (Apparently vsock port numbers are 4 bytes long — wow that's a lot of ports — and ports below 1024 are 'privileged' just like with ordinary networking.)
${pkgs.socat}/bin/socat -d -d VSOCK-LISTEN:-1,fork UNIX-SENDTO:$NOTIFY_SOCKET 2> $TMP/socat.log &
NOTIFY_VSOCK_PORT=$(${pkgs.coreutils}/bin/tail -f $TMP/socat.log | ${pkgs.gawk}/bin/awk '/listening on/ { if (match($0, /port:[0-9]*/)) { print substr($0, RSTART + 5, RLENGTH - 5); exit; } }') But the clever usage of However, QEMU does not need to take literal arguments in fw_cfg: it can also take a path, which I found quite useful before for passing through credentials from systemd units. Therefore, one only needs to somehow securely create a file and refer to it in QEMU... and we're back to step one, because filename collisions are also a thing, and I'd like to avoid them... unless we use relative paths and are It turns out we're in Internally, However, I don't seem to be able to get it working reliably for some reason. Sometimes, somehow, it just fails, and I suspect the problem is on socat's side. I'll send a draft PR in a few minutes, but socat's behavior might need to be debugged more precisely. |
Thanks for sharing your findings! PR is #313 |
While implementing the QEMU version of the notify-over-vsock feature, I seem to have overlooked the fact that the vsock port space is shared between units, and unsharing it would require a network namespace. In contrast, it looks like cloud-hypervisor doesn't actually use vsock and somehow fakes it with a UNIX socket. QEMU cannot do that. Therefore we need to choose a unique port on the host side of the vsock for every single VM, and communicate that port via the systemd credential we pass to the VM.
Because of this, it is impossible to launch more than one MicroVM that use notify sockets with QEMU.
The text was updated successfully, but these errors were encountered: