Skip to content

Commit 4591a60

Browse files
authored
Add bootrom version to config files (#703)
Presently, the BIOS version string in Propolis' SMBIOS tables is hardcoded to a default value. It would be nice to instead use the OVMF version for the BIOS version string. Because Propolis' understanding of bootroms is just a path on the filesystem to some kind of file, it's not aware of the OVMF version, or, indeed, that the bootrom even *is* OVMF (and it could conceivably be anything). Therefore, the bootrom version must be provided externally, such as by the Oxide control plane in the case of `propolis-server`, or by the user when running standalone. This PR adds a config field `bootrom_version` to the TOML config files for `propolis-server` and `propolis-standalone` which can be used to provide a value for the bootrom version string. If the version string is not provided, Propolis will continue to use the current default values. I considered changing the config format to move the `bootrom` path field and `bootrom_version` string field into a `bootrom` table, as in: ```toml [bootrom] path = "/path/to/OVMF_CODE.fd" version = "edk2-stable202402" ``` However, this would break existing configs, and I don't think it's so much nicer than ```toml bootrom = "/path/to/OVMF_CODE.fd" bootrom_version = "edk2-stable202402" ```` to justify breakage. I'm happy to change the format if others disagree. Along with #702, this branch implements the changes described in #701.
1 parent 6d4fe85 commit 4591a60

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

bin/propolis-server/src/lib/initializer.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ pub struct MachineInitializer<'a> {
115115
pub(crate) crucible_backends: CrucibleBackendMap,
116116
pub(crate) spec: &'a InstanceSpecV0,
117117
pub(crate) properties: &'a InstanceProperties,
118+
pub(crate) toml_config: &'a crate::server::VmTomlConfig,
118119
pub(crate) producer_registry: Option<ProducerRegistry>,
119120
pub(crate) state: MachineInitializerState,
120121
}
@@ -857,9 +858,16 @@ impl<'a> MachineInitializer<'a> {
857858

858859
let rom_size =
859860
self.state.rom_size_bytes.expect("ROM is already populated");
861+
let bios_version = self
862+
.toml_config
863+
.bootrom_version
864+
.as_deref()
865+
.unwrap_or("v0.8")
866+
.try_into()
867+
.expect("bootrom version string doesn't contain NUL bytes");
860868
let smb_type0 = smbios::table::Type0 {
861869
vendor: "Oxide".try_into().unwrap(),
862-
bios_version: "v0.8".try_into().unwrap(),
870+
bios_version,
863871
bios_release_date: "The Aftermath 30, 3185 YOLD"
864872
.try_into()
865873
.unwrap(),

bin/propolis-server/src/lib/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use propolis_api_types::instance_spec::{
3434
VersionedInstanceSpec,
3535
};
3636

37-
use propolis_server_config::Config as VmTomlConfig;
37+
pub use propolis_server_config::Config as VmTomlConfig;
3838
use rfb::server::VncServer;
3939
use slog::{error, info, o, warn, Logger};
4040
use thiserror::Error;

bin/propolis-server/src/lib/vm/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ impl VmController {
456456
crucible_backends: CrucibleBackendMap::new(),
457457
spec: v0_spec,
458458
properties: &properties,
459+
toml_config,
459460
producer_registry,
460461
state: MachineInitializerState::default(),
461462
};

bin/propolis-standalone/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub struct Main {
4747
pub name: String,
4848
pub cpus: u8,
4949
pub bootrom: String,
50+
pub bootrom_version: Option<String>,
5051
pub memory: usize,
5152
pub use_reservoir: Option<bool>,
5253
pub cpuid_profile: Option<String>,

bin/propolis-standalone/src/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,16 +807,20 @@ fn populate_rom(
807807
struct SmbiosParams {
808808
memory_size: usize,
809809
rom_size: usize,
810+
rom_version: String,
810811
num_cpus: u8,
811812
cpuid_ident: Option<cpuid::Entry>,
812813
cpuid_procname: Option<[cpuid::Entry; 3]>,
813814
}
814815
fn generate_smbios(params: SmbiosParams) -> anyhow::Result<smbios::TableBytes> {
815816
use smbios::table::{type0, type1, type16, type4};
816-
817+
let bios_version = params
818+
.rom_version
819+
.try_into()
820+
.expect("bootrom version string doesn't contain NUL bytes");
817821
let smb_type0 = smbios::table::Type0 {
818822
vendor: "Oxide".try_into().unwrap(),
819-
bios_version: "v0.0.1 alpha1".try_into().unwrap(),
823+
bios_version,
820824
bios_release_date: "Bureaucracy 41, 3186 YOLD".try_into().unwrap(),
821825
bios_rom_size: ((params.rom_size / (64 * 1024)) - 1) as u8,
822826
bios_characteristics: type0::BiosCharacteristics::UNSUPPORTED,
@@ -1202,6 +1206,10 @@ fn setup_instance(
12021206
generate_smbios(SmbiosParams {
12031207
memory_size: memsize,
12041208
rom_size: rom_len,
1209+
rom_version: config
1210+
.main
1211+
.bootrom_version
1212+
.unwrap_or_else(|| "v0.0.1-alpha 1".to_string()),
12051213
num_cpus: cpus,
12061214
cpuid_ident,
12071215
cpuid_procname,

crates/propolis-server-config/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pub use cpuid_profile_config::CpuidProfile;
1818
pub struct Config {
1919
pub bootrom: PathBuf,
2020

21+
pub bootrom_version: Option<String>,
22+
2123
#[serde(default, rename = "pci_bridge")]
2224
pub pci_bridges: Vec<PciBridge>,
2325

@@ -37,6 +39,7 @@ impl Default for Config {
3739
fn default() -> Self {
3840
Self {
3941
bootrom: PathBuf::new(),
42+
bootrom_version: None,
4043
pci_bridges: Vec::new(),
4144
chipset: Chipset { options: BTreeMap::new() },
4245
devices: BTreeMap::new(),

0 commit comments

Comments
 (0)