Skip to content

Commit

Permalink
Merge pull request #3254 from arixmkii/qemu-ssh-address
Browse files Browse the repository at this point in the history
Use SSHAddress for SSH forwarding in QEMU
  • Loading branch information
AkihiroSuda authored Feb 19, 2025
2 parents b55086f + ddf5aff commit 95f0262
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Config struct {
InstanceDir string
LimaYAML *limayaml.LimaYAML
SSHLocalPort int
SSHAddress string
}

// MinimumQemuVersion is the minimum supported QEMU version.
Expand Down Expand Up @@ -716,8 +717,8 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
// Configure default usernetwork with limayaml.MACAddress(driver.Instance.Dir) for eth0 interface
firstUsernetIndex := limayaml.FirstUsernetIndex(y)
if firstUsernetIndex == -1 {
args = append(args, "-netdev", fmt.Sprintf("user,id=net0,net=%s,dhcpstart=%s,hostfwd=tcp:127.0.0.1:%d-:22",
networks.SlirpNetwork, networks.SlirpIPAddress, cfg.SSHLocalPort))
args = append(args, "-netdev", fmt.Sprintf("user,id=net0,net=%s,dhcpstart=%s,hostfwd=tcp:%s:%d-:22",
networks.SlirpNetwork, networks.SlirpIPAddress, cfg.SSHAddress, cfg.SSHLocalPort))
} else {
qemuSock, err := usernet.Sock(y.Networks[firstUsernetIndex].Lima, usernet.QEMUSock)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/qemu/qemu_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func (l *LimaQemuDriver) Start(ctx context.Context) (chan error, error) {
InstanceDir: l.Instance.Dir,
LimaYAML: l.Instance.Config,
SSHLocalPort: l.SSHLocalPort,
SSHAddress: l.Instance.SSHAddress,
}
qExe, qArgs, err := Cmdline(ctx, qCfg)
if err != nil {
Expand Down

0 comments on commit 95f0262

Please sign in to comment.