mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
x86_64: add SMBIOS serial number option
Allows adding an optional serial number to the SMBIOS table. BUG=b:249382713 TEST=crosvm run --smbios serial-number=abcdef ... Change-Id: I00a00defb6904dbfa8ae38910b887e0a464787e3 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4761847 Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zihan Chen <zihanchen@google.com> Reviewed-by: Mike Gerow <gerow@google.com>
This commit is contained in:
parent
2422c65f3d
commit
54f80c60f1
2 changed files with 11 additions and 0 deletions
|
@ -1368,6 +1368,9 @@ pub struct SmbiosOptions {
|
||||||
/// System product name.
|
/// System product name.
|
||||||
pub product_name: Option<String>,
|
pub product_name: Option<String>,
|
||||||
|
|
||||||
|
/// System serial number (free-form string).
|
||||||
|
pub serial_number: Option<String>,
|
||||||
|
|
||||||
/// Additional OEM strings to add to SMBIOS table.
|
/// Additional OEM strings to add to SMBIOS table.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub oem_strings: Vec<String>,
|
pub oem_strings: Vec<String>,
|
||||||
|
|
|
@ -237,6 +237,11 @@ pub fn setup_smbios(mem: &GuestMemory, options: &SmbiosOptions) -> Result<()> {
|
||||||
handle,
|
handle,
|
||||||
manufacturer: 1, // First string written in this section
|
manufacturer: 1, // First string written in this section
|
||||||
product_name: 2, // Second 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()
|
..Default::default()
|
||||||
};
|
};
|
||||||
curptr = write_and_incr(mem, smbios_sysinfo, curptr)?;
|
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),
|
.unwrap_or(DEFAULT_SMBIOS_PRODUCT_NAME),
|
||||||
curptr,
|
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)?;
|
curptr = write_and_incr(mem, 0u8, curptr)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue