Skip to content

Commit cc0d259

Browse files
committed
xtask: Add --skip-bind-storage to run-tmt
The `--bind-storage-ro` host container-storage passthrough relies on a libvirt-managed virtiofsd, which cannot run in some environments such as nested user namespaces or cloud/non-qemu setups. Plans that normally request bind-storage previously had no way to opt out short of editing plan metadata. Add a `--skip-bind-storage` flag (and matching `BOOTC_skip_bind_storage` env var) that forces those plans to run without the host container-storage mount. Default behavior is unchanged: bind-storage is still used wherever it is requested and supported. Plans that depend on a locally built upgrade image reaching the VM via bind-storage will be unable to perform the upgrade/switch step when this is set. Assisted-by: OpenCode (Claude Opus 4.5) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 18bf103 commit cc0d259

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

crates/xtask/src/tmt.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,22 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
456456

457457
let mut opts = Vec::new();
458458

459-
// If test wants bind storage and distro supports it, add --bind-storage-ro
460-
if try_bind_storage && supports_bind_storage_ro {
459+
// If test wants bind storage, the distro supports it, and it wasn't
460+
// explicitly disabled, add --bind-storage-ro
461+
let use_bind_storage =
462+
try_bind_storage && supports_bind_storage_ro && !args.skip_bind_storage;
463+
if use_bind_storage {
461464
opts.push(BCVK_OPT_BIND_STORAGE_RO.to_string());
462465

463466
// If upgrade image is provided, set it as an environment variable for tmt
464467
// (not bcvk, as bcvk doesn't support --env)
465468
if let Some(ref upgrade_img) = args.upgrade_image {
466469
tmt_env_vars.push(format!("{}={}", ENV_BOOTC_UPGRADE_IMAGE, upgrade_img));
467470
}
471+
} else if try_bind_storage && args.skip_bind_storage {
472+
println!(
473+
"Note: Test requests bind storage but --skip-bind-storage was set; running without host container-storage mount"
474+
);
468475
} else if try_bind_storage && !supports_bind_storage_ro {
469476
println!(
470477
"Note: Test wants bind storage but skipping on {} (missing systemd.extra-unit.* support)",

crates/xtask/src/xtask.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ fn out_of_sync_error(message: &str) -> Result<()> {
4545
anyhow::bail!("{}; run `just update-generated` to update it", message)
4646
}
4747

48+
/// Parse a `0`/`1` boolean from a CLI/env value so the flag can be driven from
49+
/// the Justfile (e.g. `BOOTC_skip_bind_storage=1`).
50+
fn parse_cli_bool(s: &str) -> std::result::Result<bool, String> {
51+
match s {
52+
"1" | "true" => Ok(true),
53+
"0" | "false" => Ok(false),
54+
other => Err(format!("invalid value '{other}' (expected 0, 1, true, or false)")),
55+
}
56+
}
57+
4858
/// Build tasks for bootc
4959
#[derive(Debug, Parser)]
5060
#[command(name = "xtask")]
@@ -228,6 +238,24 @@ pub(crate) struct RunTmtArgs {
228238
#[clap(long)]
229239
pub(crate) upgrade_image: Option<String>,
230240

241+
/// Skip the `--bind-storage-ro` host container-storage virtiofs mount even for
242+
/// plans that request it. Useful where libvirt-managed virtiofsd cannot run
243+
/// (nested user namespaces, cloud/non-qemu). Plans that depend on a locally
244+
/// built upgrade image being available in-VM via bind-storage will not be able
245+
/// to perform the upgrade/switch step.
246+
///
247+
/// Takes `0`/`1`/`true`/`false` so it can be driven from the Justfile via
248+
/// `BOOTC_skip_bind_storage=1`. A bare `--skip-bind-storage` means `1`.
249+
#[arg(
250+
long,
251+
env = "BOOTC_skip_bind_storage",
252+
num_args = 0..=1,
253+
default_value_t = false,
254+
default_missing_value = "1",
255+
value_parser = parse_cli_bool,
256+
)]
257+
pub(crate) skip_bind_storage: bool,
258+
231259
/// Preserve VMs after test completion (useful for debugging)
232260
#[arg(long)]
233261
pub(crate) preserve_vm: bool,
@@ -765,3 +793,18 @@ fn validate_composefs_digest(sh: &Shell, args: &ValidateComposefsDigestArgs) ->
765793
anyhow::bail!("Composefs digest mismatch");
766794
}
767795
}
796+
797+
#[cfg(test)]
798+
mod tests {
799+
use super::*;
800+
801+
#[test]
802+
fn test_parse_cli_bool() {
803+
assert_eq!(parse_cli_bool("1"), Ok(true));
804+
assert_eq!(parse_cli_bool("true"), Ok(true));
805+
assert_eq!(parse_cli_bool("0"), Ok(false));
806+
assert_eq!(parse_cli_bool("false"), Ok(false));
807+
assert!(parse_cli_bool("").is_err());
808+
assert!(parse_cli_bool("maybe").is_err());
809+
}
810+
}

0 commit comments

Comments
 (0)