reims-ctl adds `vmx=on` to `-cpu` only where KVM offers nested VMX, so a macOS guest on Windows never sees VMX and cannot run VMs of its own such as Docker Desktop. Add a switch under Settings > CPU & Memory > Performance, off by default and applied on the next start. The switch is Reims-Go's own per-VM setting, kept in the VM directory. At start the macOS driver owns one argument that asks QEMU for VMX on every vCPU without restating the CPU model; it is not a plugin and never shows up among the VM's extra QEMU arguments. A switch file that cannot be read stops the start instead of dropping VMX silently. assisted-by:claude-code:anthropic/claude-fable-5-2
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
package vmstart
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestVMNestedVirtRoundTrip(t *testing.T) {
|
|
dir := t.TempDir()
|
|
if cfg, err := ReadVMNestedVirt(dir); err != nil || cfg.Enabled {
|
|
t.Fatalf("a VM without the file: %+v, %v", cfg, err)
|
|
}
|
|
if err := SaveVMNestedVirt(dir, VMNestedVirtConfig{Enabled: true}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg, err := ReadVMNestedVirt(dir); err != nil || !cfg.Enabled {
|
|
t.Fatalf("after switching on: %+v, %v", cfg, err)
|
|
}
|
|
entries, err := os.ReadDir(dir)
|
|
if err != nil || len(entries) != 1 || entries[0].Name() != vmNestedVirtConfigFile {
|
|
t.Fatalf("the VM directory after saving: %v, %v", entries, err)
|
|
}
|
|
if err := SaveVMNestedVirt(dir, VMNestedVirtConfig{}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := os.Stat(filepath.Join(dir, vmNestedVirtConfigFile)); !os.IsNotExist(err) {
|
|
t.Fatalf("switching off left the file behind: %v", err)
|
|
}
|
|
if err := SaveVMNestedVirt(dir, VMNestedVirtConfig{}); err != nil {
|
|
t.Fatalf("switching an off VM off again: %v", err)
|
|
}
|
|
if err := SaveVMNestedVirt("", VMNestedVirtConfig{Enabled: true}); err == nil {
|
|
t.Fatal("an empty VM directory was accepted")
|
|
}
|
|
}
|
|
|
|
func TestReadVMNestedVirtReportsADamagedFile(t *testing.T) {
|
|
dir := t.TempDir()
|
|
if err := os.WriteFile(filepath.Join(dir, vmNestedVirtConfigFile), []byte("{"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err := ReadVMNestedVirt(dir)
|
|
if err == nil || !strings.Contains(err.Error(), vmNestedVirtConfigFile) {
|
|
t.Fatalf("a damaged file must be reported with its path: %v", err)
|
|
}
|
|
}
|