Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/runners/qemu.nix
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ let
else "";

supportsNotifySocket = vsock.cid != null;
vsockHostPortOffset = 600000;

in
lib.warnIf (mem == 2048) ''
Expand All @@ -160,9 +161,13 @@ lib.warnIf (mem == 2048) ''
preStart = ''
${microvmConfig.preStart}
'' + lib.optionalString supportsNotifySocket ''
# Clean up temporary files.
${pkgs.coreutils}/bin/rm -f ./socat.log ./notify_socket.cred
# Default value: for running without systemd.
NOTIFY_VSOCK_PORT=${toString (vsockHostPortOffset + vsock.cid)}
# Start socat to forward systemd notify socket over vsock
if [ -n "''${NOTIFY_SOCKET-}" ]; then
${pkgs.socat}/bin/socat VSOCK-LISTEN:8888,fork UNIX-SENDTO:$NOTIFY_SOCKET &
${pkgs.socat}/bin/socat -d -d VSOCK-LISTEN:$NOTIFY_VSOCK_PORT,fork UNIX-SENDTO:$NOTIFY_SOCKET 2> ./socat.log &
fi
'';

Expand Down Expand Up @@ -314,7 +319,7 @@ lib.warnIf (mem == 2048) ''
# tried, SMBIOS Type 11 entries simply don't work. It looks like it might
# be broken on QEMU side. Why? I don't know.
"-fw_cfg"
"name=opt/io.systemd.credentials/vmm.notify_socket,string=vsock-stream:2:8888"
"name=opt/io.systemd.credentials/vmm.notify_socket,string=vsock-stream:2:${toString (vsockHostPortOffset + vsock.cid)}"
]
++
extraArgs
Expand Down
Loading