Skip to content

Commit 8498a19

Browse files
authored
Merge pull request #1612 from balajiv113/fix-vz-test
Fix rosetta for amd64 and default ip for slirp network in vz driver
2 parents cd8734a + 8b13578 commit 8498a19

File tree

5 files changed

+37
-18
lines changed

5 files changed

+37
-18
lines changed

hack/test-example.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ case "$NAME" in
6666
CHECKS["user-v2"]=1
6767
;;
6868
"vz")
69-
CHECKS["systemd-strict"]=
70-
CHECKS["port-forwards"]=""
7169
CHECKS["snapshot-online"]=""
7270
CHECKS["snapshot-offline"]=""
7371
;;

pkg/limayaml/defaults.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,13 +577,17 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
577577
caCerts := unique(append(append(d.CACertificates.Certs, y.CACertificates.Certs...), o.CACertificates.Certs...))
578578
y.CACertificates.Certs = caCerts
579579

580-
if y.Rosetta.Enabled == nil {
581-
y.Rosetta.Enabled = d.Rosetta.Enabled
582-
}
583-
if o.Rosetta.Enabled != nil {
584-
y.Rosetta.Enabled = o.Rosetta.Enabled
585-
}
586-
if y.Rosetta.Enabled == nil {
580+
if runtime.GOOS == "darwin" && IsNativeArch(AARCH64) {
581+
if y.Rosetta.Enabled == nil {
582+
y.Rosetta.Enabled = d.Rosetta.Enabled
583+
}
584+
if o.Rosetta.Enabled != nil {
585+
y.Rosetta.Enabled = o.Rosetta.Enabled
586+
}
587+
if y.Rosetta.Enabled == nil {
588+
y.Rosetta.Enabled = pointer.Bool(false)
589+
}
590+
} else {
587591
y.Rosetta.Enabled = pointer.Bool(false)
588592
}
589593

pkg/limayaml/defaults_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,16 @@ func TestFillDefault(t *testing.T) {
378378
"-----BEGIN CERTIFICATE-----\nYOUR-ORGS-TRUSTED-CA-CERT\n-----END CERTIFICATE-----\n",
379379
}
380380

381-
expect.Rosetta = Rosetta{
382-
Enabled: pointer.Bool(true),
383-
BinFmt: pointer.Bool(true),
381+
if runtime.GOOS == "darwin" && IsNativeArch(AARCH64) {
382+
expect.Rosetta = Rosetta{
383+
Enabled: pointer.Bool(true),
384+
BinFmt: pointer.Bool(true),
385+
}
386+
} else {
387+
expect.Rosetta = Rosetta{
388+
Enabled: pointer.Bool(false),
389+
BinFmt: pointer.Bool(true),
390+
}
384391
}
385392

386393
y = LimaYAML{}

pkg/networks/usernet/gvproxy.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ type GVisorNetstackOpts struct {
2929
Endpoint string
3030

3131
Async bool
32+
33+
DefaultLeases map[string]string
3234
}
3335

3436
var (
@@ -38,6 +40,13 @@ var (
3840
func StartGVisorNetstack(ctx context.Context, gVisorOpts *GVisorNetstackOpts) error {
3941
opts = gVisorOpts
4042

43+
leases := map[string]string{}
44+
if opts.DefaultLeases != nil {
45+
for k, v := range opts.DefaultLeases {
46+
leases[k] = v
47+
}
48+
}
49+
leases[networks.SlirpGateway] = "5a:94:ef:e4:0c:df"
4150
// The way gvisor-tap-vsock implemented slirp is different from tradition SLIRP,
4251
// - GatewayIP handling all request, also answers DNS queries
4352
// - based on NAT configuration, gateway forwards and translates calls to host
@@ -50,12 +59,10 @@ func StartGVisorNetstack(ctx context.Context, gVisorOpts *GVisorNetstackOpts) er
5059
Subnet: networks.SlirpNetwork,
5160
GatewayIP: networks.SlirpDNS,
5261
GatewayMacAddress: "5a:94:ef:e4:0c:dd",
53-
DHCPStaticLeases: map[string]string{
54-
networks.SlirpGateway: "5a:94:ef:e4:0c:df",
55-
},
56-
Forwards: map[string]string{},
57-
DNS: []types.Zone{},
58-
DNSSearchDomains: searchDomains(),
62+
DHCPStaticLeases: leases,
63+
Forwards: map[string]string{},
64+
DNS: []types.Zone{},
65+
DNSSearchDomains: searchDomains(),
5966
NAT: map[string]string{
6067
networks.SlirpGateway: "127.0.0.1",
6168
},

pkg/vz/vm_darwin.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ func startUsernet(ctx context.Context, driver *driver.BaseDriver) (*usernet.Clie
129129
Endpoint: endpointSock,
130130
FdSocket: vzSock,
131131
Async: true,
132+
DefaultLeases: map[string]string{
133+
networks.SlirpIPAddress: limayaml.MACAddress(driver.Instance.Dir),
134+
},
132135
})
133136
if err != nil {
134137
return nil, err

0 commit comments

Comments
 (0)