@@ -23,7 +23,7 @@ def partuuid_and_disk_path_tmpfs(rootfs_ubuntu_22, tmp_path):
23
23
disk_path .unlink ()
24
24
25
25
26
- def test_rescan_file (test_microvm_with_api ):
26
+ def test_rescan_file (test_microvm_with_api , io_engine ):
27
27
"""
28
28
Verify that rescan works with a file-backed virtio device.
29
29
"""
@@ -39,7 +39,7 @@ def test_rescan_file(test_microvm_with_api):
39
39
fs = drive_tools .FilesystemFile (
40
40
os .path .join (test_microvm .fsfiles , "scratch" ), size = block_size
41
41
)
42
- test_microvm .add_drive ("scratch" , fs .path )
42
+ test_microvm .add_drive ("scratch" , fs .path , io_engine = io_engine )
43
43
44
44
test_microvm .start ()
45
45
@@ -64,7 +64,7 @@ def test_rescan_file(test_microvm_with_api):
64
64
_check_block_size (test_microvm .ssh , "/dev/vdb" , fs .size ())
65
65
66
66
67
- def test_device_ordering (test_microvm_with_api ):
67
+ def test_device_ordering (test_microvm_with_api , io_engine ):
68
68
"""
69
69
Verify device ordering.
70
70
@@ -78,7 +78,7 @@ def test_device_ordering(test_microvm_with_api):
78
78
fs1 = drive_tools .FilesystemFile (
79
79
os .path .join (test_microvm .fsfiles , "scratch1" ), size = 128
80
80
)
81
- test_microvm .add_drive ("scratch1" , fs1 .path )
81
+ test_microvm .add_drive ("scratch1" , fs1 .path , io_engine = io_engine )
82
82
83
83
# Set up the microVM with 1 vCPUs, 256 MiB of RAM and a root file system
84
84
# (this is the second block device added).
@@ -89,7 +89,7 @@ def test_device_ordering(test_microvm_with_api):
89
89
fs2 = drive_tools .FilesystemFile (
90
90
os .path .join (test_microvm .fsfiles , "scratch2" ), size = 512
91
91
)
92
- test_microvm .add_drive ("scratch2" , fs2 .path )
92
+ test_microvm .add_drive ("scratch2" , fs2 .path , io_engine = io_engine )
93
93
94
94
test_microvm .start ()
95
95
@@ -112,7 +112,7 @@ def test_device_ordering(test_microvm_with_api):
112
112
_check_block_size (ssh_connection , "/dev/vdc" , fs2 .size ())
113
113
114
114
115
- def test_rescan_dev (test_microvm_with_api ):
115
+ def test_rescan_dev (test_microvm_with_api , io_engine ):
116
116
"""
117
117
Verify that rescan works with a device-backed virtio device.
118
118
"""
@@ -125,7 +125,7 @@ def test_rescan_dev(test_microvm_with_api):
125
125
126
126
# Add a scratch block device.
127
127
fs1 = drive_tools .FilesystemFile (os .path .join (test_microvm .fsfiles , "fs1" ))
128
- test_microvm .add_drive ("scratch" , fs1 .path )
128
+ test_microvm .add_drive ("scratch" , fs1 .path , io_engine = io_engine )
129
129
130
130
test_microvm .start ()
131
131
@@ -152,7 +152,7 @@ def test_rescan_dev(test_microvm_with_api):
152
152
utils .run_cmd (["losetup" , "--detach" , loopback_device ])
153
153
154
154
155
- def test_non_partuuid_boot (test_microvm_with_api ):
155
+ def test_non_partuuid_boot (test_microvm_with_api , io_engine ):
156
156
"""
157
157
Test the output reported by blockdev when booting from /dev/vda.
158
158
"""
@@ -165,7 +165,7 @@ def test_non_partuuid_boot(test_microvm_with_api):
165
165
166
166
# Add another read-only block device.
167
167
fs = drive_tools .FilesystemFile (os .path .join (test_microvm .fsfiles , "readonly" ))
168
- test_microvm .add_drive ("scratch" , fs .path , is_read_only = True )
168
+ test_microvm .add_drive ("scratch" , fs .path , is_read_only = True , io_engine = io_engine )
169
169
170
170
test_microvm .start ()
171
171
@@ -183,7 +183,7 @@ def test_non_partuuid_boot(test_microvm_with_api):
183
183
_check_drives (test_microvm , assert_dict , keys_array )
184
184
185
185
186
- def test_partuuid_boot (test_microvm_with_api , partuuid_and_disk_path_tmpfs ):
186
+ def test_partuuid_boot (test_microvm_with_api , partuuid_and_disk_path_tmpfs , io_engine ):
187
187
"""
188
188
Test the output reported by blockdev when booting with PARTUUID.
189
189
"""
@@ -204,6 +204,7 @@ def test_partuuid_boot(test_microvm_with_api, partuuid_and_disk_path_tmpfs):
204
204
disk_path ,
205
205
is_root_device = True ,
206
206
partuuid = partuuid ,
207
+ io_engine = io_engine ,
207
208
)
208
209
test_microvm .start ()
209
210
@@ -216,7 +217,7 @@ def test_partuuid_boot(test_microvm_with_api, partuuid_and_disk_path_tmpfs):
216
217
_check_drives (test_microvm , assert_dict , keys_array )
217
218
218
219
219
- def test_partuuid_update (test_microvm_with_api ):
220
+ def test_partuuid_update (test_microvm_with_api , io_engine ):
220
221
"""
221
222
Test successful switching from PARTUUID boot to /dev/vda boot.
222
223
"""
@@ -229,14 +230,19 @@ def test_partuuid_update(test_microvm_with_api):
229
230
230
231
# Add the root block device specified through PARTUUID.
231
232
test_microvm .add_drive (
232
- "rootfs" , test_microvm .rootfs_file , is_root_device = True , partuuid = "0eaa91a0-01"
233
+ "rootfs" ,
234
+ test_microvm .rootfs_file ,
235
+ is_root_device = True ,
236
+ partuuid = "0eaa91a0-01" ,
237
+ io_engine = io_engine ,
233
238
)
234
239
235
240
# Update the root block device to boot from /dev/vda.
236
241
test_microvm .add_drive (
237
242
"rootfs" ,
238
243
test_microvm .rootfs_file ,
239
244
is_root_device = True ,
245
+ io_engine = io_engine ,
240
246
)
241
247
242
248
test_microvm .start ()
@@ -249,7 +255,7 @@ def test_partuuid_update(test_microvm_with_api):
249
255
_check_drives (test_microvm , assert_dict , keys_array )
250
256
251
257
252
- def test_patch_drive (test_microvm_with_api ):
258
+ def test_patch_drive (test_microvm_with_api , io_engine ):
253
259
"""
254
260
Test replacing the backing filesystem after guest boot works.
255
261
"""
@@ -261,10 +267,12 @@ def test_patch_drive(test_microvm_with_api):
261
267
test_microvm .add_net_iface ()
262
268
263
269
fs1 = drive_tools .FilesystemFile (os .path .join (test_microvm .fsfiles , "scratch" ))
264
- test_microvm .add_drive ("scratch" , fs1 .path )
270
+ test_microvm .add_drive ("scratch" , fs1 .path , io_engine = io_engine )
265
271
266
272
test_microvm .start ()
267
273
274
+ _check_mount (test_microvm .ssh , "/dev/vdb" )
275
+
268
276
# Updates to `path_on_host` with a valid path are allowed.
269
277
fs2 = drive_tools .FilesystemFile (
270
278
os .path .join (test_microvm .fsfiles , "otherscratch" ), size = 512
@@ -273,6 +281,8 @@ def test_patch_drive(test_microvm_with_api):
273
281
drive_id = "scratch" , path_on_host = test_microvm .create_jailed_resource (fs2 .path )
274
282
)
275
283
284
+ _check_mount (test_microvm .ssh , "/dev/vdb" )
285
+
276
286
# The `lsblk` command should output 2 lines to STDOUT: "SIZE" and the size
277
287
# of the device, in bytes.
278
288
blksize_cmd = "lsblk -b /dev/vdb --output SIZE"
@@ -284,7 +294,7 @@ def test_patch_drive(test_microvm_with_api):
284
294
assert lines [1 ].strip () == size_bytes_str
285
295
286
296
287
- def test_no_flush (test_microvm_with_api ):
297
+ def test_no_flush (test_microvm_with_api , io_engine ):
288
298
"""
289
299
Verify default block ignores flush.
290
300
"""
@@ -299,6 +309,7 @@ def test_no_flush(test_microvm_with_api):
299
309
"rootfs" ,
300
310
test_microvm .rootfs_file ,
301
311
is_root_device = True ,
312
+ io_engine = io_engine ,
302
313
)
303
314
test_microvm .start ()
304
315
@@ -317,7 +328,7 @@ def test_no_flush(test_microvm_with_api):
317
328
assert fc_metrics ["block" ]["flush_count" ] == 0
318
329
319
330
320
- def test_flush (uvm_plain_rw ):
331
+ def test_flush (uvm_plain_rw , io_engine ):
321
332
"""
322
333
Verify block with flush actually flushes.
323
334
"""
@@ -332,6 +343,7 @@ def test_flush(uvm_plain_rw):
332
343
test_microvm .rootfs_file ,
333
344
is_root_device = True ,
334
345
cache_type = "Writeback" ,
346
+ io_engine = io_engine ,
335
347
)
336
348
test_microvm .start ()
337
349
@@ -371,3 +383,10 @@ def _check_drives(test_microvm, assert_dict, keys_array):
371
383
_ , stdout , stderr = test_microvm .ssh .run ("blockdev --report" )
372
384
assert stderr == ""
373
385
_process_blockdev_output (stdout , assert_dict , keys_array )
386
+
387
+
388
+ def _check_mount (ssh_connection , dev_path ):
389
+ _ , _ , stderr = ssh_connection .run (f"mount { dev_path } /tmp" , timeout = 30.0 )
390
+ assert stderr == ""
391
+ _ , _ , stderr = ssh_connection .run ("umount /tmp" , timeout = 30.0 )
392
+ assert stderr == ""
0 commit comments