Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9a291d3

Browse files
committedDec 18, 2024·
rearrange explanatory comments
1 parent 857ae93 commit 9a291d3

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed
 

‎lib/propolis-client/src/support.rs

+16
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ impl Default for Chipset {
3030
/// Generates a 20-byte NVMe device serial number from the bytes in a string
3131
/// slice. If the slice is too short to populate the entire serial number, the
3232
/// remaining bytes are filled with `pad`.
33+
///
34+
/// NOTE: Version 1.2.1 of the NVMe specification (June 5, 2016) specifies in
35+
/// section 1.5 that ASCII data fields, including serial numbers, must be
36+
/// left-justified and must use 0x20 bytes (spaces) as the padding value. This
37+
/// function allows callers to choose a non-0x20 padding value to preserve the
38+
/// serial numbers for existing disks, which serial numbers may have been used
39+
/// previously and persisted into a VM's nonvolatile EFI variables (such as its
40+
/// boot order variables).
41+
//
42+
// TODO(#790): Ideally, this routine would have no `pad` parameter at all and
43+
// would always pad with spaces, but whether this is ultimately possible depends
44+
// on whether Omicron can start space-padding serial numbers for disks that were
45+
// attached to a Propolis VM that zero-padded their serial numbers.
3346
pub fn nvme_serial_from_str(s: &str, pad: u8) -> [u8; 20] {
3447
let mut sn = [0u8; 20];
3548

@@ -600,5 +613,8 @@ mod test {
600613
nvme_serial_from_str("very_long_disk_name_goes_here", b'?'),
601614
*expected
602615
);
616+
617+
let expected = b"nonvolatile EFI\0\0\0\0\0";
618+
assert_eq!(nvme_serial_from_str("nonvolatile EFI", 0), *expected);
603619
}
604620
}

‎phd-tests/framework/src/test_vm/config.rs

+5-20
Original file line numberDiff line numberDiff line change
@@ -316,26 +316,11 @@ impl<'dr> VmConfig<'dr> {
316316
pci_path,
317317
serial_number: nvme_serial_from_str(
318318
device_name.as_str(),
319-
// TODO(#790): Propolis's NVMe controller used to pad
320-
// serial numbers with 0 bytes by default. This causes
321-
// disk serial numbers to appear in the guest to be
322-
// null-terminated strings. This, in turn, affects (or
323-
// at least may affect) how guest firmware images
324-
// identify disks when determining a VM's boot order: a
325-
// disk whose serial number is padded to 20 bytes with
326-
// spaces may not match a disk whose serial number was
327-
// padded with \0 bytes.
328-
//
329-
// Unfortunately for us, guest firmware may persist disk
330-
// identifiers to a VM's nonvolatile EFI variable store.
331-
// This means that changing from zero-padded to
332-
// space-padded serial numbers may break an existing
333-
// VM's saved boot order.
334-
//
335-
// Until we decide whether and how to preserve
336-
// compatibility for existing VMs that may have
337-
// preserved a zero-padded disk ID, continue to zero-pad
338-
// disk IDs in PHD to match previous behavior.
319+
// Omicron supplies (or will supply, as of this writing)
320+
// 0 as the padding byte to maintain compatibility for
321+
// existing disks. Match that behavior here so that PHD
322+
// and Omicron VM configurations are as similar as
323+
// possible.
339324
0,
340325
),
341326
}),

0 commit comments

Comments
 (0)
Please sign in to comment.