Skip to main content

flowey_hvlite/pipelines/
checkin_gates.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! See [`CheckinGatesCli`]
5
6use crate::pipelines_shared::ado_pools;
7use crate::pipelines_shared::gh_pools;
8use anyhow::Context as _;
9use flowey::node::prelude::AdoResourcesRepositoryId;
10use flowey::node::prelude::FlowPlatformLinuxDistro;
11use flowey::node::prelude::GhPermission;
12use flowey::node::prelude::GhPermissionValue;
13use flowey::node::prelude::ReadVar;
14use flowey::pipeline::prelude::*;
15use flowey_lib_common::git_checkout::RepoSource;
16use flowey_lib_hvlite::_jobs::build_and_publish_openhcl_igvm_from_recipe::OpenhclIgvmBuildParams;
17use flowey_lib_hvlite::_jobs::build_and_publish_openhcl_igvm_from_recipe::OpenhclIgvmOutputs;
18use flowey_lib_hvlite::_jobs::check_openvmm_hcl_size::artifact_name_openhcl_baseline;
19use flowey_lib_hvlite::_jobs::consume_and_test_nextest_vmm_tests_archive::TestContentConfig;
20use flowey_lib_hvlite::build_nextest_vmm_tests::BuildNextestVmmTestsMode;
21use flowey_lib_hvlite::build_openhcl_igvm_from_recipe::OpenhclIgvmRecipe;
22use flowey_lib_hvlite::build_openvmm_hcl::OpenvmmHclBuildProfile;
23use flowey_lib_hvlite::build_openvmm_hcl::OpenvmmHclFeature;
24use flowey_lib_hvlite::common::CommonArch;
25use flowey_lib_hvlite::common::CommonPlatform;
26use flowey_lib_hvlite::common::CommonProfile;
27use flowey_lib_hvlite::common::CommonTriple;
28use flowey_lib_hvlite::download_uefi_mu_msvm::FirmwareFlavor;
29use flowey_lib_hvlite::init_vmm_tests_content_dir::ResolveVmmTestsBuiltArtifacts;
30use flowey_lib_hvlite::init_vmm_tests_content_dir::VmmTestsPreBuiltArtifactsSelections;
31use flowey_lib_hvlite::init_vmm_tests_content_dir::vmm_tests_artifact_builders;
32use flowey_lib_hvlite::init_vmm_tests_env::PetriParams;
33use flowey_lib_hvlite::install_vmm_tests_external_deps::VmmTestsExternalDeps;
34use flowey_lib_hvlite::install_vmm_tests_external_deps::VmmTestsExternalDepsLinux;
35use flowey_lib_hvlite::install_vmm_tests_external_deps::VmmTestsExternalDepsWindows;
36use flowey_lib_hvlite::run_cargo_nextest_run::NextestProfile;
37use petri_artifacts_vmm_test::ErasedVmmTestImage;
38use petri_artifacts_vmm_test::artifacts::test_iso;
39use petri_artifacts_vmm_test::artifacts::test_vhd;
40use petri_artifacts_vmm_test::artifacts::test_vmgs;
41use std::collections::BTreeMap;
42use std::collections::BTreeSet;
43use target_lexicon::Triple;
44
45// This is a cap for surplus 2 MiB hugetlb pages, not a reservation. Keep it
46// generous enough for VMM tests without tying CI provisioning to one test's RAM.
47const HUGETLB_2MB_OVERCOMMIT_PAGES: u64 = 4096;
48
49#[derive(Copy, Clone, clap::ValueEnum)]
50enum PipelineConfig {
51    /// Run on all PRs targeting the OpenVMM GitHub repo.
52    Pr,
53    /// Run on all commits that land in a branch.
54    ///
55    /// The key difference between the CI and PR pipelines is whether things are
56    /// being built in `release` mode.
57    Ci,
58    /// Release variant of the `Pr` pipeline.
59    PrRelease,
60    /// Nightly check-in gates with Patina ClangPDB firmware.
61    PatinaNightly,
62}
63
64/// A unified pipeline defining all checkin gates required to land a commit in
65/// the OpenVMM repo.
66#[derive(clap::Args)]
67pub struct CheckinGatesCli {
68    /// Which pipeline configuration to use.
69    #[clap(long)]
70    config: PipelineConfig,
71
72    #[clap(flatten)]
73    local_run_args: Option<crate::pipelines_shared::cfg_common_params::LocalRunArgs>,
74}
75
76impl IntoPipeline for CheckinGatesCli {
77    fn into_pipeline(self, backend_hint: PipelineBackendHint) -> anyhow::Result<Pipeline> {
78        let Self {
79            config,
80            local_run_args,
81        } = self;
82
83        let patina_nightly = matches!(config, PipelineConfig::PatinaNightly);
84        if patina_nightly && !matches!(backend_hint, PipelineBackendHint::Github) {
85            anyhow::bail!("Patina nightly requires the GitHub backend");
86        }
87
88        let release = match config {
89            PipelineConfig::Ci | PipelineConfig::PrRelease | PipelineConfig::PatinaNightly => true,
90            PipelineConfig::Pr => false,
91        };
92
93        let mut pipeline = Pipeline::new();
94
95        let mut vmgstools = BTreeMap::new();
96
97        // configure pr/ci branch triggers and add gh pipeline name
98        {
99            let branches = vec!["main".into(), "release/*".into()];
100
101            // Paths that don't affect the Rust build or tests. Changes
102            // to only these paths will not trigger the CI pipeline on push.
103            //
104            // NOTE: The PR pipeline intentionally does NOT use paths-ignore,
105            // because the "openvmm checkin gates" job is a required status
106            // check. If the workflow is skipped due to path filters, the
107            // gate is never reported and the PR is blocked. The CI pipeline
108            // can still use paths-ignore since it has no required checks.
109            let ci_paths_ignore = vec!["Guide/**".into(), "petri/logview/**".into()];
110
111            match config {
112                PipelineConfig::Ci => {
113                    pipeline
114                        .gh_set_ci_triggers(GhCiTriggers {
115                            branches,
116                            paths_ignore: ci_paths_ignore.clone(),
117                            ..Default::default()
118                        })
119                        .gh_set_name("OpenVMM CI");
120                }
121                PipelineConfig::Pr => {
122                    pipeline
123                        .gh_set_pr_triggers(GhPrTriggers {
124                            branches,
125                            ..GhPrTriggers::new_draftable()
126                        })
127                        .gh_set_name("OpenVMM PR")
128                        .ado_set_pr_triggers(AdoPrTriggers {
129                            branches: vec!["main".into(), "release/*".into(), "embargo/*".into()],
130                            exclude_paths: ci_paths_ignore.clone(),
131                            ..Default::default()
132                        });
133                }
134                PipelineConfig::PrRelease => {
135                    // This workflow is triggered when a specific label is present on a PR.
136                    let mut triggers = GhPrTriggers::new_draftable();
137                    triggers.branches = branches;
138                    triggers.types.push("labeled".into());
139                    pipeline
140                        .gh_set_pr_triggers(triggers)
141                        .gh_set_name("[Optional] OpenVMM Release PR");
142                }
143                PipelineConfig::PatinaNightly => {
144                    let mut triggers = GhPrTriggers::new_draftable();
145                    triggers.branches = branches;
146                    triggers.types.push("labeled".into());
147                    pipeline
148                        .gh_set_name("OpenVMM Patina Nightly")
149                        .gh_set_pr_triggers(triggers)
150                        .gh_add_schedule_trigger(GhScheduleTriggers {
151                            cron: "0 19 * * *".into(),
152                            timezone: Some("America/Los_Angeles".into()),
153                        });
154                }
155            }
156        }
157
158        let openvmm_repo_source = match backend_hint {
159            PipelineBackendHint::Local => {
160                RepoSource::ExistingClone(ReadVar::from_static(crate::repo_root()))
161            }
162            PipelineBackendHint::Github => RepoSource::GithubSelf,
163            PipelineBackendHint::Ado => {
164                RepoSource::AdoResource(AdoResourcesRepositoryId::new_self())
165            }
166        };
167
168        if let RepoSource::GithubSelf = &openvmm_repo_source {
169            pipeline.gh_set_flowey_bootstrap_template_fn(
170                crate::pipelines_shared::gh_flowey_bootstrap_template::get_template_for_platform,
171            );
172        }
173
174        if let RepoSource::AdoResource(source) = &openvmm_repo_source {
175            let source = source.clone();
176            pipeline.ado_set_flowey_bootstrap_template_fn(move |platform, arch| {
177                crate::pipelines_shared::ado_flowey_bootstrap_template::get_template_for_platform(
178                    platform, arch, &source,
179                )
180            });
181        }
182
183        let cfg_common_params = crate::pipelines_shared::cfg_common_params::get_cfg_common_params(
184            &mut pipeline,
185            backend_hint,
186            local_run_args,
187        )?;
188
189        pipeline.inject_all_jobs_with(move |job| {
190            let mut job = job
191                .dep_on(&cfg_common_params)
192                .dep_on(|_| flowey_lib_hvlite::_jobs::cfg_versions::Request::Init)
193                .dep_on(
194                    |_| flowey_lib_hvlite::_jobs::cfg_hvlite_reposource::Params {
195                        hvlite_repo_source: openvmm_repo_source.clone(),
196                    },
197                )
198                .gh_grant_permissions::<flowey_lib_common::git_checkout::Node>([(
199                    GhPermission::Contents,
200                    GhPermissionValue::Read,
201                )])
202                .gh_grant_permissions::<flowey_lib_common::gh_task_azure_login::Node>([(
203                    GhPermission::IdToken,
204                    GhPermissionValue::Write,
205                )]);
206
207            // For the release pipeline, only run if the "release-ci-required" label is present and PR is not draft
208            if matches!(config, PipelineConfig::PrRelease) {
209                job = job.gh_dangerous_override_if(
210                    "contains(github.event.pull_request.labels.*.name, 'release-ci-required') && github.event.pull_request.draft == false",
211                );
212            }
213            // Keep patina nightly scheduled/manual runs unconditional; PR runs require the label and a non-draft PR.
214            if patina_nightly {
215                let non_pr_run = "github.event_name != 'pull_request'";
216                let has_patina_label =
217                    "contains(github.event.pull_request.labels.*.name, 'needs-patina')";
218                let ready_for_review = "github.event.pull_request.draft == false";
219                job = job.gh_dangerous_override_if(format!(
220                    "{non_pr_run} || ({has_patina_label} && {ready_for_review})",
221                ));
222            }
223
224            job
225        });
226
227        let openhcl_musl_target = |arch: CommonArch| -> Triple {
228            CommonTriple::Common {
229                arch,
230                platform: CommonPlatform::LinuxMusl,
231            }
232            .as_triple()
233        };
234
235        let (pub_vmfirmwareigvm_cvm_x64, use_vmfirmwareigvm_cvm_x64) =
236            pipeline.new_typed_artifact("x64-vmfirmwareigvm-cvm");
237        let (pub_vmfirmwareigvm_cvm_mi_secure_x64, use_vmfirmwareigvm_cvm_mi_secure_x64) =
238            pipeline.new_typed_artifact("x64-vmfirmwareigvm-cvm-mi-secure");
239
240        // initialize the various "VmmTestsArtifactsBuilder" containers, which
241        // are used to "skim off" various artifacts that the VMM test jobs
242        // require.
243        let mut vmm_tests_artifacts_linux_x86 =
244            vmm_tests_artifact_builders::VmmTestsArtifactsBuilderLinuxX86::default();
245        let mut vmm_tests_artifacts_linux_musl_x86 =
246            vmm_tests_artifact_builders::VmmTestsArtifactsBuilderLinuxMuslX86::default();
247        let mut vmm_tests_artifacts_windows_x86 =
248            vmm_tests_artifact_builders::VmmTestsArtifactsBuilderWindowsX86 {
249                use_vmfirmwareigvm_cvm_x64: Some(use_vmfirmwareigvm_cvm_x64),
250                ..Default::default()
251            };
252        let mut vmm_tests_artifacts_windows_aarch64 =
253            vmm_tests_artifact_builders::VmmTestsArtifactsBuilderWindowsAarch64::default();
254
255        // Run VMM.Perf after merge, or before merge through the opt-in release
256        // PR pipeline.
257        let enable_vmm_perf = matches!(
258            (backend_hint, config),
259            (
260                PipelineBackendHint::Github,
261                PipelineConfig::Ci | PipelineConfig::PrRelease
262            )
263        );
264        let mut use_vmm_perf_runner_gnu_x64 = None;
265        let mut use_vmm_perf_runner_musl_x64 = None;
266        let mut use_vmm_perf_openvmm_gnu_x64 = None;
267        let mut use_vmm_perf_openvmm_musl_x64 = None;
268        let mut use_vmm_perf_runner_windows_x64 = None;
269        let mut use_vmm_perf_openvmm_windows_x64 = None;
270        let mut use_vmm_perf_runner_windows_aarch64 = None;
271        let mut use_vmm_perf_openvmm_windows_aarch64 = None;
272
273        // We need to maintain a list of all jobs, so we can hang the "all good"
274        // job off of them. This is requires because github status checks only allow
275        // specifying jobs, and not workflows.
276        // There's more info in the following discussion:
277        // <https://github.com/orgs/community/discussions/12395>
278        let mut all_jobs = Vec::new();
279
280        // Quick check gate
281        //
282        // Combined fmt + clippy on one self-hosted linux machine.
283        // Catches the most common failures quickly before fanning out expensive jobs.
284        let quick_check_job = if matches!(config, PipelineConfig::Pr | PipelineConfig::PrRelease) {
285            let job = pipeline
286                .new_job(
287                    FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
288                    FlowArch::X86_64,
289                    "quick check [fmt, clippy x64-linux]",
290                )
291                .gh_set_pool(gh_pools::default_linux().0)
292                .ado_set_pool(ado_pools::default_linux())
293                // 1. xtask fmt (linux)
294                .side_effect(|done| flowey_lib_hvlite::_jobs::check_xtask_fmt::Request {
295                    target: CommonTriple::X86_64_LINUX_GNU,
296                    done,
297                })
298                // 2. clippy for x64-linux-gnu
299                .side_effect(|done| flowey_lib_hvlite::_jobs::check_clippy::Request {
300                    target: target_lexicon::triple!("x86_64-unknown-linux-gnu"),
301                    profile: CommonProfile::from_release(release),
302                    done,
303                    also_check_misc_nostd_crates: false,
304                })
305                .finish();
306
307            Some(job)
308        } else {
309            // skip in CI
310            None
311        };
312
313        // emit xtask fmt job
314        {
315            let windows_fmt_job = pipeline
316                .new_job(
317                    FlowPlatform::Windows,
318                    FlowArch::X86_64,
319                    "xtask fmt (windows)",
320                )
321                .gh_set_pool(gh_pools::windows_x64_gh().0)
322                .ado_set_pool(ado_pools::default_windows())
323                .side_effect(|done| flowey_lib_hvlite::_jobs::check_xtask_fmt::Request {
324                    target: CommonTriple::X86_64_WINDOWS_MSVC,
325                    done,
326                })
327                .finish();
328
329            let linux_fmt_job = if let Some(ref qc) = quick_check_job {
330                // PR/PrRelease: linux fmt is handled by the quick-check job
331                qc.clone()
332            } else {
333                // CI mode: keep standalone linux fmt job
334                let job = pipeline
335                    .new_job(
336                        FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
337                        FlowArch::X86_64,
338                        "xtask fmt (linux)",
339                    )
340                    .gh_set_pool(gh_pools::linux_x64_gh().0)
341                    .ado_set_pool(ado_pools::default_linux())
342                    .side_effect(|done| flowey_lib_hvlite::_jobs::check_xtask_fmt::Request {
343                        target: CommonTriple::X86_64_LINUX_GNU,
344                        done,
345                    })
346                    .finish();
347                all_jobs.push(job.clone());
348                job
349            };
350
351            // cut down on extra noise by having the linux check run first, and
352            // then if it passes, run the windows checks just in case there is a
353            // difference between the two.
354            pipeline.non_artifact_dep(&windows_fmt_job, &linux_fmt_job);
355
356            all_jobs.push(windows_fmt_job);
357        }
358
359        let linux_cargo_hack_job = pipeline
360            .new_job(
361                FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
362                FlowArch::X86_64,
363                "cargo hack (linux)",
364            )
365            .gh_set_pool(gh_pools::linux_x64_gh().0)
366            .ado_set_pool(ado_pools::default_linux())
367            .side_effect(|done| flowey_lib_hvlite::_jobs::check_cargo_hack::Request {
368                profile: CommonProfile::from_release(release),
369                done,
370            })
371            .finish();
372        all_jobs.push(linux_cargo_hack_job);
373
374        // emit shared dependencies jobs
375        //
376        // In order to ensure we start running VMM tests as soon as possible, we emit
377        // a job for windows and linux building dependencies used by VMM tests on all platforms.
378        // These jobs build dependencies for all architectures, as these dependencies are typically
379        // small and fast to build.
380        //
381        // We have to create the per-arch artifacts up front so that we don't try
382        // to mutably borrow `pipeline` while a job builder also holds a mutable borrow.
383        let mut shared_win_pipette_artifacts = Vec::new();
384        for arch in [CommonArch::Aarch64, CommonArch::X86_64] {
385            let arch_tag = match arch {
386                CommonArch::X86_64 => "x64",
387                CommonArch::Aarch64 => "aarch64",
388            };
389            let (pub_pipette_windows, use_pipette_windows) =
390                pipeline.new_typed_artifact(format!("{arch_tag}-windows-pipette"));
391            // filter off artifacts required by the VMM tests job
392            match arch {
393                CommonArch::X86_64 => {
394                    vmm_tests_artifacts_linux_x86.use_pipette_windows_x64 =
395                        Some(use_pipette_windows.clone());
396                    vmm_tests_artifacts_linux_musl_x86.use_pipette_windows_x64 =
397                        Some(use_pipette_windows.clone());
398                    vmm_tests_artifacts_windows_x86.use_pipette_windows_x64 =
399                        Some(use_pipette_windows.clone());
400                }
401                CommonArch::Aarch64 => {
402                    vmm_tests_artifacts_windows_aarch64.use_pipette_windows_aarch64 =
403                        Some(use_pipette_windows.clone());
404                }
405            }
406            shared_win_pipette_artifacts.push((arch, pub_pipette_windows));
407        }
408        let mut shared_win_job = pipeline
409            .new_job(
410                FlowPlatform::Windows,
411                FlowArch::X86_64,
412                "build artifacts (shared VMM tests) [windows]",
413            )
414            .gh_set_pool(gh_pools::default_windows().0)
415            .ado_set_pool(ado_pools::default_windows());
416        for (arch, pub_pipette_windows) in shared_win_pipette_artifacts {
417            shared_win_job = shared_win_job.publish(pub_pipette_windows, |pipette| {
418                flowey_lib_hvlite::build_pipette::Request {
419                    target: CommonTriple::Common {
420                        arch,
421                        platform: CommonPlatform::WindowsMsvc,
422                    },
423                    profile: CommonProfile::from_release(release),
424                    pipette,
425                }
426            });
427        }
428        all_jobs.push(shared_win_job.finish());
429
430        // Now do linux
431        //
432        // Create the per-arch artifacts up front so that we don't try to
433        // mutably borrow `pipeline` while the job builder also holds a
434        // mutable borrow.
435        let mut shared_linux_artifacts = Vec::new();
436        for arch in [CommonArch::Aarch64, CommonArch::X86_64] {
437            let arch_tag = match arch {
438                CommonArch::X86_64 => "x64",
439                CommonArch::Aarch64 => "aarch64",
440            };
441
442            let (pub_tpm_guest_tests, use_tpm_guest_tests) =
443                pipeline.new_typed_artifact(format!("{arch_tag}-linux-tpm_guest_tests"));
444            let (pub_guest_test_uefi, use_guest_test_uefi) =
445                pipeline.new_typed_artifact(format!("{arch_tag}-guest_test_uefi"));
446            let (pub_pipette_linux_musl, use_pipette_linux_musl) =
447                pipeline.new_typed_artifact(format!("{arch_tag}-linux-musl-pipette"));
448            let (pub_tmk_vmm, use_tmk_vmm) =
449                pipeline.new_typed_artifact(format!("{arch_tag}-linux-musl-tmk_vmm"));
450            let (pub_tmks, use_tmks) = pipeline.new_typed_artifact(format!("{arch_tag}-tmks"));
451
452            match arch {
453                CommonArch::X86_64 => {
454                    vmm_tests_artifacts_linux_x86.use_guest_test_uefi_x64 =
455                        Some(use_guest_test_uefi.clone());
456                    vmm_tests_artifacts_windows_x86.use_guest_test_uefi_x64 =
457                        Some(use_guest_test_uefi.clone());
458                    vmm_tests_artifacts_windows_x86.use_tmks_x64 = Some(use_tmks.clone());
459                    vmm_tests_artifacts_linux_x86.use_tmks_x64 = Some(use_tmks.clone());
460                    vmm_tests_artifacts_windows_x86.use_tpm_guest_tests_linux_x64 =
461                        Some(use_tpm_guest_tests.clone());
462                    vmm_tests_artifacts_linux_musl_x86.use_guest_test_uefi_x64 =
463                        Some(use_guest_test_uefi.clone());
464                    vmm_tests_artifacts_linux_musl_x86.use_tmks_x64 = Some(use_tmks.clone());
465                    vmm_tests_artifacts_windows_x86.use_pipette_linux_musl_x64 =
466                        Some(use_pipette_linux_musl.clone());
467                    vmm_tests_artifacts_linux_x86.use_pipette_linux_musl_x64 =
468                        Some(use_pipette_linux_musl.clone());
469                    vmm_tests_artifacts_linux_x86.use_tmk_vmm_linux_musl_x64 =
470                        Some(use_tmk_vmm.clone());
471                    vmm_tests_artifacts_windows_x86.use_tmk_vmm_linux_musl_x64 =
472                        Some(use_tmk_vmm.clone());
473                    vmm_tests_artifacts_linux_musl_x86.use_pipette_linux_musl_x64 =
474                        Some(use_pipette_linux_musl.clone());
475                    vmm_tests_artifacts_linux_musl_x86.use_tmk_vmm_linux_musl_x64 =
476                        Some(use_tmk_vmm.clone());
477                }
478                CommonArch::Aarch64 => {
479                    vmm_tests_artifacts_linux_x86.use_pipette_linux_musl_aarch64 =
480                        Some(use_pipette_linux_musl.clone());
481                    vmm_tests_artifacts_windows_aarch64.use_guest_test_uefi_aarch64 =
482                        Some(use_guest_test_uefi.clone());
483                    vmm_tests_artifacts_windows_aarch64.use_tmks_aarch64 = Some(use_tmks.clone());
484                    vmm_tests_artifacts_windows_aarch64.use_pipette_linux_musl_aarch64 =
485                        Some(use_pipette_linux_musl.clone());
486                    vmm_tests_artifacts_windows_aarch64.use_tmk_vmm_linux_musl_aarch64 =
487                        Some(use_tmk_vmm.clone());
488                }
489            }
490
491            shared_linux_artifacts.push((
492                arch,
493                pub_tpm_guest_tests,
494                pub_guest_test_uefi,
495                pub_pipette_linux_musl,
496                pub_tmk_vmm,
497                pub_tmks,
498            ));
499        }
500
501        // Create incubator artifact handle.
502        // Must be created before the shared_linux_job builder to avoid
503        // borrowing `pipeline` while the job builder holds a mutable borrow.
504        let (pub_incubator, _use_incubator) = pipeline.new_typed_artifact("x64-linux-incubator");
505
506        let mut shared_linux_job = pipeline
507            .new_job(
508                FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
509                FlowArch::X86_64,
510                "build artifacts (shared VMM tests) [linux]",
511            )
512            .gh_set_pool(gh_pools::linux_amd_v6_1es().0)
513            .ado_set_pool(ado_pools::default_linux());
514        for (
515            arch,
516            pub_tpm_guest_tests,
517            pub_guest_test_uefi,
518            pub_pipette_linux_musl,
519            pub_tmk_vmm,
520            pub_tmks,
521        ) in shared_linux_artifacts
522        {
523            shared_linux_job = shared_linux_job
524                .publish(pub_guest_test_uefi, |guest_test_uefi| {
525                    flowey_lib_hvlite::build_guest_test_uefi::Request {
526                        arch,
527                        profile: CommonProfile::from_release(release),
528                        guest_test_uefi,
529                    }
530                })
531                .publish(pub_tmks, |tmks| flowey_lib_hvlite::build_tmks::Request {
532                    arch,
533                    profile: CommonProfile::from_release(release),
534                    tmks,
535                })
536                .publish(pub_tpm_guest_tests, |tpm_guest_tests| {
537                    flowey_lib_hvlite::build_tpm_guest_tests::Request {
538                        target: CommonTriple::Common {
539                            arch,
540                            platform: CommonPlatform::LinuxGnu,
541                        },
542                        profile: CommonProfile::from_release(release),
543                        tpm_guest_tests,
544                    }
545                })
546                .publish(pub_pipette_linux_musl, |pipette| {
547                    flowey_lib_hvlite::build_pipette::Request {
548                        target: CommonTriple::Common {
549                            arch,
550                            platform: CommonPlatform::LinuxMusl,
551                        },
552                        profile: CommonProfile::from_release(release),
553                        pipette,
554                    }
555                })
556                .publish(pub_tmk_vmm, |tmk_vmm| {
557                    flowey_lib_hvlite::build_tmk_vmm::Request {
558                        target: CommonTriple::Common {
559                            arch,
560                            platform: CommonPlatform::LinuxMusl,
561                        },
562                        profile: CommonProfile::from_release(release),
563                        tmk_vmm,
564                    }
565                });
566        }
567
568        // Build incubator binary (x86_64 Linux, for running TCG tests on CI hosts)
569        shared_linux_job = shared_linux_job.publish(pub_incubator, |incubator| {
570            flowey_lib_hvlite::build_incubator::Request {
571                target: CommonTriple::X86_64_LINUX_GNU,
572                profile: CommonProfile::from_release(release).into(),
573                incubator,
574            }
575        });
576
577        all_jobs.push(shared_linux_job.finish());
578
579        // emit windows build machine jobs
580        //
581        // In order to ensure we start running VMM tests as soon as possible, we emit
582        // two separate windows job per arch - one for artifacts in the VMM tests
583        // hotpath, and another for any auxiliary artifacts that aren't
584        // required by VMM tests.
585        for arch in [CommonArch::Aarch64, CommonArch::X86_64] {
586            let arch_tag = match arch {
587                CommonArch::X86_64 => "x64",
588                CommonArch::Aarch64 => "aarch64",
589            };
590
591            // artifacts which _are_ in the VMM tests "hot path"
592            let (pub_openvmm, use_openvmm) =
593                pipeline.new_typed_artifact(format!("{arch_tag}-windows-openvmm"));
594
595            let (pub_tmk_vmm, use_tmk_vmm) =
596                pipeline.new_typed_artifact(format!("{arch_tag}-windows-tmk_vmm"));
597
598            let (pub_prep_steps, use_prep_steps) =
599                pipeline.new_typed_artifact(format!("{arch_tag}-windows-prep_steps"));
600
601            let (pub_vmgstool, use_vmgstool) =
602                pipeline.new_typed_artifact(format!("{arch_tag}-windows-vmgstool"));
603
604            let (pub_vmgstool_dev, use_vmgstool_dev) =
605                pipeline.new_typed_artifact(format!("{arch_tag}-windows-vmgstool-dev"));
606
607            let (pub_tpm_guest_tests, use_tpm_guest_tests_windows) =
608                pipeline.new_typed_artifact(format!("{arch_tag}-windows-tpm_guest_tests"));
609
610            let (pub_test_igvm_agent_rpc_server, use_test_igvm_agent_rpc_server) = pipeline
611                .new_typed_artifact(format!("{arch_tag}-windows-test_igvm_agent_rpc_server"));
612
613            let (pub_vmm_tests_archive, use_vmm_tests_archive) =
614                pipeline.new_typed_artifact(format!("{arch_tag}-windows-vmm-tests-archive"));
615            let (pub_vmm_perf, use_vmm_perf) =
616                pipeline.new_typed_artifact(format!("{arch_tag}-windows-vmm-perf-runner"));
617
618            // filter off interesting artifacts required by the VMM tests job
619            match arch {
620                CommonArch::X86_64 => {
621                    vmm_tests_artifacts_windows_x86.use_openvmm_windows_x64 =
622                        Some(use_openvmm.clone());
623                    vmm_tests_artifacts_windows_x86.use_tmk_vmm_windows_x64 =
624                        Some(use_tmk_vmm.clone());
625                    vmm_tests_artifacts_windows_x86.use_prep_steps_windows_x64 =
626                        Some(use_prep_steps.clone());
627                    vmm_tests_artifacts_windows_x86.use_vmgstool_windows_x64 =
628                        Some(use_vmgstool.clone());
629                    vmm_tests_artifacts_windows_x86.use_vmgstool_dev_windows_x64 =
630                        Some(use_vmgstool_dev.clone());
631                    vmm_tests_artifacts_windows_x86.use_tpm_guest_tests_windows_x64 =
632                        Some(use_tpm_guest_tests_windows.clone());
633                    vmm_tests_artifacts_windows_x86.use_test_igvm_agent_rpc_server_windows_x64 =
634                        Some(use_test_igvm_agent_rpc_server.clone());
635                    vmm_tests_artifacts_windows_x86.use_nextest_vmm_tests_archive_windows_x64 =
636                        Some(use_vmm_tests_archive.clone());
637                    use_vmm_perf_runner_windows_x64 = Some(use_vmm_perf);
638                    use_vmm_perf_openvmm_windows_x64 = Some(use_openvmm.clone());
639                }
640                CommonArch::Aarch64 => {
641                    vmm_tests_artifacts_windows_aarch64.use_openvmm_windows_aarch64 =
642                        Some(use_openvmm.clone());
643                    vmm_tests_artifacts_windows_aarch64.use_tmk_vmm_windows_aarch64 =
644                        Some(use_tmk_vmm.clone());
645                    vmm_tests_artifacts_windows_aarch64.use_vmgstool_windows_aarch64 =
646                        Some(use_vmgstool.clone());
647                    vmm_tests_artifacts_windows_aarch64.use_vmgstool_dev_windows_aarch64 =
648                        Some(use_vmgstool_dev.clone());
649                    vmm_tests_artifacts_windows_aarch64
650                        .use_nextest_vmm_tests_archive_windows_aarch64 =
651                        Some(use_vmm_tests_archive.clone());
652                    use_vmm_perf_runner_windows_aarch64 = Some(use_vmm_perf);
653                    use_vmm_perf_openvmm_windows_aarch64 = Some(use_openvmm.clone());
654                }
655            }
656            // emit a job for artifacts which _are not_ in the VMM tests "hot
657            // path"
658            // artifacts which _are not_ in the VMM tests "hot path"
659            let (pub_igvmfilegen, _use_igvmfilegen) =
660                pipeline.new_typed_artifact(format!("{arch_tag}-windows-igvmfilegen"));
661            let (pub_vmgs_lib, _use_vmgs_lib) =
662                pipeline.new_typed_artifact(format!("{arch_tag}-windows-vmgs_lib"));
663            let (pub_hypestv, _use_hypestv) =
664                pipeline.new_typed_artifact(format!("{arch_tag}-windows-hypestv"));
665            let (pub_ohcldiag_dev, _use_ohcldiag_dev) =
666                pipeline.new_typed_artifact(format!("{arch_tag}-windows-ohcldiag-dev"));
667
668            let job = pipeline
669                .new_job(
670                    FlowPlatform::Windows,
671                    FlowArch::X86_64,
672                    format!("build artifacts (not for VMM tests) [{arch_tag}-windows]"),
673                )
674                .gh_set_pool(gh_pools::default_windows().0)
675                .ado_set_pool(ado_pools::default_windows())
676                .publish(pub_hypestv, |hypestv| {
677                    flowey_lib_hvlite::build_hypestv::Request {
678                        target: CommonTriple::Common {
679                            arch,
680                            platform: CommonPlatform::WindowsMsvc,
681                        },
682                        profile: CommonProfile::from_release(release),
683                        hypestv,
684                    }
685                })
686                .publish(pub_vmgs_lib, |vmgs_lib| {
687                    flowey_lib_hvlite::build_and_test_vmgs_lib::Request {
688                        target: CommonTriple::Common {
689                            arch,
690                            platform: CommonPlatform::WindowsMsvc,
691                        },
692                        profile: CommonProfile::from_release(release),
693                        vmgs_lib,
694                    }
695                })
696                .publish(pub_igvmfilegen, |igvmfilegen| {
697                    flowey_lib_hvlite::build_igvmfilegen::Request {
698                        build_params:
699                            flowey_lib_hvlite::build_igvmfilegen::IgvmfilegenBuildParams {
700                                target: CommonTriple::Common {
701                                    arch,
702                                    platform: CommonPlatform::WindowsMsvc,
703                                },
704                                profile: CommonProfile::from_release(release).into(),
705                            },
706                        igvmfilegen,
707                    }
708                })
709                .publish(pub_ohcldiag_dev, |ohcldiag_dev| {
710                    flowey_lib_hvlite::build_ohcldiag_dev::Request {
711                        target: CommonTriple::Common {
712                            arch,
713                            platform: CommonPlatform::WindowsMsvc,
714                        },
715                        profile: CommonProfile::from_release(release),
716                        ohcldiag_dev,
717                    }
718                })
719                .publish(pub_vmm_perf, |vmm_perf| {
720                    flowey_lib_hvlite::build_vmm_perf::Request {
721                        target: CommonTriple::Common {
722                            arch,
723                            platform: CommonPlatform::WindowsMsvc,
724                        },
725                        profile: CommonProfile::from_release(release),
726                        vmm_perf,
727                    }
728                });
729
730            all_jobs.push(job.finish());
731
732            let vmgstool_target = CommonTriple::Common {
733                arch,
734                platform: CommonPlatform::WindowsMsvc,
735            };
736            if vmgstools
737                .insert(vmgstool_target.to_string(), use_vmgstool.clone())
738                .is_some()
739            {
740                anyhow::bail!("multiple vmgstools for the same target");
741            }
742
743            // emit a job for artifacts which _are_ in the VMM tests "hot path"
744            let job = pipeline
745                .new_job(
746                    FlowPlatform::Windows,
747                    FlowArch::X86_64,
748                    format!("build artifacts (for VMM tests) [{arch_tag}-windows]"),
749                )
750                .gh_set_pool(gh_pools::default_windows().0)
751                .ado_set_pool(ado_pools::default_windows())
752                .publish(pub_openvmm, |openvmm| {
753                    flowey_lib_hvlite::build_openvmm::Request {
754                        params: flowey_lib_hvlite::build_openvmm::OpenvmmBuildParams {
755                            target: CommonTriple::Common {
756                                arch,
757                                platform: CommonPlatform::WindowsMsvc,
758                            },
759                            profile: CommonProfile::from_release(release),
760                            // FIXME: this relies on openvmm default features
761                            features: [].into(),
762                        },
763                        openvmm,
764                    }
765                })
766                .publish(pub_tmk_vmm, |tmk_vmm| {
767                    flowey_lib_hvlite::build_tmk_vmm::Request {
768                        target: CommonTriple::Common {
769                            arch,
770                            platform: CommonPlatform::WindowsMsvc,
771                        },
772                        profile: CommonProfile::from_release(release),
773                        tmk_vmm,
774                    }
775                })
776                .publish(pub_prep_steps, |prep_steps| {
777                    flowey_lib_hvlite::build_prep_steps::Request {
778                        target: CommonTriple::Common {
779                            arch,
780                            platform: CommonPlatform::WindowsMsvc,
781                        },
782                        profile: CommonProfile::from_release(release),
783                        prep_steps,
784                    }
785                })
786                .publish(pub_vmgstool, |vmgstool| {
787                    flowey_lib_hvlite::build_vmgstool::Request {
788                        target: vmgstool_target.clone(),
789                        profile: CommonProfile::from_release(release),
790                        with_crypto: true,
791                        with_test_helpers: false,
792                        vmgstool,
793                    }
794                })
795                .publish(pub_vmgstool_dev, |vmgstool| {
796                    flowey_lib_hvlite::build_vmgstool::Request {
797                        target: vmgstool_target,
798                        profile: CommonProfile::from_release(release),
799                        with_crypto: true,
800                        with_test_helpers: true,
801                        vmgstool,
802                    }
803                })
804                .publish(pub_tpm_guest_tests, |tpm_guest_tests| {
805                    flowey_lib_hvlite::build_tpm_guest_tests::Request {
806                        target: CommonTriple::Common {
807                            arch,
808                            platform: CommonPlatform::WindowsMsvc,
809                        },
810                        profile: CommonProfile::from_release(release),
811                        tpm_guest_tests,
812                    }
813                })
814                .publish(
815                    pub_test_igvm_agent_rpc_server,
816                    |test_igvm_agent_rpc_server| {
817                        flowey_lib_hvlite::build_test_igvm_agent_rpc_server::Request {
818                            target: CommonTriple::Common {
819                                arch,
820                                platform: CommonPlatform::WindowsMsvc,
821                            },
822                            profile: CommonProfile::from_release(release),
823                            test_igvm_agent_rpc_server,
824                        }
825                    },
826                )
827                .publish(pub_vmm_tests_archive, |archive| {
828                    flowey_lib_hvlite::build_nextest_vmm_tests::Request {
829                        target: CommonTriple::Common {
830                            arch,
831
832                            platform: CommonPlatform::WindowsMsvc,
833                        }
834                        .as_triple(),
835                        profile: CommonProfile::from_release(release),
836                        build_mode: BuildNextestVmmTestsMode::Archive(archive),
837                    }
838                });
839
840            all_jobs.push(job.finish());
841        }
842
843        // emit linux build machine jobs (without openhcl)
844        for arch in [CommonArch::Aarch64, CommonArch::X86_64] {
845            let arch_tag = match arch {
846                CommonArch::X86_64 => "x64",
847                CommonArch::Aarch64 => "aarch64",
848            };
849
850            let (pub_openvmm, use_openvmm) =
851                pipeline.new_typed_artifact(format!("{arch_tag}-linux-openvmm"));
852            let (pub_openvmm_vhost, use_openvmm_vhost) =
853                pipeline.new_typed_artifact(format!("{arch_tag}-linux-openvmm_vhost"));
854            let (pub_igvmfilegen, _) =
855                pipeline.new_typed_artifact(format!("{arch_tag}-linux-igvmfilegen"));
856            let (pub_vmgs_lib, _) =
857                pipeline.new_typed_artifact(format!("{arch_tag}-linux-vmgs_lib"));
858            let (pub_vmgstool, use_vmgstool) =
859                pipeline.new_typed_artifact(format!("{arch_tag}-linux-vmgstool"));
860            let (pub_vmgstool_dev, _use_vmgstool_dev) =
861                pipeline.new_typed_artifact(format!("{arch_tag}-linux-vmgstool-dev"));
862            let (pub_ohcldiag_dev, _) =
863                pipeline.new_typed_artifact(format!("{arch_tag}-linux-ohcldiag-dev"));
864            // Also build openvmm and openvmm_vhost for musl on this job,
865            // alongside pipette and tmk_vmm. This enables running VMM tests
866            // on Azure Linux (MSHV) runners which have an older glibc.
867            let (pub_openvmm_musl, use_openvmm_musl) =
868                pipeline.new_typed_artifact(format!("{arch_tag}-linux-musl-openvmm"));
869            let (pub_openvmm_vhost_musl, use_openvmm_vhost_musl) =
870                pipeline.new_typed_artifact(format!("{arch_tag}-linux-musl-openvmm_vhost"));
871            let (pub_prep_steps_musl, use_prep_steps_musl) =
872                pipeline.new_typed_artifact(format!("{arch_tag}-linux-musl-prep_steps"));
873            let (pub_vmm_tests_archive, use_vmm_tests_archive) =
874                pipeline.new_typed_artifact(format!("{arch_tag}-linux-vmm-tests-archive"));
875            let (pub_vmm_tests_archive_musl, use_vmm_tests_archive_musl) =
876                pipeline.new_typed_artifact(format!("{arch_tag}-linux-musl-vmm-tests-archive"));
877            let (pub_vmm_perf_gnu, use_vmm_perf_gnu) =
878                pipeline.new_typed_artifact(format!("{arch_tag}-linux-vmm-perf-runner"));
879            let (pub_vmm_perf_musl, use_vmm_perf_musl) =
880                pipeline.new_typed_artifact(format!("{arch_tag}-linux-musl-vmm-perf-runner"));
881            let snp_igvm_artifact = matches!(arch, CommonArch::X86_64)
882                .then(|| pipeline.new_typed_artifact("x64-linux-snp-linux-direct-igvm"));
883            let mshv_host_boot_artifact = matches!(arch, CommonArch::X86_64)
884                .then(|| pipeline.new_typed_artifact("x64-mshv-host-boot"));
885            let mshv_payload_artifact = matches!(arch, CommonArch::X86_64)
886                .then(|| pipeline.new_typed_artifact("x64-mshv-boot-artifacts"));
887
888            // skim off interesting artifacts required by the VMM tests job
889            match arch {
890                CommonArch::X86_64 => {
891                    vmm_tests_artifacts_linux_x86.use_openvmm_linux_x64 = Some(use_openvmm.clone());
892                    vmm_tests_artifacts_linux_x86.use_openvmm_vhost_linux_x64 =
893                        Some(use_openvmm_vhost.clone());
894                    vmm_tests_artifacts_linux_x86.use_prep_steps_linux_musl_x64 =
895                        Some(use_prep_steps_musl.clone());
896                    vmm_tests_artifacts_linux_x86.use_openvmm_linux_musl_x64 =
897                        Some(use_openvmm_musl.clone());
898                    vmm_tests_artifacts_linux_musl_x86.use_openvmm_linux_musl_x64 =
899                        Some(use_openvmm_musl.clone());
900                    vmm_tests_artifacts_linux_musl_x86.use_openvmm_vhost_linux_musl_x64 =
901                        Some(use_openvmm_vhost_musl.clone());
902                    vmm_tests_artifacts_linux_musl_x86.use_prep_steps_linux_musl_x64 =
903                        Some(use_prep_steps_musl.clone());
904                    vmm_tests_artifacts_linux_x86.use_nextest_vmm_tests_archive_linux_x64 =
905                        Some(use_vmm_tests_archive.clone());
906                    vmm_tests_artifacts_linux_x86.use_nextest_vmm_tests_archive_linux_musl_x64 =
907                        Some(use_vmm_tests_archive_musl.clone());
908                    vmm_tests_artifacts_linux_musl_x86
909                        .use_nextest_vmm_tests_archive_linux_musl_x64 =
910                        Some(use_vmm_tests_archive_musl.clone());
911                    let (_, use_snp_igvm) = snp_igvm_artifact.as_ref().unwrap();
912                    vmm_tests_artifacts_linux_x86.use_snp_linux_direct_igvm_x64 =
913                        Some(use_snp_igvm.clone());
914                    vmm_tests_artifacts_linux_musl_x86.use_snp_linux_direct_igvm_x64 =
915                        Some(use_snp_igvm.clone());
916                    let (_, use_mshv_host_boot) = mshv_host_boot_artifact.as_ref().unwrap();
917                    vmm_tests_artifacts_linux_x86.use_mshv_host_boot_x64 =
918                        Some(use_mshv_host_boot.clone());
919                    vmm_tests_artifacts_windows_x86.use_mshv_host_boot_x64 =
920                        Some(use_mshv_host_boot.clone());
921                    let (_, use_mshv_payloads) = mshv_payload_artifact.as_ref().unwrap();
922                    vmm_tests_artifacts_linux_x86.use_mshv_boot_artifacts_x64 =
923                        Some(use_mshv_payloads.clone());
924                    vmm_tests_artifacts_windows_x86.use_mshv_boot_artifacts_x64 =
925                        Some(use_mshv_payloads.clone());
926                    vmm_tests_artifacts_windows_x86.use_nextest_vmm_tests_archive_linux_musl_x64 =
927                        Some(use_vmm_tests_archive_musl.clone());
928                    vmm_tests_artifacts_windows_x86.use_openvmm_linux_musl_x64 =
929                        Some(use_openvmm_musl.clone());
930                    vmm_tests_artifacts_windows_x86.use_prep_steps_linux_musl_x64 =
931                        Some(use_prep_steps_musl.clone());
932                    use_vmm_perf_runner_gnu_x64 = Some(use_vmm_perf_gnu);
933                    use_vmm_perf_runner_musl_x64 = Some(use_vmm_perf_musl);
934                    use_vmm_perf_openvmm_gnu_x64 = Some(use_openvmm.clone());
935                    use_vmm_perf_openvmm_musl_x64 = Some(use_openvmm_musl.clone());
936                }
937                CommonArch::Aarch64 => {
938                    vmm_tests_artifacts_linux_x86.use_openvmm_linux_musl_aarch64 =
939                        Some(use_openvmm_musl.clone());
940                    vmm_tests_artifacts_linux_x86
941                        .use_nextest_vmm_tests_archive_linux_musl_aarch64 =
942                        Some(use_vmm_tests_archive_musl.clone());
943                }
944            }
945
946            let vmgstool_target = CommonTriple::Common {
947                arch,
948                platform: CommonPlatform::LinuxGnu,
949            };
950            if vmgstools
951                .insert(vmgstool_target.to_string(), use_vmgstool.clone())
952                .is_some()
953            {
954                anyhow::bail!("multiple vmgstools for the same target");
955            }
956
957            // Emit a job for building dependencies used by just linux vmm tests
958            let job = pipeline
959                .new_job(
960                    FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
961                    FlowArch::X86_64,
962                    format!("build artifacts (for VMM tests) [{arch_tag}-linux]"),
963                )
964                .gh_set_pool(gh_pools::default_linux().0)
965                .ado_set_pool(ado_pools::default_linux())
966                .publish(pub_openvmm, |openvmm| {
967                    flowey_lib_hvlite::build_openvmm::Request {
968                        params: flowey_lib_hvlite::build_openvmm::OpenvmmBuildParams {
969                            target: CommonTriple::Common {
970                                arch,
971                                platform: CommonPlatform::LinuxGnu,
972                            },
973                            profile: CommonProfile::from_release(release),
974                            // FIXME: this relies on openvmm default features
975                            features: [flowey_lib_hvlite::build_openvmm::OpenvmmFeature::Tpm]
976                                .into(),
977                        },
978                        openvmm,
979                    }
980                })
981                .publish(pub_openvmm_vhost, |openvmm_vhost| {
982                    flowey_lib_hvlite::build_openvmm_vhost::Request {
983                        params: flowey_lib_hvlite::build_openvmm_vhost::OpenvmmVhostBuildParams {
984                            target: CommonTriple::Common {
985                                arch,
986                                platform: CommonPlatform::LinuxGnu,
987                            },
988                            profile: CommonProfile::from_release(release),
989                        },
990                        openvmm_vhost,
991                    }
992                })
993                .publish(pub_vmgstool, |vmgstool| {
994                    flowey_lib_hvlite::build_vmgstool::Request {
995                        target: vmgstool_target.clone(),
996                        profile: CommonProfile::from_release(release),
997                        with_crypto: true,
998                        with_test_helpers: false,
999                        vmgstool,
1000                    }
1001                })
1002                .publish(pub_vmgstool_dev, |vmgstool| {
1003                    flowey_lib_hvlite::build_vmgstool::Request {
1004                        target: vmgstool_target,
1005                        profile: CommonProfile::from_release(release),
1006                        with_crypto: true,
1007                        with_test_helpers: true,
1008                        vmgstool,
1009                    }
1010                })
1011                .publish(pub_vmgs_lib, |vmgs_lib| {
1012                    flowey_lib_hvlite::build_and_test_vmgs_lib::Request {
1013                        target: CommonTriple::Common {
1014                            arch,
1015                            platform: CommonPlatform::LinuxGnu,
1016                        },
1017                        profile: CommonProfile::from_release(release),
1018                        vmgs_lib,
1019                    }
1020                })
1021                .publish(pub_igvmfilegen, |igvmfilegen| {
1022                    flowey_lib_hvlite::build_igvmfilegen::Request {
1023                        build_params:
1024                            flowey_lib_hvlite::build_igvmfilegen::IgvmfilegenBuildParams {
1025                                target: CommonTriple::Common {
1026                                    arch,
1027                                    platform: CommonPlatform::LinuxGnu,
1028                                },
1029                                profile: CommonProfile::from_release(release).into(),
1030                            },
1031                        igvmfilegen,
1032                    }
1033                })
1034                .publish(pub_ohcldiag_dev, |ohcldiag_dev| {
1035                    flowey_lib_hvlite::build_ohcldiag_dev::Request {
1036                        target: CommonTriple::Common {
1037                            arch,
1038                            platform: CommonPlatform::LinuxGnu,
1039                        },
1040                        profile: CommonProfile::from_release(release),
1041                        ohcldiag_dev,
1042                    }
1043                })
1044                .publish(pub_openvmm_musl, |openvmm| {
1045                    flowey_lib_hvlite::build_openvmm::Request {
1046                        params: flowey_lib_hvlite::build_openvmm::OpenvmmBuildParams {
1047                            target: CommonTriple::Common {
1048                                arch,
1049                                platform: CommonPlatform::LinuxMusl,
1050                            },
1051                            profile: CommonProfile::from_release(release),
1052                            features: [flowey_lib_hvlite::build_openvmm::OpenvmmFeature::Tpm]
1053                                .into(),
1054                        },
1055                        openvmm,
1056                    }
1057                })
1058                .publish(pub_openvmm_vhost_musl, |openvmm_vhost| {
1059                    flowey_lib_hvlite::build_openvmm_vhost::Request {
1060                        params: flowey_lib_hvlite::build_openvmm_vhost::OpenvmmVhostBuildParams {
1061                            target: CommonTriple::Common {
1062                                arch,
1063                                platform: CommonPlatform::LinuxMusl,
1064                            },
1065                            profile: CommonProfile::from_release(release),
1066                        },
1067                        openvmm_vhost,
1068                    }
1069                })
1070                .publish(pub_prep_steps_musl, |prep_steps| {
1071                    flowey_lib_hvlite::build_prep_steps::Request {
1072                        target: CommonTriple::Common {
1073                            arch,
1074                            platform: CommonPlatform::LinuxMusl,
1075                        },
1076                        profile: CommonProfile::from_release(release),
1077                        prep_steps,
1078                    }
1079                })
1080                .publish(pub_vmm_tests_archive, |archive| {
1081                    flowey_lib_hvlite::build_nextest_vmm_tests::Request {
1082                        target: CommonTriple::Common {
1083                            arch,
1084                            platform: CommonPlatform::LinuxGnu,
1085                        }
1086                        .as_triple(),
1087                        profile: CommonProfile::from_release(release),
1088                        build_mode: BuildNextestVmmTestsMode::Archive(archive),
1089                    }
1090                })
1091                .publish(pub_vmm_tests_archive_musl, |archive| {
1092                    flowey_lib_hvlite::build_nextest_vmm_tests::Request {
1093                        target: CommonTriple::Common {
1094                            arch,
1095                            platform: CommonPlatform::LinuxMusl,
1096                        }
1097                        .as_triple(),
1098                        profile: CommonProfile::from_release(release),
1099                        build_mode: BuildNextestVmmTestsMode::Archive(archive),
1100                    }
1101                })
1102                .publish(pub_vmm_perf_gnu, |vmm_perf| {
1103                    flowey_lib_hvlite::build_vmm_perf::Request {
1104                        target: CommonTriple::Common {
1105                            arch,
1106                            platform: CommonPlatform::LinuxGnu,
1107                        },
1108                        profile: CommonProfile::from_release(release),
1109                        vmm_perf,
1110                    }
1111                })
1112                .publish(pub_vmm_perf_musl, |vmm_perf| {
1113                    flowey_lib_hvlite::build_vmm_perf::Request {
1114                        target: CommonTriple::Common {
1115                            arch,
1116                            platform: CommonPlatform::LinuxMusl,
1117                        },
1118                        profile: CommonProfile::from_release(release),
1119                        vmm_perf,
1120                    }
1121                });
1122
1123            let job = if let Some((pub_snp_igvm, _)) = snp_igvm_artifact {
1124                job.publish(pub_snp_igvm, |snp_linux_direct_igvm| {
1125                    flowey_lib_hvlite::build_snp_linux_direct_igvm::Request {
1126                        snp_linux_direct_igvm,
1127                    }
1128                })
1129            } else {
1130                job
1131            };
1132            let job = if let Some((pub_host_boot, _)) = mshv_host_boot_artifact {
1133                job.publish(pub_host_boot, |host_boot| {
1134                    flowey_lib_hvlite::build_mshv_host_boot::Request {
1135                        profile: CommonProfile::from_release(release),
1136                        host_boot,
1137                    }
1138                })
1139            } else {
1140                job
1141            };
1142            let job = if let Some((publish, _)) = mshv_payload_artifact {
1143                job.publish(publish, |artifacts| {
1144                    flowey_lib_hvlite::resolve_mshv_boot_artifacts::Request {
1145                        arch: CommonArch::X86_64,
1146                        artifacts,
1147                    }
1148                })
1149            } else {
1150                job
1151            };
1152            all_jobs.push(job.finish());
1153        }
1154
1155        let mut use_openhcl_igvm_files_mi_secure_x86 = BTreeMap::new();
1156        let mut pub_vmfirmwareigvm_cvm_x64 = Some(pub_vmfirmwareigvm_cvm_x64);
1157        let mut pub_vmfirmwareigvm_cvm_mi_secure_x64 = Some(pub_vmfirmwareigvm_cvm_mi_secure_x64);
1158
1159        // emit openhcl build job
1160        for (arch, mi_secure) in [
1161            (CommonArch::Aarch64, false),
1162            (CommonArch::X86_64, false),
1163            (CommonArch::X86_64, true),
1164        ] {
1165            let arch_tag = match arch {
1166                CommonArch::X86_64 => "x64",
1167                CommonArch::Aarch64 => "aarch64",
1168            };
1169
1170            let additional_tag = mi_secure.then_some("mi-secure");
1171
1172            let openvmm_hcl_profile = if release {
1173                OpenvmmHclBuildProfile::OpenvmmHclShip
1174            } else {
1175                OpenvmmHclBuildProfile::Debug
1176            };
1177
1178            let mut igvm_recipes = match (arch, mi_secure) {
1179                (CommonArch::X86_64, false) => vec![
1180                    OpenhclIgvmRecipe::X64,
1181                    OpenhclIgvmRecipe::X64Devkern,
1182                    OpenhclIgvmRecipe::X64TestLinuxDirect,
1183                    OpenhclIgvmRecipe::X64TestSivm,
1184                    OpenhclIgvmRecipe::X64TestLinuxDirectDevkern,
1185                    OpenhclIgvmRecipe::X64Cvm,
1186                ],
1187                (CommonArch::X86_64, true) => vec![
1188                    OpenhclIgvmRecipe::X64,
1189                    OpenhclIgvmRecipe::X64TestLinuxDirect,
1190                    OpenhclIgvmRecipe::X64Cvm,
1191                ],
1192                (CommonArch::Aarch64, false) => {
1193                    vec![
1194                        OpenhclIgvmRecipe::Aarch64,
1195                        OpenhclIgvmRecipe::Aarch64Devkern,
1196                    ]
1197                }
1198                _ => unreachable!(),
1199            };
1200            if flowey_lib_hvlite::_jobs::cfg_versions::OPENHCL_KERNEL_DEV_VERSION.is_none() {
1201                igvm_recipes.retain(|recipe| !recipe.uses_dev_kernel());
1202            }
1203
1204            let (mut pub_openhcl_igvms, use_openhcl_igvms) =
1205                pipeline.new_typed_artifact_collection(igvm_recipes.clone(), additional_tag, None);
1206            let (mut pub_openhcl_igvms_extras, _use_openhcl_igvms_extras) = pipeline
1207                .new_typed_artifact_collection(
1208                    igvm_recipes.clone(),
1209                    additional_tag,
1210                    Some("extras"),
1211                );
1212            let (pub_openhcl_baseline, _use_openhcl_baseline) =
1213                (matches!(config, PipelineConfig::Ci) && !mi_secure)
1214                    .then(|| pipeline.new_typed_artifact(artifact_name_openhcl_baseline(arch)))
1215                    .unzip();
1216            // skim off interesting artifacts required by the VMM tests job
1217            match (arch, mi_secure) {
1218                (CommonArch::X86_64, false) => {
1219                    vmm_tests_artifacts_windows_x86.use_openhcl_standard_x64 =
1220                        use_openhcl_igvms.get(&OpenhclIgvmRecipe::X64).cloned();
1221                    vmm_tests_artifacts_windows_x86.use_openhcl_cvm_x64 =
1222                        use_openhcl_igvms.get(&OpenhclIgvmRecipe::X64Cvm).cloned();
1223                    vmm_tests_artifacts_windows_x86.use_openhcl_linux_direct_x64 =
1224                        use_openhcl_igvms
1225                            .get(&OpenhclIgvmRecipe::X64TestLinuxDirect)
1226                            .cloned();
1227                    vmm_tests_artifacts_windows_x86.use_openhcl_sivm_x64 = use_openhcl_igvms
1228                        .get(&OpenhclIgvmRecipe::X64TestSivm)
1229                        .cloned();
1230                }
1231                (CommonArch::X86_64, true) => {
1232                    // we'll skim these off later so we can reuse most of the
1233                    // standard x64 builder
1234                    use_openhcl_igvm_files_mi_secure_x86 = use_openhcl_igvms;
1235                }
1236                (CommonArch::Aarch64, false) => {
1237                    vmm_tests_artifacts_windows_aarch64.use_openhcl_standard_aarch64 =
1238                        use_openhcl_igvms.get(&OpenhclIgvmRecipe::Aarch64).cloned();
1239                }
1240                _ => unreachable!(),
1241            }
1242
1243            let build_openhcl_job_tag = |arch_tag, mi_secure| {
1244                format!(
1245                    "build openhcl {}[{arch_tag}-linux]",
1246                    if mi_secure { "(mi-secure) " } else { "" }
1247                )
1248            };
1249            let job = pipeline
1250                .new_job(
1251                    FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
1252                    FlowArch::X86_64,
1253                    build_openhcl_job_tag(arch_tag, mi_secure),
1254                )
1255                .gh_set_pool(gh_pools::linux_amd_v6_1es().0)
1256                .ado_set_pool(ado_pools::default_linux())
1257                .dep_on(|ctx| {
1258                    let mut pub_openhcl_baseline = pub_openhcl_baseline;
1259
1260                    flowey_lib_hvlite::_jobs::build_and_publish_openhcl_igvm_from_recipe::Params {
1261                        igvm_files: igvm_recipes
1262                            .into_iter()
1263                            .map(|recipe| {
1264                                let pub_openhcl_igvm = pub_openhcl_igvms.remove(&recipe).unwrap();
1265                                let pub_openhcl_igvm_extras =
1266                                    pub_openhcl_igvms_extras.remove(&recipe).unwrap();
1267                                let vmfirmwareigvm_dll = if recipe == OpenhclIgvmRecipe::X64Cvm
1268                                    && arch == CommonArch::X86_64
1269                                {
1270                                    if mi_secure {
1271                                        pub_vmfirmwareigvm_cvm_mi_secure_x64.take()
1272                                    } else {
1273                                        pub_vmfirmwareigvm_cvm_x64.take()
1274                                    }
1275                                } else {
1276                                    None
1277                                };
1278                                // The size baseline always uses the standard recipe,
1279                                let baseline_artifact = match recipe {
1280                                    OpenhclIgvmRecipe::X64 | OpenhclIgvmRecipe::Aarch64 => {
1281                                        pub_openhcl_baseline.take()
1282                                    }
1283                                    _ => None,
1284                                };
1285                                (
1286                                    OpenhclIgvmBuildParams {
1287                                        profile: openvmm_hcl_profile,
1288                                        recipe,
1289                                        custom_target: Some(CommonTriple::Custom(
1290                                            openhcl_musl_target(arch),
1291                                        )),
1292                                        extra_features: if mi_secure {
1293                                            [OpenvmmHclFeature::MiSecure].into()
1294                                        } else {
1295                                            BTreeSet::new()
1296                                        },
1297                                        uefi_firmware_flavor: patina_nightly
1298                                            .then_some(FirmwareFlavor::PatinaClangPdb),
1299                                        // mi secure uses release_cfg=false to select dev manifests (with larger
1300                                        // VTL2 memory) since mi-secure adds overhead that may not fit in
1301                                        // the tighter release memory budget.
1302                                        release_cfg: release && !mi_secure,
1303                                        // Enable confidential diagnostics on the CVM IGVM
1304                                        // consumed by the VMM tests.
1305                                        confidential_debug: true,
1306                                    },
1307                                    OpenhclIgvmOutputs {
1308                                        openhcl_igvm: ctx.publish_typed_artifact(pub_openhcl_igvm),
1309                                        openhcl_igvm_extras: ctx
1310                                            .publish_typed_artifact(pub_openhcl_igvm_extras),
1311                                        vmfirmwareigvm_dll: vmfirmwareigvm_dll
1312                                            .map(|artifact| ctx.publish_typed_artifact(artifact)),
1313                                        artifact_openhcl_verify_size_baseline: baseline_artifact
1314                                            .map(|artifact| ctx.publish_typed_artifact(artifact)),
1315                                    },
1316                                )
1317                            })
1318                            .collect(),
1319                    }
1320                });
1321
1322            all_jobs.push(job.finish());
1323
1324            // TODO: Once we have a few runs of the openvmm-mirror PR pipeline, this job can be re-worked to use ADO artifacts instead of GH artifacts.
1325            if matches!(config, PipelineConfig::Pr)
1326                && !matches!(backend_hint, PipelineBackendHint::Ado)
1327                && !mi_secure
1328            {
1329                let job = pipeline
1330                    .new_job(
1331                        FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
1332                        FlowArch::X86_64,
1333                        format!("verify openhcl binary size [{}]", arch_tag),
1334                    )
1335                    .gh_set_pool(gh_pools::linux_x64_gh().0)
1336                    .side_effect(|done| {
1337                        flowey_lib_hvlite::_jobs::check_openvmm_hcl_size::Request {
1338                            target: CommonTriple::Common {
1339                                arch,
1340                                platform: CommonPlatform::LinuxMusl,
1341                            },
1342                            done,
1343                            pipeline_name: "openvmm-ci.yaml".into(),
1344                            job_name: build_openhcl_job_tag(arch_tag, mi_secure),
1345                        }
1346                    });
1347                all_jobs.push(job.finish());
1348            }
1349        }
1350
1351        // Emit clippy + unit-test jobs
1352        //
1353        // The only reason we bundle clippy and unit-tests together is to avoid
1354        // requiring another build agent.
1355        struct ClippyUnitTestJobParams<'a> {
1356            platform: FlowPlatform,
1357            arch: FlowArch,
1358            gh_pool: GhRunner,
1359            ado_pool: Option<AdoPool>,
1360            clippy_targets: Option<(&'a str, &'a [(Triple, bool)])>,
1361            unit_test_target: Option<(&'a str, Triple)>,
1362        }
1363
1364        let macos_clippy_targets = [(target_lexicon::triple!("aarch64-apple-darwin"), false)];
1365        let x64_linux_macos_clippy_targets = [
1366            (target_lexicon::triple!("x86_64-unknown-linux-gnu"), false),
1367            (target_lexicon::triple!("aarch64-apple-darwin"), false),
1368        ];
1369
1370        for ClippyUnitTestJobParams {
1371            platform,
1372            arch,
1373            gh_pool,
1374            ado_pool,
1375            clippy_targets,
1376            unit_test_target,
1377        } in [
1378            ClippyUnitTestJobParams {
1379                platform: FlowPlatform::Windows,
1380                arch: FlowArch::X86_64,
1381                gh_pool: gh_pools::windows_intel_v6_1es().0,
1382                ado_pool: Some(ado_pools::windows_amd_v6_1es()),
1383                clippy_targets: Some((
1384                    "x64-windows",
1385                    &[(target_lexicon::triple!("x86_64-pc-windows-msvc"), false)],
1386                )),
1387                unit_test_target: Some((
1388                    "x64-windows",
1389                    target_lexicon::triple!("x86_64-pc-windows-msvc"),
1390                )),
1391            },
1392            ClippyUnitTestJobParams {
1393                platform: FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
1394                arch: FlowArch::X86_64,
1395                gh_pool: gh_pools::linux_amd_v6_1es().0,
1396                ado_pool: Some(ado_pools::linux_amd_v6_1es()),
1397                clippy_targets: if quick_check_job.is_some() {
1398                    // quick check already ran clippy for x64-linux;
1399                    // still need macos cross-clippy here.
1400                    Some(("macos", macos_clippy_targets.as_slice()))
1401                } else {
1402                    Some((
1403                        "x64-linux, macos",
1404                        x64_linux_macos_clippy_targets.as_slice(),
1405                    ))
1406                },
1407                unit_test_target: Some((
1408                    "x64-linux",
1409                    target_lexicon::triple!("x86_64-unknown-linux-gnu"),
1410                )),
1411            },
1412            ClippyUnitTestJobParams {
1413                platform: FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
1414                arch: FlowArch::X86_64,
1415                gh_pool: gh_pools::linux_amd_v6_1es().0,
1416                ado_pool: Some(ado_pools::linux_amd_v6_1es()),
1417                clippy_targets: Some((
1418                    "x64-linux-musl, misc nostd",
1419                    &[(openhcl_musl_target(CommonArch::X86_64), true)],
1420                )),
1421                unit_test_target: Some(("x64-linux-musl", openhcl_musl_target(CommonArch::X86_64))),
1422            },
1423            ClippyUnitTestJobParams {
1424                platform: FlowPlatform::Windows,
1425                arch: FlowArch::Aarch64,
1426                gh_pool: gh_pools::windows_arm_v6_1es().0,
1427                ado_pool: None,
1428                clippy_targets: Some((
1429                    "aarch64-windows",
1430                    &[(target_lexicon::triple!("aarch64-pc-windows-msvc"), false)],
1431                )),
1432                unit_test_target: Some((
1433                    "aarch64-windows",
1434                    target_lexicon::triple!("aarch64-pc-windows-msvc"),
1435                )),
1436            },
1437            ClippyUnitTestJobParams {
1438                platform: FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
1439                arch: FlowArch::Aarch64,
1440                gh_pool: gh_pools::linux_arm_v5_1es().0,
1441                ado_pool: None,
1442                clippy_targets: Some((
1443                    "aarch64-linux",
1444                    &[(target_lexicon::triple!("aarch64-unknown-linux-gnu"), false)],
1445                )),
1446                unit_test_target: Some((
1447                    "aarch64-linux",
1448                    target_lexicon::triple!("aarch64-unknown-linux-gnu"),
1449                )),
1450            },
1451            ClippyUnitTestJobParams {
1452                platform: FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
1453                arch: FlowArch::Aarch64,
1454                gh_pool: gh_pools::linux_arm_v5_1es().0,
1455                ado_pool: None,
1456                clippy_targets: Some((
1457                    "aarch64-linux-musl, misc nostd",
1458                    &[(openhcl_musl_target(CommonArch::Aarch64), true)],
1459                )),
1460                unit_test_target: Some((
1461                    "aarch64-linux-musl",
1462                    openhcl_musl_target(CommonArch::Aarch64),
1463                )),
1464            },
1465        ] {
1466            // Skip unsupported jobs on ADO backend
1467            if matches!(backend_hint, PipelineBackendHint::Ado) && ado_pool.is_none() {
1468                continue;
1469            }
1470
1471            let mut job_name = Vec::new();
1472            if let Some((label, _)) = &clippy_targets {
1473                job_name.push(format!("clippy [{label}]"));
1474            }
1475            if let Some((label, _)) = &unit_test_target {
1476                job_name.push(format!("unit tests [{label}]"));
1477            }
1478            let job_name = job_name.join(", ");
1479
1480            let unit_test_target = unit_test_target.map(|(label, target)| {
1481                let test_label = format!("{label}-unit-tests");
1482                let pub_unit_test_junit_xml = if matches!(backend_hint, PipelineBackendHint::Local)
1483                {
1484                    Some(pipeline.new_artifact(&test_label).0)
1485                } else {
1486                    None
1487                };
1488                (test_label, target, pub_unit_test_junit_xml)
1489            });
1490
1491            let mut clippy_unit_test_job = pipeline
1492                .new_job(platform, arch, job_name)
1493                .gh_set_pool(gh_pool);
1494
1495            if let Some(pool) = ado_pool {
1496                clippy_unit_test_job = clippy_unit_test_job.ado_set_pool(pool);
1497            }
1498
1499            if let Some((_, targets)) = clippy_targets {
1500                for (target, also_check_misc_nostd_crates) in targets {
1501                    clippy_unit_test_job = clippy_unit_test_job.side_effect(|done| {
1502                        flowey_lib_hvlite::_jobs::check_clippy::Request {
1503                            target: target.clone(),
1504                            profile: CommonProfile::from_release(release),
1505                            done,
1506                            also_check_misc_nostd_crates: *also_check_misc_nostd_crates,
1507                        }
1508                    });
1509                }
1510            }
1511
1512            if let Some((test_label, target, pub_unit_test_junit_xml)) = unit_test_target {
1513                clippy_unit_test_job = clippy_unit_test_job
1514                    .dep_on(|ctx| {
1515                        flowey_lib_hvlite::_jobs::build_and_run_nextest_unit_tests::Params {
1516                            junit_test_label: test_label,
1517                            nextest_profile: NextestProfile::Ci,
1518                            fail_job_on_test_fail: true,
1519                            target: target.clone(),
1520                            profile: CommonProfile::from_release(release),
1521                            artifact_dir: pub_unit_test_junit_xml.map(|x| ctx.publish_artifact(x)),
1522                            done: ctx.new_done_handle(),
1523                        }
1524                    })
1525                    .side_effect(|done| {
1526                        flowey_lib_hvlite::_jobs::build_and_run_doc_tests::Params {
1527                            target,
1528                            profile: CommonProfile::from_release(release),
1529                            done,
1530                        }
1531                    });
1532            }
1533
1534            all_jobs.push(clippy_unit_test_job.finish());
1535        }
1536
1537        let vmm_tests_artifacts_windows_intel_x86 = vmm_tests_artifacts_windows_x86
1538            .clone()
1539            .finish()
1540            .map_err(|missing| {
1541                anyhow::anyhow!("missing required windows-intel vmm_tests artifact: {missing}")
1542            })?;
1543        let vmm_tests_artifacts_windows_intel_mi_secure_x86 = {
1544            let mut builder = vmm_tests_artifacts_windows_x86.clone();
1545            builder.use_vmfirmwareigvm_cvm_x64 = Some(use_vmfirmwareigvm_cvm_mi_secure_x64);
1546            builder.use_openhcl_standard_x64 = use_openhcl_igvm_files_mi_secure_x86
1547                .get(&OpenhclIgvmRecipe::X64)
1548                .cloned();
1549            builder.use_openhcl_cvm_x64 = use_openhcl_igvm_files_mi_secure_x86
1550                .get(&OpenhclIgvmRecipe::X64Cvm)
1551                .cloned();
1552            builder.use_openhcl_linux_direct_x64 = use_openhcl_igvm_files_mi_secure_x86
1553                .get(&OpenhclIgvmRecipe::X64TestLinuxDirect)
1554                .cloned();
1555            builder
1556        }
1557        .finish()
1558        .map_err(|missing| {
1559            anyhow::anyhow!(
1560                "missing required windows-intel-mi-secure vmm_tests artifact: {missing}"
1561            )
1562        })?;
1563        let vmm_tests_artifacts_windows_intel_tdx_x86 = vmm_tests_artifacts_windows_x86
1564            .clone()
1565            .finish()
1566            .map_err(|missing| {
1567                anyhow::anyhow!("missing required windows-intel-tdx vmm_tests artifact: {missing}")
1568            })?;
1569        let vmm_tests_artifacts_windows_amd_x86 = vmm_tests_artifacts_windows_x86
1570            .clone()
1571            .finish()
1572            .map_err(|missing| {
1573                anyhow::anyhow!("missing required windows-amd vmm_tests artifact: {missing}")
1574            })?;
1575        let vmm_tests_artifacts_windows_amd_snp_x86 = vmm_tests_artifacts_windows_x86
1576            .finish()
1577            .map_err(|missing| {
1578                anyhow::anyhow!("missing required windows-amd-snp vmm_tests artifact: {missing}")
1579            })?;
1580        let vmm_tests_artifacts_linux_snp_mshv_x86 = vmm_tests_artifacts_linux_musl_x86
1581            .clone()
1582            .finish()
1583            .map_err(|missing| {
1584                anyhow::anyhow!(
1585                    "missing required linux-snp-mshv (musl) vmm_tests artifact: {missing}"
1586                )
1587            })?;
1588        let vmm_tests_artifacts_linux_mshv_x86 = vmm_tests_artifacts_linux_musl_x86
1589            .finish()
1590            .map_err(|missing| {
1591                anyhow::anyhow!("missing required linux-mshv (musl) vmm_tests artifact: {missing}")
1592            })?;
1593        let vmm_tests_artifacts_linux_x86 =
1594            vmm_tests_artifacts_linux_x86.finish().map_err(|missing| {
1595                anyhow::anyhow!("missing required linux vmm_tests artifact: {missing}")
1596            })?;
1597        let vmm_tests_artifacts_windows_aarch64 = vmm_tests_artifacts_windows_aarch64
1598            .finish()
1599            .map_err(|missing| {
1600                anyhow::anyhow!("missing required windows-aarch64 vmm_tests artifact: {missing}")
1601            })?;
1602
1603        // Emit VMM tests runner jobs
1604        struct VmmTestJobParams<'a> {
1605            platform: FlowPlatform,
1606            arch: FlowArch,
1607            gh_pool: (GhRunner, NextestProfile),
1608            ado_pool: Option<AdoPool>,
1609            label: &'a str,
1610            target: CommonTriple,
1611            resolve_vmm_tests_artifacts: ResolveVmmTestsBuiltArtifacts,
1612            nextest_filter_expr: String,
1613            downloaded_artifacts: Vec<ErasedVmmTestImage>,
1614            prep_steps_variants: Vec<String>,
1615            external_deps: VmmTestsExternalDeps,
1616            prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections,
1617        }
1618
1619        let standard_filter = {
1620            // Standard VM-based CI machines should be able to run all tests except
1621            // those that require special hardware features (tdx/snp) or need to be
1622            // run on a baremetal host.
1623            let mut filter = "all()".to_string();
1624
1625            // Run "very_heavy" tests that require lots of VPs on the self-hosted
1626            // CVM runners that have more cores.
1627            filter.push_str(" & !test(very_heavy)");
1628
1629            // Even though VBS tests can run on standard CI machines, we exclude
1630            // them here to avoid needing to run prep_steps on non-self-hosted
1631            // runners. This saves several minutes of CI time that would be used
1632            // for very few tests. We need to run prep_steps on CVM runners
1633            // anyways, so we might as well run those tests there.
1634            //
1635            // Include other CVM flavors here so they show up in the inverse.
1636            filter.push_str(" & !test(vbs) & !test(snp) & !test(tdx)");
1637
1638            // Run PCAT tests on CVM runners to avoid downloading the Gen1 VHDs
1639            filter.push_str(" & !test(pcat)");
1640
1641            // Currently, we don't have a good way for ADO runners to authenticate in GitHub
1642            // (that don't involve PATs) which is a requirement to download GH Workflow Artifacts
1643            // required by the upgrade and downgrade servicing tests. For now,
1644            // we will exclude these tests from running in the internal mirror.
1645            if matches!(backend_hint, PipelineBackendHint::Ado) {
1646                filter.push_str(" & !(test(servicing) & (test(upgrade) + test(downgrade)))");
1647            }
1648
1649            // Run these tests on the cvm runners where we don't
1650            // need to download the extra VHDs (since they are cached).
1651            filter.push_str(
1652                " & !test(ubuntu_2404_server_x64) & !test(windows_datacenter_core_2025_x64)",
1653            );
1654
1655            filter
1656        };
1657
1658        let windows_x64_host_test_artifacts = vec![
1659            test_vhd::ALPINE_3_23_X64.into(),
1660            test_vhd::GEN2_WINDOWS_DATA_CENTER_CORE2022_X64.into(),
1661            test_vhd::UBUNTU_2404_SERVER_X64.into(),
1662            test_vhd::UBUNTU_2504_SERVER_X64.into(),
1663            test_vmgs::VMGS_WITH_BOOT_ENTRY.into(),
1664            test_vmgs::VMGS_WITH_16K_TPM.into(),
1665        ];
1666
1667        let linux_x64_host_test_artifacts = vec![
1668            test_vhd::ALPINE_3_23_X64.into(),
1669            test_vhd::GEN2_WINDOWS_DATA_CENTER_CORE2022_X64.into(),
1670            test_vhd::GEN2_WINDOWS_DATA_CENTER_CORE2025_X64.into(),
1671            test_vhd::UBUNTU_2404_SERVER_X64.into(),
1672            test_vhd::UBUNTU_2504_SERVER_X64.into(),
1673            test_vmgs::VMGS_WITH_BOOT_ENTRY.into(),
1674            test_vmgs::VMGS_WITH_16K_TPM.into(),
1675        ];
1676
1677        let linux_x64_emu_host_test_artifacts = {
1678            let mut artifacts = linux_x64_host_test_artifacts.clone();
1679            artifacts.extend_from_slice(&[
1680                test_vhd::ALPINE_3_23_AARCH64.into(),
1681                test_vhd::UBUNTU_2404_SERVER_AARCH64.into(),
1682            ]);
1683            artifacts
1684        };
1685
1686        // Prep variants needed by tests in the standard x64 filter
1687        // (e.g. boot_no_vmbus_windows needs the no-vmbus prepped VHD).
1688        let standard_x64_prep_variants: Vec<String> = vec!["no-vmbus".into()];
1689
1690        // Run the OpenHCL subset of the standard tests against the mi-secure
1691        // builds. Exclude tests that check OpenHCL memory usage against fixed
1692        // baselines, since mi-secure's guard pages change the memory usage.
1693        let mi_secure_filter = format!(
1694            "({standard_filter}) & test(openhcl) & !test(memory_validation) & !test(heuristic)"
1695        );
1696
1697        // Run everything that we didn't run in the standard filter
1698        let cvm_filter = format!("!({standard_filter})");
1699
1700        let windows_x64_cvm_test_artifacts = vec![
1701            test_vhd::FREE_BSD_13_2_X64.into(),
1702            test_iso::FREE_BSD_13_2_X64.into(),
1703            test_vhd::GEN1_WINDOWS_DATA_CENTER_CORE2022_X64.into(),
1704            test_vhd::GEN2_WINDOWS_DATA_CENTER_CORE2022_X64.into(),
1705            test_vhd::GEN2_WINDOWS_DATA_CENTER_CORE2025_X64.into(),
1706            test_vhd::UBUNTU_2404_SERVER_X64.into(),
1707            test_vhd::UBUNTU_2504_SERVER_X64.into(),
1708            test_vmgs::VMGS_WITH_16K_TPM.into(),
1709        ];
1710
1711        let standard_x64_prebuilt_artifacts = VmmTestsPreBuiltArtifactsSelections {
1712            test_linux_initrd_x64: true,
1713            test_linux_kernel_x64: true,
1714            test_linux_bzimage_x64: true,
1715            uefi_x64: true,
1716            release_openhcl_standard_x64: !matches!(backend_hint, PipelineBackendHint::Ado),
1717            release_openhcl_linux_direct_x64: !matches!(backend_hint, PipelineBackendHint::Ado),
1718            ..Default::default()
1719        };
1720
1721        for VmmTestJobParams {
1722            platform,
1723            arch,
1724            gh_pool,
1725            ado_pool,
1726            label,
1727            target,
1728            resolve_vmm_tests_artifacts,
1729            nextest_filter_expr,
1730            downloaded_artifacts,
1731            prep_steps_variants,
1732            external_deps,
1733            prebuilt_artifacts,
1734        } in [
1735            VmmTestJobParams {
1736                platform: FlowPlatform::Windows,
1737                arch: FlowArch::X86_64,
1738                gh_pool: gh_pools::windows_intel_v6_1es(),
1739                ado_pool: Some(ado_pools::windows_intel_v6_1es()),
1740                label: "x64-windows-intel",
1741                target: CommonTriple::X86_64_WINDOWS_MSVC,
1742                resolve_vmm_tests_artifacts: vmm_tests_artifacts_windows_intel_x86,
1743                nextest_filter_expr: standard_filter.clone(),
1744                downloaded_artifacts: windows_x64_host_test_artifacts.clone(),
1745                prep_steps_variants: standard_x64_prep_variants.clone(),
1746                external_deps: VmmTestsExternalDeps::Windows(VmmTestsExternalDepsWindows {
1747                    hyperv: true,
1748                    whp: true,
1749                    hardware_isolation: false,
1750                }),
1751                prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections {
1752                    mshv_test_kernel_x64: true,
1753                    ..standard_x64_prebuilt_artifacts.clone()
1754                },
1755            },
1756            VmmTestJobParams {
1757                platform: FlowPlatform::Windows,
1758                arch: FlowArch::X86_64,
1759                gh_pool: gh_pools::windows_intel_v6_1es(),
1760                ado_pool: Some(ado_pools::windows_intel_v6_1es()),
1761                label: "x64-windows-intel-mi-secure",
1762                target: CommonTriple::X86_64_WINDOWS_MSVC,
1763                resolve_vmm_tests_artifacts: vmm_tests_artifacts_windows_intel_mi_secure_x86,
1764                nextest_filter_expr: mi_secure_filter,
1765                downloaded_artifacts: windows_x64_host_test_artifacts.clone(),
1766                prep_steps_variants: Vec::new(),
1767                external_deps: VmmTestsExternalDeps::Windows(VmmTestsExternalDepsWindows {
1768                    hyperv: true,
1769                    whp: true,
1770                    hardware_isolation: false,
1771                }),
1772                prebuilt_artifacts: standard_x64_prebuilt_artifacts.clone(),
1773            },
1774            VmmTestJobParams {
1775                platform: FlowPlatform::Windows,
1776                arch: FlowArch::X86_64,
1777                gh_pool: gh_pools::windows_tdx_gnr_self_hosted_baremetal(),
1778                ado_pool: None,
1779                label: "x64-windows-intel-tdx",
1780                target: CommonTriple::X86_64_WINDOWS_MSVC,
1781                resolve_vmm_tests_artifacts: vmm_tests_artifacts_windows_intel_tdx_x86,
1782                nextest_filter_expr: cvm_filter.clone(),
1783                downloaded_artifacts: windows_x64_cvm_test_artifacts.clone(),
1784                prep_steps_variants: vec!["standard".into()],
1785                external_deps: VmmTestsExternalDeps::Windows(VmmTestsExternalDepsWindows {
1786                    hyperv: true,
1787                    whp: true,
1788                    hardware_isolation: true,
1789                }),
1790                prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections {
1791                    release_openhcl_linux_direct_x64: false,
1792                    ..standard_x64_prebuilt_artifacts.clone()
1793                },
1794            },
1795            VmmTestJobParams {
1796                platform: FlowPlatform::Windows,
1797                arch: FlowArch::X86_64,
1798                // a Windows hypervisor bug causes VMM tests to crash
1799                // when running on v7, so use v6
1800                gh_pool: gh_pools::windows_amd_v6_1es(),
1801                ado_pool: Some(ado_pools::windows_amd_v6_1es()),
1802                label: "x64-windows-amd",
1803                target: CommonTriple::X86_64_WINDOWS_MSVC,
1804                resolve_vmm_tests_artifacts: vmm_tests_artifacts_windows_amd_x86,
1805                nextest_filter_expr: standard_filter.clone(),
1806                downloaded_artifacts: windows_x64_host_test_artifacts.clone(),
1807                prep_steps_variants: standard_x64_prep_variants.clone(),
1808                external_deps: VmmTestsExternalDeps::Windows(VmmTestsExternalDepsWindows {
1809                    hyperv: true,
1810                    whp: true,
1811                    hardware_isolation: false,
1812                }),
1813                prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections {
1814                    mshv_test_kernel_x64: true,
1815                    ..standard_x64_prebuilt_artifacts.clone()
1816                },
1817            },
1818            VmmTestJobParams {
1819                platform: FlowPlatform::Windows,
1820                arch: FlowArch::X86_64,
1821                gh_pool: gh_pools::windows_snp_self_hosted_baremetal(),
1822                ado_pool: None,
1823                label: "x64-windows-amd-snp",
1824                target: CommonTriple::X86_64_WINDOWS_MSVC,
1825                resolve_vmm_tests_artifacts: vmm_tests_artifacts_windows_amd_snp_x86,
1826                // - Hyper-V VBS VMs fail on AMD with recent prerelease builds
1827                // TODO: re-enable once fixed.
1828                nextest_filter_expr: format!("{cvm_filter} & !(test(hyperv) & test(vbs))"),
1829                downloaded_artifacts: windows_x64_cvm_test_artifacts,
1830                prep_steps_variants: vec!["standard".into()],
1831                external_deps: VmmTestsExternalDeps::Windows(VmmTestsExternalDepsWindows {
1832                    hyperv: true,
1833                    whp: true,
1834                    hardware_isolation: true,
1835                }),
1836                prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections {
1837                    release_openhcl_linux_direct_x64: false,
1838                    ..standard_x64_prebuilt_artifacts.clone()
1839                },
1840            },
1841            VmmTestJobParams {
1842                platform: FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
1843                arch: FlowArch::X86_64,
1844                gh_pool: gh_pools::linux_amd_v7_1es(),
1845                ado_pool: Some(ado_pools::linux_amd_v6_1es()),
1846                label: "x64-linux-amd-kvm",
1847                target: CommonTriple::X86_64_LINUX_GNU,
1848                resolve_vmm_tests_artifacts: vmm_tests_artifacts_linux_x86,
1849                // - No legal way to obtain gen1 pcat blobs on non-msft linux machines
1850                nextest_filter_expr: "all() & !test(pcat)".into(),
1851                downloaded_artifacts: linux_x64_emu_host_test_artifacts.clone(),
1852                prep_steps_variants: standard_x64_prep_variants.clone(),
1853                external_deps: VmmTestsExternalDeps::Linux(VmmTestsExternalDepsLinux {
1854                    hugetlb_2mb_overcommit_pages: Some(HUGETLB_2MB_OVERCOMMIT_PAGES),
1855                    prepare_vhost_vsock: true,
1856                }),
1857                prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections {
1858                    test_linux_kernel_aarch64: true,
1859                    test_linux_kernel_cca_aarch64: true,
1860                    test_linux_initrd_aarch64: true,
1861                    uefi_aarch64: true,
1862                    qemu_system_aarch64_linux_x64: true,
1863                    mshv_test_kernel_x64: true,
1864                    release_openhcl_standard_x64: false,
1865                    ..standard_x64_prebuilt_artifacts
1866                },
1867            },
1868            VmmTestJobParams {
1869                platform: FlowPlatform::Linux(FlowPlatformLinuxDistro::AzureLinux),
1870                arch: FlowArch::X86_64,
1871                // mshv image needs to be updated to use nvme for v6+ skus
1872                gh_pool: gh_pools::linux_mshv_intel_v5_1es(),
1873                ado_pool: None,
1874                label: "x64-linux-intel-mshv",
1875                target: CommonTriple::X86_64_LINUX_MUSL,
1876                resolve_vmm_tests_artifacts: vmm_tests_artifacts_linux_mshv_x86,
1877                // - No legal way to obtain gen1 pcat blobs on non-msft linux machines
1878                // - No additional coverage gained by running qemu tests on mshv
1879                //   runners as well as kvm, since it is emulated.
1880                nextest_filter_expr: "all() & !test(pcat) & !test(qemu)".into(),
1881                downloaded_artifacts: linux_x64_host_test_artifacts.clone(),
1882                prep_steps_variants: standard_x64_prep_variants.clone(),
1883                external_deps: VmmTestsExternalDeps::Linux(VmmTestsExternalDepsLinux {
1884                    hugetlb_2mb_overcommit_pages: None,
1885                    prepare_vhost_vsock: true,
1886                }),
1887                prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections {
1888                    release_openhcl_standard_x64: false,
1889                    ..standard_x64_prebuilt_artifacts.clone()
1890                },
1891            },
1892            VmmTestJobParams {
1893                platform: FlowPlatform::Linux(FlowPlatformLinuxDistro::AzureLinux),
1894                arch: FlowArch::X86_64,
1895                gh_pool: gh_pools::linux_snp_mshv_self_hosted(),
1896                ado_pool: None,
1897                label: "x64-linux-amd-snp-mshv",
1898                target: CommonTriple::X86_64_LINUX_MUSL,
1899                resolve_vmm_tests_artifacts: vmm_tests_artifacts_linux_snp_mshv_x86,
1900                nextest_filter_expr: "test(linux_x64_snp)".to_string(),
1901                downloaded_artifacts: Vec::new(),
1902                prep_steps_variants: Vec::new(),
1903                external_deps: VmmTestsExternalDeps::Linux(VmmTestsExternalDepsLinux {
1904                    hugetlb_2mb_overcommit_pages: None,
1905                    prepare_vhost_vsock: false,
1906                }),
1907                prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections {
1908                    test_linux_kernel_x64: true,
1909                    test_linux_initrd_x64: true,
1910                    ..Default::default()
1911                },
1912            },
1913            VmmTestJobParams {
1914                platform: FlowPlatform::Windows,
1915                arch: FlowArch::Aarch64,
1916                gh_pool: gh_pools::windows_arm_self_hosted_baremetal(),
1917                ado_pool: None,
1918                label: "aarch64-windows",
1919                target: CommonTriple::AARCH64_WINDOWS_MSVC,
1920                resolve_vmm_tests_artifacts: vmm_tests_artifacts_windows_aarch64,
1921                nextest_filter_expr: "all()".to_string(),
1922                downloaded_artifacts: vec![
1923                    test_vhd::ALPINE_3_23_AARCH64.into(),
1924                    test_vhd::UBUNTU_2404_SERVER_AARCH64.into(),
1925                    test_vhd::WINDOWS_11_ENTERPRISE_AARCH64.into(),
1926                    test_vmgs::VMGS_WITH_BOOT_ENTRY.into(),
1927                    test_vmgs::VMGS_WITH_16K_TPM.into(),
1928                ],
1929                prep_steps_variants: Vec::new(),
1930                external_deps: VmmTestsExternalDeps::Windows(VmmTestsExternalDepsWindows {
1931                    hyperv: true,
1932                    whp: true,
1933                    hardware_isolation: false,
1934                }),
1935                prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections {
1936                    test_linux_kernel_aarch64: true,
1937                    test_linux_initrd_aarch64: true,
1938                    uefi_aarch64: true,
1939                    release_openhcl_standard_aarch64: !matches!(
1940                        backend_hint,
1941                        PipelineBackendHint::Ado
1942                    ),
1943                    ..Default::default()
1944                },
1945            },
1946        ] {
1947            // Skip unsupported jobs on ADO backend
1948            if matches!(backend_hint, PipelineBackendHint::Ado) && ado_pool.is_none() {
1949                continue;
1950            }
1951
1952            let test_label = format!("{label}-vmm-tests");
1953
1954            let (gh_pool, nextest_profile) = gh_pool;
1955
1956            let mut vmm_tests_run_job = pipeline
1957                .new_job(platform, arch, format!("run vmm-tests [{label}]"))
1958                .gh_set_pool(gh_pool);
1959
1960            if let Some(pool) = ado_pool {
1961                vmm_tests_run_job = vmm_tests_run_job.ado_set_pool(pool);
1962            }
1963
1964            // TODO: maybe this should be inferred
1965            let require_2mb_hugetlb = matches!(
1966                external_deps,
1967                VmmTestsExternalDeps::Linux(VmmTestsExternalDepsLinux {
1968                    hugetlb_2mb_overcommit_pages: Some(_),
1969                    ..
1970                })
1971            );
1972
1973            vmm_tests_run_job = vmm_tests_run_job.dep_on(|ctx| {
1974                flowey_lib_hvlite::_jobs::consume_and_test_nextest_vmm_tests_archive::Params {
1975                    junit_test_label: test_label,
1976                    target: target.as_triple(),
1977                    nextest_profile,
1978                    nextest_filter_expr: Some(nextest_filter_expr),
1979                    test_content_config: TestContentConfig::Uninitialized {
1980                        test_content_dir: None,
1981                        built_artifacts: resolve_vmm_tests_artifacts(ctx),
1982                        prebuilt_artifacts,
1983                        uefi_firmware_flavor: patina_nightly
1984                            .then_some(FirmwareFlavor::PatinaClangPdb),
1985                        needs_virtio_win_drivers: true,
1986                    },
1987                    downloaded_artifacts,
1988                    prep_steps_variants,
1989                    external_deps,
1990                    upload_logs_on_success: true,
1991                    fail_job_on_test_fail: true,
1992                    repetitions: std::num::NonZeroU64::new(1).unwrap(),
1993                    petri_params: PetriParams {
1994                        disable_remote_artifacts: true,
1995                        reuse_prepped_vhds: false,
1996                        require_2mb_hugetlb,
1997                    },
1998                    test_content_dir_as_repo_root: false,
1999                    done: ctx.new_done_handle(),
2000                }
2001            });
2002
2003            let vmm_tests_run_job = vmm_tests_run_job.finish();
2004            // The Windows SNP tests are unstable, so don't require them to pass before merging a PR.
2005            if label != "x64-windows-amd-snp" {
2006                all_jobs.push(vmm_tests_run_job);
2007            }
2008        }
2009
2010        if enable_vmm_perf {
2011            let runner_gnu =
2012                use_vmm_perf_runner_gnu_x64.context("missing x64 Linux GNU VMM.Perf runner")?;
2013            let runner_musl =
2014                use_vmm_perf_runner_musl_x64.context("missing x64 Linux MUSL VMM.Perf runner")?;
2015            let openvmm_gnu = use_vmm_perf_openvmm_gnu_x64
2016                .context("missing x64 Linux GNU OpenVMM artifact for VMM.Perf")?;
2017            let openvmm_musl = use_vmm_perf_openvmm_musl_x64
2018                .context("missing x64 Linux MUSL OpenVMM artifact for VMM.Perf")?;
2019            let runner_windows =
2020                use_vmm_perf_runner_windows_x64.context("missing x64 Windows VMM.Perf runner")?;
2021            let openvmm_windows = use_vmm_perf_openvmm_windows_x64
2022                .context("missing x64 Windows OpenVMM artifact for VMM.Perf")?;
2023            let runner_windows_aarch64 = use_vmm_perf_runner_windows_aarch64
2024                .context("missing ARM64 Windows VMM.Perf runner")?;
2025            let openvmm_windows_aarch64 = use_vmm_perf_openvmm_windows_aarch64
2026                .context("missing ARM64 Windows OpenVMM artifact for VMM.Perf")?;
2027            for (label, platform, flow_arch, target, pool, openvmm, runner, hugetlb_pages) in [
2028                (
2029                    "x64-linux-amd-kvm",
2030                    FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
2031                    FlowArch::X86_64,
2032                    CommonTriple::X86_64_LINUX_GNU,
2033                    gh_pools::linux_amd_v7_1es().0,
2034                    openvmm_gnu,
2035                    runner_gnu,
2036                    Some(HUGETLB_2MB_OVERCOMMIT_PAGES),
2037                ),
2038                (
2039                    "x64-linux-intel-mshv",
2040                    FlowPlatform::Linux(FlowPlatformLinuxDistro::AzureLinux),
2041                    FlowArch::X86_64,
2042                    CommonTriple::X86_64_LINUX_MUSL,
2043                    gh_pools::linux_mshv_intel_v5_1es().0,
2044                    openvmm_musl,
2045                    runner_musl,
2046                    None,
2047                ),
2048                (
2049                    "x64-windows-amd",
2050                    FlowPlatform::Windows,
2051                    FlowArch::X86_64,
2052                    CommonTriple::X86_64_WINDOWS_MSVC,
2053                    gh_pools::windows_amd_v6_1es().0,
2054                    openvmm_windows.clone(),
2055                    runner_windows.clone(),
2056                    None,
2057                ),
2058                (
2059                    "x64-windows-intel",
2060                    FlowPlatform::Windows,
2061                    FlowArch::X86_64,
2062                    CommonTriple::X86_64_WINDOWS_MSVC,
2063                    gh_pools::windows_intel_v6_1es().0,
2064                    openvmm_windows,
2065                    runner_windows,
2066                    None,
2067                ),
2068                (
2069                    "aarch64-windows",
2070                    FlowPlatform::Windows,
2071                    FlowArch::Aarch64,
2072                    CommonTriple::AARCH64_WINDOWS_MSVC,
2073                    gh_pools::windows_arm_self_hosted_baremetal().0,
2074                    openvmm_windows_aarch64,
2075                    runner_windows_aarch64,
2076                    None,
2077                ),
2078            ] {
2079                let job = pipeline
2080                    .new_job(platform, flow_arch, format!("run vmm-perf [{label}]"))
2081                    .gh_set_pool(pool)
2082                    .with_timeout_in_minutes(120)
2083                    .dep_on(|_| flowey_lib_hvlite::_jobs::cfg_versions::Request::Init)
2084                    .dep_on(
2085                        |ctx| flowey_lib_hvlite::_jobs::setup_and_run_vmm_perf::Params {
2086                            label: format!("{label}-vmm-perf"),
2087                            target: target.clone(),
2088                            runner: ctx.use_typed_artifact(&runner),
2089                            openvmm: ctx.use_typed_artifact(&openvmm),
2090                            profiles: flowey_lib_hvlite::run_vmm_perf::all_profiles(),
2091                            vm_sizes_json: None,
2092                            parameters_json: None,
2093                            runtime_archive: None,
2094                            root_dir: None,
2095                            hugetlb_2mb_overcommit_pages: hugetlb_pages,
2096                            done: ctx.new_done_handle(),
2097                        },
2098                    )
2099                    .finish();
2100                all_jobs.push(job);
2101            }
2102        }
2103
2104        // test the flowey local backend by running cargo xflowey build-igvm on x64
2105        {
2106            if matches!(backend_hint, PipelineBackendHint::Github) {
2107                let job = pipeline
2108                    .new_job(
2109                        FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
2110                        FlowArch::X86_64,
2111                        "test flowey local backend",
2112                    )
2113                    .gh_set_pool(gh_pools::linux_x64_gh().0)
2114                    .side_effect(|done| {
2115                        flowey_lib_hvlite::_jobs::test_local_flowey_build_igvm::Request {
2116                            base_recipe: OpenhclIgvmRecipe::X64,
2117                            done,
2118                        }
2119                    });
2120                all_jobs.push(job.finish());
2121            }
2122        }
2123
2124        // Build the vendored source tree without the repository's
2125        // `.packages/` provisioning, as a Linux distribution would.
2126        {
2127            let distro_build_job = pipeline
2128                .new_job(
2129                    FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
2130                    FlowArch::X86_64,
2131                    "build openvmm [distribution config, x64-linux-gnu]",
2132                )
2133                .gh_set_pool(gh_pools::linux_x64_gh().0)
2134                .ado_set_pool(ado_pools::default_linux())
2135                .side_effect(|done| {
2136                    flowey_lib_hvlite::_jobs::check_distro_build_from_checkout::Request { done }
2137                })
2138                .finish();
2139
2140            all_jobs.push(distro_build_job);
2141        }
2142
2143        // all jobs depend on the quick-check gate
2144        if let Some(ref quick_check) = quick_check_job {
2145            for job in all_jobs.iter() {
2146                pipeline.non_artifact_dep(job, quick_check);
2147            }
2148            all_jobs.push(quick_check.clone());
2149        }
2150
2151        if matches!(config, PipelineConfig::Pr)
2152            && matches!(backend_hint, PipelineBackendHint::Github)
2153        {
2154            // Add a job that depends on all others as a workaround for
2155            // https://github.com/orgs/community/discussions/12395.
2156            //
2157            // This workaround then itself requires _another_ workaround, requiring
2158            // the use of `gh_dangerous_override_if`, and some additional custom job
2159            // logic, to deal with https://github.com/actions/runner/issues/2566.
2160            //
2161            // TODO: Add a way for this job to skip flowey setup and become a true
2162            // no-op.
2163            let all_good_job = pipeline
2164                .new_job(
2165                    FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
2166                    FlowArch::X86_64,
2167                    "openvmm checkin gates",
2168                )
2169                .gh_set_pool(gh_pools::linux_x64_gh().0)
2170                // always run this job, regardless whether or not any previous jobs failed
2171                .gh_dangerous_override_if("always() && github.event.pull_request.draft == false")
2172                .gh_dangerous_global_env_var("ANY_JOBS_FAILED", "${{ contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'failure') }}")
2173                .side_effect(|done| flowey_lib_hvlite::_jobs::all_good_job::Params {
2174                    did_fail_env_var: "ANY_JOBS_FAILED".into(),
2175                    done,
2176                })
2177                .finish();
2178
2179            for job in all_jobs.iter() {
2180                pipeline.non_artifact_dep(&all_good_job, job);
2181            }
2182        }
2183
2184        if matches!(config, PipelineConfig::Ci)
2185            && matches!(backend_hint, PipelineBackendHint::Github)
2186        {
2187            let publish_vmgstool_job = pipeline
2188                .new_job(
2189                    FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
2190                    FlowArch::X86_64,
2191                    "publish vmgstool",
2192                )
2193                .gh_grant_permissions::<flowey_lib_common::publish_gh_release::Node>([(
2194                    GhPermission::Contents,
2195                    GhPermissionValue::Write,
2196                )])
2197                .gh_set_pool(gh_pools::linux_x64_gh().0)
2198                .dep_on(
2199                    |ctx| flowey_lib_hvlite::_jobs::publish_vmgstool_gh_release::Request {
2200                        vmgstools: vmgstools
2201                            .into_iter()
2202                            .map(|(t, v)| (t, ctx.use_typed_artifact(&v)))
2203                            .collect(),
2204                        done: ctx.new_done_handle(),
2205                    },
2206                )
2207                .finish();
2208
2209            // All other jobs must succeed in order to publish
2210            for job in all_jobs.iter() {
2211                pipeline.non_artifact_dep(&publish_vmgstool_job, job);
2212            }
2213        }
2214
2215        Ok(pipeline)
2216    }
2217}