Pick the OVMF variant for a given dstack OS version string ("MAJOR.MINOR.PATCH"). Treats `0.5.10 <= v < 0.6.0` and `v >= 0.6.1` as `Stable202505`, everything else as `Pre202505`. Used as a fallback when `VmConfig::ovmf_variant` is absent.
(version: &str)
| 27 | /// Treats `0.5.10 <= v < 0.6.0` and `v >= 0.6.1` as `Stable202505`, everything else as |
| 28 | /// `Pre202505`. Used as a fallback when `VmConfig::ovmf_variant` is absent. |
| 29 | pub fn ovmf_variant_for_version(version: &str) -> Result<OvmfVariant> { |
| 30 | let parts: Vec<u32> = version |
| 31 | .split('.') |
| 32 | .map(|p| { |
| 33 | p.parse::<u32>() |
| 34 | .with_context(|| format!("invalid version component: {p}")) |
| 35 | }) |
| 36 | .collect::<Result<Vec<_>, _>>()?; |
| 37 | if parts.len() != 3 { |
| 38 | bail!("expected MAJOR.MINOR.PATCH, got {version}"); |
| 39 | } |
| 40 | let v = (parts[0], parts[1], parts[2]); |
| 41 | let stable = ((0, 5, 10)..(0, 6, 0)).contains(&v) || v >= (0, 6, 1); |
| 42 | Ok(if stable { |
| 43 | OvmfVariant::Stable202505 |
| 44 | } else { |
| 45 | OvmfVariant::Pre202505 |
| 46 | }) |
| 47 | } |
| 48 | |
| 49 | /// Extract the `MAJOR.MINOR.PATCH` version suffix from a dstack image name. |
| 50 | /// |
no test coverage detected