Skip to content

Commit 3a6502a

Browse files
authored
Merge pull request #703 from AkihiroSuda/arm-qemu7
aarch64: unset highmem=off for QEMU >= 7.0
2 parents e231af1 + de9fd82 commit 3a6502a

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

pkg/qemu/qemu.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ type features struct {
150150
// e.g. "Available netdev backend types:\nsocket\nhubport\ntap\nuser\nvde\nbridge\vhost-user\n"
151151
// Not machine-readable, but checking strings.Contains() should be fine.
152152
NetdevHelp []byte
153+
// MachineHelp is the output of `qemu-system-x86_64 -machine help`
154+
// e.g. "Supported machines are:\nakita...\n...virt-6.2...\n...virt-7.0...\n...\n"
155+
// Not machine-readable, but checking strings.Contains() should be fine.
156+
MachineHelp []byte
153157
}
154158

155159
func inspectFeatures(exe string) (*features, error) {
@@ -181,6 +185,19 @@ func inspectFeatures(exe string) (*features, error) {
181185
f.NetdevHelp = stderr.Bytes()
182186
}
183187
}
188+
189+
cmd = exec.Command(exe, "-machine", "help")
190+
cmd.Stdout = &stdout
191+
cmd.Stderr = &stderr
192+
if err := cmd.Run(); err != nil {
193+
logrus.Warnf("failed to run %v: stdout=%q, stderr=%q", cmd.Args, stdout.String(), stderr.String())
194+
} else {
195+
f.MachineHelp = stdout.Bytes()
196+
if len(f.MachineHelp) == 0 {
197+
f.MachineHelp = stderr.Bytes()
198+
}
199+
}
200+
184201
return &f, nil
185202
}
186203

@@ -220,7 +237,15 @@ func Cmdline(cfg Config) (string, []string, error) {
220237
args = appendArgsIfNoConflict(args, "-machine", "q35,accel="+accel)
221238
}
222239
case limayaml.AARCH64:
223-
args = appendArgsIfNoConflict(args, "-machine", "virt,accel="+accel+",highmem=off")
240+
machine := "virt,accel=" + accel
241+
// 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"
242+
// 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)"
243+
// https://github.com/lima-vm/lima/issues/680
244+
// https://github.com/lima-vm/lima/pull/24
245+
if !strings.Contains(string(features.MachineHelp), "virt-7.0") {
246+
machine += ",highmem=off"
247+
}
248+
args = appendArgsIfNoConflict(args, "-machine", machine)
224249
}
225250

226251
// SMP

0 commit comments

Comments
 (0)