@@ -7,6 +7,7 @@ use std::sync::Arc;
7
7
use anyhow:: Context ;
8
8
use cpuid_utils:: CpuidIdent ;
9
9
use propolis_client:: {
10
+ support:: nvme_serial_from_str,
10
11
types:: {
11
12
Board , BootOrderEntry , BootSettings , Chipset , ComponentV0 , Cpuid ,
12
13
CpuidEntry , CpuidVendor , InstanceMetadata , InstanceSpecV0 ,
@@ -313,6 +314,30 @@ impl<'dr> VmConfig<'dr> {
313
314
backend_name. clone ( ) . into_string ( ) ,
314
315
) ,
315
316
pci_path,
317
+ serial_number : nvme_serial_from_str (
318
+ 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.
339
+ 0 ,
340
+ ) ,
316
341
} ) ,
317
342
} ;
318
343
0 commit comments