@@ -49,7 +49,7 @@ type Config struct {
49
49
50
50
// MinimumQemuVersion is the minimum supported QEMU version.
51
51
const (
52
- MinimumQemuVersion = "4 .0.0"
52
+ MinimumQemuVersion = "7 .0.0"
53
53
)
54
54
55
55
// EnsureDisk also ensures the kernel and the initrd.
@@ -313,9 +313,6 @@ type features struct {
313
313
// e.g. "Available CPUs:\n...\nx86 base...\nx86 host...\n...\n"
314
314
// Not machine-readable, but checking strings.Contains() should be fine.
315
315
CPUHelp []byte
316
-
317
- // VersionGEQ7 is true when the QEMU version seems v7.0.0 or later
318
- VersionGEQ7 bool
319
316
}
320
317
321
318
func inspectFeatures (exe , machine string ) (* features , error ) {
@@ -359,7 +356,6 @@ func inspectFeatures(exe, machine string) (*features, error) {
359
356
f .MachineHelp = stderr .Bytes ()
360
357
}
361
358
}
362
- f .VersionGEQ7 = strings .Contains (string (f .MachineHelp ), "-7.0" )
363
359
364
360
// Avoid error: "No machine specified, and there is no default"
365
361
cmd = exec .Command (exe , "-cpu" , "help" , "-machine" , machine )
@@ -377,56 +373,15 @@ func inspectFeatures(exe, machine string) (*features, error) {
377
373
return & f , nil
378
374
}
379
375
380
- // showDarwinARM64HVFQEMU620Warning shows a warning on M1 macOS when QEMU is older than 6.2.0_1.
381
- //
382
- // See:
383
- // - https://gitlab.com/qemu-project/qemu/-/issues/899
384
- // - https://github.com/Homebrew/homebrew-core/pull/96743
385
- // - https://github.com/lima-vm/lima/issues/712
386
- func showDarwinARM64HVFQEMU620Warning (exe , accel string , features * features ) {
387
- if runtime .GOOS != "darwin" {
388
- return
389
- }
390
- if runtime .GOARCH != "arm64" {
391
- return
392
- }
393
- if accel != "hvf" {
394
- return
395
- }
396
- if features .VersionGEQ7 {
397
- return
398
- }
399
- if exeFull , err := exec .LookPath (exe ); err == nil {
400
- if exeResolved , err2 := filepath .EvalSymlinks (exeFull ); err2 == nil {
401
- if strings .Contains (exeResolved , "Cellar/qemu/6.2.0_" ) {
402
- // Homebrew's QEMU 6.2.0_1 or later
403
- return
404
- }
405
- }
406
- }
407
- w := "This version of QEMU might not be able to boot recent Linux guests on M1 macOS hosts."
408
- if _ , err := exec .LookPath ("brew" ); err == nil {
409
- w += "Run `brew upgrade` and make sure your QEMU version is 6.2.0_1 or later."
410
- } else {
411
- w += `Reinstall QEMU with the following commits (included in QEMU 7.0.0):
412
- - https://github.com/qemu/qemu/commit/ad99f64f "hvf: arm: Use macros for sysreg shift/masking"
413
- - https://github.com/qemu/qemu/commit/7f6c295c "hvf: arm: Handle unknown ID registers as RES0"
414
- `
415
- w += "See https://github.com/Homebrew/homebrew-core/pull/96743 for the further information."
416
- }
417
- logrus .Warn (w )
418
- }
419
-
420
376
// adjustMemBytesDarwinARM64HVF adjusts the memory to be <= 3 GiB, only when the following conditions are met:
421
377
//
422
378
// - Host OS < macOS 12.4
423
379
// - Host Arch == arm64
424
380
// - Accel == hvf
425
- // - QEMU >= 7.0
426
381
//
427
382
// This adjustment is required for avoiding host kernel panic. The issue was fixed in macOS 12.4 Beta 1.
428
383
// See https://github.com/lima-vm/lima/issues/795 https://gitlab.com/qemu-project/qemu/-/issues/903#note_911000975
429
- func adjustMemBytesDarwinARM64HVF (memBytes int64 , accel string , features * features ) int64 {
384
+ func adjustMemBytesDarwinARM64HVF (memBytes int64 , accel string ) int64 {
430
385
const safeSize = 3 * 1024 * 1024 * 1024 // 3 GiB
431
386
if memBytes <= safeSize {
432
387
return memBytes
@@ -440,9 +395,6 @@ func adjustMemBytesDarwinARM64HVF(memBytes int64, accel string, features *featur
440
395
if accel != "hvf" {
441
396
return memBytes
442
397
}
443
- if ! features .VersionGEQ7 {
444
- return memBytes
445
- }
446
398
macOSProductVersion , err := osutil .ProductVersion ()
447
399
if err != nil {
448
400
logrus .Warn (err )
@@ -451,8 +403,8 @@ func adjustMemBytesDarwinARM64HVF(memBytes int64, accel string, features *featur
451
403
if ! macOSProductVersion .LessThan (* semver .New ("12.4.0" )) {
452
404
return memBytes
453
405
}
454
- logrus .Warnf ("Reducing the guest memory from %s to %s, to avoid host kernel panic on macOS <= 12.3 with QEMU >= 7.0 ; " +
455
- "Please update macOS to 12.4 or later, or downgrade QEMU to 6.2 ; " +
406
+ logrus .Warnf ("Reducing the guest memory from %s to %s, to avoid host kernel panic on macOS <= 12.3; " +
407
+ "Please update macOS to 12.4 or later; " +
456
408
"See https://github.com/lima-vm/lima/issues/795 for the further background." ,
457
409
units .BytesSize (float64 (memBytes )), units .BytesSize (float64 (safeSize )))
458
410
memBytes = safeSize
@@ -503,25 +455,20 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
503
455
if y .VMOpts .QEMU .MinimumVersion != nil && version .LessThan (* semver .New (* y .VMOpts .QEMU .MinimumVersion )) {
504
456
logrus .Fatalf ("QEMU %v is too old, template requires %q or later" , version , * y .VMOpts .QEMU .MinimumVersion )
505
457
}
506
- if runtime .GOOS == "darwin" && runtime .GOARCH == "arm64" && version .Equal (* semver .New ("8.2.0" )) {
507
- logrus .Fatal ("QEMU 8.2.0 is no longer supported on ARM Mac due to <https://gitlab.com/qemu-project/qemu/-/issues/1990>. " +
508
- "Please upgrade QEMU to v8.2.1 (or downgrade to v8.1.x)." )
509
- }
510
458
}
511
459
512
460
// Architecture
513
461
accel := Accel (* y .Arch )
514
462
if ! strings .Contains (string (features .AccelHelp ), accel ) {
515
463
return "" , nil , fmt .Errorf ("accelerator %q is not supported by %s" , accel , exe )
516
464
}
517
- showDarwinARM64HVFQEMU620Warning (exe , accel , features )
518
465
519
466
// Memory
520
467
memBytes , err := units .RAMInBytes (* y .Memory )
521
468
if err != nil {
522
469
return "" , nil , err
523
470
}
524
- memBytes = adjustMemBytesDarwinARM64HVF (memBytes , accel , features )
471
+ memBytes = adjustMemBytesDarwinARM64HVF (memBytes , accel )
525
472
args = appendArgsIfNoConflict (args , "-m" , strconv .Itoa (int (memBytes >> 20 )))
526
473
527
474
if * y .MountType == limayaml .VIRTIOFS {
@@ -569,14 +516,6 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
569
516
}
570
517
case limayaml .AARCH64 :
571
518
machine := "virt,accel=" + accel
572
- // QEMU >= 7.0 requires highmem=off NOT to be set, otherwise fails with "Addressing limited to 32 bits, but memory exceeds it by 1073741824 bytes"
573
- // QEMU < 7.0 requires highmem=off to be set, otherwise fails with "VCPU supports less PA bits (36) than requested by the memory map (40)"
574
- // https://github.com/lima-vm/lima/issues/680
575
- // https://github.com/lima-vm/lima/pull/24
576
- // But when the memory size is <= 3 GiB, we can always set highmem=off.
577
- if ! features .VersionGEQ7 || memBytes <= 3 * 1024 * 1024 * 1024 {
578
- machine += ",highmem=off"
579
- }
580
519
args = appendArgsIfNoConflict (args , "-machine" , machine )
581
520
case limayaml .RISCV64 :
582
521
// https://github.com/tianocore/edk2/blob/edk2-stable202408/OvmfPkg/RiscVVirt/README.md#test
@@ -876,23 +815,15 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
876
815
}
877
816
878
817
switch * y .Arch {
818
+ // FIXME: use virtio-gpu on all the architectures
879
819
case limayaml .X8664 , limayaml .RISCV64 :
880
820
args = append (args , "-device" , "virtio-vga" )
881
- args = append (args , "-device" , "virtio-keyboard-pci" )
882
- args = append (args , "-device" , "virtio-" + input + "-pci" )
883
- args = append (args , "-device" , "qemu-xhci,id=usb-bus" )
884
- case limayaml .AARCH64 , limayaml .ARMV7L , limayaml .PPC64LE , limayaml .S390X :
885
- if features .VersionGEQ7 {
886
- args = append (args , "-device" , "virtio-gpu" )
887
- args = append (args , "-device" , "virtio-keyboard-pci" )
888
- args = append (args , "-device" , "virtio-" + input + "-pci" )
889
- } else { // kernel panic with virtio and old versions of QEMU
890
- args = append (args , "-vga" , "none" , "-device" , "ramfb" )
891
- args = append (args , "-device" , "usb-kbd,bus=usb-bus" )
892
- args = append (args , "-device" , "usb-" + input + ",bus=usb-bus" )
893
- }
894
- args = append (args , "-device" , "qemu-xhci,id=usb-bus" )
821
+ default :
822
+ args = append (args , "-device" , "virtio-gpu" )
895
823
}
824
+ args = append (args , "-device" , "virtio-keyboard-pci" )
825
+ args = append (args , "-device" , "virtio-" + input + "-pci" )
826
+ args = append (args , "-device" , "qemu-xhci,id=usb-bus" )
896
827
897
828
// Parallel
898
829
args = append (args , "-parallel" , "none" )
0 commit comments