Skip to content

BaseChipsetBuilder should accept VmChipsetResult directly instead of piecemeal fields #3463

@moor-coding

Description

@moor-coding

Summary

VmManifestBuilder::build() returns a VmChipsetResult containing chipset (the manifest), chipset_devices, pci_chipset_devices, and capabilities. At every call site, that struct is immediately destructured and its fields are passed individually into BaseChipsetBuilder via separate builder calls:

// underhill_core/src/worker.rs (and openvmm_core/src/worker/dispatch.rs)
let VmChipsetResult {
    chipset,
    mut chipset_devices,
    pci_chipset_devices,
    capabilities,
} = chipset.build()?;

// ... later ...

BaseChipsetBuilder::new(foundation, devices)
    .with_expected_manifest(chipset)
    .with_device_handles(chipset_devices)
    .with_pci_device_handles(pci_chipset_devices)
    // ...
    .build(...)
    .await?;

This pattern appears in at least two places:

  • openhcl/underhill_core/src/worker.rs
  • openvmm/openvmm_core/src/worker/dispatch.rs

Proposed Change

1. BaseChipsetBuilder: accept VmChipsetResult directly

Add a with_vm_chipset_result(result: VmChipsetResult) method (or integrate it into BaseChipsetBuilder::new) so callers can pass the whole VmChipsetResult directly, eliminating the repetitive destructuring at each call site.

2. VmConfig in openvmm_core: consolidate chipset fields

VmConfig currently stores the VmChipsetResult fields split across separate fields:

  • chipset: BaseChipsetManifest
  • chipset_devices: Vec<ChipsetDeviceHandle>
  • pci_chipset_devices: Vec<LegacyPciChipsetDeviceHandle>
  • chipset_capabilities: VmChipsetCapabilities

These are effectively the same as VmChipsetResult. Replacing them with a single VmChipsetResult field would keep the two types in sync and reduce divergence risk.

Motivation

  • VmChipsetResult's fields were designed together and are produced together — splitting them apart at every consumer is accidental complexity.
  • If VmChipsetResult gains or loses fields in the future, each call site must be updated manually; a single with_vm_chipset_result call handles this automatically.
  • Reduces boilerplate at call sites.

Affected Files

  • vmm_core/vmotherboard/src/base_chipset.rs — add the new method
  • openhcl/underhill_core/src/worker.rs — update call site
  • openvmm/openvmm_core/src/worker/dispatch.rs — update call site and VmConfig
  • openvmm/openvmm_entry/src/lib.rs — update call site
  • petri/src/vm/openvmm/construct.rs — may need updating depending on how VmChipsetResult flows through

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions