fix(gpu): auto-rebind stale Windows DriverStore Vulkan ICD before VM start
This commit is contained in:
1 parent
dc534b72b4
commit
957da43b2d
9 files changed
+417
-1
No files matched your search
@@ -3,13 +3,18 @@ package reims
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/Nwflower/reims-go/internal/host"
|
||||
"github.com/Nwflower/reims-go/internal/i18n"
|
||||
)
|
||||
|
||||
@@ -152,10 +157,95 @@ func (w *captureWriter) String() string {
|
||||
return w.buf.String()
|
||||
}
|
||||
|
||||
// StartWithCompat starts a VM and automatically recovers once if QEMU aborts
|
||||
var driverStoreICDPattern = regexp.MustCompile(`^([a-z]:/(?:[^/]+/)*driverstore/filerepository)/([^/]+)_[0-9a-f]{8,}/([^/]+(?:/[^/]+)*)$`)
|
||||
|
||||
func parseDriverStoreICD(raw string) []string {
|
||||
cleaned := path.Clean(strings.ToLower(strings.ReplaceAll(strings.TrimSpace(raw), `\`, "/")))
|
||||
return driverStoreICDPattern.FindStringSubmatch(cleaned)
|
||||
}
|
||||
|
||||
// ResolveStaleDriverStoreICD matches a stale ICD to the same driver package and
|
||||
// relative path, provided exactly one physical adapter matches and is usable.
|
||||
func ResolveStaleDriverStoreICD(oldPath string, gpus []host.GPUInfo) (newPath string, ambiguous bool) {
|
||||
old := parseDriverStoreICD(oldPath)
|
||||
if old == nil {
|
||||
return "", false
|
||||
}
|
||||
var matched []host.GPUInfo
|
||||
for _, gpu := range gpus {
|
||||
if gpu.Kind == host.GPUVirtual {
|
||||
continue
|
||||
}
|
||||
candidate := parseDriverStoreICD(gpu.VulkanICD)
|
||||
if candidate != nil && slices.Equal(candidate[1:], old[1:]) {
|
||||
matched = append(matched, gpu)
|
||||
}
|
||||
}
|
||||
if len(matched) != 1 {
|
||||
return "", len(matched) > 1
|
||||
}
|
||||
gpu := matched[0]
|
||||
// Warning grades can also come from PCI IDs alone. A Vulkan version
|
||||
// confirms that the adapter was probed.
|
||||
if gpu.VulkanVersion == "" || (gpu.Compat != host.GPUCompatSupported && gpu.Compat != host.GPUCompatWarn) {
|
||||
return "", false
|
||||
}
|
||||
return gpu.VulkanICD, false
|
||||
}
|
||||
|
||||
func (c *Client) reconcileStaleGPUICD(ctx context.Context, name string, stderr io.Writer, onNote func(string)) error {
|
||||
detail, err := c.Show(ctx, name)
|
||||
if err != nil || detail.Graphics != "reims-vgpu" || detail.State == "running" {
|
||||
return nil
|
||||
}
|
||||
oldPath := strings.TrimSpace(detail.GPU)
|
||||
if !strings.HasSuffix(strings.ToLower(oldPath), ".json") {
|
||||
return nil
|
||||
}
|
||||
stat := c.statFile
|
||||
if stat == nil {
|
||||
stat = os.Stat
|
||||
}
|
||||
if _, err := stat(oldPath); !errors.Is(err, os.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
|
||||
probe := c.probeGPUs
|
||||
if probe == nil {
|
||||
probe = host.ProbeVulkanGPUs
|
||||
}
|
||||
if onNote == nil && stderr != nil {
|
||||
onNote = func(msg string) { fmt.Fprintln(stderr, msg) }
|
||||
}
|
||||
newPath, _ := ResolveStaleDriverStoreICD(oldPath, probe())
|
||||
if newPath == "" {
|
||||
msg := i18n.M(c.Locale, "err.gpu_icd_stale", i18n.Vars{"path": oldPath})
|
||||
if onNote != nil {
|
||||
onNote(msg)
|
||||
}
|
||||
return errors.New(msg)
|
||||
}
|
||||
var setErrBuf bytes.Buffer
|
||||
if err := c.Set(ctx, SetOpts{Name: name, GPU: newPath}, io.Discard, &setErrBuf); err != nil {
|
||||
if detail := strings.TrimSpace(setErrBuf.String()); detail != "" {
|
||||
return fmt.Errorf("reims-ctl set %s --gpu: %w (%s)", name, err, detail)
|
||||
}
|
||||
return fmt.Errorf("reims-ctl set %s --gpu: %w", name, err)
|
||||
}
|
||||
if onNote != nil {
|
||||
onNote(i18n.M(c.Locale, "compat.gpu_icd_rebound", i18n.Vars{"old": oldPath, "new": newPath}))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// StartWithCompat checks the configured Vulkan ICD before starting a VM and
|
||||
// automatically recovers once if QEMU aborts
|
||||
// with the WHPX nested-virtualization property error (hr=80370302) by writing
|
||||
// `-machine kernel-irqchip=off` via `reims-ctl set` (D3) and retrying start.
|
||||
func (c *Client) StartWithCompat(ctx context.Context, name string, stdout, stderr io.Writer, onNote func(string)) error {
|
||||
if err := c.reconcileStaleGPUICD(ctx, name, stderr, onNote); err != nil {
|
||||
return err
|
||||
}
|
||||
outCap := &captureWriter{dst: stdout}
|
||||
errCap := &captureWriter{dst: stderr}
|
||||
err := c.Start(ctx, name, outCap, errCap)
|
||||
|
||||
@@ -1,13 +1,274 @@
|
||||
package reims
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"cmp"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Nwflower/reims-go/internal/host"
|
||||
"github.com/Nwflower/reims-go/internal/i18n"
|
||||
)
|
||||
|
||||
const (
|
||||
fileRepository = "C:/Windows/System32/DriverStore/FileRepository/"
|
||||
intelOldICD = fileRepository + "iigd_dch.inf_amd64_010a7b33a54cb65d/igvk64.json"
|
||||
intelNewICD = fileRepository + "iigd_dch.inf_amd64_413e993a06fd9302/igvk64.json"
|
||||
nvidiaNewICD = fileRepository + "nv_dispig.inf_amd64_b45678ef/Vulkan/nv-vk64.json"
|
||||
)
|
||||
|
||||
func TestResolveStaleDriverStoreICD(t *testing.T) {
|
||||
intel := host.GPUInfo{Kind: host.GPUIntegrated, VulkanICD: intelNewICD, VulkanVersion: "1.4.0", Compat: host.GPUCompatSupported}
|
||||
nvidia := host.GPUInfo{Kind: host.GPUDiscrete, VulkanICD: nvidiaNewICD, VulkanVersion: "1.4.0", Compat: host.GPUCompatSupported}
|
||||
amd := host.GPUInfo{Kind: host.GPUDiscrete, VulkanICD: fileRepository + "u0406575.inf_amd64_9abc5678/amd-vulkan64.json", VulkanVersion: "1.3.0", Compat: host.GPUCompatWarn}
|
||||
mixed := intel
|
||||
mixed.VulkanICD = "c:/WINDOWS\\System32/DRIVERSTORE\\FileRepository/IIGD_DCH.INF_AMD64_413E993A06FD9302\\IGVK64.JSON"
|
||||
secondIntel := intel
|
||||
secondIntel.VulkanICD = fileRepository + "iigd_dch.inf_amd64_1234567890abcdef/igvk64.json"
|
||||
unprobed := intel
|
||||
unprobed.VulkanVersion = ""
|
||||
unprobed.Compat = host.GPUCompatUnknown
|
||||
warnUnprobed := amd
|
||||
warnUnprobed.VulkanVersion = ""
|
||||
unsupported := intel
|
||||
unsupported.Compat = host.GPUCompatUnsupported
|
||||
virtual := intel
|
||||
virtual.Kind = host.GPUVirtual
|
||||
differentINF := intel
|
||||
differentINF.VulkanICD = fileRepository + "iigd_other.inf_amd64_413e993a06fd9302/igvk64.json"
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
oldPath string
|
||||
gpus []host.GPUInfo
|
||||
wantPath string
|
||||
ambiguous bool
|
||||
}{
|
||||
{name: "Intel Arc B390", oldPath: intelOldICD, gpus: []host.GPUInfo{intel}, wantPath: intelNewICD},
|
||||
{name: "NVIDIA nested manifest", oldPath: fileRepository + "nv_dispig.inf_amd64_a12345cd/Vulkan/nv-vk64.json", gpus: []host.GPUInfo{nvidia}, wantPath: nvidiaNewICD},
|
||||
{name: "AMD warning grade", oldPath: fileRepository + "u0406575.inf_amd64_1234abcd/amd-vulkan64.json", gpus: []host.GPUInfo{amd}, wantPath: amd.VulkanICD},
|
||||
{name: "mixed case and separators", oldPath: strings.ReplaceAll(intelOldICD, "/", "\\"), gpus: []host.GPUInfo{mixed}, wantPath: mixed.VulkanICD},
|
||||
{name: "Intel and NVIDIA", oldPath: intelOldICD, gpus: []host.GPUInfo{nvidia, intel}, wantPath: intelNewICD},
|
||||
{name: "different vendor", oldPath: intelOldICD, gpus: []host.GPUInfo{nvidia}},
|
||||
{name: "same vendor multiple adapters", oldPath: intelOldICD, gpus: []host.GPUInfo{intel, secondIntel}, ambiguous: true},
|
||||
{name: "shared manifest", oldPath: intelOldICD, gpus: []host.GPUInfo{intel, intel}, ambiguous: true},
|
||||
{name: "unprobed also counts towards ambiguity", oldPath: intelOldICD, gpus: []host.GPUInfo{intel, unprobed}, ambiguous: true},
|
||||
{name: "only match unprobed", oldPath: intelOldICD, gpus: []host.GPUInfo{unprobed}},
|
||||
{name: "PCI-based warning without a probe", oldPath: fileRepository + "u0406575.inf_amd64_1234abcd/amd-vulkan64.json", gpus: []host.GPUInfo{warnUnprobed}},
|
||||
{name: "only match unsupported", oldPath: intelOldICD, gpus: []host.GPUInfo{unsupported}},
|
||||
{name: "ignore virtual adapter", oldPath: intelOldICD, gpus: []host.GPUInfo{virtual, intel}, wantPath: intelNewICD},
|
||||
{name: "different INF package", oldPath: intelOldICD, gpus: []host.GPUInfo{differentINF}},
|
||||
{name: "different repository", oldPath: "D" + intelOldICD[1:], gpus: []host.GPUInfo{intel}},
|
||||
{name: "different relative path", oldPath: fileRepository + "iigd_dch.inf_amd64_010a7b33a54cb65d/Vulkan/igvk64.json", gpus: []host.GPUInfo{intel}},
|
||||
{name: "invalid package hash", oldPath: fileRepository + "iigd_dch.inf_amd64_0123456g/igvk64.json", gpus: []host.GPUInfo{intel}},
|
||||
{name: "short package hash", oldPath: fileRepository + "iigd_dch.inf_amd64_0123456/igvk64.json", gpus: []host.GPUInfo{intel}},
|
||||
{name: "custom path", oldPath: "C:/custom/igvk64.json", gpus: []host.GPUInfo{intel}},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got, ambiguous := ResolveStaleDriverStoreICD(tc.oldPath, tc.gpus)
|
||||
if got != tc.wantPath || ambiguous != tc.ambiguous {
|
||||
t.Fatalf("ResolveStaleDriverStoreICD() = (%q, %v), want (%q, %v)", got, ambiguous, tc.wantPath, tc.ambiguous)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartWithCompatStaleGPUICD(t *testing.T) {
|
||||
const name = "macOS test"
|
||||
const newPath = "C:/Windows/System32/DriverStore/FileRepository/iigd_dch.inf_amd64_413e993a06fd9302/ICD manifests/igvk64.json"
|
||||
const oldPath = "C:/Windows/System32/DriverStore/FileRepository/iigd_dch.inf_amd64_010a7b33a54cb65d/ICD manifests/igvk64.json"
|
||||
const customPath = "C:/custom/igvk64.JSON"
|
||||
intel := host.GPUInfo{Kind: host.GPUIntegrated, VulkanICD: newPath, VulkanVersion: "1.4.0", Compat: host.GPUCompatSupported}
|
||||
show := "show\t" + name
|
||||
start := "start\t" + name
|
||||
set := "set\t" + name + "\t--gpu\t" + newPath
|
||||
rebound := "显卡 Vulkan ICD 路径已从 " + oldPath + " 更新为 " + newPath
|
||||
stale := "原显卡的 Vulkan ICD 文件已不存在(" + oldPath + ")。在设置 → 图形与显示器中重新选择显卡,或选择自动"
|
||||
staleCustom := "The selected GPU's Vulkan ICD file no longer exists (" + customPath + "). In Settings → Graphics & displays, reselect the GPU or choose Automatic"
|
||||
binary, err := os.Executable()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
gpu string
|
||||
graphics string
|
||||
state string
|
||||
statErr error
|
||||
gpus []host.GPUInfo
|
||||
fail string
|
||||
twice bool
|
||||
useStderr bool
|
||||
wantCalls []string
|
||||
wantStats []string
|
||||
wantProbe int
|
||||
wantNote string
|
||||
wantStale bool
|
||||
}{
|
||||
{name: "existing file", gpu: oldPath, wantCalls: []string{show, start}, wantStats: []string{oldPath}},
|
||||
{name: "auto", gpu: "automatic: the only GPU", wantCalls: []string{show, start}},
|
||||
{name: "GPU name", gpu: "Intel Arc B390", wantCalls: []string{show, start}},
|
||||
{name: "SVGA", gpu: oldPath, graphics: "VMware SVGA", wantCalls: []string{show, start}},
|
||||
{name: "running", gpu: oldPath, state: "running, pid 1234", wantCalls: []string{show, start}},
|
||||
{name: "show failure", gpu: oldPath, fail: "show", wantCalls: []string{show, start}},
|
||||
{name: "stat permission denied", gpu: oldPath, statErr: os.ErrPermission, wantCalls: []string{show, start}, wantStats: []string{oldPath}},
|
||||
{name: "rebind once across two starts", gpu: oldPath, statErr: os.ErrNotExist, gpus: []host.GPUInfo{intel}, twice: true, wantCalls: []string{show, set, start, show, start}, wantStats: []string{oldPath, newPath}, wantProbe: 1, wantNote: rebound},
|
||||
{name: "rebind note falls back to stderr", gpu: oldPath, statErr: os.ErrNotExist, gpus: []host.GPUInfo{intel}, useStderr: true, wantCalls: []string{show, set, start}, wantStats: []string{oldPath}, wantProbe: 1, wantNote: rebound},
|
||||
{name: "ambiguous", gpu: oldPath, statErr: os.ErrNotExist, gpus: []host.GPUInfo{intel, intel}, wantCalls: []string{show}, wantStats: []string{oldPath}, wantProbe: 1, wantNote: stale, wantStale: true},
|
||||
{name: "no match", gpu: oldPath, statErr: os.ErrNotExist, wantCalls: []string{show}, wantStats: []string{oldPath}, wantProbe: 1, wantNote: stale, wantStale: true},
|
||||
{name: "missing custom JSON", gpu: customPath, statErr: os.ErrNotExist, gpus: []host.GPUInfo{intel}, useStderr: true, wantCalls: []string{show}, wantStats: []string{customPath}, wantProbe: 1, wantNote: staleCustom, wantStale: true},
|
||||
{name: "set failure", gpu: oldPath, statErr: os.ErrNotExist, gpus: []host.GPUInfo{intel}, fail: "set", wantCalls: []string{show, set}, wantStats: []string{oldPath}, wantProbe: 1},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
gpuFile := filepath.Join(dir, "gpu")
|
||||
if err := os.WriteFile(gpuFile, []byte(tc.gpu), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
locale := i18n.ZhCN
|
||||
if tc.gpu == customPath {
|
||||
locale = i18n.EnUS
|
||||
}
|
||||
var statPaths, notes []string
|
||||
probes := 0
|
||||
client := Client{
|
||||
Binary: binary,
|
||||
Env: append(os.Environ(),
|
||||
"REIMS_TEST_CTL_DIR="+dir,
|
||||
"REIMS_TEST_CTL_GRAPHICS="+cmp.Or(tc.graphics, "reims-vgpu"),
|
||||
"REIMS_TEST_CTL_STATE="+cmp.Or(tc.state, "stopped"),
|
||||
"REIMS_TEST_CTL_FAIL="+tc.fail,
|
||||
),
|
||||
Locale: locale,
|
||||
statFile: func(path string) (os.FileInfo, error) {
|
||||
statPaths = append(statPaths, path)
|
||||
if path == newPath {
|
||||
return nil, nil
|
||||
}
|
||||
if tc.statErr == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, &os.PathError{Op: "stat", Path: path, Err: tc.statErr}
|
||||
},
|
||||
probeGPUs: func() []host.GPUInfo {
|
||||
probes++
|
||||
return tc.gpus
|
||||
},
|
||||
}
|
||||
var stderr bytes.Buffer
|
||||
onNote := func(msg string) { notes = append(notes, msg) }
|
||||
if tc.useStderr {
|
||||
onNote = nil
|
||||
}
|
||||
|
||||
err := client.StartWithCompat(t.Context(), name, nil, &stderr, onNote)
|
||||
switch {
|
||||
case tc.wantStale:
|
||||
if err == nil || err.Error() != tc.wantNote {
|
||||
t.Fatalf("start error = %v, want %q", err, tc.wantNote)
|
||||
}
|
||||
case tc.fail == "set":
|
||||
var exitErr *exec.ExitError
|
||||
if !errors.As(err, &exitErr) || exitErr.ExitCode() != 7 || !strings.Contains(err.Error(), "reims-ctl set "+name+" --gpu") {
|
||||
t.Fatalf("start error = %v, want wrapped set exit status 7", err)
|
||||
}
|
||||
case err != nil:
|
||||
t.Fatal(err)
|
||||
}
|
||||
if tc.twice {
|
||||
if err := client.StartWithCompat(t.Context(), name, nil, &stderr, onNote); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
calls, err := os.ReadFile(filepath.Join(dir, "commands"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if want := strings.Join(tc.wantCalls, "\n") + "\n"; string(calls) != want {
|
||||
t.Errorf("reims-ctl commands = %q, want %q", calls, want)
|
||||
}
|
||||
if probes != tc.wantProbe || !slices.Equal(statPaths, tc.wantStats) {
|
||||
t.Errorf("probes = %d, stat paths = %q, want %d and %q", probes, statPaths, tc.wantProbe, tc.wantStats)
|
||||
}
|
||||
wantGPU := tc.gpu
|
||||
if slices.Contains(tc.wantCalls, set) && tc.fail != "set" {
|
||||
wantGPU = newPath
|
||||
}
|
||||
gpu, err := os.ReadFile(gpuFile)
|
||||
if err != nil || string(gpu) != wantGPU {
|
||||
t.Errorf("saved GPU = %q, err = %v, want %q", gpu, err, wantGPU)
|
||||
}
|
||||
var wantNotes []string
|
||||
wantStderr := ""
|
||||
if tc.useStderr {
|
||||
wantStderr = tc.wantNote + "\n"
|
||||
} else if tc.wantNote != "" {
|
||||
wantNotes = []string{tc.wantNote}
|
||||
}
|
||||
if !slices.Equal(notes, wantNotes) || stderr.String() != wantStderr {
|
||||
t.Errorf("notes = %q, stderr = %q, want %q and %q", notes, stderr.String(), wantNotes, wantStderr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
if os.Getenv("REIMS_TEST_CTL_DIR") != "" {
|
||||
// Client.run invokes the test binary with the original ctl arguments.
|
||||
os.Args = append([]string{os.Args[0], "-test.run=^TestHelperProcess$", "--"}, os.Args[1:]...)
|
||||
}
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func TestHelperProcess(t *testing.T) {
|
||||
dir := os.Getenv("REIMS_TEST_CTL_DIR")
|
||||
if dir == "" {
|
||||
return
|
||||
}
|
||||
args := os.Args[3:]
|
||||
if len(args) < 2 {
|
||||
t.Fatalf("expected ctl command and VM name, got %q", args)
|
||||
}
|
||||
log, err := os.OpenFile(filepath.Join(dir, "commands"), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, writeErr := fmt.Fprintln(log, strings.Join(args, "\t"))
|
||||
if closeErr := log.Close(); writeErr != nil || closeErr != nil {
|
||||
t.Fatalf("record ctl call: write %v, close %v", writeErr, closeErr)
|
||||
}
|
||||
if args[0] == os.Getenv("REIMS_TEST_CTL_FAIL") {
|
||||
os.Exit(7)
|
||||
}
|
||||
gpuFile := filepath.Join(dir, "gpu")
|
||||
switch args[0] {
|
||||
case "show":
|
||||
gpu, err := os.ReadFile(gpuFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Printf("%s\n state %s\n graphics %s\n gpu %s\n", args[1], os.Getenv("REIMS_TEST_CTL_STATE"), os.Getenv("REIMS_TEST_CTL_GRAPHICS"), gpu)
|
||||
case "set":
|
||||
if len(args) != 4 || args[2] != "--gpu" {
|
||||
t.Fatalf("expected set <name> --gpu <path>, got %q", args)
|
||||
}
|
||||
if err := os.WriteFile(gpuFile, []byte(args[3]), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
case "start":
|
||||
default:
|
||||
t.Fatalf("unexpected ctl command %q", args)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildDeleteArgs(t *testing.T) {
|
||||
got := BuildDeleteArgs("macos-tahoe", false)
|
||||
want := []string{"delete", "--yes", "macos-tahoe"}
|
||||
|
||||
@@ -24,6 +24,9 @@ type Client struct {
|
||||
Binary string
|
||||
Env []string
|
||||
Locale i18n.Locale
|
||||
|
||||
probeGPUs func() []host.GPUInfo
|
||||
statFile func(string) (os.FileInfo, error)
|
||||
}
|
||||
|
||||
func NewClient(cfg *config.Config, installed rt.Installed) *Client {
|
||||
|
||||
@@ -173,3 +173,23 @@ func TestParseShowNonDefaultLines(t *testing.T) {
|
||||
t.Errorf("reims-vgpu / 30 s parsed as %q / %d", d.Graphics, d.StopTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFixedDriverStoreICDShowAndSetArgs(t *testing.T) {
|
||||
for _, path := range []string{
|
||||
"C:\\Windows\\System32\\DriverStore\\FileRepository\\iigd_dch.inf_amd64_010a7b33a54cb65d\\igvk64.json",
|
||||
"C:\\Windows\\System32\\DriverStore\\FileRepository\\nv_dispig.inf_amd64_b45678ef\\ICD manifests\\nv-vk64.json",
|
||||
} {
|
||||
t.Run(path, func(t *testing.T) {
|
||||
const name = "m0"
|
||||
detail := ParseShow(name, name+"\n state stopped\n graphics reims-vgpu\n gpu "+path+"\n")
|
||||
if detail.GPU != path || detail.Graphics != "reims-vgpu" || detail.State != "stopped" {
|
||||
t.Fatalf("unexpected VM detail: %+v", detail)
|
||||
}
|
||||
args, err := BuildSetArgs(SetOpts{Name: name, GPU: detail.GPU})
|
||||
want := []string{"set", name, "--gpu", path}
|
||||
if err != nil || !reflect.DeepEqual(args, want) {
|
||||
t.Fatalf("BuildSetArgs() = %q, %v, want %q, nil", args, err, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,11 @@ func Inspect(dataRoot string) Report {
|
||||
}
|
||||
}
|
||||
|
||||
// ProbeVulkanGPUs returns no adapters on hosts without Windows Vulkan probing.
|
||||
func ProbeVulkanGPUs() []GPUInfo {
|
||||
return nil
|
||||
}
|
||||
|
||||
func PinProcessToPCores(pid uint32, mask uint64) error {
|
||||
return SetProcessAffinityMask(pid, mask)
|
||||
}
|
||||
|
||||
@@ -543,6 +543,11 @@ func isUSBBusVolume(vol string) bool {
|
||||
return busType == 7
|
||||
}
|
||||
|
||||
// ProbeVulkanGPUs returns the current Vulkan adapters without using Inspect's cache.
|
||||
func ProbeVulkanGPUs() []GPUInfo {
|
||||
return probeVulkanGPUs()
|
||||
}
|
||||
|
||||
func probeVulkanGPUs() []GPUInfo {
|
||||
const baseKey = `SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}`
|
||||
var regGPUs []GPUInfo
|
||||
|
||||
@@ -60,6 +60,7 @@ var catalog = map[Locale]map[string]string{
|
||||
"close": "关闭",
|
||||
"closeWindow": "关闭",
|
||||
"collapseLogs": "收起日志",
|
||||
"compat.gpu_icd_rebound": "显卡 Vulkan ICD 路径已从 {old} 更新为 {new}",
|
||||
"copy": "复制",
|
||||
"copyTechInfo": "复制技术信息",
|
||||
"core.preflight.whpx_irqchip_advice": "宿主不支持 nested-virt 属性且当前运行时未包含非致命降级补丁,启动虚拟机时将自动附加 kernel-irqchip=off",
|
||||
@@ -117,6 +118,7 @@ var catalog = map[Locale]map[string]string{
|
||||
"err.dataroot.busy_tasks": "仍有后台下载或创建任务进行中,请等待任务结束或取消后再切换数据目录",
|
||||
"err.dataroot.busy_vms": "仍有虚拟机正在运行,请先全部关机后再切换数据目录",
|
||||
"err.gpu_device_lost": "宿主显卡 Vulkan 设备丢失(ERROR_DEVICE_LOST)。请更新显卡驱动;若为 AMD Vega/Polaris 等受影响显卡,请改用其他独显或在设置中将虚拟显卡切为 VMware SVGA",
|
||||
"err.gpu_icd_stale": "原显卡的 Vulkan ICD 文件已不存在({path})。在设置 → 图形与显示器中重新选择显卡,或选择自动",
|
||||
"err.gpu_vulkan_floor": "宿主显卡不满足 Reims vGPU 的 Vulkan 1.3 硬件要求。请更新显卡驱动,或在设置中将虚拟显卡切为 VMware SVGA(软件渲染)",
|
||||
"err.guest_tools_disabled": "Guest Tools 传输服务已在插件页停用,启用后才能使用剪贴板、共享文件夹与防休眠",
|
||||
"err.plugin.high_risk_unapproved": "插件「{id}」包含高危权限,需要先确认授权后才能启用",
|
||||
@@ -564,6 +566,7 @@ var catalog = map[Locale]map[string]string{
|
||||
"close": "Close",
|
||||
"closeWindow": "Close",
|
||||
"collapseLogs": "Hide logs",
|
||||
"compat.gpu_icd_rebound": "Updated the GPU Vulkan ICD path from {old} to {new}",
|
||||
"copy": "Copy",
|
||||
"copyTechInfo": "Copy technical details",
|
||||
"core.preflight.whpx_irqchip_advice": "Host lacks nested-virt property and runtime lacks nested-virt-nonfatal capability; kernel-irqchip=off will be auto-applied",
|
||||
@@ -621,6 +624,7 @@ var catalog = map[Locale]map[string]string{
|
||||
"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.gpu_device_lost": "Host Vulkan GPU device lost (ERROR_DEVICE_LOST). Update GPU drivers; on affected AMD Vega/Polaris GPUs, switch to another discrete GPU or use VMware SVGA in VM Settings",
|
||||
"err.gpu_icd_stale": "The selected GPU's Vulkan ICD file no longer exists ({path}). In Settings → Graphics & displays, reselect the GPU or choose Automatic",
|
||||
"err.gpu_vulkan_floor": "Host GPU does not meet Reims vGPU's Vulkan 1.3 requirements. Update GPU drivers or switch graphics to VMware SVGA (software rendering) in VM Settings",
|
||||
"err.guest_tools_disabled": "Guest Tools Transport is turned off on the Plugins page; turn it on to use clipboard, shared folders and keep-awake",
|
||||
"err.plugin.high_risk_unapproved": "Plugin “{id}” requests high-risk permissions and requires confirmation before enabling",
|
||||
@@ -1030,6 +1034,7 @@ var paramOrder = map[string][]string{
|
||||
"cli.start.running_in_tray": {"name"},
|
||||
"cli.start.spawning_tray": {"name"},
|
||||
"cli.start.timeout": {"name", "timeout"},
|
||||
"compat.gpu_icd_rebound": {"old", "new"},
|
||||
"core.start.warn.offline_helper_skipped": {"err"},
|
||||
"core.start.warn.opencore_lang_failed": {"err"},
|
||||
"core.start.warn.opencore_picker_failed": {"err"},
|
||||
@@ -1049,6 +1054,7 @@ var paramOrder = map[string][]string{
|
||||
"err.clone.overlay_exists": {"path"},
|
||||
"err.clone.source_running": {"name"},
|
||||
"err.commit_memory": {"need", "avail", "rec"},
|
||||
"err.gpu_icd_stale": {"path"},
|
||||
"err.plugin.high_risk_unapproved": {"id"},
|
||||
"err.plugin.in_use": {"id", "reason"},
|
||||
"err.plugin.system_locked": {"id"},
|
||||
|
||||
@@ -67,6 +67,19 @@
|
||||
"doctor.gpu.err.vulkan_cpu": "Software Vulkan implementation does not meet the vGPU floor; use VMware SVGA instead",
|
||||
"err.gpu_device_lost": "Host Vulkan GPU device lost (ERROR_DEVICE_LOST). Update GPU drivers; on affected AMD Vega/Polaris GPUs, switch to another discrete GPU or use VMware SVGA in VM Settings",
|
||||
"err.gpu_vulkan_floor": "Host GPU does not meet Reims vGPU's Vulkan 1.3 requirements. Update GPU drivers or switch graphics to VMware SVGA (software rendering) in VM Settings",
|
||||
"compat.gpu_icd_rebound": {
|
||||
"message": "Updated the GPU Vulkan ICD path from {old} to {new}",
|
||||
"$params": [
|
||||
"old",
|
||||
"new"
|
||||
]
|
||||
},
|
||||
"err.gpu_icd_stale": {
|
||||
"message": "The selected GPU's Vulkan ICD file no longer exists ({path}). In Settings → Graphics & displays, reselect the GPU or choose Automatic",
|
||||
"$params": [
|
||||
"path"
|
||||
]
|
||||
},
|
||||
"doctor.runtime": "Portable Runtime",
|
||||
"doctor.runtime.none": "Not installed (run `reims-go runtime install <archive>`)",
|
||||
"doctor.runtime.active": {
|
||||
|
||||
@@ -67,6 +67,19 @@
|
||||
"doctor.gpu.err.vulkan_cpu": "软件渲染 Vulkan 实现不满足 vGPU 硬件加速要求,请改用 VMware SVGA",
|
||||
"err.gpu_device_lost": "宿主显卡 Vulkan 设备丢失(ERROR_DEVICE_LOST)。请更新显卡驱动;若为 AMD Vega/Polaris 等受影响显卡,请改用其他独显或在设置中将虚拟显卡切为 VMware SVGA",
|
||||
"err.gpu_vulkan_floor": "宿主显卡不满足 Reims vGPU 的 Vulkan 1.3 硬件要求。请更新显卡驱动,或在设置中将虚拟显卡切为 VMware SVGA(软件渲染)",
|
||||
"compat.gpu_icd_rebound": {
|
||||
"message": "显卡 Vulkan ICD 路径已从 {old} 更新为 {new}",
|
||||
"$params": [
|
||||
"old",
|
||||
"new"
|
||||
]
|
||||
},
|
||||
"err.gpu_icd_stale": {
|
||||
"message": "原显卡的 Vulkan ICD 文件已不存在({path})。在设置 → 图形与显示器中重新选择显卡,或选择自动",
|
||||
"$params": [
|
||||
"path"
|
||||
]
|
||||
},
|
||||
"doctor.runtime": "便携运行时",
|
||||
"doctor.runtime.none": "尚未安装(运行 reims-go runtime install <压缩包> 导入)",
|
||||
"doctor.runtime.active": {
|
||||
|
||||
Reference in new issue
Block a user