`harmony`'s `kvm` feature pulls in `libvirt`, which doesn't link on
aarch64-unknown-linux-gnu (no aarch64 `libvirt-dev` package on most
distros). The device-side workflow needs a binary that runs ON the
Pi and only does enrollment — no VM-rehearsal — but the example was
unconditionally enabling `kvm`, so the cross-compile failed at link
time with `undefined reference to virStoragePoolFree` etc.
Fixes by gating the rehearsal bits behind a new `vm-rehearsal`
Cargo feature (default-on for workstation builds, opt-out via
`--no-default-features` for device builds):
* `Cargo.toml`: harmony dep is now `default-features = false,
features = ["podman"]` (podman is needed unconditionally — the
operator CRD types depend on it). New `vm-rehearsal` feature
enables `harmony/kvm` on demand.
* `main.rs`: every libvirt-touching import, CLI flag
(`--launch-pi-vm`, `--vm-rehearsal`, `--vm-*`), CLI branch, and
helper function (`boot_*_vm`, `RehearsalImage`) is now
`#[cfg(feature = "vm-rehearsal")]`. With the feature off, none
of it is referenced and nothing tries to link libvirt.
* README: documents both build flavors with copy-paste commands.
Workstation build (unchanged):
cargo build --release -p example_fleet_device_enroll
Device-side build (the new path):
cargo build --release --target aarch64-unknown-linux-gnu \
-p example_fleet_device_enroll --no-default-features
36 lines
1.3 KiB
TOML
36 lines
1.3 KiB
TOML
[package]
|
|
name = "example_fleet_device_enroll"
|
|
version.workspace = true
|
|
edition = "2024"
|
|
license.workspace = true
|
|
|
|
[[bin]]
|
|
name = "fleet_device_enroll"
|
|
path = "src/main.rs"
|
|
|
|
[features]
|
|
default = ["vm-rehearsal"]
|
|
# `--launch-pi-vm` and `--vm-rehearsal` flags. Enables the `kvm`
|
|
# feature on `harmony`, which pulls in libvirt (`libvirt-dev`) and
|
|
# does NOT cross-compile for arm64 (no aarch64 libvirt static libs
|
|
# in most distros). Disable this feature when building the
|
|
# enrollment binary FOR the target device:
|
|
# cargo build --release --target aarch64-unknown-linux-gnu \
|
|
# -p example_fleet_device_enroll --no-default-features
|
|
# A device-side build leaves out the rehearsal code entirely; the
|
|
# binary is enrollment-only and links with no native dependencies.
|
|
vm-rehearsal = ["harmony/kvm"]
|
|
|
|
[dependencies]
|
|
# `podman` is required even on device-side builds (the operator CRD
|
|
# definitions in `harmony::modules::fleet::operator` depend on
|
|
# `podman` types via the reconciler-contracts shape). `kvm` is the
|
|
# only feature that pulls libvirt and stays opt-in via `vm-rehearsal`.
|
|
harmony = { path = "../../harmony", default-features = false, features = ["podman"] }
|
|
harmony_types = { path = "../../harmony_types" }
|
|
tokio.workspace = true
|
|
log.workspace = true
|
|
env_logger.workspace = true
|
|
anyhow.workspace = true
|
|
clap.workspace = true
|