diff --git a/docs/architecture.md b/docs/architecture.md index 35e7794..2f104f9 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -96,7 +96,7 @@ flowchart TB ### 4.4 宿主机体检与硬件调优 - **免提权 WHPX 检测**:通过 `WinHvPlatform.dll`(`WHvGetCapability`)与系统功能查询判断状态,仅在缺失且用户确认时通过 `ShellExecuteW(..., "runas", ...)` 触发 UAC 启用。 -- **提交内存预检**:通过 `GlobalMemoryStatusEx` 检查可用提交内存(`AvailPageFile`),因为 QEMU 在 Windows 上会一次性提交整块客体内存;建机时推荐安全档位,启动前余量不足时提前拦截。 +- **提交内存预检**:QEMU 在 Windows 上会一次性提交整块客体内存,所以预检看的是 Windows 还能提交多少内存。这个值等于当前剩余可提交量(`GlobalMemoryStatusEx` 的 `AvailPageFile`)加上页面文件还能扩展的大小;后者按 `NtQuerySystemInformation(SystemPageFileInformationEx)` 给出的每个页面文件的上限计算,并受所在盘剩余空间限制。提交超出当前上限时,系统托管或设了最大值的页面文件会当场扩展,所以不能只看当前上限;页面文件为固定大小或已禁用时,扩展部分为零。建机时推荐安全档位,启动前余量不足时提前拦截。 - **GPU 与大小核**:扫描注册表 Vulkan ICD 并过滤虚拟显示适配器;解析 `GetLogicalProcessorInformationEx` 识别 P / E / LP-E 三层混合核心,支持按 VM 实时调整进程亲和性,避免超售卡顿。宿主只评估通用硬件事实;`kernel_irqchip`、冷重启等 macOS/WHPX 建议由所属驱动的 `driver.OptimizationAdvisor` 提供,与启动准备共用运行时判定。 ### 4.5 应用内更新 diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index a970978..99c768e 100644 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -1067,6 +1067,7 @@ export namespace host { memory_spec?: HostMemorySpec; commit_avail_gb: number; commit_limit_gb: number; + paging_file_growth_gb?: number; data_root: string; data_root_drive_type?: string; defender_realtime_active?: boolean; @@ -1115,6 +1116,7 @@ export namespace host { this.memory_spec = this.convertValues(source["memory_spec"], HostMemorySpec); this.commit_avail_gb = source["commit_avail_gb"]; this.commit_limit_gb = source["commit_limit_gb"]; + this.paging_file_growth_gb = source["paging_file_growth_gb"]; this.data_root = source["data_root"]; this.data_root_drive_type = source["data_root_drive_type"]; this.defender_realtime_active = source["defender_realtime_active"]; diff --git a/internal/host/host.go b/internal/host/host.go index 31eaa80..3896739 100644 --- a/internal/host/host.go +++ b/internal/host/host.go @@ -82,9 +82,12 @@ type Report struct { // Commit memory: QEMU commits all guest RAM at start (CreateFileMapping), so // a VM needs its memory free in the commit charge, not just in physical RAM. // Measured 2026-11-28: 14.7 GiB commit free with 17.3 GiB physical free, and a - // 16G guest failed ("Cannot set up guest memory"). portable-runtime-spec.md §5.1. + // 16G guest failed ("Cannot set up guest memory"); the paging file setup of + // that host was not recorded. Both values include what the paging files can + // still grow (CommitHeadroom): Windows grows them when a commit needs it. CommitAvailGB float64 `json:"commit_avail_gb"` CommitLimitGB float64 `json:"commit_limit_gb"` + PagingFileGrowthGB float64 `json:"paging_file_growth_gb,omitempty"` // part of both values above DataRoot string `json:"data_root"` DataRootDriveType string `json:"data_root_drive_type,omitempty"` DeepBackingChains []BackingChainIssue `json:"deep_backing_chains,omitempty"` diff --git a/internal/host/host_windows.go b/internal/host/host_windows.go index cbaad68..784d5ec 100644 --- a/internal/host/host_windows.go +++ b/internal/host/host_windows.go @@ -170,9 +170,10 @@ func Inspect(dataRoot string) Report { if ms, ok := memoryStatus(); ok { rep.MemoryLoadPct = int(ms.MemoryLoad) } - if limitGB, availGB, ok := probeCommitGB(); ok { + if limitGB, availGB, growthGB, ok := probeCommitGB(); ok { rep.CommitLimitGB = limitGB rep.CommitAvailGB = availGB + rep.PagingFileGrowthGB = growthGB } if freeGB, ok := probeFreeDiskGB(dataRoot); ok { rep.FreeDiskGB = freeGB @@ -444,16 +445,26 @@ func probeMemoryGB() (totalGB, availGB float64, ok bool) { return float64(ms.TotalPhys) / gb, float64(ms.AvailPhys) / gb, true } -// probeCommitGB reads the system commit limit and what is still free in it. -// GlobalMemoryStatusEx's "page file" fields are the commit limit and the -// available commit for the system (not the page file alone). -func probeCommitGB() (limitGB, availGB float64, ok bool) { +// probeCommitGB reads the commit limit Windows can reach and the commit it can +// still grant, including what the paging files can still grow +// (CommitHeadroom). GlobalMemoryStatusEx's "page file" fields are the current +// commit limit and free commit (not the page file alone); growthGB is the +// part added on top of them. When the paging files can't be read, growth is +// taken as zero and the current values stand. +func probeCommitGB() (limitGB, availGB, growthGB float64, ok bool) { ms, ok := memoryStatus() if !ok { - return 0, 0, false + return 0, 0, 0, false } const gb = 1024 * 1024 * 1024 - return float64(ms.TotalPageFile) / gb, float64(ms.AvailPageFile) / gb, true + limitGB, availGB = float64(ms.TotalPageFile)/gb, float64(ms.AvailPageFile)/gb + files, err := probePagingFiles() + if err != nil { + return limitGB, availGB, 0, true + } + growthGB = PagingFileGrowthGB(files) + limitGB, availGB = CommitHeadroom(limitGB, availGB, files) + return limitGB, availGB, growthGB, true } func memoryStatus() (memoryStatusEx, bool) { @@ -463,9 +474,10 @@ func memoryStatus() (memoryStatusEx, bool) { return ms, r != 0 } -// CommitAvailGB is the commit memory free right now (for start-time checks). +// CommitAvailGB is the commit memory Windows can grant right now, paging file +// growth included (for start-time checks). func CommitAvailGB() (float64, bool) { - _, avail, ok := probeCommitGB() + _, avail, _, ok := probeCommitGB() return avail, ok } diff --git a/internal/host/memory.go b/internal/host/memory.go index 63dc0db..7e07f58 100644 --- a/internal/host/memory.go +++ b/internal/host/memory.go @@ -1,15 +1,68 @@ package host +import "strings" + // StartMarginGB is the commit memory a VM needs beyond its guest RAM: QEMU's own // allocations and the graphics path. Conservative; refine with measurements. const StartMarginGB = 1.0 +// pagingFileDiskReserveGB is the free space left on a paging file's volume +// when estimating how far the file can still grow. +const pagingFileDiskReserveGB = 2.0 + // memoryChoices are the sizes the UI offers (GB). var memoryChoices = []float64{4, 6, 8, 12, 16, 24, 32, 48, 64} +// PagingFile is one paging file as Windows reports it, plus the free space of +// the volume it lives on. +type PagingFile struct { + Volume string // e.g. `C:\`; files on one volume share its free space + CurrentGB float64 // current size + MaxGB float64 // largest size Windows may grow it to + VolumeFreeGB float64 +} + +// CommitHeadroom returns the commit limit Windows can reach and the commit it +// can still grant, counting what paging files can still grow on top of the +// current limit and free commit. A commit larger than the free commit makes +// Windows grow a system-managed or min/max-sized paging file on the spot +// (measured 2026-12-01: one 24.3 GB CreateFileMapping with 14.3 GB free grew +// the limit from 37.4 to 47.4 GB), so the current limit alone refuses VMs +// that would start. Growth is capped by each file's maximum and its volume's +// free space less pagingFileDiskReserveGB; a fixed-size or absent paging file +// adds nothing. +func CommitHeadroom(limitGB, availGB float64, files []PagingFile) (reachableLimitGB, reachableAvailGB float64) { + growth := PagingFileGrowthGB(files) + return limitGB + growth, availGB + growth +} + +// PagingFileGrowthGB is how much the paging files can still grow in total. +func PagingFileGrowthGB(files []PagingFile) float64 { + volumeLeft := map[string]float64{} + total := 0.0 + for _, f := range files { + vol := strings.ToUpper(f.Volume) + left, seen := volumeLeft[vol] + if !seen { + left = f.VolumeFreeGB - pagingFileDiskReserveGB + } + grow := f.MaxGB - f.CurrentGB + if grow > left { + grow = left + } + if grow <= 0 { + volumeLeft[vol] = left + continue + } + volumeLeft[vol] = left - grow + total += grow + } + return total +} + // RecommendedMemoryGB is the largest offered size that fits both in 60% of -// physical RAM and in the commit memory free now (minus StartMarginGB and 2 GB -// headroom for the host). At least 4. +// physical RAM and in the commit memory Windows can still grant (minus +// StartMarginGB and 2 GB headroom for the host). At least 4. func RecommendedMemoryGB(rep Report) float64 { limit := rep.TotalRAMGB * 0.6 if rep.CommitAvailGB > 0 { diff --git a/internal/host/memory_test.go b/internal/host/memory_test.go index d6dc239..93316dd 100644 --- a/internal/host/memory_test.go +++ b/internal/host/memory_test.go @@ -2,8 +2,50 @@ package host import "testing" +func TestPagingFileGrowth(t *testing.T) { + cases := []struct { + name string + files []PagingFile + want float64 + }{ + {"no paging file", nil, 0}, + // The measured host: system-managed 5.6 GB file, max 37.5 GB (1/8 of C:), 141.7 GB free. + {"system managed", []PagingFile{{Volume: `C:\`, CurrentGB: 5.6, MaxGB: 37.5, VolumeFreeGB: 141.7}}, 31.9}, + {"fixed size", []PagingFile{{Volume: `C:\`, CurrentGB: 16, MaxGB: 16, VolumeFreeGB: 100}}, 0}, + {"max below current", []PagingFile{{Volume: `C:\`, CurrentGB: 8, MaxGB: 4, VolumeFreeGB: 100}}, 0}, + {"disk nearly full", []PagingFile{{Volume: `C:\`, CurrentGB: 4, MaxGB: 40, VolumeFreeGB: 5}}, 3}, + {"disk below reserve", []PagingFile{{Volume: `C:\`, CurrentGB: 4, MaxGB: 40, VolumeFreeGB: 1}}, 0}, + {"two files share one volume", []PagingFile{ + {Volume: `D:\`, CurrentGB: 2, MaxGB: 10, VolumeFreeGB: 12}, + {Volume: `d:\`, CurrentGB: 2, MaxGB: 10, VolumeFreeGB: 12}, + }, 10}, + {"files on two volumes", []PagingFile{ + {Volume: `C:\`, CurrentGB: 2, MaxGB: 6, VolumeFreeGB: 50}, + {Volume: `D:\`, CurrentGB: 1, MaxGB: 3, VolumeFreeGB: 50}, + }, 6}, + } + for _, tc := range cases { + got := PagingFileGrowthGB(tc.files) + if diff := got - tc.want; diff > 1e-9 || diff < -1e-9 { + t.Errorf("%s: got %.2f, want %.2f", tc.name, got, tc.want) + } + } +} + +func TestCommitHeadroomAddsGrowth(t *testing.T) { + // Task Manager on the measured host: 30.7 / 37.4 GB committed. The current + // limit leaves 6.7 GB, which refused an 8G guest that starts fine. + limit, avail := CommitHeadroom(37.4, 6.7, []PagingFile{{Volume: `C:\`, CurrentGB: 5.6, MaxGB: 37.5, VolumeFreeGB: 141.7}}) + if limit < 69.2 || limit > 69.4 || avail < 38.5 || avail > 38.7 { + t.Fatalf("got limit %.2f avail %.2f, want ~69.3 / ~38.6", limit, avail) + } + if limit, avail := CommitHeadroom(37.4, 6.7, nil); limit != 37.4 || avail != 6.7 { + t.Fatalf("no paging file info: got %.2f / %.2f, want the current values", limit, avail) + } +} + func TestRecommendedMemoryFollowsCommitMemory(t *testing.T) { - // The measured case: 32 GB host, 14.7 GiB commit free -> 16G fails, 8G fits. + // 32 GB host with 14.7 GiB commit Windows can still grant -> 8G. if got := RecommendedMemoryGB(Report{TotalRAMGB: 31.8, CommitAvailGB: 14.7}); got != 8 { t.Fatalf("got %v, want 8", got) } diff --git a/internal/host/pagefile_windows.go b/internal/host/pagefile_windows.go new file mode 100644 index 0000000..b0ff49d --- /dev/null +++ b/internal/host/pagefile_windows.go @@ -0,0 +1,128 @@ +//go:build windows + +package host + +import ( + "encoding/binary" + "errors" + "os" + "path/filepath" + "strings" + "unicode/utf16" + "unsafe" + + "golang.org/x/sys/windows" +) + +// systemPageFileInformationEx is SYSTEM_INFORMATION_CLASS 144 (Windows 8+): +// SYSTEM_PAGEFILE_INFORMATION followed by the file's minimum and maximum size, +// which the plain class 18 leaves out. +const systemPageFileInformationEx = 144 + +// Offsets inside one SYSTEM_PAGEFILE_INFORMATION_EX entry on 64-bit Windows. +const ( + pfNextEntryOffset = 0 // ULONG + pfTotalSize = 4 // ULONG, pages + pfNameLength = 16 // UNICODE_STRING.Length, bytes + pfNameBuffer = 24 // UNICODE_STRING.Buffer + pfMaximumSize = 36 // ULONG, pages + pfEntryMinSize = 40 +) + +// rawPagingFile is one entry as NtQuerySystemInformation returns it. +type rawPagingFile struct { + Name string // NT path such as `\??\C:\pagefile.sys` + SizePg uint32 + MaxSizePg uint32 +} + +// parsePagingFilesEx walks the SYSTEM_PAGEFILE_INFORMATION_EX list in buf. +// base is the address of buf[0]: the kernel writes each name into buf and +// stores its address, so a name is read back by offset and only when it lies +// inside buf. +func parsePagingFilesEx(buf []byte, base uintptr) ([]rawPagingFile, error) { + var out []rawPagingFile + off := 0 + for { + if off < 0 || off+pfEntryMinSize > len(buf) { + return nil, errors.New("paging file list is truncated") + } + e := buf[off:] + next := binary.LittleEndian.Uint32(e[pfNextEntryOffset:]) + nameLen := int(binary.LittleEndian.Uint16(e[pfNameLength:])) + namePtr := uintptr(binary.LittleEndian.Uint64(e[pfNameBuffer:])) + name := "" + if nameLen > 0 && namePtr >= base { + start := int(namePtr - base) + if start >= 0 && start+nameLen <= len(buf) { + u := make([]uint16, nameLen/2) + for i := range u { + u[i] = binary.LittleEndian.Uint16(buf[start+2*i:]) + } + name = string(utf16.Decode(u)) + } + } + out = append(out, rawPagingFile{ + Name: name, + SizePg: binary.LittleEndian.Uint32(e[pfTotalSize:]), + MaxSizePg: binary.LittleEndian.Uint32(e[pfMaximumSize:]), + }) + if next == 0 { + return out, nil + } + off += int(next) + } +} + +// pagingFileVolume turns `\??\C:\pagefile.sys` into `C:\`. +func pagingFileVolume(ntPath string) string { + p := strings.TrimPrefix(ntPath, `\??\`) + if vol := filepath.VolumeName(p); vol != "" { + return vol + `\` + } + return "" +} + +// probePagingFiles lists the paging files in use with their maximum size and +// their volume's free space. An empty list (paging file disabled) is valid. +func probePagingFiles() ([]PagingFile, error) { + size := 16 * 1024 + for { + buf := make([]byte, size) + var ret uint32 + err := windows.NtQuerySystemInformation(systemPageFileInformationEx, unsafe.Pointer(&buf[0]), uint32(len(buf)), &ret) + if errors.Is(err, windows.STATUS_INFO_LENGTH_MISMATCH) && size < 1<<20 { + size *= 4 + continue + } + if err != nil { + return nil, err + } + if ret == 0 { + return nil, nil + } + raw, err := parsePagingFilesEx(buf[:ret], uintptr(unsafe.Pointer(&buf[0]))) + if err != nil { + return nil, err + } + pageGB := float64(os.Getpagesize()) / (1024 * 1024 * 1024) + files := make([]PagingFile, 0, len(raw)) + for _, r := range raw { + vol := pagingFileVolume(r.Name) + if vol == "" { + continue + } + free, ok := probeFreeDiskGB(vol) + if !ok { + continue + } + files = append(files, PagingFile{ + Volume: vol, + CurrentGB: float64(r.SizePg) * pageGB, + MaxGB: float64(r.MaxSizePg) * pageGB, + VolumeFreeGB: free, + }) + } + return files, nil + } +} diff --git a/internal/host/pagefile_windows_test.go b/internal/host/pagefile_windows_test.go new file mode 100644 index 0000000..fcdd132 --- /dev/null +++ b/internal/host/pagefile_windows_test.go @@ -0,0 +1,87 @@ +//go:build windows + +package host + +import ( + "encoding/binary" + "testing" + "unicode/utf16" +) + +// pagingFileEntry writes one SYSTEM_PAGEFILE_INFORMATION_EX entry at off, +// with its name stored at nameOff inside the same buffer. +func pagingFileEntry(buf []byte, base uintptr, off, next, nameOff int, name string, sizePg, maxPg uint32) { + e := buf[off:] + binary.LittleEndian.PutUint32(e[pfNextEntryOffset:], uint32(next)) + binary.LittleEndian.PutUint32(e[pfTotalSize:], sizePg) + u := utf16.Encode([]rune(name)) + binary.LittleEndian.PutUint16(e[pfNameLength:], uint16(2*len(u))) + binary.LittleEndian.PutUint64(e[pfNameBuffer:], uint64(base)+uint64(nameOff)) + binary.LittleEndian.PutUint32(e[pfMaximumSize:], maxPg) + for i, c := range u { + binary.LittleEndian.PutUint16(buf[nameOff+2*i:], c) + } +} + +func TestParsePagingFilesEx(t *testing.T) { + const base = uintptr(0x10000) + buf := make([]byte, 512) + pagingFileEntry(buf, base, 0, 48, 200, `\??\C:\pagefile.sys`, 1469696, 9830400) + pagingFileEntry(buf, base, 48, 0, 300, `\??\D:\pagefile.sys`, 1024, 1024) + got, err := parsePagingFilesEx(buf, base) + if err != nil { + t.Fatal(err) + } + want := []rawPagingFile{ + {Name: `\??\C:\pagefile.sys`, SizePg: 1469696, MaxSizePg: 9830400}, + {Name: `\??\D:\pagefile.sys`, SizePg: 1024, MaxSizePg: 1024}, + } + if len(got) != len(want) { + t.Fatalf("got %d entries, want %d", len(got), len(want)) + } + for i := range want { + if got[i] != want[i] { + t.Errorf("entry %d: got %+v, want %+v", i, got[i], want[i]) + } + } + if v := pagingFileVolume(got[0].Name); v != `C:\` { + t.Errorf("volume: got %q, want C:\\", v) + } +} + +func TestParsePagingFilesExRejectsBadInput(t *testing.T) { + const base = uintptr(0x10000) + if _, err := parsePagingFilesEx(make([]byte, pfEntryMinSize-1), base); err == nil { + t.Error("short buffer: want error") + } + buf := make([]byte, 128) + pagingFileEntry(buf, base, 0, 100, 60, `\??\C:\pagefile.sys`, 1, 2) // next entry runs past the end + if _, err := parsePagingFilesEx(buf, base); err == nil { + t.Error("truncated list: want error") + } + buf = make([]byte, 128) + pagingFileEntry(buf, base, 0, 0, 60, `\??\C:\pagefile.sys`, 1, 2) + binary.LittleEndian.PutUint64(buf[pfNameBuffer:], 0x5000) // name outside the buffer + got, err := parsePagingFilesEx(buf, base) + if err != nil || len(got) != 1 || got[0].Name != "" { + t.Errorf("name outside buffer: got %+v, %v; want one entry with no name", got, err) + } +} + +func TestProbePagingFilesLive(t *testing.T) { + files, err := probePagingFiles() + if err != nil { + t.Fatalf("probePagingFiles: %v", err) + } + for _, f := range files { + if f.Volume == "" || f.CurrentGB <= 0 || f.MaxGB < 0 || f.VolumeFreeGB < 0 { + t.Errorf("implausible paging file %+v", f) + } + t.Logf("%s current %.1f GB max %.1f GB volume free %.1f GB", f.Volume, f.CurrentGB, f.MaxGB, f.VolumeFreeGB) + } + limit, avail, growth, ok := probeCommitGB() + if !ok || limit <= 0 || avail < 0 || avail > limit || growth < 0 { + t.Fatalf("probeCommitGB = %.1f, %.1f, %.1f, %v", limit, avail, growth, ok) + } + t.Logf("reachable commit limit %.1f GB, can grant %.1f GB, paging file growth %.1f GB", limit, avail, growth) +} diff --git a/internal/i18n/catalog_gen.go b/internal/i18n/catalog_gen.go index 8190834..0b2e1b0 100644 --- a/internal/i18n/catalog_gen.go +++ b/internal/i18n/catalog_gen.go @@ -125,7 +125,7 @@ var catalog = map[Locale]map[string]string{ "err.clone.overlay_exists": "目标增量磁盘文件已存在:{path}", "err.clone.same_name": "新虚拟机名称不能与原虚拟机相同", "err.clone.source_running": "请先关闭「{name}」再派生副本,以保证母盘数据一致", - "err.commit_memory": "内存不够启动:这台虚拟机要 {need, number, .0} GB,Windows 现在只能再分配 {avail, number, .1} GB。关掉一些程序再试,或在设置里把内存改为 {rec, number, .0} GB", + "err.commit_memory": "内存不够启动:这台虚拟机需要 {need, number, .0} GB(客体内存 {mem, number, .0} GB 加运行开销),Windows 现在最多还能分配 {avail, number, .1} GB(已算上页面文件可自动扩展的部分)。关掉一些程序再试,或在设置里把内存改为 {rec, number, .0} GB", "err.dataroot.busy_tasks": "仍有后台下载或创建任务进行中,请等待任务结束或取消后再切换数据目录", "err.dataroot.busy_vms": "仍有虚拟机正在运行,请先全部关机后再切换数据目录", "err.dataroot.damaged": "数据目录 {dir} 的数据版本记录已损坏,已以只读方式打开,没有做任何修改。确认目录来自当前或更早的版本后,可在界面中修复版本记录", @@ -533,7 +533,7 @@ var catalog = map[Locale]map[string]string{ "validate.invalid_name": "名称须以字母或数字开头,仅支持 A-Z、0-9、.、_、-", "validate.invalid_resolution": "分辨率格式须为 宽x高(如 1920x1080)", "validate.invalid_ssh_port": "SSH 端口须在 0 到 65535 之间", - "validate.memory_exceeds_commit": "分配内存 {mem, number, .0}G 超出 Windows 提交上限(含页面文件共 {limit, number, .1} GB);请设为 {rec, number, .0}G 或更低", + "validate.memory_exceeds_commit": "分配内存 {mem, number, .0}G 超出 Windows 提交上限(含页面文件可扩展到的大小,共 {limit, number, .1} GB);请设为 {rec, number, .0}G 或更低", "validate.memory_exceeds_host": "分配内存 {mem, number, .0}G 超出宿主安全上限(宿主共 {host, number, .1} GB)", "validate.missing_name": "虚拟机名称不能为空", "validate.missing_release": "请选择要离线安装的 macOS 版本", @@ -682,7 +682,7 @@ var catalog = map[Locale]map[string]string{ "err.clone.overlay_exists": "CoW overlay file already exists: {path}", "err.clone.same_name": "Choose a different name from the source VM", "err.clone.source_running": "Stop “{name}” before deriving a CoW clone so the backing disk is clean", - "err.commit_memory": "Not enough memory to start: this VM needs {need, number, .0} GB and Windows can commit only {avail, number, .1} GB more. Close some programs, or set its memory to {rec, number, .0} GB", + "err.commit_memory": "Not enough memory to start: this VM needs {need, number, .0} GB ({mem, number, .0} GB guest memory plus overhead) and Windows can commit at most {avail, number, .1} GB more, counting how far the page file can grow. Close some programs, or set its memory to {rec, number, .0} GB", "err.dataroot.busy_tasks": "Wait for active download or creation tasks to finish before switching the data folder", "err.dataroot.busy_vms": "Stop all running virtual machines before switching the data folder", "err.dataroot.damaged": "The data version record in {dir} is damaged. The folder was opened read-only and nothing was changed. If it comes from this or an older version, you can repair the record in the app", @@ -1090,7 +1090,7 @@ var catalog = map[Locale]map[string]string{ "validate.invalid_name": "VM name must start with a letter/digit and use only A-Z, 0-9, ., _, -", "validate.invalid_resolution": "Resolution must match WIDTHxHEIGHT (e.g. 1920x1080)", "validate.invalid_ssh_port": "SSH port must be 0..65535", - "validate.memory_exceeds_commit": "Memory {mem, number, .0}G can't fit in Windows' commit limit ({limit, number, .1} GB including the page file); choose {rec, number, .0}G or less", + "validate.memory_exceeds_commit": "Memory {mem, number, .0}G can't fit in Windows' commit limit ({limit, number, .1} GB, counting how far the page file can grow); choose {rec, number, .0}G or less", "validate.memory_exceeds_host": "Memory {mem, number, .0}G exceeds safe host limit (host total {host, number, .1} GB)", "validate.missing_name": "VM name is required", "validate.missing_release": "Choose the macOS release to install offline", @@ -1156,7 +1156,7 @@ var paramOrder = map[string][]string{ "err.clone.no_disk": {"name"}, "err.clone.overlay_exists": {"path"}, "err.clone.source_running": {"name"}, - "err.commit_memory": {"need", "avail", "rec"}, + "err.commit_memory": {"need", "mem", "avail", "rec"}, "err.dataroot.damaged": {"dir"}, "err.dataroot.locked": {"dir"}, "err.dataroot.migration_failed": {"dir"}, diff --git a/internal/macos/startprep/startprep.go b/internal/macos/startprep/startprep.go index 8af171a..ad7868e 100644 --- a/internal/macos/startprep/startprep.go +++ b/internal/macos/startprep/startprep.go @@ -79,7 +79,7 @@ func (p *Prep) CheckMemory(memory string, rep host.Report) error { if !ok || memGB+host.StartMarginGB <= avail { return nil } - return fmt.Errorf("%s", i18n.T(p.cfg.Locale, "err.commit_memory", memGB, avail, host.RecommendedMemoryGB(rep))) + return fmt.Errorf("%s", i18n.T(p.cfg.Locale, "err.commit_memory", memGB+host.StartMarginGB, memGB, avail, host.RecommendedMemoryGB(rep))) } // Prepare brings a stopped VM's configuration up to date before it starts: diff --git a/locales/en-US/native.json b/locales/en-US/native.json index a749479..1bda9d3 100644 --- a/locales/en-US/native.json +++ b/locales/en-US/native.json @@ -223,9 +223,10 @@ }, "err.update_relaunch": "The new version is installed but didn't reopen; start Reims-Go again", "err.commit_memory": { - "message": "Not enough memory to start: this VM needs {need, number, .0} GB and Windows can commit only {avail, number, .1} GB more. Close some programs, or set its memory to {rec, number, .0} GB", + "message": "Not enough memory to start: this VM needs {need, number, .0} GB ({mem, number, .0} GB guest memory plus overhead) and Windows can commit at most {avail, number, .1} GB more, counting how far the page file can grow. Close some programs, or set its memory to {rec, number, .0} GB", "$params": [ "need", + "mem", "avail", "rec" ] @@ -369,7 +370,7 @@ ] }, "validate.memory_exceeds_commit": { - "message": "Memory {mem, number, .0}G can't fit in Windows' commit limit ({limit, number, .1} GB including the page file); choose {rec, number, .0}G or less", + "message": "Memory {mem, number, .0}G can't fit in Windows' commit limit ({limit, number, .1} GB, counting how far the page file can grow); choose {rec, number, .0}G or less", "$params": [ "mem", "limit", diff --git a/locales/zh-CN/native.json b/locales/zh-CN/native.json index 88247a4..ddf0aa5 100644 --- a/locales/zh-CN/native.json +++ b/locales/zh-CN/native.json @@ -223,9 +223,10 @@ }, "err.update_relaunch": "新版本已安装,但没能自动重新打开,请手动启动 Reims-Go", "err.commit_memory": { - "message": "内存不够启动:这台虚拟机要 {need, number, .0} GB,Windows 现在只能再分配 {avail, number, .1} GB。关掉一些程序再试,或在设置里把内存改为 {rec, number, .0} GB", + "message": "内存不够启动:这台虚拟机需要 {need, number, .0} GB(客体内存 {mem, number, .0} GB 加运行开销),Windows 现在最多还能分配 {avail, number, .1} GB(已算上页面文件可自动扩展的部分)。关掉一些程序再试,或在设置里把内存改为 {rec, number, .0} GB", "$params": [ "need", + "mem", "avail", "rec" ] @@ -369,7 +370,7 @@ ] }, "validate.memory_exceeds_commit": { - "message": "分配内存 {mem, number, .0}G 超出 Windows 提交上限(含页面文件共 {limit, number, .1} GB);请设为 {rec, number, .0}G 或更低", + "message": "分配内存 {mem, number, .0}G 超出 Windows 提交上限(含页面文件可扩展到的大小,共 {limit, number, .1} GB);请设为 {rec, number, .0}G 或更低", "$params": [ "mem", "limit",