Skip to content

Commit 3c022c5

Browse files
committed
Fix hostresolver setting for VZ, but disable it by default
Since it was implicitly disabled for VZ, we cannot simply fix the bug, but change the default to match the previous de-facto default. See #4089 for more info. Signed-off-by: Jan Dubois <[email protected]>
1 parent aad73df commit 3c022c5

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

pkg/cidata/cidata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ func templateArgs(ctx context.Context, bootScripts bool, instDir, name string, i
275275
for _, addr := range instConfig.DNS {
276276
args.DNSAddresses = append(args.DNSAddresses, addr.String())
277277
}
278-
case firstUsernetIndex != -1 || *instConfig.VMType == limatype.VZ:
279-
args.DNSAddresses = append(args.DNSAddresses, args.SlirpDNS)
280278
case *instConfig.HostResolver.Enabled:
281279
args.UDPDNSLocalPort = udpDNSLocalPort
282280
args.TCPDNSLocalPort = tcpDNSLocalPort
283281
args.DNSAddresses = append(args.DNSAddresses, args.SlirpDNS)
282+
case firstUsernetIndex != -1 || *instConfig.VMType == limatype.VZ:
283+
args.DNSAddresses = append(args.DNSAddresses, args.SlirpDNS)
284284
default:
285285
args.DNSAddresses, err = osutil.DNSAddresses()
286286
if err != nil {

pkg/driver/vz/vz_driver_darwin.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ func (l *LimaVzDriver) FillConfig(ctx context.Context, cfg *limatype.LimaYAML, _
131131
cfg.MountType = ptr.Of(limatype.VIRTIOFS)
132132
}
133133

134+
if cfg.HostResolver.Enabled == nil {
135+
cfg.HostResolver.Enabled = ptr.Of(false)
136+
}
137+
134138
//nolint:staticcheck // Migration of top-level Rosetta if specified
135139
if (cfg.VMOpts.VZ.Rosetta.Enabled == nil && cfg.VMOpts.VZ.Rosetta.BinFmt == nil) && (!isEmpty(cfg.Rosetta)) {
136140
logrus.Debug("Migrating top-level Rosetta configuration to vmOpts.vz.rosetta")

pkg/driverutil/vm.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/sirupsen/logrus"
1515

1616
"github.com/lima-vm/lima/v2/pkg/limatype"
17+
"github.com/lima-vm/lima/v2/pkg/ptr"
1718
"github.com/lima-vm/lima/v2/pkg/registry"
1819
)
1920

@@ -47,6 +48,10 @@ func validateConfigAgainstDriver(ctx context.Context, y *limatype.LimaYAML, file
4748
return err
4849
}
4950

51+
if y.HostResolver.Enabled == nil {
52+
y.HostResolver.Enabled = ptr.Of(true)
53+
}
54+
5055
return nil
5156
}
5257

pkg/limayaml/defaults.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,7 @@ func FillDefault(ctx context.Context, y, d, o *limatype.LimaYAML, filePath strin
538538
if o.HostResolver.Enabled != nil {
539539
y.HostResolver.Enabled = o.HostResolver.Enabled
540540
}
541-
if y.HostResolver.Enabled == nil {
542-
y.HostResolver.Enabled = ptr.Of(true)
543-
}
541+
// Default will be filled in by driver (true, except for VZ)
544542

545543
if y.HostResolver.IPv6 == nil {
546544
y.HostResolver.IPv6 = d.HostResolver.IPv6

templates/default.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ propagateProxyEnv: null
565565
# can only work when using a vmnet network interface and the host has working
566566
# IPv6 configured as well.
567567
hostResolver:
568-
# 🟢 Builtin default: true
568+
# 🟢 Builtin default: true (except for vmType: vz, where it is false)
569569
enabled: null
570570
# 🟢 Builtin default: false
571571
ipv6: null

0 commit comments

Comments
 (0)