@@ -50,6 +50,25 @@ func New(driver *driver.BaseDriver) *LimaQemuDriver {
50
50
}
51
51
52
52
func (l * LimaQemuDriver ) Validate () error {
53
+ // Ask the user to sign the qemu binary with the "com.apple.security.hypervisor" if needed.
54
+ // Workaround for https://github.com/lima-vm/lima/issues/1742
55
+ if runtime .GOOS == "darwin" && l .BaseDriver .Instance .VMType == limayaml .QEMU {
56
+ macOSProductVersion , err := osutil .ProductVersion ()
57
+ if err != nil {
58
+ return err
59
+ }
60
+ // The codesign --xml option is only available on macOS Monterey and later
61
+ if ! macOSProductVersion .LessThan (* semver .New ("12.0.0" )) {
62
+ qExe , _ , err := Exe (l .BaseDriver .Instance .Arch )
63
+ if err != nil {
64
+ return fmt .Errorf ("failed to find the QEMU binary for the architecture %q: %w" , l .BaseDriver .Instance .Arch , err )
65
+ }
66
+ if accel := Accel (l .BaseDriver .Instance .Arch ); accel == "hvf" {
67
+ entitlementutil .AskToSignIfNotSignedProperly (qExe )
68
+ }
69
+ }
70
+ }
71
+
53
72
if * l .Instance .Config .MountType == limayaml .VIRTIOFS && runtime .GOOS != "linux" {
54
73
return fmt .Errorf ("field `mountType` must be %q or %q for QEMU driver on non-Linux, got %q" ,
55
74
limayaml .REVSSHFS , limayaml .NINEP , * l .Instance .Config .MountType )
@@ -411,25 +430,6 @@ func (l *LimaQemuDriver) GuestAgentConn(ctx context.Context) (net.Conn, error) {
411
430
return dialContext , err
412
431
}
413
432
414
- func (l * LimaQemuDriver ) CheckBinarySignature (_ context.Context , arch string ) error {
415
- macOSProductVersion , err := osutil .ProductVersion ()
416
- if err != nil {
417
- return err
418
- }
419
- // The codesign --xml option is only available on macOS Monterey and later
420
- if ! macOSProductVersion .LessThan (* semver .New ("12.0.0" )) {
421
- qExe , _ , err := Exe (arch )
422
- if err != nil {
423
- return fmt .Errorf ("failed to find the QEMU binary for the architecture %q: %w" , arch , err )
424
- }
425
- if accel := Accel (arch ); accel == "hvf" {
426
- entitlementutil .AskToSignIfNotSignedProperly (qExe )
427
- }
428
- }
429
-
430
- return nil
431
- }
432
-
433
433
type qArgTemplateApplier struct {
434
434
files []* os.File
435
435
}
0 commit comments