diff --git a/arch/src/lib.rs b/arch/src/lib.rs index 6e5f39d75f..a104902c55 100644 --- a/arch/src/lib.rs +++ b/arch/src/lib.rs @@ -1368,6 +1368,9 @@ pub struct SmbiosOptions { /// System product name. pub product_name: Option, + /// System serial number (free-form string). + pub serial_number: Option, + /// Additional OEM strings to add to SMBIOS table. #[serde(default)] pub oem_strings: Vec, diff --git a/x86_64/src/smbios.rs b/x86_64/src/smbios.rs index dc5ab11e40..90c58c63f1 100644 --- a/x86_64/src/smbios.rs +++ b/x86_64/src/smbios.rs @@ -237,6 +237,11 @@ pub fn setup_smbios(mem: &GuestMemory, options: &SmbiosOptions) -> Result<()> { handle, manufacturer: 1, // First string written in this section product_name: 2, // Second string written in this section + serial_number: if options.serial_number.is_some() { + 3 // Third string written in this section + } else { + 0 // Serial number not specified + }, ..Default::default() }; curptr = write_and_incr(mem, smbios_sysinfo, curptr)?; @@ -256,6 +261,9 @@ pub fn setup_smbios(mem: &GuestMemory, options: &SmbiosOptions) -> Result<()> { .unwrap_or(DEFAULT_SMBIOS_PRODUCT_NAME), curptr, )?; + if let Some(serial_number) = options.serial_number.as_deref() { + curptr = write_string(mem, serial_number, curptr)?; + } curptr = write_and_incr(mem, 0u8, curptr)?; }