@@ -24,7 +24,6 @@ import (
24
24
"github.com/coreos/go-semver/semver"
25
25
"github.com/digitalocean/go-qemu/qmp"
26
26
"github.com/digitalocean/go-qemu/qmp/raw"
27
- "github.com/lima-vm/lima/pkg/driver"
28
27
"github.com/lima-vm/lima/pkg/executil"
29
28
"github.com/lima-vm/lima/pkg/limayaml"
30
29
"github.com/lima-vm/lima/pkg/networks/usernet"
@@ -36,23 +35,29 @@ import (
36
35
)
37
36
38
37
type LimaQemuDriver struct {
39
- * driver.BaseDriver
38
+ Instance * store.Instance
39
+ SSHLocalPort int
40
+ VSockPort int
41
+ VirtioPort string
42
+
40
43
qCmd * exec.Cmd
41
44
qWaitCh chan error
42
45
43
46
vhostCmds []* exec.Cmd
44
47
}
45
48
46
- func New (driver * driver.BaseDriver ) * LimaQemuDriver {
47
- driver .VSockPort = 0
48
- driver .VirtioPort = filenames .VirtioPort
49
+ func New (inst * store.Instance ) * LimaQemuDriver {
49
50
// virtserialport doesn't seem to work reliably: https://github.com/lima-vm/lima/issues/2064
50
51
// but on Windows default Unix socket forwarding is not available
52
+ var virtioPort string
53
+ virtioPort = filenames .VirtioPort
51
54
if runtime .GOOS != "windows" {
52
- driver . VirtioPort = ""
55
+ virtioPort = ""
53
56
}
54
57
return & LimaQemuDriver {
55
- BaseDriver : driver ,
58
+ Instance : inst ,
59
+ VSockPort : 0 ,
60
+ VirtioPort : virtioPort ,
56
61
}
57
62
}
58
63
@@ -211,7 +216,7 @@ func (l *LimaQemuDriver) Start(ctx context.Context) (chan error, error) {
211
216
go func () {
212
217
if usernetIndex := limayaml .FirstUsernetIndex (l .Instance .Config ); usernetIndex != - 1 {
213
218
client := usernet .NewClientByName (l .Instance .Config .Networks [usernetIndex ].Lima )
214
- err := client .ConfigureDriver (ctx , l .BaseDriver )
219
+ err := client .ConfigureDriver (ctx , l .Instance , l . SSHLocalPort )
215
220
if err != nil {
216
221
l .qWaitCh <- err
217
222
}
@@ -259,11 +264,11 @@ func (l *LimaQemuDriver) checkBinarySignature() error {
259
264
}
260
265
// The codesign --xml option is only available on macOS Monterey and later
261
266
if ! macOSProductVersion .LessThan (* semver .New ("12.0.0" )) {
262
- qExe , _ , err := Exe (l .BaseDriver . Instance .Arch )
267
+ qExe , _ , err := Exe (l .Instance .Arch )
263
268
if err != nil {
264
- return fmt .Errorf ("failed to find the QEMU binary for the architecture %q: %w" , l .BaseDriver . Instance .Arch , err )
269
+ return fmt .Errorf ("failed to find the QEMU binary for the architecture %q: %w" , l .Instance .Arch , err )
265
270
}
266
- if accel := Accel (l .BaseDriver . Instance .Arch ); accel == "hvf" {
271
+ if accel := Accel (l .Instance .Arch ); accel == "hvf" {
267
272
entitlementutil .AskToSignIfNotSignedProperly (qExe )
268
273
}
269
274
}
0 commit comments