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