From 9077704379f47ddf263d150b654f1a9d9855b71f Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 27 Nov 2026 00:12:11 -0500 Subject: [PATCH] Read live game cores from the path the app writes and accept only well-formed lists The x86-64 client runs with its own HOME, so the reader now uses the fixed guest path the app writes. A list such as 6- keeps the session value instead of reaching taskset. --- .../overlay/usr/local/bin/steam-compatibility | 4 ++-- tools/tests/test_game_cpus_live.py | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility index b54e692517..be66f3bc01 100755 --- a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility +++ b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility @@ -227,9 +227,9 @@ dd_components() { DD_GAME_CPUS_SETUP = """ dd_game_cpus() { - local live="${HOME:-/root}/.config/droiddeck/game-cores" cpus + local live=/root/.config/droiddeck/game-cores cpus if [ -f "$live" ] && cpus=$(<"$live") 2>/dev/null; then - case $cpus in *[!0-9,-]*) cpus=${DD_GAME_CPUS:-} ;; esac + [[ -z $cpus || $cpus =~ ^[0-9]+(-[0-9]+)?(,[0-9]+(-[0-9]+)?)*$ ]] || cpus=${DD_GAME_CPUS:-} if [ -z "$cpus" ] && [ -n "${DD_CLIENT_CPUS:-}" ]; then cpus=$(nproc --all 2>/dev/null) && cpus=0-$((cpus - 1)) || cpus= fi diff --git a/tools/tests/test_game_cpus_live.py b/tools/tests/test_game_cpus_live.py index d7128ca661..90db2c0471 100644 --- a/tools/tests/test_game_cpus_live.py +++ b/tools/tests/test_game_cpus_live.py @@ -14,8 +14,7 @@ class LiveGameCpusTest(unittest.TestCase): self.temp = tempfile.TemporaryDirectory() self.addCleanup(self.temp.cleanup) base = Path(self.temp.name) - self.home = base / "home" - (self.home / ".config/droiddeck").mkdir(parents=True) + self.live = base / "game-cores" tools = base / "tools" tools.mkdir() for name, body in (("taskset", "exit 0"), ("nproc", "echo 8")): @@ -26,10 +25,11 @@ class LiveGameCpusTest(unittest.TestCase): def run_setup(self, live=None, **extra): if live is not None: - (self.home / ".config/droiddeck/game-cores").write_text(live) - script = COMPAT["DD_GAME_CPUS_SETUP"] + '\ndd_game_cpus\necho "taskset=${DD_TASKSET:-}"\necho "cpus=${DD_GAME_CPUS-unset}"\n' + self.live.write_text(live) + setup = COMPAT["DD_GAME_CPUS_SETUP"].replace("/root/.config/droiddeck/game-cores", str(self.live)) + script = setup + '\ndd_game_cpus\necho "taskset=${DD_TASKSET:-}"\necho "cpus=${DD_GAME_CPUS-unset}"\n' env = {key: value for key, value in os.environ.items() if not key.startswith("DD_")} - env.update(HOME=str(self.home), PATH=self.path, **extra) + env.update(PATH=self.path, **extra) result = subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True, check=True) return result.stdout.splitlines() @@ -50,7 +50,13 @@ class LiveGameCpusTest(unittest.TestCase): self.assertEqual(self.run_setup(), ["taskset=", "cpus=unset"]) def test_an_unreadable_value_keeps_the_session_value(self): - self.assertEqual(self.run_setup("3;rm\n", DD_GAME_CPUS="4,5"), ["taskset=taskset -c 4,5", "cpus=4,5"]) + for bad in ("3;rm\n", "6-\n", "-3\n", "3,,4\n", "3,\n"): + self.assertEqual(self.run_setup(bad, DD_GAME_CPUS="4,5"), ["taskset=taskset -c 4,5", "cpus=4,5"], bad) + + def test_the_file_is_found_whatever_home_the_client_runs_with(self): + self.assertEqual(self.run_setup("6,7\n", DD_GAME_CPUS="3,4,5,6,7", HOME="/root/.droiddeck-x64"), + ["taskset=taskset -c 6,7", "cpus=6,7"]) + self.assertIn("live=/root/.config/droiddeck/game-cores ", COMPAT["DD_GAME_CPUS_SETUP"]) if __name__ == "__main__":