Skip to content

Commit eb4f0f0

Browse files
committed
qemu: use stream netdev with reconnect for socketVMNet networking
Use -netdev stream instead of legacy -netdev socket for socketVMNet networking on macOS Intel (QEMU backend), with version-appropriate reconnect. Applies to all socketVMNet modes (bridged, shared, host). QEMU >= 9.2: stream with reconnect-ms=500 QEMU 8.0-9.1: stream with reconnect=1 (seconds granularity) QEMU 7.2-7.9: stream without reconnect QEMU < 7.2: fall back to socket (no stream support) The stream backend connects directly to the socket_vmnet UNIX socket, eliminating the pre-dialed fd approach. When reconnect is available, QEMU automatically re-establishes the connection after link failures, recovering VM networking without manual restart. In testing, stream netdev showed ~2x throughput improvement over legacy socket netdev (~1.84 Gbits/sec vs ~970 Mbits/sec). Feature-detected via -netdev help output; version checked for the reconnect parameter which was renamed from reconnect (8.0) to reconnect-ms (9.2) and the old form removed in 10.2. Signed-off-by: Lon C. Lundgren <lon@ocelot.net>
1 parent 2d4314e commit eb4f0f0

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

pkg/driver/qemu/qemu.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,17 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
816816
if err != nil {
817817
return "", nil, err
818818
}
819-
args = append(args, "-netdev", fmt.Sprintf("socket,id=net%d,fd={{ fd_connect %q }}", i+1, sock))
820-
// TODO: should we also validate that the socket exists, or do we rely on the
821-
// networks reconciler to throw an error when the network cannot start?
819+
if strings.Contains(string(features.NetdevHelp), "stream") {
820+
netdev := fmt.Sprintf("stream,id=net%d,server=off,addr.type=unix,addr.path=%s", i+1, sock)
821+
if !version.LessThan(*semver.New("9.2.0")) {
822+
netdev += ",reconnect-ms=500"
823+
} else if !version.LessThan(*semver.New("8.0.0")) {
824+
netdev += ",reconnect=1"
825+
}
826+
args = append(args, "-netdev", netdev)
827+
} else {
828+
args = append(args, "-netdev", fmt.Sprintf("socket,id=net%d,fd={{ fd_connect %q }}", i+1, sock))
829+
}
822830
}
823831
} else if nw.Socket != "" {
824832
args = append(args, "-netdev", fmt.Sprintf("socket,id=net%d,fd={{ fd_connect %q }}", i+1, nw.Socket))

0 commit comments

Comments
 (0)