diff --git a/docs/os/BUILD_AND_QUALIFY.md b/docs/os/BUILD_AND_QUALIFY.md index 023f68c9..76749b23 100644 --- a/docs/os/BUILD_AND_QUALIFY.md +++ b/docs/os/BUILD_AND_QUALIFY.md @@ -18,7 +18,8 @@ for an installed system or place private data in this live image. The reserved `phios-agent` account cannot read the operator home and runs no agent by default. The browser keeps Chromium's sandbox. The compositor's autostart imports its -Wayland environment before starting `phios-session.target`. Transport, curiosity +Wayland environment after validating its socket, then stops/starts +`phios-session.target` to rebind any active services from a previous session. Transport, curiosity projection, optional history, browser and Waybar have separate user services. Session exit stops the target. Default state is `%h/.local/state/phios` with umask 0077. History is not auto-enabled: an operator must create and review @@ -61,6 +62,15 @@ The harness then resets the VM and requires the complete fixture on a second, distinct kernel boot ID. Both desktop captures are preserved. This fixture is omitted from normal locally built previews. +The follow-up normal-image gate also replaces stale manager display variables +while Chromium and Waybar are active, calls the packaged ready hook and requires +new running browser/panel process IDs after the manager imports the connected +compositor's display environment on both live boots. The +focused shell tests cover the VirtualBox/VMSVGA cursor selection separately. +QEMU rebinding does not qualify Windows VirtualBox's driver path; see +VIRTUALBOX_COMPATIBILITY.md for the supplied field evidence and required new-ISO +automatic-startup retest. + A fixture pass is evidence for the checks it performs. Review the screenshot and session behavior. It does not prove installation, persisted receipts, crash recovery, whole-OS updates, hardware compatibility or a Linux effect diff --git a/docs/os/DESKTOP_OPERATION.md b/docs/os/DESKTOP_OPERATION.md index 7195c9be..bfba715f 100644 --- a/docs/os/DESKTOP_OPERATION.md +++ b/docs/os/DESKTOP_OPERATION.md @@ -81,6 +81,14 @@ machine are separate hardware tests. ## Candidate qualification scope +The owner-reported Windows 11 Home / VirtualBox live compatibility case, its +initial renderer/cursor failures and exact working recipe are preserved in +[VIRTUALBOX_COMPATIBILITY.md](VIRTUALBOX_COMPATIBILITY.md). The follow-up wrapper +limits its automatic cursor override to detected VirtualBox plus VMSVGA. The +ready hook validates the compositor socket, imports its environment, then +stops/starts session services so active processes cannot retain an old display. +This does not add physical GPU support or change operator authority. + The new exact normal live gate attaches only a restricted QEMU user-network Ethernet device on the documentation range `192.0.2.0/24`, without port forwarding, and an emulated HDA device with a null audio backend. It checks the actual DHCP diff --git a/docs/os/HARDWARE_QUALIFICATION.md b/docs/os/HARDWARE_QUALIFICATION.md index c9ebd333..cd91b556 100644 --- a/docs/os/HARDWARE_QUALIFICATION.md +++ b/docs/os/HARDWARE_QUALIFICATION.md @@ -9,6 +9,7 @@ this GPU, motherboard firmware, audio, network radios or physical power loss. | Target | Current evidence | Gate | | --- | --- | --- | | Disposable x64 UEFI/KVM VM, 2 CPUs, 4 GiB RAM, 32-GiB disk | Exact normal live/install/data/recovery/Linux proof, virtual DHCP/audio and manual PAM locking passed in code-continuation run 36832501182; separate ephemeral signed-update/interruption QA passed in the same source run | Future final artifact and actual signed release transition must be qualified separately | +| Windows 11 Home / Oracle VirtualBox, VMSVGA, 128 MB VRAM, 8 GiB RAM, 4 CPUs, 64 GB virtual disk | Owner reported live UEFI/PAM and interactive desktop pass on exact ISO `376fd601...`, after enabling 3D, setting the cursor override and rebinding session services; initial renderer and cursor failures retained in VIRTUALBOX_COMPATIBILITY.md | New automatic compatibility candidate needs a separate local VirtualBox retest; no physical or installation inference | | Supplied Skytech/Core Ultra 9/RTX 5070 machine | No boot or driver observations | Live boot, GPU/input/network/audio/firmware tests first | | Dedicated empty physical test disk | No selected disk or test | Exact installer identity/blankness/confirmation, no-media boot, persistence, update and recovery | diff --git a/docs/os/RELEASE_HANDOFF.md b/docs/os/RELEASE_HANDOFF.md index a8b131be..287d4a78 100644 --- a/docs/os/RELEASE_HANDOFF.md +++ b/docs/os/RELEASE_HANDOFF.md @@ -29,6 +29,17 @@ verify its complete ISO/source/artifact hashes against SHA256SUMS and provenance and retain the receipts with that exact build. The separate QA image contains test fixtures and is not the physical observation candidate. +The owner also tested this exact candidate in Windows 11 Home / VirtualBox on +2026-10-01. Live UEFI/PAM and interactive desktop worked after enabling VMSVGA +3D acceleration, exporting the cursor workaround and rebinding the session +target. Initial renderer/cursor failures and the full supplied configuration +remain in [VIRTUALBOX_COMPATIBILITY.md](VIRTUALBOX_COMPATIBILITY.md) and +`evidence/virtualbox-field-1c16c473.json`. The narrow automatic startup correction +is a separate candidate stacked after this handoff; its new bytes need their +own qualification and local VirtualBox retest. The table above and existing +receipts retain their original tested identities. Skytech/RTX 5070 remains +physically untested. + ## Ordered code review Review the component PRs in dependency order after assessing each boundary: diff --git a/docs/os/VIRTUALBOX_COMPATIBILITY.md b/docs/os/VIRTUALBOX_COMPATIBILITY.md new file mode 100644 index 00000000..262021fa --- /dev/null +++ b/docs/os/VIRTUALBOX_COMPATIBILITY.md @@ -0,0 +1,135 @@ +# VirtualBox live compatibility observation + +On 2026-10-01 Mikey reported a local live test on Windows 11 Home using Oracle +VirtualBox. This is owner-supplied compatibility evidence for the existing +qualified normal candidate, with the failed configurations preserved below. +It does not qualify physical Skytech/RTX 5070 hardware, installation, audio, +network connectivity, suspend, a signed transition or publication. + +| Tested identity | Value | +| --- | --- | +| Source PR | [281](https://github.com/MichaelWave369/PhiOS/pull/281) | +| Reviewed head | `3d282bdd6466052def8e632245f312863040cafc` | +| Qualified prospective source | `1c16c4732442d69d2c7b5763212f1977860a15ae` | +| Normal ISO SHA-256 | `376fd601f66b13dccd6a08644a7b807129f315882d355fd376d0934a80ae29aa` | +| Existing qualification | [36832501182](https://github.com/MichaelWave369/PhiOS/actions/runs/36832501182) | +| Field receipt | [virtualbox-field-1c16c473.json](evidence/virtualbox-field-1c16c473.json) | + +The field report supplied this identity; this review did not independently hash +the owner's mounted ISO or acquire the raw Wayfire/service logs. The attached +desktop screenshot was inspected: PhiShell v0.16.0 and a visible pointer are +present. The receipt retains the screenshot digest, without copying the image +into the public repository. Interaction and the staged failures/successes are +owner observations. The exact VirtualBox version was not supplied. + +A later owner cold boot showed `vmwgfx` warning about an unsupported hypervisor +and the separate unavailable TDX host feature before boot continued. The field +receipt preserves those screenshot messages and its digest. The messages alone +do not establish a fatal boot failure or persistence of the manual cursor +override after a power cycle. Keep this observation separate from a new-ISO +automatic startup pass. + +## Configuration and outcomes + +Arch Linux (64-bit) guest, EFI enabled, Secure Boot off, 8192 MB RAM, four vCPUs, +64 GB virtual disk, VMSVGA, 128 MB video RAM, NAT and no shared folders. The exact +normal ISO above was mounted. No installation was reported. + +| Stage | Configuration / observation | Result | +| --- | --- | --- | +| Initial live boot | EFI, live environment, greetd/tuigreet, public `phios` / `phios` PAM and tty login | PASS | +| Initial renderer | VMSVGA, 3D acceleration off; graphical session immediately exits | FAIL | +| Renderer retry | Power off VM, enable 3D acceleration, retain VMSVGA/128 MB | PASS: PhiShell, Reality Ledger, launcher, windows and Waybar visible | +| Initial pointer | Hover/right-click works after renderer retry, pointer invisible | FAIL | +| Cursor workaround | Export `WLR_NO_HARDWARE_CURSORS=1` before launching `phios-session` from tty2 | PASS: visible functional cursor and rendering; desktop initially blank | +| Existing services | Browser and Waybar active; Chromium uses `--ozone-platform=wayland --app=http://127.0.0.1:3969/`; Waybar sees display | Active services alone did not establish a rendered desktop | +| Session rebinding | Stop then start `phios-session.target` from the new graphical session | PASS: full PhiShell/Waybar desktop, cursor and normal interaction | + +Reported initial renderer messages, retained verbatim: + +```text +VMware: No 3D enabled +MESA-EGL warning: egl: failed to create dri2 screen +EGL_NOT_INITIALIZED +Failed to initialize EGL context +Could not initialize renderer +Failed to create renderer +``` + +The pointer behavior is consistent with a hardware-cursor issue. Services left +running from the previous session are consistent with the blank desktop after +launching a new compositor: importing environment variables does not change an +already-running process. These are bounded diagnoses, not additional raw-log +observations or evidence for every VirtualBox version. + +## Reproduced manual recipe on the original candidate + +Power off the VM and select VMSVGA, 128 MB VRAM and **3D acceleration on**. +After ordinary live tty login, launch: + +```sh +export WLR_NO_HARDWARE_CURSORS=1 +phios-session +``` + +If earlier user services remain bound to the old session, open the ordinary +Linux terminal in the new graphical session with Super+Alt+Enter and run: + +```sh +systemctl --user stop phios-session.target +systemctl --user start phios-session.target +``` + +The live overlay is volatile. This manual recipe documents the owner's result; +it does not claim the original ISO contains an automatic compatibility fix. + +## Narrow candidate correction and verification + +The follow-up session wrapper sources a packaged compatibility helper before +starting Wayfire. The helper requires **both** successful +`systemd-detect-virt --vm` identification as `oracle` and a sysfs PCI display +device with vendor/device `15ad:0405` (VMSVGA). Only this combination sets +`WLR_NO_HARDWARE_CURSORS=1`. VMware shares the PCI identity, so the PCI device +alone is insufficient. Missing/failed detection or another device leaves the +cursor environment unchanged. No Guest Additions, new kernel/driver, global +cursor setting or real-hardware renderer behavior is added. Host-side 3D +acceleration remains an operator VM setting. + +The Wayfire autostart hook refuses missing display/runtime variables or a +non-socket display path. It imports the compositor's Wayland/runtime/desktop +environment into the user systemd and D-Bus activation environments, clears an +obsolete Xwayland DISPLAY when none is supplied, then stops/starts the existing +session target. Existing PartOf dependencies rebind browser, panel and other +session services. Session cleanup and non-root startup remain in place. + +Focused tests execute the shell helper with captured PCI identities and check +VirtualBox selection, VMware/KVM/real-hardware exclusion, incomplete detection, +operator environment preservation, socket gating, relative/absolute +display paths, import-before-restart ordering and failure propagation. The +normal-image QEMU gate additionally contaminates the manager's display variables +while the real browser and panel are active, invokes the packaged ready hook, +and requires replacement running browser/panel process IDs after the user +manager imports the connected compositor's display environment and clears stale +DISPLAY on both live boots. This verifies rebinding under QEMU; +it does not emulate a Windows VirtualBox 3D driver or prove the new automatic +cursor branch in VirtualBox. + +Changed source and ISO bytes require their own complete qualification and a +fresh local VirtualBox test of automatic startup without manual exports/target +restart. Keep the original candidate hashes/receipts intact. Do not merge, tag, +sign, publish or infer physical support from this observation. + +The first follow-up normal-image attempt rendered PhiShell/Waybar but failed +the new probe while it tried to obtain a service process's display environment +from `/proc/PID/environ`; the initial timeout omitted the failing PID/environment +predicate. Its install/recovery phase was skipped. The revised probe +uses the user manager's explicit `show-environment` state, validates only its +display keys, connects to the actual compositor socket and requires individually +active replacement Chromium/Waybar processes. The failed source/ISO, serial +exception, screenshot and independently checked compact-archive hashes remain +in [virtualbox-compatibility-attempts.json](evidence/virtualbox-compatibility-attempts.json). +The failed gate is not replaced by its screenshot or a separate QA result. + +Detection references: [systemd virtualization identifiers](https://github.com/systemd/systemd/blob/main/src/basic/virt.c), +[Oracle VMSVGA PCI definitions](https://github.com/VirtualBox/virtualbox/blob/main/src/VBox/Devices/Graphics/DevVGA-SVGA.h), +and [systemd PartOf lifecycle semantics](https://www.freedesktop.org/software/systemd/man/systemd.unit.html). diff --git a/docs/os/evidence/virtualbox-compatibility-attempts.json b/docs/os/evidence/virtualbox-compatibility-attempts.json new file mode 100644 index 00000000..706d28f4 --- /dev/null +++ b/docs/os/evidence/virtualbox-compatibility-attempts.json @@ -0,0 +1,60 @@ +{ + "schema_version": "phios.virtualbox-compatibility-attempts.v1", + "release_ready": false, + "publication_authority": false, + "attempts": [ + { + "run_id": 36913191826, + "run_attempt": 1, + "url": "https://github.com/MichaelWave369/PhiOS/actions/runs/36913191826", + "reviewed_head": "5825e2cf6ffd5df0888ffa3b64a5c275d7d980f4", + "source_commit": "146e470f6d9ee0e5ff8700cf3fab5e779c9ddacd", + "source_tree": "e2df371c387b2a6b5ea87fb2177122f29d285679", + "normal_iso_producer_sha256": "f544ce35f4ae09ecf67b18f19b079a94489c65f10a8bd8cd74a8f3626c2abab2", + "iso_independently_hashed_by_this_review": false, + "normal_image_qualification": "failed at added live rebinding probe; installation/recovery skipped", + "guest_serial_exception": "RuntimeError: no supervised desktop environment available for rebinding", + "missing_process_or_environment_predicate_not_preserved_by_initial_probe": true, + "desktop_screenshot_visually_inspected": true, + "desktop_screenshot_observed": [ + "PhiShell rendered", + "Waybar rendered" + ], + "rendered_screenshot_does_not_qualify_failed_gate": true, + "compact_archive": { + "artifact_id": 11188487889, + "url": "https://github.com/MichaelWave369/PhiOS/actions/runs/36913191826/artifacts/11188487889", + "sha256": "bc5e43352c47353f48c5b0510c1048ad4833bafb8c769b678c4576c7e11e6999", + "size": 623589, + "independently_downloaded_and_digest_verified": true + }, + "normal_image_artifact": { + "artifact_id": 11188572974, + "url": "https://github.com/MichaelWave369/PhiOS/actions/runs/36913191826/artifacts/11188572974", + "independently_downloaded": false + }, + "retained_files": { + "_temp/phios-preview/preview-evidence.json": { + "sha256": "28eccfc72dc1358b3a9a791f296eafd278ae6e724c8bf41169ce3a0a55f9a147", + "size": 1677 + }, + "_temp/phios-preview/screen.png": { + "sha256": "2232616c417afef6a13500cd82e85865fc66556c0244f101b21a0119ec0352e8", + "size": 429348 + }, + "_temp/phios-preview/serial.log": { + "sha256": "7c3c854a31590a63db0d1c25267399c5891e646299c976c6a2c3f4a699db78de", + "size": 33815 + } + }, + "python_tests_passed": 2352, + "existing_optional_python_skips": 6, + "repair_scope": "qualification probe only: obtain explicit user-manager display environment, require individually active named replacement processes, retain failure diagnostics; production session/cursor correction unchanged", + "separate_qa_result_cannot_qualify_failed_normal_image": true, + "original_1c16c473_candidate_receipts_preserved": true, + "virtualbox_new_automatic_fix_retested": false, + "physical_hardware_qualified": false, + "release_ready": false + } + ] +} diff --git a/docs/os/evidence/virtualbox-field-1c16c473.json b/docs/os/evidence/virtualbox-field-1c16c473.json new file mode 100644 index 00000000..33a9dd2f --- /dev/null +++ b/docs/os/evidence/virtualbox-field-1c16c473.json @@ -0,0 +1,126 @@ +{ + "schema_version": "phios.owner-vm-field-observation.v1", + "observation_date": "2026-10-01", + "reporter": "Mikey / Michael Hughes", + "evidence_origin": "owner report in continuation conversation; attached desktop screenshot inspected", + "candidate": { + "version": "0.1.0-alpha.1", + "source_pr": 281, + "head_commit": "3d282bdd6466052def8e632245f312863040cafc", + "qualified_prospective_source": "1c16c4732442d69d2c7b5763212f1977860a15ae", + "iso_sha256": "376fd601f66b13dccd6a08644a7b807129f315882d355fd376d0934a80ae29aa", + "identity_supplied_by_owner": true, + "mounted_iso_independently_hashed_by_this_review": false, + "existing_qualification_run": "https://github.com/MichaelWave369/PhiOS/actions/runs/36832501182" + }, + "configuration": { + "host_os": "Windows 11 Home", + "hypervisor": "Oracle VirtualBox", + "hypervisor_version": null, + "guest_type": "Arch Linux (64-bit)", + "efi": true, + "secure_boot": false, + "memory_mb": 8192, + "vcpu": 4, + "virtual_disk_gb_reported": 64, + "graphics_controller": "VMSVGA", + "video_memory_mb": 128, + "network": "NAT", + "shared_folders": false, + "exact_candidate_iso_mounted_reported": true, + "initial_3d_acceleration": false, + "working_3d_acceleration": true + }, + "attempts": [ + { + "stage": "initial live boot, 3D acceleration off", + "uefi_boot": "pass", + "live_environment": "pass", + "greetd_tuigreet": "pass", + "public_live_account_pam": "pass", + "tty_login": "pass", + "wayfire_renderer": "fail", + "graphical_session": "failed immediately", + "reported_wayfire_log_messages": [ + "VMware: No 3D enabled", + "MESA-EGL warning: egl: failed to create dri2 screen", + "EGL_NOT_INITIALIZED", + "Failed to initialize EGL context", + "Could not initialize renderer", + "Failed to create renderer" + ] + }, + { + "stage": "powered off, enabled 3D acceleration, retained VMSVGA/128 MB", + "wayfire_renderer": "pass", + "phishell_reality_ledger_launcher_windows_waybar_visible": "pass", + "hover_and_right_click": "pass", + "visible_pointer": "fail" + }, + { + "stage": "tty2 exported cursor override before launching phios-session", + "commands": ["export WLR_NO_HARDWARE_CURSORS=1", "phios-session"], + "wayfire_renderer": "pass", + "visible_functional_pointer": "pass", + "desktop_initially_blank": true, + "reported_service_observations": { + "phios-browser.service": "active/running", + "chromium_arguments": "--ozone-platform=wayland --app=http://127.0.0.1:3969/", + "phios-waybar.service": "active/running", + "waybar_recognized_display": true + } + }, + { + "stage": "session target rebound from terminal in the new graphical session", + "commands": [ + "systemctl --user stop phios-session.target", + "systemctl --user start phios-session.target" + ], + "full_phios_desktop": "pass", + "phishell_and_waybar_visible": "pass", + "visible_functional_pointer": "pass", + "interactive_desktop_use": "pass" + } + ], + "diagnosis": { + "renderer_failure": "isolated to the reported renderer/EGL path with 3D acceleration off", + "cursor": "consistent with a Wayfire/wlroots hardware-cursor issue under VirtualBox", + "blank_desktop": "consistent with existing user service processes retaining the previous Wayland session/socket", + "inferences_are_not_additional_raw_log_evidence": true + }, + "screenshot": { + "supplied_name": "image.png", + "sha256": "cf22251373df22c6cbb230d0e6e2b3b8bf5269f7555e25e7a9a5717ded86560e", + "bytes": 583611, + "visually_inspected": true, + "observed": ["PhiShell v0.16.0 visible", "mouse pointer visible"], + "published_in_repository": false, + "does_not_independently_prove_interaction_or_prior_attempts": true + }, + "raw_wayfire_and_service_logs_acquired": false, + "additional_cold_boot_observation": { + "date": "2026-10-01", + "owner_action": "power off then power on", + "reported_boot_continued_after_messages": true, + "messages_visually_observed": [ + "virt/tdx: TDX not supported by the host platform", + "vmwgfx 0000:00:02.0: [drm] *ERROR* vmwgfx seems to be running on an unsupported hypervisor.", + "vmwgfx 0000:00:02.0: [drm] *ERROR* This configuration is likely broken.", + "vmwgfx 0000:00:02.0: [drm] *ERROR* Please switch to a supported graphics device to avoid problems." + ], + "screenshot_name": "Screenshot 2026-10-01 121913.png", + "screenshot_sha256": "3badeec3fe20ef7f601bcb21a93a3eb7409740a19c3aabf2c999d4b2cb279354", + "screenshot_bytes": 57487, + "screenshot_visually_inspected": true, + "screenshot_published_in_repository": false, + "new_independent_iso_hash_acquired": false, + "automatic_cursor_or_service_rebinding_pass_inferred": false + }, + "automatic_fix_on_new_candidate_virtualbox_retested": false, + "installation_qualified_by_this_observation": false, + "physical_hardware_qualified": false, + "skytech_rtx_5070_qualified": false, + "signed_release_transition_qualified": false, + "release_ready": false, + "publication_authority": false +} diff --git a/packaging/arch/phishell/PKGBUILD b/packaging/arch/phishell/PKGBUILD index 54c9a58e..aa127976 100644 --- a/packaging/arch/phishell/PKGBUILD +++ b/packaging/arch/phishell/PKGBUILD @@ -1,6 +1,6 @@ pkgname=phishell pkgver=0.16.0 -pkgrel=2 +pkgrel=3 pkgdesc='PhiShell browser interface and local observation transport' arch=('any') url='https://github.com/MichaelWave369/PhiOS' @@ -29,6 +29,7 @@ package() { install -Dm755 packaging/linux/session/phios-open-shell "$pkgdir/usr/bin/phios-open-shell" install -Dm755 packaging/linux/session/phios-lock "$pkgdir/usr/bin/phios-lock" install -Dm755 packaging/linux/session/phios-session-ready "$pkgdir/usr/lib/phishell/session-ready" + install -Dm644 packaging/linux/session/virtualbox-compat.sh "$pkgdir/usr/lib/phishell/virtualbox-compat.sh" install -Dm644 packaging/linux/session/phios.desktop "$pkgdir/usr/share/wayland-sessions/phios.desktop" for unit in packaging/linux/session/*.service packaging/linux/session/*.target; do install -Dm644 "$unit" "$pkgdir/usr/lib/systemd/user/${unit##*/}" diff --git a/packaging/linux/session/phios-session b/packaging/linux/session/phios-session index 7e2964d2..6efa424e 100755 --- a/packaging/linux/session/phios-session +++ b/packaging/linux/session/phios-session @@ -9,6 +9,8 @@ export XDG_CURRENT_DESKTOP=Wayfire export XDG_SESSION_DESKTOP=phios export XDG_SESSION_TYPE=wayland export WLR_RENDERER_ALLOW_SOFTWARE=1 +source /usr/lib/phishell/virtualbox-compat.sh +phios_virtualbox_cursor_compat export PHIOS_STATE_ROOT="$HOME/.local/state/phios" export PHIOS_CURIOSITY_ROOT="$PHIOS_STATE_ROOT/curiosity" mkdir -p "$PHIOS_STATE_ROOT" diff --git a/packaging/linux/session/phios-session-ready b/packaging/linux/session/phios-session-ready index eebd07d0..68e571da 100755 --- a/packaging/linux/session/phios-session-ready +++ b/packaging/linux/session/phios-session-ready @@ -1,5 +1,20 @@ #!/usr/bin/env bash set -euo pipefail -systemctl --user import-environment WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP -dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP +if [[ -z ${WAYLAND_DISPLAY:-} || -z ${XDG_RUNTIME_DIR:-} ]]; then + echo 'PhiOS session services require the compositor Wayland environment.' >&2 + exit 1 +fi +wayland_socket=$WAYLAND_DISPLAY +[[ $wayland_socket == /* ]] || wayland_socket="$XDG_RUNTIME_DIR/$wayland_socket" +if [[ ! -S $wayland_socket ]]; then + echo 'PhiOS session services require an existing Wayland socket.' >&2 + exit 1 +fi +# Empty DISPLAY clears a previous Xwayland session's value in both managers. +export DISPLAY="${DISPLAY:-}" +systemctl --user import-environment WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP XDG_RUNTIME_DIR +dbus-update-activation-environment --systemd WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP XDG_RUNTIME_DIR +# start alone preserves active processes bound to a previous Wayland socket. +# Stop/start propagates through the existing PartOf session dependencies. +systemctl --user stop phios-session.target systemctl --user start phios-session.target diff --git a/packaging/linux/session/virtualbox-compat.sh b/packaging/linux/session/virtualbox-compat.sh new file mode 100644 index 00000000..eb9e93e8 --- /dev/null +++ b/packaging/linux/session/virtualbox-compat.sh @@ -0,0 +1,18 @@ +# Sourced by phios-session before Wayfire starts. No real-hardware default. +phios_virtualbox_cursor_compat() { + local virtualization device vendor product class + virtualization=$(systemd-detect-virt --vm 2>/dev/null) || return 0 + [[ $virtualization == oracle ]] || return 0 + # VMSVGA shares VMware's PCI ID; that ID alone must not select this fix. + for device in "${1:-/sys/bus/pci/devices}"/*; do + [[ -r "$device/vendor" && -r "$device/device" && -r "$device/class" ]] || continue + read -r vendor < "$device/vendor" || continue + read -r product < "$device/device" || continue + read -r class < "$device/class" || continue + if [[ $vendor == 0x15ad && $product == 0x0405 && $class == 0x03???? ]]; then + export WLR_NO_HARDWARE_CURSORS=1 + return 0 + fi + done + return 0 +} diff --git a/packaging/linux/tests/desktop_probe.py b/packaging/linux/tests/desktop_probe.py index fe6bb8bb..a3dda89a 100644 --- a/packaging/linux/tests/desktop_probe.py +++ b/packaging/linux/tests/desktop_probe.py @@ -3,6 +3,8 @@ import json import os +import shlex +import socket import struct import subprocess import tempfile @@ -20,6 +22,88 @@ def restricted_dhcp_lease(network: dict) -> bool: and options.count('dhcp_server_identifier = 192.0.2.2') == 1) +def session_display_environment(wire: str) -> dict: + """Read only display keys from systemctl's shell-quoted environment output.""" + observed = {} + keys = {'WAYLAND_DISPLAY', 'XDG_RUNTIME_DIR', 'XDG_CURRENT_DESKTOP', 'DISPLAY'} + for line in wire.splitlines(): + name = line.split('=', 1)[0] + if name not in keys: + continue + fields = shlex.split(line) + if len(fields) != 1 or '=' not in fields[0] or name in observed: + raise ValueError('ambiguous manager display environment') + observed[name] = fields[0].split('=', 1)[1] + if any(not observed.get(key) for key in keys - {'DISPLAY'}): + raise ValueError('missing manager compositor environment') + return observed + + +def session_rebind(source: str) -> dict: + """Exercise the packaged ready hook against already-running real services.""" + assert os.getuid() == 1000 and os.geteuid() == 1000 + assert Path('/usr/share/phios/source-commit').read_text().strip() == source + assert Path('/usr/lib/phishell/virtualbox-compat.sh').is_file() + args = ['systemctl', '--user'] + units = ['phios-browser.service', 'phios-waybar.service'] + + def service_pids() -> dict: + return {unit: int(subprocess.check_output(args + ['show', unit, '--property=MainPID', '--value'], text=True)) + for unit in units} + + def environment() -> dict: + return session_display_environment(subprocess.check_output(args + ['show-environment'], text=True)) + + def running(pids: dict) -> bool: + try: + return all(pids[unit] > 0 and Path(f'/proc/{pids[unit]}/comm').read_text().strip() == name + and subprocess.run(args + ['is-active', '--quiet', unit]).returncode == 0 + for unit, name in zip(units, ['chromium', 'waybar'])) + except FileNotFoundError: + return False + + for _ in range(90): + previous = service_pids() + if running(previous): + current_environment = environment() + break + time.sleep(1) + else: + states = {unit: subprocess.check_output(args + ['show', unit, '--property=ActiveState', '--value'], text=True).strip() + for unit in units} + raise RuntimeError('no supervised desktop processes available for rebinding: ' + json.dumps({'pids': previous, 'states': states})) + display = current_environment['WAYLAND_DISPLAY'] + runtime = current_environment['XDG_RUNTIME_DIR'] + path = Path(display) if display.startswith('/') else Path(runtime) / display + assert path.is_socket() + with socket.socket(socket.AF_UNIX) as channel: + channel.settimeout(5) + channel.connect(str(path)) + # The compositor stays running; the manager intentionally holds an obsolete + # display. The existing processes must be replaced, not accepted as active. + subprocess.run(args + ['set-environment', 'WAYLAND_DISPLAY=phios-stale-display', 'DISPLAY=:999'], check=True) + child_env = {**os.environ, 'WAYLAND_DISPLAY': display, 'XDG_RUNTIME_DIR': runtime, + 'XDG_CURRENT_DESKTOP': current_environment['XDG_CURRENT_DESKTOP'], 'DISPLAY': ''} + subprocess.run(['/usr/lib/phishell/session-ready'], env=child_env, check=True, timeout=60) + for _ in range(90): + current = service_pids() + if all(current[unit] != previous[unit] for unit in units) and running(current): + imported = environment() + if (imported['WAYLAND_DISPLAY'] == display and imported['XDG_RUNTIME_DIR'] == runtime + and imported['XDG_CURRENT_DESKTOP'] == current_environment['XDG_CURRENT_DESKTOP'] + and imported.get('DISPLAY') == ''): + break + time.sleep(1) + else: + raise RuntimeError('active desktop services did not rebind to the compositor environment') + observed = {'source_commit': source, 'uid': os.getuid(), 'active_services_restarted': True, + 'stale_manager_environment_replaced': True, 'replacement_processes_after_compositor_environment_import': True, + 'stale_xwayland_display_cleared': True, 'services': units, + 'virtualbox_qualified': False, 'release_ready': False} + print('PHIOS_SESSION_REBIND_OK:' + json.dumps(observed), flush=True) + return observed + + def desktop_services(source: str, *, wired: bool = False) -> dict: assert os.getuid() == 1000 and os.geteuid() == 1000 assert Path('/usr/share/phios/source-commit').read_text().strip() == source diff --git a/packaging/linux/tests/qemu_preview.py b/packaging/linux/tests/qemu_preview.py index 22db233e..ebdb3f0a 100644 --- a/packaging/linux/tests/qemu_preview.py +++ b/packaging/linux/tests/qemu_preview.py @@ -180,9 +180,12 @@ def program(value: str) -> None: time.sleep(2) text = '' desktop = Path(__file__).with_name('desktop_probe.py').read_text().replace('from __future__ import annotations\n', '') - program(f'SOURCE={source!r}\nSTAGE="first"\n' + desktop + f'\ndesktop_services({source!r}, wired=True)\n' + PROBE) + program(f'SOURCE={source!r}\nSTAGE="first"\n' + desktop + f'\nsession_rebind({source!r})\ndesktop_services({source!r}, wired=True)\n' + PROBE) first = json.loads(wait(r'PHIOS_PREVIEW_OK:(\{[^\r\n]+\})')[1]) assert first['source_commit'] == source and first['stage'] == 'first' + rebind = json.loads(wait(r'PHIOS_SESSION_REBIND_OK:(\{[^\r\n]+\})')[1]) + rebind.update({'boot_id': first['boot_id']}) + receipt.setdefault('session_rebind_boots', []).append(rebind) desktop_result = json.loads(wait(r'PHIOS_DESKTOP_SERVICES_OK:(\{[^\r\n]+\})')[1]) desktop_result.update({'boot_id': first['boot_id'], 'stage': 'first'}) receipt.setdefault('desktop_service_boots', []).append(desktop_result) diff --git a/tests/test_os_desktop_probe_v01.py b/tests/test_os_desktop_probe_v01.py index 7e5f572a..3236594f 100644 --- a/tests/test_os_desktop_probe_v01.py +++ b/tests/test_os_desktop_probe_v01.py @@ -46,3 +46,28 @@ def test_static_ambiguous_or_forwarding_configuration_never_qualifies(change): else: network['DHCP4.OPTION'] = [] assert not probe.restricted_dhcp_lease(network) + + +def test_manager_display_observation_parses_quoted_values_and_drops_unrelated_keys(): + wire = "WAYLAND_DISPLAY=wayland-1\nXDG_RUNTIME_DIR='/run/user/1000'\nXDG_CURRENT_DESKTOP=Wayfire\nDISPLAY=\nPRIVATE_UNRELATED_VALUE=discarded\n" + assert probe.session_display_environment(wire) == { + 'WAYLAND_DISPLAY': 'wayland-1', 'XDG_RUNTIME_DIR': '/run/user/1000', + 'XDG_CURRENT_DESKTOP': 'Wayfire', 'DISPLAY': '', + } + + +@pytest.mark.parametrize('change', ['absent_display', 'absent_runtime', 'empty_runtime', 'duplicate_display', 'split_value']) +def test_incomplete_or_ambiguous_manager_display_environment_never_qualifies(change): + wire = "WAYLAND_DISPLAY=wayland-1\nXDG_RUNTIME_DIR=/run/user/1000\nXDG_CURRENT_DESKTOP=Wayfire\nDISPLAY=\n" + if change == 'absent_display': + wire = wire.replace('WAYLAND_DISPLAY=wayland-1\n', '') + elif change == 'absent_runtime': + wire = wire.replace('XDG_RUNTIME_DIR=/run/user/1000\n', '') + elif change == 'empty_runtime': + wire = wire.replace('XDG_RUNTIME_DIR=/run/user/1000', 'XDG_RUNTIME_DIR=') + elif change == 'duplicate_display': + wire += 'WAYLAND_DISPLAY=wayland-2\n' + else: + wire = wire.replace('WAYLAND_DISPLAY=wayland-1', 'WAYLAND_DISPLAY=wayland-1 unexpected') + with pytest.raises(ValueError): + probe.session_display_environment(wire) diff --git a/tests/test_os_virtualbox_session_v01.py b/tests/test_os_virtualbox_session_v01.py new file mode 100644 index 00000000..b494ab41 --- /dev/null +++ b/tests/test_os_virtualbox_session_v01.py @@ -0,0 +1,182 @@ +from __future__ import annotations + +import json +import os +import stat +import subprocess +import tempfile +from pathlib import Path + +import pytest + +REPO = Path(__file__).resolve().parents[1] +SESSION = REPO / 'packaging/linux/session' + + +def command(path: Path, body: str) -> None: + path.write_text('#!/usr/bin/env python3\n' + body) + path.chmod(0o755) + + +@pytest.fixture +def commands(tmp_path: Path) -> tuple[dict[str, str], Path]: + binaries = tmp_path / 'bin' + binaries.mkdir() + events = tmp_path / 'events.jsonl' + for name in ['systemctl', 'dbus-update-activation-environment']: + command(binaries / name, '''import json, os, sys +from pathlib import Path +name = Path(sys.argv[0]).name +with open(os.environ['EVENTS'], 'a') as stream: + stream.write(json.dumps({'command': [name, *sys.argv[1:]], 'environment': { + key: os.environ.get(key) for key in ['WAYLAND_DISPLAY', 'DISPLAY', 'XDG_RUNTIME_DIR', 'XDG_CURRENT_DESKTOP']}}) + '\\n') +label = name + (':' + sys.argv[2] if name == 'systemctl' else '') +sys.exit(19 if os.environ.get('FAIL_COMMAND') == label else 0) +''') + command(binaries / 'systemd-detect-virt', '''import os, sys +assert sys.argv[1:] == ['--vm'] +print(os.environ['VIRTUALIZATION']) +sys.exit(int(os.environ.get('VIRT_STATUS', '0'))) +''') + env = {**os.environ, 'PATH': str(binaries) + os.pathsep + os.environ['PATH'], 'EVENTS': str(events)} + env.pop('WLR_NO_HARDWARE_CURSORS', None) + return env, events + + +def pci_device(root: Path, *, vendor: str = '0x15ad', product: str = '0x0405', + display_class: str = '0x030000', slot: str = '0000:00:02.0') -> Path: + device = root / slot + device.mkdir(parents=True) + for name, value in [('vendor', vendor), ('device', product), ('class', display_class)]: + (device / name).write_text(value + '\n') + return device + + +def compatibility(env: dict[str, str], root: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run(['bash', '-c', + 'set -euo pipefail; source "$1"; phios_virtualbox_cursor_compat "$2"; ' + 'printf "%s" "${WLR_NO_HARDWARE_CURSORS-unset}"', + 'compat-test', str(SESSION / 'virtualbox-compat.sh'), str(root)], + env=env, capture_output=True, text=True, timeout=10) + + +def test_only_detected_virtualbox_with_vmsvga_selects_software_cursor(commands, tmp_path): + env, _ = commands + pci_device(tmp_path / 'pci', vendor='0x8086', product='0x1234', slot='0000:00:01.0') + pci_device(tmp_path / 'pci') + result = compatibility({**env, 'VIRTUALIZATION': 'oracle'}, tmp_path / 'pci') + assert result.returncode == 0 and result.stdout == '1' + + +@pytest.mark.parametrize('hypervisor', ['none', 'kvm', 'qemu', 'vmware', 'microsoft', 'docker', '']) +def test_vmsvga_pci_identity_alone_never_enables_virtualbox_fix(commands, tmp_path, hypervisor): + env, _ = commands + pci_device(tmp_path / 'pci') + result = compatibility({**env, 'VIRTUALIZATION': hypervisor}, tmp_path / 'pci') + assert result.returncode == 0 and result.stdout == 'unset' + + +@pytest.mark.parametrize('device', ['vboxsvga', 'nvidia', 'wrong_class', 'missing_id', 'empty', 'unavailable']) +def test_unmatched_or_incomplete_display_observation_does_not_change_cursor(commands, tmp_path, device): + env, _ = commands + root = tmp_path / 'pci' + if device == 'vboxsvga': + pci_device(root, vendor='0x80ee', product='0xbeef') + elif device == 'nvidia': + pci_device(root, vendor='0x10de', product='0x2f04') + elif device == 'wrong_class': + pci_device(root, display_class='0x020000') + elif device == 'missing_id': + pci_device(root).joinpath('device').unlink() + elif device == 'empty': + pci_device(root).joinpath('vendor').write_text('') + result = compatibility({**env, 'VIRTUALIZATION': 'oracle'}, root) + assert result.returncode == 0 and result.stdout == 'unset' + + +def test_detection_failure_is_nonfatal_and_does_not_select_a_fix(commands, tmp_path): + env, _ = commands + pci_device(tmp_path / 'pci') + result = compatibility({**env, 'VIRTUALIZATION': 'oracle', 'VIRT_STATUS': '1'}, tmp_path / 'pci') + assert result.returncode == 0 and result.stdout == 'unset' + + +def test_nonvirtualbox_operator_cursor_environment_is_preserved(commands, tmp_path): + env, _ = commands + result = compatibility({**env, 'VIRTUALIZATION': 'none', 'WLR_NO_HARDWARE_CURSORS': '1'}, tmp_path / 'pci') + assert result.returncode == 0 and result.stdout == '1' + + +@pytest.fixture +def wayland(): + with tempfile.TemporaryDirectory(prefix='phios-session-test-') as directory: + runtime = Path(directory) + # This shell test checks file type; the QEMU probe connects to the real + # compositor. A socket inode needs no listener/network permission here. + os.mknod(runtime / 'wayland-1', stat.S_IFSOCK | 0o600) + yield runtime + + +def ready(env: dict[str, str]) -> subprocess.CompletedProcess[str]: + return subprocess.run(['bash', str(SESSION / 'phios-session-ready')], env=env, + capture_output=True, text=True, timeout=10) + + +def recorded(events: Path) -> list[dict]: + return [json.loads(line) for line in events.read_text().splitlines()] if events.exists() else [] + + +@pytest.mark.parametrize('absolute_display', [False, True]) +@pytest.mark.parametrize('xwayland_display', ['', ':1']) +def test_new_socket_environment_is_imported_before_active_services_are_restarted( + commands, wayland, absolute_display, xwayland_display, +): + env, events = commands + env.update({'XDG_RUNTIME_DIR': str(wayland), 'XDG_CURRENT_DESKTOP': 'Wayfire', + 'WAYLAND_DISPLAY': str(wayland / 'wayland-1') if absolute_display else 'wayland-1'}) + env.pop('DISPLAY', None) + if xwayland_display: + env['DISPLAY'] = xwayland_display + result = ready(env) + assert result.returncode == 0, result.stderr + rows = recorded(events) + assert [row['command'] for row in rows] == [ + ['systemctl', '--user', 'import-environment', 'WAYLAND_DISPLAY', 'DISPLAY', + 'XDG_CURRENT_DESKTOP', 'XDG_RUNTIME_DIR'], + ['dbus-update-activation-environment', '--systemd', 'WAYLAND_DISPLAY', 'DISPLAY', + 'XDG_CURRENT_DESKTOP', 'XDG_RUNTIME_DIR'], + ['systemctl', '--user', 'stop', 'phios-session.target'], + ['systemctl', '--user', 'start', 'phios-session.target'], + ] + assert all(row['environment'] == {'WAYLAND_DISPLAY': env['WAYLAND_DISPLAY'], + 'DISPLAY': xwayland_display, 'XDG_RUNTIME_DIR': str(wayland), 'XDG_CURRENT_DESKTOP': 'Wayfire'} + for row in rows) + + +@pytest.mark.parametrize('case', ['no_display', 'no_runtime', 'no_socket', 'regular_file']) +def test_no_services_or_activation_environment_change_without_wayland_socket(commands, wayland, case): + env, events = commands + env.update({'WAYLAND_DISPLAY': 'wayland-1', 'XDG_RUNTIME_DIR': str(wayland), 'XDG_CURRENT_DESKTOP': 'Wayfire'}) + if case == 'no_display': + env.pop('WAYLAND_DISPLAY') + elif case == 'no_runtime': + env.pop('XDG_RUNTIME_DIR') + else: + env['WAYLAND_DISPLAY'] = 'absent' + if case == 'regular_file': + (wayland / 'absent').write_text('not a Wayland socket') + result = ready(env) + assert result.returncode != 0 and 'require' in result.stderr + assert recorded(events) == [] + + +@pytest.mark.parametrize(('failure', 'calls'), [ + ('systemctl:import-environment', 1), ('dbus-update-activation-environment', 2), + ('systemctl:stop', 3), ('systemctl:start', 4), +]) +def test_import_or_stop_failure_cannot_start_services_and_start_failure_is_reported(commands, wayland, failure, calls): + env, events = commands + result = ready({**env, 'WAYLAND_DISPLAY': 'wayland-1', 'XDG_RUNTIME_DIR': str(wayland), + 'XDG_CURRENT_DESKTOP': 'Wayfire', 'FAIL_COMMAND': failure}) + assert result.returncode == 19 + assert len(recorded(events)) == calls