From b70609bde48d15ac1c36df711fdce8684046a60e Mon Sep 17 00:00:00 2001 From: clover caruso Date: Sat, 28 Nov 2026 20:40:41 -0800 Subject: [PATCH] win11-gaming: rebuild ext-rachel as Clover's gaming VM Rachel never used the guest, so it is wiped and reprovisioned for Clover: account snow, owned by her dashboard account, reachable only with config/admin.pub through Snow Globe. The host relay user, her keys and the internet-facing port 2223 go away. Apollo streams to Moonlight on the LAN through DNAT of its stream ports; the router forwards none of them. The 3090 is no longer claimed by vfio-pci at boot: libvirt moves it to the guest when it starts and back to nvidia when it stops, so local AI is enabled again and shares the card with the guest. Assisted-by: claude-opus-5.5 --- config/ext-rachel.json | 20 ------ config/win11-gaming.json | 9 +++ nixos/ext-rachel.nix | 150 --------------------------------------- nixos/knife-linux.nix | 6 +- nixos/snowglobe.nix | 7 +- nixos/win11-gaming.nix | 113 +++++++++++++++++++++++++++++ tools/ext-rachel.md | 33 --------- tools/win11-gaming.md | 33 +++++++++ 8 files changed, 161 insertions(+), 210 deletions(-) delete mode 100644 config/ext-rachel.json create mode 100644 config/win11-gaming.json delete mode 100644 nixos/ext-rachel.nix create mode 100644 nixos/win11-gaming.nix delete mode 100644 tools/ext-rachel.md create mode 100644 tools/win11-gaming.md diff --git a/config/ext-rachel.json b/config/ext-rachel.json deleted file mode 100644 index cd69ab5c584a162a8203ed21b1b12f7f2bdd289d..0000000000000000000000000000000000000000 --- a/config/ext-rachel.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "dataset": "work/ext-rachel", - "root": "/srv/ext-rachel", - "bridge": "virbr-ext", - "mac": "52:54:00:e7:00:02", - "gatewayAddress": "10.101.0.1", - "guestAddress": "10.101.0.2", - "sshPort": 2223, - "cpus": "3-7,19-23", - "gpu": [ - "10de:2204", - "10de:1aef" - ], - "authorizedKeys": [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBFQ8bkawCPFLOdVbUs/tf19bFflcal4Ss3BwjGa6mun", - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJVKqjtc1WZyfyQZIZzbNvZ7L2yEYh6rn7k7uGpiuNwP", - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOihVPOrOuT79omYc+AJYkmZceaAphi+7vOnhaYi87Hx", - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMpxNpkRLTUijhd3HSaOvKYn2MWXEY+YEFdsPNZhBROn" - ] -} diff --git a/config/win11-gaming.json b/config/win11-gaming.json new file mode 100644 index 0000000000000000000000000000000000000000..45ca96dde98c5a3b348d05820f37980eef11eb0a --- /dev/null +++ b/config/win11-gaming.json @@ -0,0 +1,9 @@ +{ + "dataset": "work/win11-gaming", + "root": "/srv/win11-gaming", + "bridge": "virbr-ext", + "mac": "52:54:00:e7:00:02", + "gatewayAddress": "10.101.0.1", + "guestAddress": "10.101.0.2", + "cpus": "3-7,19-23" +} diff --git a/nixos/ext-rachel.nix b/nixos/ext-rachel.nix deleted file mode 100644 index 7b1b6cab37552245b52d6d8f7ce06c2c836a6752..0000000000000000000000000000000000000000 --- a/nixos/ext-rachel.nix +++ /dev/null @@ -1,150 +0,0 @@ -{ lib, pkgs, ... }: -let - box = builtins.fromJSON (builtins.readFile ../config/ext-rachel.json); - privateRanges = [ "10.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16" "100.64.0.0/10" "169.254.0.0/16" ]; - # Open forwarding: libvirt adds no firewall rules, so the rules below are the whole policy. - network = pkgs.writeText "ext-rachel-network.xml" '' - - ext-rachel - - - - - - - - ''; -in -{ - # The 3090 belongs to the guest; vfio-pci claims it before nvidia can. - boot.initrd.kernelModules = [ "vfio_pci" "vfio" "vfio_iommu_type1" ]; - boot.kernelParams = [ "vfio-pci.ids=${lib.concatStringsSep "," box.gpu}" ]; - hardware.nvidia.nvidiaPersistenced = lib.mkForce false; - - systemd.services.ext-rachel-storage = { - wantedBy = [ "multi-user.target" ]; - before = [ "libvirtd.service" ]; - requires = [ "zfs-import-work.service" ]; - after = [ "zfs-import-work.service" "zfs-mount.service" ]; - serviceConfig = { Type = "oneshot"; RemainAfterExit = true; }; - script = '' - if ! ${pkgs.zfs}/bin/zfs list -H -o name ${box.dataset} >/dev/null 2>&1; then - ${pkgs.zfs}/bin/zfs create -o mountpoint=${box.root} -o compression=lz4 -o atime=off -o recordsize=64K ${box.dataset} - fi - ${pkgs.zfs}/bin/zfs set quota=560G ${box.dataset} - test "$(${pkgs.util-linux}/bin/findmnt -n -o SOURCE --mountpoint ${box.root})" = ${box.dataset} - chmod 0700 ${box.root} - ''; - }; - - systemd.services.ext-rachel-network = { - wantedBy = [ "multi-user.target" ]; - requires = [ "libvirtd.service" ]; - after = [ "libvirtd.service" ]; - before = [ "libvirt-guests.service" ]; - serviceConfig = { Type = "oneshot"; RemainAfterExit = true; }; - path = [ pkgs.libvirt ]; - script = '' - virsh net-info ext-rachel >/dev/null 2>&1 || virsh net-define ${network} - virsh net-autostart ext-rachel - virsh net-info ext-rachel | grep -q '^Active:.*yes' || virsh net-start ext-rachel - ''; - }; - - # Pinned vCPUs alone would still share those cores with host processes. - virtualisation.libvirtd.hooks.qemu.ext-rachel-cpus = pkgs.writeShellScript "ext-rachel-cpus" '' - test "$1" = ext-rachel -a "$2" = started || exit 0 - # The guest may start before knife-linux reserves its own CPUs here. - reserved=$(cat /sys/fs/cgroup/machine.slice/cpuset.cpus.exclusive) - echo "''${reserved:+$reserved,}${box.cpus}" > /sys/fs/cgroup/machine.slice/cpuset.cpus.exclusive - for scope in /sys/fs/cgroup/machine.slice/machine-qemu*ext\\x2drachel.scope; do - echo ${box.cpus} > $scope/cpuset.cpus.exclusive - echo ${box.cpus} > $scope/cpuset.cpus - echo root > $scope/cpuset.cpus.partition - done - ''; - - # libvirt-guests suspends guests at host shutdown, which fails with a passed-through GPU. - systemd.services.ext-rachel-shutdown = { - wantedBy = [ "multi-user.target" ]; - after = [ "libvirt-guests.service" ]; - # Stopping this unit shuts the guest down; a changed unit must not do that on switch. - restartIfChanged = false; - serviceConfig = { Type = "oneshot"; RemainAfterExit = true; TimeoutStopSec = 300; }; - path = [ pkgs.libvirt ]; - script = "true"; - preStop = '' - virsh shutdown ext-rachel 2>/dev/null || exit 0 - for _ in $(seq 1 120); do - virsh domstate ext-rachel | grep -q 'shut off' && exit 0 - sleep 2 - done - ''; - }; - - # Port 22 is the host's sshd, so the host account `rachel` only relays into the guest with its own key. - users.users.rachel = { - isSystemUser = true; - group = "rachel"; - home = "/var/lib/ext-rachel-relay"; - createHome = true; - shell = pkgs.bash; - openssh.authorizedKeys.keys = box.authorizedKeys; - }; - users.groups.rachel = { }; - systemd.services.ext-rachel-relay-key = { - wantedBy = [ "multi-user.target" ]; - serviceConfig = { Type = "oneshot"; RemainAfterExit = true; User = "rachel"; }; - script = '' - test -f ~/id_ed25519 || ${pkgs.openssh}/bin/ssh-keygen -q -t ed25519 -N "" -C ext-rachel-relay -f ~/id_ed25519 - ''; - }; - services.openssh.extraConfig = let - relay = pkgs.writeShellScript "ext-rachel-relay" '' - ssh() { exec ${pkgs.openssh}/bin/ssh -F /dev/null -e none -o BatchMode=yes -i ~/id_ed25519 \ - -o UserKnownHostsFile=~/known_hosts -o StrictHostKeyChecking=accept-new "$@" rachel@${box.guestAddress} "''${cmd[@]}"; } - case "$SSH_ORIGINAL_COMMAND" in - "") cmd=(); [ -t 0 ] && ssh -t || ssh ;; - *sftp-server) cmd=(sftp); ssh -s ;; - *) cmd=("$SSH_ORIGINAL_COMMAND"); [ -t 0 ] && ssh -t || ssh ;; - esac - ''; - in '' - Match User rachel - ForceCommand ${relay} - PasswordAuthentication no - KbdInteractiveAuthentication no - AllowTcpForwarding no - AllowAgentForwarding no - AllowStreamLocalForwarding no - PermitTunnel no - X11Forwarding no - ''; - - networking.nat = { - enable = true; - externalInterface = "enp4s0"; - internalInterfaces = [ box.bridge ]; - forwardPorts = [ - { sourcePort = box.sshPort; destination = "${box.guestAddress}:22"; proto = "tcp"; } - ]; - }; - - networking.firewall.extraCommands = '' - iptables -N ext-rachel 2>/dev/null || iptables -F ext-rachel - iptables -A ext-rachel -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT - ${lib.concatMapStringsSep "\n" (range: "iptables -A ext-rachel -d ${range} -j DROP") privateRanges} - iptables -A ext-rachel -p tcp --dport 25 -j DROP - iptables -A ext-rachel -j ACCEPT - iptables -I FORWARD -i ${box.bridge} -j ext-rachel - iptables -I nixos-fw 1 -i ${box.bridge} -j DROP - iptables -I nixos-fw 1 -i ${box.bridge} -p udp -m multiport --dports 53,67 -j ACCEPT - iptables -I nixos-fw 1 -i ${box.bridge} -p tcp --dport 53 -j ACCEPT - iptables -I nixos-fw 1 -i ${box.bridge} -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT - ''; - networking.firewall.extraStopCommands = '' - iptables -D FORWARD -i ${box.bridge} -j ext-rachel 2>/dev/null || true - iptables -F ext-rachel 2>/dev/null || true - iptables -X ext-rachel 2>/dev/null || true - ''; -} diff --git a/nixos/knife-linux.nix b/nixos/knife-linux.nix index c2ffaa86f0daf5bc11d73389e2d842bb0e5336ed..c2b17f268a74388d716ad3e07f343fbbedf3df65 100644 --- a/nixos/knife-linux.nix +++ b/nixos/knife-linux.nix @@ -15,7 +15,7 @@ let ''; run = "${podman}/bin/knife-linux-podman"; cpus = "8-15,24-31"; - extRachel = builtins.fromJSON (builtins.readFile ../config/ext-rachel.json); + win11Gaming = builtins.fromJSON (builtins.readFile ../config/win11-gaming.json); checkWork = pkgs.writeShellScript "check-knife-work" '' test "$(${pkgs.util-linux}/bin/findmnt -n -o SOURCE --mountpoint /srv/work)" = work ''; @@ -74,12 +74,12 @@ in "--device=/dev/kvm" "localhost/knife-linux" ]; - # Agents get 8 cores to themselves, ext-rachel 5 and the host keeps three. A partition + # Agents get 8 cores to themselves, win11-gaming 5 and the host keeps three. A partition # rather than a CPU quota: an exhausted quota freezes the Knife server with the builds. ExecStartPost = "-" + pkgs.writeShellScript "knife-linux-cpus" '' set -e scope=/sys/fs/cgroup$(${run} inspect --format '{{.State.CgroupPath}}' knife-linux) - echo ${cpus},${extRachel.cpus} > /sys/fs/cgroup/machine.slice/cpuset.cpus.exclusive + echo ${cpus},${win11Gaming.cpus} > /sys/fs/cgroup/machine.slice/cpuset.cpus.exclusive echo ${cpus} > $scope/cpuset.cpus.exclusive echo ${cpus} > $scope/cpuset.cpus echo root > $scope/cpuset.cpus.partition diff --git a/nixos/snowglobe.nix b/nixos/snowglobe.nix index 8ce4adec79ce5e481ef2c3f4b06922876a692d7d..4f3dd43be828a509ab7f2a3e7fa10d93b6937a63 100644 --- a/nixos/snowglobe.nix +++ b/nixos/snowglobe.nix @@ -8,7 +8,6 @@ let irohNetwork = builtins.fromJSON (builtins.readFile ../service/iroh-relay/network.json); spacebarVoice = builtins.fromJSON (builtins.readFile ../service/spacebar/voice-network.json); extMantikafasi = builtins.fromJSON (builtins.readFile ../config/ext-mantikafasi.json); - extRachel = builtins.fromJSON (builtins.readFile ../config/ext-rachel.json); udpPorts = xmppUDPPorts ++ [ irohNetwork.quic spacebarVoice.media spacebarVoice.nativeMedia ]; encryptionRoots = { clover = "clover"; @@ -19,7 +18,7 @@ let }; in { - imports = [ ./snowglobe-network.nix ./mac-studio-sandbox.nix ./knife-linux.nix ./adb.nix ./mac-vm.nix ./ext-mantikafasi.nix ./ext-rachel.nix ./vm-disks.nix ./zfs-read-cache.nix ./gpu-unlock.nix ]; + imports = [ ./snowglobe-network.nix ./mac-studio-sandbox.nix ./knife-linux.nix ./adb.nix ./mac-vm.nix ./ext-mantikafasi.nix ./win11-gaming.nix ./vm-disks.nix ./zfs-read-cache.nix ./gpu-unlock.nix ]; networking.hostName = "snowglobe"; environment.etc."machine-info".text = '' @@ -88,7 +87,7 @@ in script = '' description="$(${pkgs.python3}/bin/python3 ${./upnp-discover.py} ${lib.escapeShellArg config.networking.defaultGateway.address})" exec ${pkgs.miniupnpc}/bin/upnpc -u "$description" -e "Snow Globe services" -r \ - ${lib.concatMapStringsSep " " (port: "${toString port} TCP") (xmppTCPPorts ++ [ extMantikafasi.sshPort extMantikafasi.vncPort extRachel.sshPort ])} \ + ${lib.concatMapStringsSep " " (port: "${toString port} TCP") (xmppTCPPorts ++ [ extMantikafasi.sshPort extMantikafasi.vncPort ])} \ ${lib.concatMapStringsSep " " (port: "${toString port} UDP") (udpPorts ++ lib.range xmppNetwork.relay_first xmppNetwork.relay_last)} ''; }; @@ -149,7 +148,7 @@ in }; environment.variables.SNOWGLOBE_POOL = pool; environment.variables.SNOWGLOBE_DOMAIN = "paperclover.net"; - environment.variables.SNOWGLOBE_LOCAL_AI = "false"; + environment.variables.SNOWGLOBE_LOCAL_AI = "true"; system.stateVersion = "26.05"; } diff --git a/nixos/win11-gaming.nix b/nixos/win11-gaming.nix new file mode 100644 index 0000000000000000000000000000000000000000..98086859d74e4756ebb750451d0733b4fe0aa236 --- /dev/null +++ b/nixos/win11-gaming.nix @@ -0,0 +1,113 @@ +{ lib, pkgs, ... }: +let + box = builtins.fromJSON (builtins.readFile ../config/win11-gaming.json); + privateRanges = [ "10.0.0.0/8" "172.16.0.0/12" "192.168.0.0/16" "100.64.0.0/10" "169.254.0.0/16" ]; + # Apollo's Moonlight ports; its web UI (47990) stays reachable only from Snow Globe. + streamTCP = [ 47984 47989 48010 ]; + streamUDP = [ 47998 47999 48000 48002 48010 ]; + # Open forwarding: libvirt adds no firewall rules, so the rules below are the whole policy. + network = pkgs.writeText "win11-gaming-network.xml" '' + + win11-gaming + + + + + + + + ''; +in +{ + # libvirt moves the 3090 between nvidia and vfio-pci when the guest starts and stops; the daemon would hold it open. + hardware.nvidia.nvidiaPersistenced = lib.mkForce false; + + systemd.services.win11-gaming-storage = { + wantedBy = [ "multi-user.target" ]; + before = [ "libvirtd.service" ]; + requires = [ "zfs-import-work.service" ]; + after = [ "zfs-import-work.service" "zfs-mount.service" ]; + serviceConfig = { Type = "oneshot"; RemainAfterExit = true; }; + script = '' + if ! ${pkgs.zfs}/bin/zfs list -H -o name ${box.dataset} >/dev/null 2>&1; then + ${pkgs.zfs}/bin/zfs create -o mountpoint=${box.root} -o compression=lz4 -o atime=off -o recordsize=64K ${box.dataset} + fi + ${pkgs.zfs}/bin/zfs set quota=560G ${box.dataset} + test "$(${pkgs.util-linux}/bin/findmnt -n -o SOURCE --mountpoint ${box.root})" = ${box.dataset} + chmod 0700 ${box.root} + ''; + }; + + systemd.services.win11-gaming-network = { + wantedBy = [ "multi-user.target" ]; + requires = [ "libvirtd.service" ]; + after = [ "libvirtd.service" ]; + before = [ "libvirt-guests.service" ]; + serviceConfig = { Type = "oneshot"; RemainAfterExit = true; }; + path = [ pkgs.libvirt ]; + script = '' + virsh net-info win11-gaming >/dev/null 2>&1 || virsh net-define ${network} + virsh net-autostart win11-gaming + virsh net-info win11-gaming | grep -q '^Active:.*yes' || virsh net-start win11-gaming + ''; + }; + + # Pinned vCPUs alone would still share those cores with host processes. + virtualisation.libvirtd.hooks.qemu.win11-gaming-cpus = pkgs.writeShellScript "win11-gaming-cpus" '' + test "$1" = win11-gaming -a "$2" = started || exit 0 + # The guest may start before knife-linux reserves its own CPUs here. + reserved=$(cat /sys/fs/cgroup/machine.slice/cpuset.cpus.exclusive) + echo "''${reserved:+$reserved,}${box.cpus}" > /sys/fs/cgroup/machine.slice/cpuset.cpus.exclusive + for scope in /sys/fs/cgroup/machine.slice/machine-qemu*win11\\x2dgaming.scope; do + echo ${box.cpus} > $scope/cpuset.cpus.exclusive + echo ${box.cpus} > $scope/cpuset.cpus + echo root > $scope/cpuset.cpus.partition + done + ''; + + # libvirt-guests suspends guests at host shutdown, which fails with a passed-through GPU. + systemd.services.win11-gaming-shutdown = { + wantedBy = [ "multi-user.target" ]; + after = [ "libvirt-guests.service" ]; + # Stopping this unit shuts the guest down; a changed unit must not do that on switch. + restartIfChanged = false; + serviceConfig = { Type = "oneshot"; RemainAfterExit = true; TimeoutStopSec = 300; }; + path = [ pkgs.libvirt ]; + script = "true"; + preStop = '' + virsh shutdown win11-gaming 2>/dev/null || exit 0 + for _ in $(seq 1 120); do + virsh domstate win11-gaming | grep -q 'shut off' && exit 0 + sleep 2 + done + ''; + }; + + # The router forwards none of these ports, so only the LAN reaches the stream. + networking.nat = { + enable = true; + externalInterface = "enp4s0"; + internalInterfaces = [ box.bridge ]; + forwardPorts = + map (port: { sourcePort = port; destination = "${box.guestAddress}:${toString port}"; proto = "tcp"; }) streamTCP + ++ map (port: { sourcePort = port; destination = "${box.guestAddress}:${toString port}"; proto = "udp"; }) streamUDP; + }; + + networking.firewall.extraCommands = '' + iptables -N win11-gaming 2>/dev/null || iptables -F win11-gaming + iptables -A win11-gaming -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT + ${lib.concatMapStringsSep "\n" (range: "iptables -A win11-gaming -d ${range} -j DROP") privateRanges} + iptables -A win11-gaming -p tcp --dport 25 -j DROP + iptables -A win11-gaming -j ACCEPT + iptables -I FORWARD -i ${box.bridge} -j win11-gaming + iptables -I nixos-fw 1 -i ${box.bridge} -j DROP + iptables -I nixos-fw 1 -i ${box.bridge} -p udp -m multiport --dports 53,67 -j ACCEPT + iptables -I nixos-fw 1 -i ${box.bridge} -p tcp --dport 53 -j ACCEPT + iptables -I nixos-fw 1 -i ${box.bridge} -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT + ''; + networking.firewall.extraStopCommands = '' + iptables -D FORWARD -i ${box.bridge} -j win11-gaming 2>/dev/null || true + iptables -F win11-gaming 2>/dev/null || true + iptables -X win11-gaming 2>/dev/null || true + ''; +} diff --git a/tools/ext-rachel.md b/tools/ext-rachel.md deleted file mode 100644 index c3bc971b9388eef8fc5648b3773727f8103626f1..0000000000000000000000000000000000000000 --- a/tools/ext-rachel.md +++ /dev/null @@ -1,33 +0,0 @@ -# ext-rachel - -`ext-rachel` is a Windows 11 Pro libvirt guest (`windows-11-pro-v2` preset, 10 vCPU, 40 GiB) owned by the -dashboard user `rachel`, with the RTX 3090 passed through. Its 500 GB disk is a standalone qcow2 on the `work` -NVMe pool (`work/ext-rachel` at `/srv/ext-rachel`); the creation artifacts, seed and `access.json` stay in -`/srv/vm/ext-rachel`. `config/ext-rachel.json` and `nixos/ext-rachel.nix` own the host side. - -``` -internet ──UPnP──> Snow Globe :2223 ─DNAT─> 10.101.0.2:22 (Windows OpenSSH, PowerShell) -internet ──> Snow Globe :22 as rachel ─ForceCommand ssh─> 10.101.0.2:22 -dashboard console / Computer MCP ─── libvirt VNC + guest agent (owner rachel) -guest ── virbr-ext (forward mode='open') ── MASQUERADE ── internet only -``` - -- **GPU:** `vfio-pci.ids` claims both 3090 functions at boot, so local AI is off (`SNOWGLOBE_LOCAL_AI=false`) - and `nvidia-persistenced` is disabled. The guest uses the GeForce driver; the emulated VGA stays the primary - display so the dashboard console and Computer MCP keep working. Games pick the 3090 in Windows' Graphics - settings ("High performance"). Restoring local AI means removing the import, a reboot, and redeploying. -- **Isolation:** libvirt adds no rules for an open network; `ext-rachel` drops new connections to private, - CGNAT and link-local ranges and port 25. From the guest, Snow Globe answers only DHCP and DNS. - Snow Globe itself can still connect into the guest. -- **CPUs and memory:** vCPUs are pinned 1:1 to cores 3-7 and their siblings 19-23, which a libvirt hook makes an - exclusive cpuset partition beside `knife-linux` (8 cores); the host keeps 0-2 and 16-18. VFIO pins all 40 GiB, so - the ZFS ARC floor is 16 GiB and `knife-linux` is capped at 72 GiB to leave headroom. -- **OpenSSH:** the guest runs the Win32-OpenSSH MSI. The Windows `OpenSSH.Server` capability was removed because its - servicing deleted the MSI's `sshd` service; `msiexec /fa ` restores it. -- **Shutdown:** `ext-rachel-shutdown` shuts the guest down before `libvirt-guests`, whose managed save cannot - capture a VFIO device. -- **Access:** account `rachel`, password in `/srv/vm/ext-rachel/access.json`. - `ssh rachel@snowglobe.paperclover.net` takes only the keys in `config/ext-rachel.json`; the host account - relays shells, commands and sftp/scp into the guest with `/var/lib/ext-rachel-relay/id_ed25519`, whose public - half must be in the guest's `administrators_authorized_keys`. Port 2223 also takes the password. MCP: `https://snowglobe.paperclover.net/mcp/computer`, - signed in as `rachel`; MCP grants only reach VMs the connection's own account owns. diff --git a/tools/win11-gaming.md b/tools/win11-gaming.md new file mode 100644 index 0000000000000000000000000000000000000000..480b7bdfdc30b1f755b9d76941d30e9aa333f86f --- /dev/null +++ b/tools/win11-gaming.md @@ -0,0 +1,33 @@ +# win11-gaming + +`win11-gaming` is Clover's Windows 11 Pro libvirt guest for games (`windows-11-pro-v2` preset, 10 vCPU, +40 GiB, account `snow`), with the RTX 3090 passed through. Its 500 GB disk is a standalone qcow2 on the `work` +NVMe pool (`work/win11-gaming` at `/srv/win11-gaming`); NVRAM, seed, `domain.xml`, `access.json` and +`apollo.json` stay in `/srv/vm/win11-gaming`. `config/win11-gaming.json` and `nixos/win11-gaming.nix` own the +host side. + +``` +LAN ── Snow Globe 10.0.0.1 :47984,47989,48010/tcp :47998-48002,48010/udp ─DNAT─> Apollo (Moonlight host) +Snow Globe ── ssh snow@10.101.0.2 (config/admin.pub only) / Apollo web API :47990 +dashboard console / Computer MCP ─── libvirt VNC + guest agent (owner Clover) +guest ── virbr-ext (forward mode='open') ── MASQUERADE ── internet only +``` + +- **GPU:** the 3090 serves either this guest or local AI, chosen with the dashboard's Games/AI switch. The + domain's `managed='yes'` hostdevs make libvirt move both functions to vfio-pci at start and back to nvidia at + shut off; `nvidia-persistenced` stays off so nothing holds the device. Windows Update is barred from driver + updates (`ExcludeWUDriversInQualityUpdate`); install GeForce drivers with `-s -n`. +- **Streaming:** Apollo 0.4.6 (a Sunshine fork) encodes HEVC on NVENC and creates a SudoVDA virtual display at + each client's resolution, so no monitor or dummy plug is needed. `sg game` on the Mac pairs and streams with + Moonlight; another client (the Apple TV) shows a PIN for `sg game pin `. Apollo's web login is in + `apollo.json`; its UI only answers Snow Globe. The router forwards none of the stream ports. +- **Isolation:** libvirt adds no rules for an open network; the `win11-gaming` chain drops new connections to + private, CGNAT and link-local ranges and port 25. From the guest, Snow Globe answers only DHCP and DNS. + Snow Globe and the forwarded stream ports can still reach into the guest. +- **CPUs and memory:** vCPUs are pinned 1:1 to cores 3-7 and their siblings 19-23, which a libvirt hook makes an + exclusive cpuset partition beside `knife-linux` (8 cores); the host keeps 0-2 and 16-18. VFIO pins all 40 GiB, so + the ZFS ARC floor is 16 GiB and `knife-linux` is capped at 72 GiB to leave headroom. +- **OpenSSH:** the Windows `OpenSSH.Server` capability, key-only, PowerShell as the shell: + `ssh -J root@10.0.0.1 snow@10.101.0.2`. +- **Shutdown:** `win11-gaming-shutdown` shuts the guest down before `libvirt-guests`, whose managed save cannot + capture a VFIO device. -- 2.54.1