File tree 2 files changed +10
-8
lines changed
2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -34,13 +34,13 @@ pub struct VmSpec {
34
34
}
35
35
36
36
impl VmSpec {
37
- /// Yields an array of handles to this VM's Crucible disks.
38
- pub fn get_crucible_disks ( & self ) -> Vec < Arc < dyn disk:: DiskConfig > > {
37
+ pub fn get_disk_by_device_name (
38
+ & self ,
39
+ name : & str ,
40
+ ) -> Option < & Arc < dyn disk:: DiskConfig > > {
39
41
self . disk_handles
40
42
. iter ( )
41
- . filter ( |d| d. as_crucible ( ) . is_some ( ) )
42
- . cloned ( )
43
- . collect ( )
43
+ . find ( |disk| disk. device_name ( ) . as_str ( ) == name)
44
44
}
45
45
46
46
/// Update the Crucible backend specs in the instance spec to match the
Original file line number Diff line number Diff line change @@ -95,8 +95,9 @@ async fn vcr_replace_test(ctx: &Framework) {
95
95
// necessary because Crucible doesn't permit VCR replacements for volumes
96
96
// whose read-only parents are local files (which is true for artifact-based
97
97
// Crucible disks).
98
+ const DATA_DISK_NAME : & str = "vcr-replacement-target" ;
98
99
config. data_disk (
99
- "vcr-replacement-target" ,
100
+ DATA_DISK_NAME ,
100
101
DiskSource :: Blank ( 1024 * 1024 * 1024 ) ,
101
102
DiskInterface :: Nvme ,
102
103
DiskBackend :: Crucible {
@@ -107,8 +108,9 @@ async fn vcr_replace_test(ctx: &Framework) {
107
108
) ;
108
109
109
110
let spec = config. vm_spec ( ctx) . await ?;
110
- let disks = spec. get_crucible_disks ( ) ;
111
- let disk = disks[ 0 ] . as_crucible ( ) . unwrap ( ) ;
111
+ let disk_hdl =
112
+ spec. get_disk_by_device_name ( DATA_DISK_NAME ) . cloned ( ) . unwrap ( ) ;
113
+ let disk = disk_hdl. as_crucible ( ) . unwrap ( ) ;
112
114
113
115
let mut vm = ctx. spawn_vm_with_spec ( spec, None ) . await ?;
114
116
vm. launch ( ) . await ?;
You can’t perform that action at this time.
0 commit comments