@@ -132,10 +132,11 @@ impl<'dr> VmConfig<'dr> {
132132 self
133133 }
134134
135- /// Add a new disk to the VM config, and add it to the front of the VM's boot order.
135+ /// Add a new disk to the VM config, and add it to the front of the VM's
136+ /// boot order.
136137 ///
137- /// The added disk will have the name `boot-disk`, and replace the previous existing
138- /// `boot-disk`.
138+ /// The added disk will have the name `boot-disk`, and replace the previous
139+ /// existing `boot-disk`.
139140 pub fn boot_disk (
140141 & mut self ,
141142 artifact : & ' dr str ,
@@ -207,28 +208,37 @@ impl<'dr> VmConfig<'dr> {
207208 } )
208209 . context ( "serializing Propolis server config" ) ?;
209210
210- // The first disk in the boot list might not be the disk a test *actually* expects to boot.
211+ // The first disk in the boot list might not be the disk a test
212+ // *actually* expects to boot.
211213 //
212- // If there are multiple bootable disks in the boot order, we'll assume they're all
213- // the same guest OS kind. So look for `boot-disk` - if there isn't a disk named
214- // `boot-disk` then fall back to hoping the first disk in the boot order is a bootable
215- // disk, and if *that* isn't a bootable disk, maybe the first disk is.
214+ // If there are multiple bootable disks in the boot order, we'll assume
215+ // they're all the same guest OS kind. So look for `boot-disk` - if
216+ // there isn't a disk named `boot-disk` then fall back to hoping the
217+ // first disk in the boot order is a bootable disk, and if *that* isn't
218+ // a bootable disk, maybe the first disk is.
216219 //
217- // TODO: theoretically we might want to accept configuration of a specific guest OS adapter
218- // and avoid the guessing games. So far the above supports existing tests and makes them
219- // "Just Work", but a more complicated test may want more control here.
220- let boot_disk =
221- self . disks . iter ( ) . find ( |d| d. name == "boot-disk" )
222- . or_else ( || if let Some ( boot_order) = self . boot_order . as_ref ( ) {
223- boot_order. first ( ) . and_then ( |name| self . disks . iter ( ) . find ( |d| & d. name == name) )
220+ // TODO: theoretically we might want to accept configuration of a
221+ // specific guest OS adapter and avoid the guessing games. So far the
222+ // above supports existing tests and makes them "Just Work", but a more
223+ // complicated test may want more control here.
224+ let boot_disk = self
225+ . disks
226+ . iter ( )
227+ . find ( |d| d. name == "boot-disk" )
228+ . or_else ( || {
229+ if let Some ( boot_order) = self . boot_order . as_ref ( ) {
230+ boot_order. first ( ) . and_then ( |name| {
231+ self . disks . iter ( ) . find ( |d| & d. name == name)
232+ } )
224233 } else {
225234 None
226- } )
227- . or_else ( || self . disks . first ( ) )
228- . expect ( "VM config includes at least one disk (and maybe a boot order)?" ) ;
235+ }
236+ } )
237+ . or_else ( || self . disks . first ( ) )
238+ . expect ( "VM config includes at least one disk" ) ;
229239
230- // XXX: assuming all bootable images are equivalent to the first, or at least the same
231- // guest OS kind.
240+ // XXX: assuming all bootable images are equivalent to the first, or at
241+ // least the same guest OS kind.
232242 let DiskSource :: Artifact ( boot_artifact) = boot_disk. source else {
233243 unreachable ! ( "boot disks always use artifacts as sources" ) ;
234244 } ;
@@ -242,7 +252,6 @@ impl<'dr> VmConfig<'dr> {
242252 let mut disk_handles = Vec :: new ( ) ;
243253 for disk in self . disks . iter ( ) {
244254 disk_handles. push (
245- // format!("data-disk-{}", idx)
246255 make_disk ( disk. name . to_owned ( ) , framework, disk)
247256 . await
248257 . context ( "creating disk" ) ?,
0 commit comments