fix(display): honor runtime VM screen environment
This commit is contained in:
1 parent
e0a25bb243
commit
6388865cbb
2 files changed
+12
-12
No files matched your search
@@ -122,12 +122,16 @@ func coldDisplayHost(string) host.Report {
|
||||
}
|
||||
|
||||
func TestDriverColdStartHonorsDirectScreenOverride(t *testing.T) {
|
||||
const primaryStart = "set normal-vm --resolution 5120x2880\nstart normal-vm fixed=1\n"
|
||||
const secondaryStart = "set normal-vm --resolution 3200x2000\nstart normal-vm fixed=\n"
|
||||
for _, tc := range []struct {
|
||||
name, parent, configured string
|
||||
name, parent, configured, want string
|
||||
}{
|
||||
{name: "parent process", parent: "1"},
|
||||
{name: "VM env only", configured: "[env]\nREIMS_VGPU_WINDOW_SCREENS = '1'\n"},
|
||||
{name: "VM extra_env overrides parent", parent: "0", configured: "[extra_env]\nREIMS_VGPU_WINDOW_SCREENS = '1'\n"},
|
||||
{name: "parent process", parent: "1", want: secondaryStart},
|
||||
{name: "VM extra_env only", configured: "[extra_env]\nREIMS_VGPU_WINDOW_SCREENS = '1'\n", want: secondaryStart},
|
||||
{name: "VM extra_env overrides parent", parent: "0", configured: "[extra_env]\nREIMS_VGPU_WINDOW_SCREENS = '1'\n", want: secondaryStart},
|
||||
{name: "VM env table is ignored", parent: "0", configured: "[env]\nREIMS_VGPU_WINDOW_SCREENS = '1'\n", want: primaryStart},
|
||||
{name: "empty VM extra_env overrides parent", parent: "1", configured: "[extra_env]\nREIMS_VGPU_WINDOW_SCREENS = ''\n", want: primaryStart},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
d, dir, commands := newColdDisplayDriver(t, "3840x2160", "reims-vgpu")
|
||||
@@ -146,8 +150,8 @@ func TestDriverColdStartHonorsDirectScreenOverride(t *testing.T) {
|
||||
if _, err := d.startWithHost(ctx, req, coldDisplayHost); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := commands(); got != "set normal-vm --resolution 3200x2000\nstart normal-vm fixed=\n" {
|
||||
t.Fatalf("reims-ctl = %q", got)
|
||||
if got := commands(); got != tc.want {
|
||||
t.Fatalf("reims-ctl = %q, want %q", got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -848,7 +848,7 @@ func ReadConfiguredResolution(vmDir string) (raw string, found bool) {
|
||||
return *cfg.Display.Resolution, true
|
||||
}
|
||||
|
||||
// ReadConfiguredEnv reads a per-VM environment override from vm.toml.
|
||||
// ReadConfiguredEnv reads a per-VM environment override from reims-ctl's extra_env table.
|
||||
func ReadConfiguredEnv(vmDir, key string) (string, bool) {
|
||||
if vmDir == "" {
|
||||
return "", false
|
||||
@@ -859,15 +859,11 @@ func ReadConfiguredEnv(vmDir, key string) (string, bool) {
|
||||
}
|
||||
var cfg struct {
|
||||
ExtraEnv map[string]string `toml:"extra_env"`
|
||||
Env map[string]string `toml:"env"`
|
||||
}
|
||||
if err := toml.Unmarshal(data, &cfg); err != nil {
|
||||
return "", false
|
||||
}
|
||||
if value, ok := cfg.ExtraEnv[key]; ok {
|
||||
return value, true
|
||||
}
|
||||
value, ok := cfg.Env[key]
|
||||
value, ok := cfg.ExtraEnv[key]
|
||||
return value, ok
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user