@@ -38,6 +38,10 @@ import (
38
38
"github.com/sirupsen/logrus"
39
39
)
40
40
41
+ // RecommendedQemuVersion is the recommemded QEMU version.
42
+ // See commit 8c48cb3eef178914f1b8fffee324aab0c445fec5 .
43
+ const RecommendedQemuVersion = "7.1.0"
44
+
41
45
type Config struct {
42
46
Name string
43
47
InstanceDir string
@@ -47,11 +51,6 @@ type Config struct {
47
51
VirtioGA bool
48
52
}
49
53
50
- // MinimumQemuVersion is the minimum supported QEMU version.
51
- const (
52
- MinimumQemuVersion = "4.0.0"
53
- )
54
-
55
54
// EnsureDisk also ensures the kernel and the initrd.
56
55
func EnsureDisk (ctx context.Context , cfg Config ) error {
57
56
diffDisk := filepath .Join (cfg .InstanceDir , filenames .DiffDisk )
@@ -313,9 +312,6 @@ type features struct {
313
312
// e.g. "Available CPUs:\n...\nx86 base...\nx86 host...\n...\n"
314
313
// Not machine-readable, but checking strings.Contains() should be fine.
315
314
CPUHelp []byte
316
-
317
- // VersionGEQ7 is true when the QEMU version seems v7.0.0 or later
318
- VersionGEQ7 bool
319
315
}
320
316
321
317
func inspectFeatures (exe , machine string ) (* features , error ) {
@@ -359,7 +355,6 @@ func inspectFeatures(exe, machine string) (*features, error) {
359
355
f .MachineHelp = stderr .Bytes ()
360
356
}
361
357
}
362
- f .VersionGEQ7 = strings .Contains (string (f .MachineHelp ), "-7.0" )
363
358
364
359
// Avoid error: "No machine specified, and there is no default"
365
360
cmd = exec .Command (exe , "-cpu" , "help" , "-machine" , machine )
@@ -377,56 +372,15 @@ func inspectFeatures(exe, machine string) (*features, error) {
377
372
return & f , nil
378
373
}
379
374
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
375
// adjustMemBytesDarwinARM64HVF adjusts the memory to be <= 3 GiB, only when the following conditions are met:
421
376
//
422
377
// - Host OS < macOS 12.4
423
378
// - Host Arch == arm64
424
379
// - Accel == hvf
425
- // - QEMU >= 7.0
426
380
//
427
381
// This adjustment is required for avoiding host kernel panic. The issue was fixed in macOS 12.4 Beta 1.
428
382
// 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 {
383
+ func adjustMemBytesDarwinARM64HVF (memBytes int64 , accel string ) int64 {
430
384
const safeSize = 3 * 1024 * 1024 * 1024 // 3 GiB
431
385
if memBytes <= safeSize {
432
386
return memBytes
@@ -440,9 +394,6 @@ func adjustMemBytesDarwinARM64HVF(memBytes int64, accel string, features *featur
440
394
if accel != "hvf" {
441
395
return memBytes
442
396
}
443
- if ! features .VersionGEQ7 {
444
- return memBytes
445
- }
446
397
macOSProductVersion , err := osutil .ProductVersion ()
447
398
if err != nil {
448
399
logrus .Warn (err )
@@ -451,8 +402,8 @@ func adjustMemBytesDarwinARM64HVF(memBytes int64, accel string, features *featur
451
402
if ! macOSProductVersion .LessThan (* semver .New ("12.4.0" )) {
452
403
return memBytes
453
404
}
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 ; " +
405
+ logrus .Warnf ("Reducing the guest memory from %s to %s, to avoid host kernel panic on macOS <= 12.3; " +
406
+ "Please update macOS to 12.4 or later; " +
456
407
"See https://github.com/lima-vm/lima/issues/795 for the further background." ,
457
408
units .BytesSize (float64 (memBytes )), units .BytesSize (float64 (safeSize )))
458
409
memBytes = safeSize
@@ -500,28 +451,26 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
500
451
if version .LessThan (* semver .New (MinimumQemuVersion )) {
501
452
logrus .Fatalf ("QEMU %v is too old, %v or later required" , version , MinimumQemuVersion )
502
453
}
454
+ if version .LessThan (* semver .New (RecommendedQemuVersion )) {
455
+ logrus .Warnf ("QEMU %v is too old, %v or later is recommended" , version , RecommendedQemuVersion )
456
+ }
503
457
if y .VMOpts .QEMU .MinimumVersion != nil && version .LessThan (* semver .New (* y .VMOpts .QEMU .MinimumVersion )) {
504
458
logrus .Fatalf ("QEMU %v is too old, template requires %q or later" , version , * y .VMOpts .QEMU .MinimumVersion )
505
459
}
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
460
}
511
461
512
462
// Architecture
513
463
accel := Accel (* y .Arch )
514
464
if ! strings .Contains (string (features .AccelHelp ), accel ) {
515
465
return "" , nil , fmt .Errorf ("accelerator %q is not supported by %s" , accel , exe )
516
466
}
517
- showDarwinARM64HVFQEMU620Warning (exe , accel , features )
518
467
519
468
// Memory
520
469
memBytes , err := units .RAMInBytes (* y .Memory )
521
470
if err != nil {
522
471
return "" , nil , err
523
472
}
524
- memBytes = adjustMemBytesDarwinARM64HVF (memBytes , accel , features )
473
+ memBytes = adjustMemBytesDarwinARM64HVF (memBytes , accel )
525
474
args = appendArgsIfNoConflict (args , "-m" , strconv .Itoa (int (memBytes >> 20 )))
526
475
527
476
if * y .MountType == limayaml .VIRTIOFS {
@@ -569,14 +518,6 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
569
518
}
570
519
case limayaml .AARCH64 :
571
520
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
521
args = appendArgsIfNoConflict (args , "-machine" , machine )
581
522
case limayaml .RISCV64 :
582
523
// https://github.com/tianocore/edk2/blob/edk2-stable202408/OvmfPkg/RiscVVirt/README.md#test
@@ -876,23 +817,15 @@ func Cmdline(ctx context.Context, cfg Config) (exe string, args []string, err er
876
817
}
877
818
878
819
switch * y .Arch {
820
+ // FIXME: use virtio-gpu on all the architectures
879
821
case limayaml .X8664 , limayaml .RISCV64 :
880
822
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" )
823
+ default :
824
+ args = append (args , "-device" , "virtio-gpu" )
895
825
}
826
+ args = append (args , "-device" , "virtio-keyboard-pci" )
827
+ args = append (args , "-device" , "virtio-" + input + "-pci" )
828
+ args = append (args , "-device" , "qemu-xhci,id=usb-bus" )
896
829
897
830
// Parallel
898
831
args = append (args , "-parallel" , "none" )
0 commit comments