feat(vm): configure guest integration and VirGL defaults
Some checks are pending
ci / test (push) Waiting to run
Some checks are pending
ci / test (push) Waiting to run
This commit is contained in:
parent
77cb0b88e2
commit
e98d4ed38e
12 changed files with 382 additions and 12 deletions
|
|
@ -5,6 +5,19 @@ this file is the curated, human-readable summary.
|
|||
|
||||
## Unreleased — Fast defaults with user-controlled source builds
|
||||
|
||||
- **Virtual machine guest integration (2026-10-01).** The installer now
|
||||
detects QEMU/KVM, VMware and VirtualBox, selects matching guest packages
|
||||
and Mesa video targets, and enables their applicable services. Mango gains
|
||||
`wlr-randr`, a corrected low-resolution check, a preferred-mode change
|
||||
watcher and the session agents for SPICE/VirtualBox channels. The
|
||||
interactive QEMU launcher selects VirGL when the host can run it and
|
||||
provides a guest-agent port. The visible playground was restarted with
|
||||
VirGL (`+virgl`) and displayed the desktop. GTK window zoom works; native
|
||||
guest resolution change on GTK resize and VMware/VirtualBox sessions remain
|
||||
unverified. A concurrent assistant handshake test now uses the same
|
||||
personal-storage environment lock as the state-writing tests, eliminating a
|
||||
full-suite race found during verification. See `docs/VIRTUAL-MACHINES.md`.
|
||||
|
||||
- **Nix commands available after installation (2026-10-01).** `sys install
|
||||
cmatrix --legacy --nix` now installs into a persistent shared Nix profile
|
||||
instead of only realising a temporary shell. Phoebus adds both the shared
|
||||
|
|
|
|||
|
|
@ -74,7 +74,11 @@ DISK=/tmp/phoebus/target.qcow2 OVMF_CODE=... OVMF_VARS=... \
|
|||
python3 installer/tests/vm/serial-driver.py boot
|
||||
```
|
||||
|
||||
`installer/tests/vm/run-vm.sh` launches an interactive VM instead.
|
||||
`installer/tests/vm/run-vm.sh` launches an interactive VM instead. It selects
|
||||
VirGL automatically when a writable host render node is available; use
|
||||
`--graphics 2d` for compatibility or `--graphics gl` to require acceleration.
|
||||
Guest package selection and the limits of window resize are described in
|
||||
`docs/VIRTUAL-MACHINES.md`.
|
||||
|
||||
### Debian-Live appliance harness
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,28 @@
|
|||
Rolling note between work sessions. **Update this file before you finish**, then
|
||||
commit it. It should be short and current; use `git log` for detail.
|
||||
|
||||
- **VM guest defaults (2026-10-01):** The visible playground was gracefully
|
||||
restarted on its existing disposable qcow2 with `virtio-vga-gl` and GTK GL;
|
||||
LUKS, login and Mango + DMS succeeded, and the guest reported `+virgl`.
|
||||
The window remains 1400×900. The installer now probes QEMU/KVM, VMware and
|
||||
VirtualBox via `systemd-detect-virt` plus DMI, selects corresponding guest
|
||||
packages and Mesa video targets (`virgl` or `vmware`), and enables the
|
||||
relevant units. Gentoo's QEMU agent starts by udev when its port appears,
|
||||
so it is not enabled as a static unit. Mango installs `wlr-randr`, fixes its
|
||||
low-resolution check, watches changed preferred modes, and starts available
|
||||
SPICE/VirtualBox session agents. The disposable QEMU launcher selects VirGL
|
||||
when the host has a render node and exposes a QEMU guest-agent port.
|
||||
Portage dependency previews resolved all three package stacks. The current
|
||||
QEMU GTK window zooms on resize without changing the guest preferred mode;
|
||||
VMware/VirtualBox runtime behavior, SPICE window resize and a fresh
|
||||
installed ISO are unverified. Rust format, warning-free Clippy, workspace
|
||||
tests, release and static builds, VM safety tests, and ShellCheck pass.
|
||||
`make check` initially exposed a concurrent assistant bridge test writing
|
||||
into another test's personal-storage fixture; the handshake test now takes
|
||||
the same environment lock and uses its own fixture, and `make check` passes.
|
||||
`make doctor` still fails only the host free-space gate (11 GiB versus the
|
||||
requested 20 GiB). See `docs/VIRTUAL-MACHINES.md`.
|
||||
|
||||
- **Nix executable integration (2026-10-01):** `sys install --nix` now uses a
|
||||
persistent `/nix/var/nix/profiles/profile`; `nix prepare` still only
|
||||
realises packages. New Nix bootstrap writes `/etc/profile.d/nix.sh` with
|
||||
|
|
|
|||
|
|
@ -48,6 +48,15 @@ disposable VM; `serial-driver.py recovery` now automates the same check.
|
|||
|
||||
## Matrix
|
||||
|
||||
Virtual-machine integration: QEMU/KVM, VMware and VirtualBox detection,
|
||||
hypervisor-specific guest packages, Mesa video targets, system services and
|
||||
Mango display helpers are implemented and unit-tested. The current visible
|
||||
QEMU VM booted with `virtio-vga-gl`, logged in, and reported `+virgl`; the
|
||||
`wlr-randr` package was installed and inspected there. GTK scales the guest
|
||||
view on host window resize, but guest resolution did not follow that resize.
|
||||
VMware and VirtualBox integration is Portage-previewed but **not VM verified**.
|
||||
See `docs/VIRTUAL-MACHINES.md`.
|
||||
|
||||
| Area | Implemented | Unit tested | VM verified | Hardware verified |
|
||||
|------|-------------|-------------|-------------|-------------------|
|
||||
| Config (TOML + legacy), validation | yes | yes | yes | n/a |
|
||||
|
|
|
|||
43
docs/VIRTUAL-MACHINES.md
Normal file
43
docs/VIRTUAL-MACHINES.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Virtual machine guests
|
||||
|
||||
Phoebus detects the installer environment with `systemd-detect-virt --vm` and
|
||||
DMI vendor/product information. A Mango desktop install selects only the
|
||||
matching guest tools. The distribution kernel and Mesa remain the graphics
|
||||
foundation; the hypervisor must expose its accelerated adapter and the host
|
||||
must provide acceleration. Guest software cannot create 3D acceleration when
|
||||
the host disables it.
|
||||
|
||||
| Host | Phoebus install selection | Host graphics setting | Resize path |
|
||||
|---|---|---|---|
|
||||
| QEMU/KVM | `qemu-guest-agent`, `spice-vdagent`, Mesa `virgl`, `wlr-randr` | VirtIO GPU with VirGL and a GL-capable display; the Phoebus `run-vm.sh` chooses `virtio-vga-gl` automatically when the host has a usable render node | GTK scales the visible guest image to the window. For guest resolution changes, provide a SPICE vdagent channel and a client that sends display configuration (for example virt-viewer). |
|
||||
| VMware | `open-vm-tools` with `resolutionkms`, Mesa `vmware`, `wlr-randr` | Enable the VMware accelerated graphics adapter in VM settings | `vmtoolsd` plus the virtual DRM driver's preferred-mode events; Phoebus applies a newly advertised preferred mode in Mango. |
|
||||
| VirtualBox | Guest Additions with `gui`, Mesa `vmware` for the VMSVGA adapter, `wlr-randr` | Select VMSVGA and enable 3D acceleration if the host supports it | Guest Additions service and `VBoxClient-all` in the Mango session; Phoebus also applies a newly advertised preferred mode. |
|
||||
|
||||
The display watcher acts only when the hypervisor advertises a *new* preferred
|
||||
mode. A manual choice remains in place if the preferred mode did not change.
|
||||
If DMS has written an output configuration, Phoebus leaves it alone. The
|
||||
existing low-VGA boot promotion now checks the `wlr-randr` output correctly.
|
||||
|
||||
`run-vm.sh --graphics auto` is the default for the disposable interactive
|
||||
QEMU launcher. `--graphics gl` requires VirGL; `--graphics 2d` is an explicit
|
||||
compatibility choice. The launcher uses `virtio-vga` variants so the UEFI and
|
||||
LUKS prompt remain visible. It also provides a QEMU guest-agent virtio port;
|
||||
Gentoo's udev rule starts the otherwise static guest-agent unit when that port
|
||||
appears.
|
||||
|
||||
## Verification boundary
|
||||
|
||||
The visible QEMU playground booted and reached Mango + DarkMaterialShell with
|
||||
`virtio-vga-gl`; the guest kernel reported `+virgl`. In this VM, GTK window
|
||||
resizing scaled the guest image, but did not change the guest's advertised
|
||||
preferred mode. The QEMU resize watcher therefore cannot claim guest
|
||||
resolution changes through this GTK setup. The new `wlr-randr` package was
|
||||
installed and its output inspected in this disposable VM. Portage dependency
|
||||
previews resolved the QEMU, VMware and VirtualBox package atoms. VMware and
|
||||
VirtualBox guest sessions, 3D rendering and resize events still require tests
|
||||
in those hypervisors before they are called VM verified.
|
||||
|
||||
The guest setup follows [QEMU's VirtIO GPU documentation](https://www.qemu.org/docs/master/system/devices/virtio/virtio-gpu.html),
|
||||
[SPICE's guest agent description](https://www.spice-space.org/spice-user-manual.html),
|
||||
[Oracle's VirtualBox Guest Additions manual](https://download.virtualbox.org/virtualbox/7.2.2/UserManual.pdf),
|
||||
and the [Gentoo guest package guidance](https://wiki.gentoo.org/wiki/Virtual_machines).
|
||||
|
|
@ -43,6 +43,48 @@ impl GpuVendor {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum VirtualMachine {
|
||||
#[default]
|
||||
None,
|
||||
Qemu,
|
||||
Vmware,
|
||||
Virtualbox,
|
||||
Other,
|
||||
}
|
||||
|
||||
impl VirtualMachine {
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::None => "physical",
|
||||
Self::Qemu => "QEMU/KVM",
|
||||
Self::Vmware => "VMware",
|
||||
Self::Virtualbox => "VirtualBox",
|
||||
Self::Other => "other virtual machine",
|
||||
}
|
||||
}
|
||||
|
||||
/// Prefer the hypervisor's reported identity, with DMI as a fallback.
|
||||
pub fn detect(virt: &str, vendor: &str, product: &str) -> Self {
|
||||
let identity = format!("{virt} {vendor} {product}").to_ascii_lowercase();
|
||||
if identity.contains("virtualbox") || identity.contains("innotek") || virt == "oracle" {
|
||||
Self::Virtualbox
|
||||
} else if identity.contains("vmware") {
|
||||
Self::Vmware
|
||||
} else if ["qemu", "kvm", "bochs", "rhev", "ovirt"]
|
||||
.iter()
|
||||
.any(|name| identity.contains(name))
|
||||
{
|
||||
Self::Qemu
|
||||
} else if !virt.is_empty() && virt != "none" {
|
||||
Self::Other
|
||||
} else {
|
||||
Self::None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CpuInfo {
|
||||
pub vendor: String,
|
||||
|
|
@ -100,6 +142,8 @@ pub struct NetworkDevice {
|
|||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct HardwareReport {
|
||||
pub firmware: Option<FirmwareMode>,
|
||||
#[serde(default)]
|
||||
pub virtual_machine: VirtualMachine,
|
||||
pub cpu: CpuInfo,
|
||||
pub memory_mib: u64,
|
||||
pub gpus: Vec<GpuInfo>,
|
||||
|
|
@ -157,6 +201,10 @@ impl HardwareReport {
|
|||
pub fn render(&self) -> String {
|
||||
let mut out = String::new();
|
||||
out.push_str(&format!("Firmware: {}\n", self.firmware_str()));
|
||||
out.push_str(&format!(
|
||||
"Environment: {}\n",
|
||||
self.virtual_machine.as_str()
|
||||
));
|
||||
out.push_str(&format!("CPU: {}\n", self.cpu.model));
|
||||
out.push_str(&format!(
|
||||
"CPU cores: {} threads / {} logical CPUs\n",
|
||||
|
|
@ -212,6 +260,30 @@ impl HardwareReport {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn identifies_supported_vm_families_without_confusing_physical_hosts() {
|
||||
assert_eq!(
|
||||
VirtualMachine::detect("kvm", "QEMU", "Standard PC"),
|
||||
VirtualMachine::Qemu
|
||||
);
|
||||
assert_eq!(
|
||||
VirtualMachine::detect("oracle", "innotek GmbH", "VirtualBox"),
|
||||
VirtualMachine::Virtualbox
|
||||
);
|
||||
assert_eq!(
|
||||
VirtualMachine::detect("vmware", "VMware, Inc.", "VMware Virtual Platform"),
|
||||
VirtualMachine::Vmware
|
||||
);
|
||||
assert_eq!(
|
||||
VirtualMachine::detect("none", "LENOVO", "ThinkPad"),
|
||||
VirtualMachine::None
|
||||
);
|
||||
assert_eq!(
|
||||
VirtualMachine::detect("xen", "Xen", "HVM domU"),
|
||||
VirtualMachine::Other
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn low_memory_recommends_safe() {
|
||||
let mut hw = HardwareReport {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
//! target unit-testable and keeps parity with the proven Bash output.
|
||||
|
||||
use crate::config::{DesktopProfile, InstallConfig};
|
||||
use crate::hardware::{CpuInfo, GpuVendor, HardwareReport};
|
||||
use crate::hardware::{CpuInfo, GpuVendor, HardwareReport, VirtualMachine};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Package sets
|
||||
|
|
@ -48,6 +48,31 @@ pub fn desktop_packages(profile: DesktopProfile) -> Vec<&'static str> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Install only the integration stack for the hypervisor running the installer.
|
||||
/// Kernel DRM drivers for these devices are supplied by the distribution kernel.
|
||||
pub fn vm_guest_packages(vm: VirtualMachine) -> &'static [&'static str] {
|
||||
match vm {
|
||||
VirtualMachine::Qemu => &[
|
||||
"app-emulation/qemu-guest-agent",
|
||||
"app-emulation/spice-vdagent",
|
||||
],
|
||||
VirtualMachine::Vmware => &["app-emulation/open-vm-tools"],
|
||||
VirtualMachine::Virtualbox => &["app-emulation/virtualbox-guest-additions"],
|
||||
VirtualMachine::None | VirtualMachine::Other => &[],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn vm_guest_service(vm: VirtualMachine) -> Option<&'static str> {
|
||||
match vm {
|
||||
// Gentoo's QEMU agent unit is static; its udev rule starts it when
|
||||
// org.qemu.guest_agent.0 appears. `systemctl enable` would fail.
|
||||
VirtualMachine::Qemu => None,
|
||||
VirtualMachine::Vmware => Some("vmtoolsd.service"),
|
||||
VirtualMachine::Virtualbox => Some("virtualbox-guest-additions.service"),
|
||||
VirtualMachine::None | VirtualMachine::Other => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The canonical desktop: Mango + DankMaterialShell, plus terminal and desktop portals.
|
||||
///
|
||||
/// Kitty is the terminal and stays the default; `st` is deliberately not
|
||||
|
|
@ -72,6 +97,8 @@ pub fn mango_desktop_packages() -> Vec<&'static str> {
|
|||
"gui-apps/wl-clipboard",
|
||||
"gui-apps/grim",
|
||||
"gui-apps/slurp",
|
||||
// Output management is used for VM/window resize and display shortcuts.
|
||||
"gui-apps/wlr-randr",
|
||||
"gui-libs/gtk-layer-shell",
|
||||
// XWayland & Terminal (Kitty stays; no st)
|
||||
"x11-base/xwayland",
|
||||
|
|
@ -806,6 +833,11 @@ pub fn video_cards(hardware: &HardwareReport) -> String {
|
|||
GpuVendor::Unknown => {}
|
||||
}
|
||||
}
|
||||
match hardware.virtual_machine {
|
||||
VirtualMachine::Qemu => push("virgl", &mut cards),
|
||||
VirtualMachine::Vmware | VirtualMachine::Virtualbox => push("vmware", &mut cards),
|
||||
VirtualMachine::None | VirtualMachine::Other => {}
|
||||
}
|
||||
if cards.is_empty() {
|
||||
cards.push("dummy".into());
|
||||
}
|
||||
|
|
@ -905,6 +937,7 @@ pub fn accept_keywords_mango() -> String {
|
|||
o.push_str("gui-apps/dankmaterialshell\n");
|
||||
o.push_str("gui-apps/danksearch\n");
|
||||
o.push_str("gui-apps/quickshell\n");
|
||||
o.push_str("gui-apps/wlr-randr\n");
|
||||
o.push_str("gui-libs/scenefx\n");
|
||||
o.push_str("media-gfx/swayimg\n");
|
||||
o.push_str("x11-misc/matugen\n");
|
||||
|
|
@ -1029,6 +1062,17 @@ pub fn package_use(config: &InstallConfig, hardware: &HardwareReport) -> String
|
|||
o.push_str("# Mango + DankMaterialShell desktop dependencies\n");
|
||||
o.push_str("dev-cpp/cpptrace unwind\n");
|
||||
o.push_str("sys-libs/zlib minizip\n");
|
||||
match hardware.virtual_machine {
|
||||
VirtualMachine::Virtualbox => {
|
||||
o.push_str("# VirtualBox graphical guest tools and Wayland resize helper\n");
|
||||
o.push_str("app-emulation/virtualbox-guest-additions gui\n");
|
||||
}
|
||||
VirtualMachine::Vmware => {
|
||||
o.push_str("# VMware KMS resolution integration\n");
|
||||
o.push_str("app-emulation/open-vm-tools resolutionkms X\n");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
// Seat management: libseat must speak to seatd (standalone server),
|
||||
// logind (systemd sessions) and its builtin fallback, so Mango gets
|
||||
// a seat on physical hardware, VMs, and under the greeter alike.
|
||||
|
|
@ -1345,7 +1389,8 @@ pub const PHOEBUS_MANGO_SESSION_SCRIPT: &str = r#"#!/bin/bash
|
|||
set -u
|
||||
|
||||
if [ -z "${XDG_RUNTIME_DIR:-}" ]; then
|
||||
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||
XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||
export XDG_RUNTIME_DIR
|
||||
fi
|
||||
if [ ! -d "$XDG_RUNTIME_DIR" ]; then
|
||||
echo "phoebus-session-mango: XDG_RUNTIME_DIR $XDG_RUNTIME_DIR is missing" >&2
|
||||
|
|
@ -1370,6 +1415,7 @@ export _JAVA_AWT_WM_NONREPARENTING=1
|
|||
# Include Nix profile commands in the graphical session, even when greetd
|
||||
# starts this script without a login shell. All child terminals inherit PATH.
|
||||
if [ -r /etc/profile.d/nix.sh ]; then
|
||||
# shellcheck source=/dev/null
|
||||
. /etc/profile.d/nix.sh
|
||||
fi
|
||||
|
||||
|
|
@ -1439,7 +1485,8 @@ while [ -z "$socket" ]; do
|
|||
for candidate in "$XDG_RUNTIME_DIR"/wayland-*; do
|
||||
if [ -S "$candidate" ]; then
|
||||
socket="$candidate"
|
||||
export WAYLAND_DISPLAY="$(basename "$candidate")"
|
||||
WAYLAND_DISPLAY="$(basename "$candidate")"
|
||||
export WAYLAND_DISPLAY
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
|
@ -1461,7 +1508,7 @@ done
|
|||
# to low VGA (<= 800x600), pick the best supported widescreen resolution.
|
||||
if command -v wlr-randr >/dev/null 2>&1; then
|
||||
for out in $(wlr-randr 2>/dev/null | awk '/^[A-Za-z0-9-]+ "/ {print $1}'); do
|
||||
if wlr-randr --output "$out" 2>/dev/null | grep -qE "current.*(640x480|800x600)"; then
|
||||
if wlr-randr --output "$out" 2>/dev/null | grep -qE '(640x480|800x600) px,.*\(.*current'; then
|
||||
for m in 1280x768 1440x900 1920x1080 1024x768; do
|
||||
if wlr-randr --output "$out" --mode "$m" 2>/dev/null; then
|
||||
break
|
||||
|
|
@ -1471,6 +1518,42 @@ if command -v wlr-randr >/dev/null 2>&1; then
|
|||
done
|
||||
fi
|
||||
|
||||
# Apply a changed host-advertised preferred mode. An intentional user mode
|
||||
# choice leaves the preferred list unchanged, so it is not overridden.
|
||||
vm_preferred_modes() {
|
||||
wlr-randr 2>/dev/null | awk '/^[^[:space:]]/ {out=$1} /\(preferred/ {print out, $1}'
|
||||
}
|
||||
vm_auto_resize() {
|
||||
previous="$(vm_preferred_modes)"
|
||||
while kill -0 "$MANGO_PID" 2>/dev/null; do
|
||||
sleep 2
|
||||
[ -s "$HOME/.config/mango/dms/outputs.conf" ] && continue
|
||||
modes="$(vm_preferred_modes)"
|
||||
[ -z "$modes" ] && continue
|
||||
if [ "$modes" != "$previous" ]; then
|
||||
while read -r output _; do
|
||||
[ -n "$output" ] && wlr-randr --output "$output" --preferred >/dev/null 2>&1 || true
|
||||
done <<< "$modes"
|
||||
previous="$modes"
|
||||
fi
|
||||
done
|
||||
}
|
||||
if command -v wlr-randr >/dev/null 2>&1 \
|
||||
&& command -v systemd-detect-virt >/dev/null 2>&1 \
|
||||
&& systemd-detect-virt --vm --quiet; then
|
||||
start_helper vm_auto_resize
|
||||
fi
|
||||
|
||||
# Mango does not run XDG autostart entries. Start the SPICE session agent only
|
||||
# when its host channel exists.
|
||||
if [ -e /dev/virtio-ports/com.redhat.spice.0 ] \
|
||||
&& command -v spice-vdagent >/dev/null 2>&1; then
|
||||
start_helper spice-vdagent
|
||||
fi
|
||||
if [ -e /dev/vboxguest ] && command -v VBoxClient-all >/dev/null 2>&1; then
|
||||
start_helper VBoxClient-all
|
||||
fi
|
||||
|
||||
# Export the graphical environment to the systemd user manager so user
|
||||
# services (dms.service, portals) can reach the compositor.
|
||||
if command -v dbus-update-activation-environment >/dev/null 2>&1; then
|
||||
|
|
@ -2524,6 +2607,35 @@ mod tests {
|
|||
use crate::config::{DesktopProfile, Encryption, InstallConfig};
|
||||
use crate::hardware::CpuInfo;
|
||||
|
||||
#[test]
|
||||
fn vm_guest_packages_are_specific_to_the_detected_hypervisor() {
|
||||
assert!(vm_guest_packages(VirtualMachine::None).is_empty());
|
||||
assert!(vm_guest_packages(VirtualMachine::Other).is_empty());
|
||||
assert!(vm_guest_packages(VirtualMachine::Qemu).contains(&"app-emulation/qemu-guest-agent"));
|
||||
assert_eq!(
|
||||
vm_guest_service(VirtualMachine::Vmware),
|
||||
Some("vmtoolsd.service")
|
||||
);
|
||||
assert_eq!(
|
||||
vm_guest_packages(VirtualMachine::Virtualbox),
|
||||
&["app-emulation/virtualbox-guest-additions"]
|
||||
);
|
||||
assert!(mango_desktop_packages().contains(&"gui-apps/wlr-randr"));
|
||||
assert!(accept_keywords_mango().contains("gui-apps/wlr-randr\n"));
|
||||
let mut hw = HardwareReport {
|
||||
virtual_machine: VirtualMachine::Qemu,
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(video_cards(&hw), "virgl");
|
||||
hw.virtual_machine = VirtualMachine::Vmware;
|
||||
assert_eq!(video_cards(&hw), "vmware");
|
||||
let mut config = InstallConfig::default();
|
||||
config.desktop.profile = DesktopProfile::Mango;
|
||||
assert!(package_use(&config, &hw).contains("app-emulation/open-vm-tools resolutionkms X"));
|
||||
hw.virtual_machine = VirtualMachine::Virtualbox;
|
||||
assert_eq!(video_cards(&hw), "vmware");
|
||||
assert!(package_use(&config, &hw).contains("app-emulation/virtualbox-guest-additions gui"));
|
||||
}
|
||||
#[test]
|
||||
fn base_packages_include_storage_tools() {
|
||||
let pkgs = base_packages();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use std::path::Path;
|
||||
|
||||
use phoebus_core::hardware::{HardwareReport, VirtualMachine};
|
||||
use phoebus_core::policy::{PackagePolicyEngine, PolicyContext};
|
||||
use phoebus_core::system as sysgen;
|
||||
use phoebus_core::{DesktopProfile, InstallConfig};
|
||||
|
|
@ -16,6 +17,7 @@ use crate::portage;
|
|||
pub fn install(
|
||||
exec: &Exec,
|
||||
config: &InstallConfig,
|
||||
hardware: &HardwareReport,
|
||||
engine: &PackagePolicyEngine,
|
||||
ctx: &PolicyContext,
|
||||
) -> Result<()> {
|
||||
|
|
@ -32,6 +34,11 @@ pub fn install(
|
|||
.into_iter()
|
||||
.map(str::to_string),
|
||||
);
|
||||
packages.extend(
|
||||
sysgen::vm_guest_packages(hardware.virtual_machine)
|
||||
.iter()
|
||||
.map(|atom| (*atom).to_string()),
|
||||
);
|
||||
if config.desktop.flatpak {
|
||||
packages.push("sys-apps/flatpak".to_string());
|
||||
}
|
||||
|
|
@ -188,7 +195,11 @@ fn configure_cups_local(target: &phoebus_core::TargetRoot) -> Result<()> {
|
|||
|
||||
/// Configure authenticated graphical login with greetd. The installed system
|
||||
/// always authenticates; only the live ISO uses automatic login.
|
||||
pub fn configure_login(exec: &Exec, config: &InstallConfig) -> Result<()> {
|
||||
pub fn configure_login(
|
||||
exec: &Exec,
|
||||
config: &InstallConfig,
|
||||
hardware: &HardwareReport,
|
||||
) -> Result<()> {
|
||||
if !config.desktop.profile.is_desktop() {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
@ -201,6 +212,37 @@ pub fn configure_login(exec: &Exec, config: &InstallConfig) -> Result<()> {
|
|||
)?;
|
||||
ensure_greeter_user(exec)?;
|
||||
let root = Path::new(&exec.root);
|
||||
if let Some(service) = sysgen::vm_guest_service(hardware.virtual_machine) {
|
||||
// The selected package must supply its documented systemd unit.
|
||||
portage::chroot(exec, root, "systemctl", &["enable", service]).map_err(|e| {
|
||||
ExecError::operation(
|
||||
"desktop",
|
||||
&format!("enable VM guest service {service}"),
|
||||
e.to_string(),
|
||||
)
|
||||
})?;
|
||||
exec.logger
|
||||
.info(format!("enabled VM guest integration: {service}"));
|
||||
}
|
||||
if hardware.virtual_machine == VirtualMachine::Qemu {
|
||||
let socket = target.resolve("usr/lib/systemd/system/spice-vdagentd.socket")?;
|
||||
if socket.exists() {
|
||||
portage::chroot(
|
||||
exec,
|
||||
root,
|
||||
"systemctl",
|
||||
&["enable", "spice-vdagentd.socket"],
|
||||
)?;
|
||||
}
|
||||
}
|
||||
if hardware.virtual_machine == VirtualMachine::Virtualbox {
|
||||
portage::chroot(
|
||||
exec,
|
||||
root,
|
||||
"usermod",
|
||||
&["-aG", "vboxguest", &config.user.username],
|
||||
)?;
|
||||
}
|
||||
for service in sysgen::desktop_login_services() {
|
||||
portage::chroot(exec, root, "systemctl", &["enable", service]).map_err(|e| {
|
||||
ExecError::operation(
|
||||
|
|
@ -605,7 +647,7 @@ mod tests {
|
|||
let mut cfg = InstallConfig::default();
|
||||
cfg.desktop.profile = DesktopProfile::Mango;
|
||||
write_session_script(&exec, &cfg).unwrap();
|
||||
configure_login(&exec, &cfg).unwrap();
|
||||
configure_login(&exec, &cfg, &HardwareReport::default()).unwrap();
|
||||
|
||||
assert!(exec.root.join("etc/greetd/config.toml").is_file());
|
||||
// The installer shortcut is live-medium only; an installed system must
|
||||
|
|
@ -678,7 +720,7 @@ mod tests {
|
|||
let exec = make_exec(runner);
|
||||
let mut cfg = InstallConfig::default();
|
||||
cfg.desktop.profile = DesktopProfile::None;
|
||||
configure_login(&exec, &cfg).unwrap();
|
||||
configure_login(&exec, &cfg, &HardwareReport::default()).unwrap();
|
||||
assert!(!exec.root.join("etc/greetd/config.toml").exists());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use std::path::Path;
|
|||
|
||||
use phoebus_core::disk::{Disk, DiskKind};
|
||||
use phoebus_core::hardware::{
|
||||
CpuInfo, FirmwareMode, GpuInfo, GpuVendor, HardwareReport, NetworkDevice,
|
||||
CpuInfo, FirmwareMode, GpuInfo, GpuVendor, HardwareReport, NetworkDevice, VirtualMachine,
|
||||
};
|
||||
|
||||
use crate::command::{CommandSpec, ProcessRunner};
|
||||
|
|
@ -163,6 +163,11 @@ fn lspci_filter(runner: &dyn ProcessRunner, pattern: &str) -> Vec<String> {
|
|||
|
||||
pub fn probe_hardware(runner: &dyn ProcessRunner) -> HardwareReport {
|
||||
let cpu = probe_cpu();
|
||||
let virtual_machine = VirtualMachine::detect(
|
||||
capture(runner, "systemd-detect-virt", &["--vm"]).trim(),
|
||||
&read_trim("/sys/class/dmi/id/sys_vendor").unwrap_or_default(),
|
||||
&read_trim("/sys/class/dmi/id/product_name").unwrap_or_default(),
|
||||
);
|
||||
let gpu_lines = lspci_filter(
|
||||
runner,
|
||||
"VGA compatible controller|3D controller|Display controller",
|
||||
|
|
@ -224,6 +229,7 @@ pub fn probe_hardware(runner: &dyn ProcessRunner) -> HardwareReport {
|
|||
|
||||
HardwareReport {
|
||||
firmware: Some(probe_firmware()),
|
||||
virtual_machine,
|
||||
cpu,
|
||||
memory_mib: probe_memory_mib(),
|
||||
gpus,
|
||||
|
|
|
|||
|
|
@ -902,6 +902,9 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_handshake_and_history() {
|
||||
let _env = env_lock();
|
||||
let personal = tempdir().unwrap();
|
||||
let _guard = EnvGuard::set("PHOEBUS_PERSONAL_DIR", personal.path().as_os_str());
|
||||
let temp = tempdir().unwrap();
|
||||
let root = temp.path();
|
||||
let exec = make_test_exec(root);
|
||||
|
|
|
|||
|
|
@ -842,9 +842,15 @@ impl Installer {
|
|||
}
|
||||
self.exec.mount_chroot()?;
|
||||
let result: Result<()> = (|| {
|
||||
desktop::install(&self.exec, &self.config, &self.engine, &self.policy_ctx)?;
|
||||
desktop::install(
|
||||
&self.exec,
|
||||
&self.config,
|
||||
&self.hardware,
|
||||
&self.engine,
|
||||
&self.policy_ctx,
|
||||
)?;
|
||||
desktop::write_session_script(&self.exec, &self.config)?;
|
||||
desktop::configure_login(&self.exec, &self.config)?;
|
||||
desktop::configure_login(&self.exec, &self.config, &self.hardware)?;
|
||||
desktop::configure_flatpak(&self.exec, &self.config)?;
|
||||
// Fast defaults, target-only: system-wide Flatpaks from Flathub.
|
||||
// The review UI already showed the delivery set (see
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ MEM="4096"
|
|||
CPUS="4"
|
||||
BOOT="d"
|
||||
DISPLAY_OPT="gtk"
|
||||
GRAPHICS="auto"
|
||||
EXTRA=()
|
||||
|
||||
usage() {
|
||||
|
|
@ -34,6 +35,7 @@ Options:
|
|||
--mem MiB RAM in MiB (default 4096)
|
||||
--cpus N vCPUs (default 4)
|
||||
--display OPT QEMU display (default gtk; use none for headless)
|
||||
--graphics MODE auto (default), gl, or 2d; GTK auto uses VirGL when available
|
||||
--disk-boot Boot from the scratch disk instead of the ISO
|
||||
--help Show this help
|
||||
|
||||
|
|
@ -50,6 +52,7 @@ while (($#)); do
|
|||
--mem) shift; MEM="${1:-}" ;;
|
||||
--cpus) shift; CPUS="${1:-}" ;;
|
||||
--display) shift; DISPLAY_OPT="${1:-}" ;;
|
||||
--graphics) shift; GRAPHICS="${1:-}" ;;
|
||||
--disk-boot) BOOT="c" ;;
|
||||
--help|-h) usage; exit 0 ;;
|
||||
*) echo "unknown option: $1" >&2; usage; exit 2 ;;
|
||||
|
|
@ -58,6 +61,8 @@ while (($#)); do
|
|||
done
|
||||
|
||||
[[ -n "$ISO" ]] || { echo "error: --iso is required" >&2; usage; exit 2; }
|
||||
[[ "$GRAPHICS" == auto || "$GRAPHICS" == gl || "$GRAPHICS" == 2d ]] || {
|
||||
echo "error: --graphics must be auto, gl, or 2d" >&2; exit 2; }
|
||||
[[ -r "$ISO" ]] || { echo "error: cannot read ISO: $ISO" >&2; exit 2; }
|
||||
command -v qemu-system-x86_64 >/dev/null 2>&1 || {
|
||||
echo "error: qemu-system-x86_64 not found" >&2; exit 1; }
|
||||
|
|
@ -90,6 +95,34 @@ if [[ ! -f "$DISK" ]]; then
|
|||
echo "creating scratch disk $DISK ($DISK_SIZE)"
|
||||
qemu-img create -f qcow2 "$DISK" "$DISK_SIZE" >/dev/null
|
||||
fi
|
||||
|
||||
VIDEO_DEVICE="virtio-vga"
|
||||
if [[ "$DISPLAY_OPT" == gtk* && "$GRAPHICS" != 2d ]]; then
|
||||
render_node=false
|
||||
for node in /dev/dri/renderD*; do
|
||||
if [[ -r "$node" && -w "$node" ]]; then render_node=true; break; fi
|
||||
done
|
||||
gl_probe=false
|
||||
if [[ "$render_node" == true ]] && command -v timeout >/dev/null 2>&1; then
|
||||
probe_rc=0
|
||||
timeout 2s qemu-system-x86_64 -machine q35 -nodefaults \
|
||||
-device virtio-vga-gl -display egl-headless,gl=on \
|
||||
-S -monitor none -serial none >/dev/null 2>&1 || probe_rc=$?
|
||||
if [[ "$probe_rc" == 0 || "$probe_rc" == 124 ]]; then gl_probe=true; fi
|
||||
fi
|
||||
if [[ "$render_node" == true && "$gl_probe" == true ]] \
|
||||
&& qemu-system-x86_64 -device help | grep 'name "virtio-vga-gl"' >/dev/null; then
|
||||
VIDEO_DEVICE="virtio-vga-gl"
|
||||
DISPLAY_OPT="${DISPLAY_OPT},gl=on,zoom-to-fit=on"
|
||||
elif [[ "$GRAPHICS" == gl ]]; then
|
||||
echo "error: VirGL requires a writable DRM render node and working host EGL/VirGL" >&2
|
||||
exit 1
|
||||
fi
|
||||
elif [[ "$GRAPHICS" == gl ]]; then
|
||||
echo "error: --graphics gl requires a GTK display" >&2
|
||||
exit 2
|
||||
fi
|
||||
echo "Graphics: $VIDEO_DEVICE ($DISPLAY_OPT)"
|
||||
if [[ ! -f "$VARS" ]]; then
|
||||
cp "$OVMF_VARS_SRC" "$VARS"
|
||||
fi
|
||||
|
|
@ -114,6 +147,8 @@ echo
|
|||
echo "Inside the VM run: /tmp/phoebus-installer --plan"
|
||||
echo "Remember: the scratch disk is disposable."
|
||||
|
||||
# QEMU option values deliberately contain comma-separated properties.
|
||||
# shellcheck disable=SC2054
|
||||
QEMU=(qemu-system-x86_64
|
||||
-machine q35
|
||||
"${ACCEL[@]}"
|
||||
|
|
@ -125,7 +160,10 @@ QEMU=(qemu-system-x86_64
|
|||
-drive if=pflash,format=raw,file="$VARS"
|
||||
-drive file="$DISK",if=virtio,format=qcow2
|
||||
-netdev user,id=n0 -device virtio-net-pci,netdev=n0
|
||||
-device virtio-vga
|
||||
-device "$VIDEO_DEVICE"
|
||||
-chardev socket,id=qga,path="$WORKDIR/qga.sock",server=on,wait=off
|
||||
-device virtio-serial-pci
|
||||
-device virtserialport,chardev=qga,name=org.qemu.guest_agent.0
|
||||
-boot "order=$BOOT"
|
||||
-cdrom "$ISO"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue