147
147
else "" ;
148
148
149
149
supportsNotifySocket = vsock . cid != null ;
150
+ vsockHostPortOffset = 600000 ;
150
151
151
152
in
152
153
lib . warnIf ( mem == 2048 ) ''
@@ -163,15 +164,11 @@ lib.warnIf (mem == 2048) ''
163
164
# Clean up temporary files.
164
165
${ pkgs . coreutils } /bin/rm -f ./socat.log ./notify_socket.cred
165
166
# Default value: for running without systemd.
166
- NOTIFY_VSOCK_PORT=8888
167
+ NOTIFY_VSOCK_PORT=${ toString ( vsockHostPortOffset + vsock . cid ) }
167
168
# Start socat to forward systemd notify socket over vsock
168
169
if [ -n "'' ${NOTIFY_SOCKET-}" ]; then
169
- ${ pkgs . socat } /bin/socat -d -d VSOCK-LISTEN:-1,fork UNIX-SENDTO:$NOTIFY_SOCKET 2> ./socat.log &
170
- NOTIFY_VSOCK_PORT=$({ ${ pkgs . coreutils } /bin/tail -f ./socat.log || true; } | ${ pkgs . gawk } /bin/awk '/listening on/ { if (match($0, /port:[0-9]*/)) { print substr($0, RSTART + 5, RLENGTH - 5); exit; } }')
171
- echo "Picked port for notify vsock: $NOTIFY_VSOCK_PORT"
170
+ ${ pkgs . socat } /bin/socat -d -d VSOCK-LISTEN:$NOTIFY_VSOCK_PORT,fork UNIX-SENDTO:$NOTIFY_SOCKET 2> ./socat.log &
172
171
fi
173
- echo -n "vsock-stream:2:$NOTIFY_VSOCK_PORT" > ./notify_socket.cred
174
-
175
172
'' ;
176
173
177
174
command = lib . escapeShellArgs (
@@ -322,7 +319,7 @@ lib.warnIf (mem == 2048) ''
322
319
# tried, SMBIOS Type 11 entries simply don't work. It looks like it might
323
320
# be broken on QEMU side. Why? I don't know.
324
321
"-fw_cfg"
325
- "name=opt/io.systemd.credentials/vmm.notify_socket,file=./notify_socket.cred "
322
+ "name=opt/io.systemd.credentials/vmm.notify_socket,string=vsock-stream:2: ${ toString ( vsockHostPortOffset + vsock . cid ) } "
326
323
]
327
324
++
328
325
extraArgs
0 commit comments