Skip to content

Commit c3a8755

Browse files
committed
remove wsl2 checks from hostagent.go
Signed-off-by: Ansuman Sahoo <anshumansahoo500@gmail.com>
1 parent 68bfaa5 commit c3a8755

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pkg/hostagent/hostagent.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ func New(ctx context.Context, instName string, stdout io.Writer, signalCh chan o
136136
if err != nil {
137137
return nil, err
138138
}
139-
if *inst.Config.VMType == limatype.WSL2 {
140-
sshLocalPort = inst.SSHLocalPort
141-
}
142139

143140
var udpDNSLocalPort, tcpDNSLocalPort int
144141
if *inst.Config.HostResolver.Enabled {
@@ -157,6 +154,14 @@ func New(ctx context.Context, instName string, stdout io.Writer, signalCh chan o
157154
return nil, fmt.Errorf("failed to create driver instance: %w", err)
158155
}
159156

157+
if limaDriver.Info().Features.DynamicSSHAddress {
158+
sshLocalPort = inst.SSHLocalPort
159+
limaDriver, err = driverutil.CreateConfiguredDriver(inst, sshLocalPort)
160+
if err != nil {
161+
return nil, fmt.Errorf("failed to recreate driver instance: %w", err)
162+
}
163+
}
164+
160165
vSockPort := limaDriver.Info().VsockPort
161166
virtioPort := limaDriver.Info().VirtioPort
162167

@@ -338,8 +343,7 @@ func (a *HostAgent) Run(ctx context.Context) error {
338343
return err
339344
}
340345

341-
// WSL instance SSH address isn't known until after VM start
342-
if *a.instConfig.VMType == limatype.WSL2 {
346+
if a.driver.Info().Features.DynamicSSHAddress {
343347
sshAddr, err := a.driver.SSHAddress(ctx)
344348
if err != nil {
345349
return err
@@ -575,7 +579,7 @@ func (a *HostAgent) watchGuestAgentEvents(ctx context.Context) {
575579
// TODO: use vSock (when QEMU for macOS gets support for vSock)
576580

577581
// Setup all socket forwards and defer their teardown
578-
if *a.instConfig.VMType != limatype.WSL2 {
582+
if !a.driver.Info().Features.SkipSocketForwarding {
579583
logrus.Debugf("Forwarding unix sockets")
580584
for _, rule := range a.instConfig.PortForwards {
581585
if rule.GuestSocket != "" {

0 commit comments

Comments
 (0)