@@ -3238,6 +3238,8 @@ mod tests {
3238
3238
// line (We tag the command line from cloud-hypervisor for that purpose).
3239
3239
// The third device is added to validate that hotplug works correctly since
3240
3240
// it is being added to the L2 VM through hotplugging mechanism.
3241
+ // Also, we pass-through a vitio-blk device to the L2 VM to test the 32-bit
3242
+ // vfio device support
3241
3243
fn test_vfio ( ) {
3242
3244
setup_vfio_network_interfaces ( ) ;
3243
3245
@@ -3263,7 +3265,7 @@ mod tests {
3263
3265
)
3264
3266
. expect ( "copying of cloud-init disk failed" ) ;
3265
3267
3266
- let mut vfio_disk_path = workload_path;
3268
+ let mut vfio_disk_path = workload_path. clone ( ) ;
3267
3269
vfio_disk_path. push ( "vfio.img" ) ;
3268
3270
3269
3271
// Create the vfio disk image
@@ -3279,6 +3281,9 @@ mod tests {
3279
3281
panic ! ( "mkfs.ext4 command generated an error" ) ;
3280
3282
}
3281
3283
3284
+ let mut blk_file_path = workload_path;
3285
+ blk_file_path. push ( "blk.img" ) ;
3286
+
3282
3287
let vfio_tap0 = "vfio-tap0" ;
3283
3288
let vfio_tap1 = "vfio-tap1" ;
3284
3289
let vfio_tap2 = "vfio-tap2" ;
@@ -3301,6 +3306,7 @@ mod tests {
3301
3306
)
3302
3307
. as_str ( ) ,
3303
3308
format ! ( "path={}" , vfio_disk_path. to_str( ) . unwrap( ) ) . as_str ( ) ,
3309
+ format ! ( "path={},iommu=on" , blk_file_path. to_str( ) . unwrap( ) ) . as_str ( ) ,
3304
3310
] )
3305
3311
. args ( & [
3306
3312
"--cmdline" ,
@@ -3374,27 +3380,38 @@ mod tests {
3374
3380
. trim( )
3375
3381
. parse:: <u32 >( )
3376
3382
. unwrap_or_default( ) ,
3377
- 7 ,
3383
+ 8 ,
3384
+ ) ;
3385
+
3386
+ // Check both if /dev/vdc exists and if the block size is 16M in L2 VM
3387
+ assert_eq ! (
3388
+ guest
3389
+ . ssh_command_l2_1( "lsblk | grep vdc | grep -c 16M" )
3390
+ . unwrap( )
3391
+ . trim( )
3392
+ . parse:: <u32 >( )
3393
+ . unwrap_or_default( ) ,
3394
+ 1
3378
3395
) ;
3379
3396
3380
3397
// Hotplug an extra virtio-net device through L2 VM.
3381
3398
guest. ssh_command_l1 (
3382
- "echo 0000:00:08 .0 | sudo tee /sys/bus/pci/devices/0000:00:08 .0/driver/unbind" ,
3399
+ "echo 0000:00:09 .0 | sudo tee /sys/bus/pci/devices/0000:00:09 .0/driver/unbind" ,
3383
3400
) . unwrap ( ) ;
3384
3401
guest
3385
3402
. ssh_command_l1 (
3386
- "echo 0000:00:08 .0 | sudo tee /sys/bus/pci/drivers/vfio-pci/bind" ,
3403
+ "echo 0000:00:09 .0 | sudo tee /sys/bus/pci/drivers/vfio-pci/bind" ,
3387
3404
)
3388
3405
. unwrap ( ) ;
3389
3406
let vfio_hotplug_output = guest
3390
3407
. ssh_command_l1 (
3391
3408
"sudo /mnt/ch-remote \
3392
3409
--api-socket=/tmp/ch_api.sock \
3393
- add-device path=/sys/bus/pci/devices/0000:00:08 .0,id=vfio123",
3410
+ add-device path=/sys/bus/pci/devices/0000:00:09 .0,id=vfio123",
3394
3411
)
3395
3412
. unwrap ( ) ;
3396
3413
assert ! (
3397
- vfio_hotplug_output. contains( "{\" id\" :\" vfio123\" ,\" bdf\" :\" 0000:00:07 .0\" }" )
3414
+ vfio_hotplug_output. contains( "{\" id\" :\" vfio123\" ,\" bdf\" :\" 0000:00:08 .0\" }" )
3398
3415
) ;
3399
3416
3400
3417
thread:: sleep ( std:: time:: Duration :: new ( 10 , 0 ) ) ;
@@ -3414,15 +3431,15 @@ mod tests {
3414
3431
3415
3432
// Check the amount of PCI devices appearing in L2 VM.
3416
3433
// There should be one more device than before, raising the count
3417
- // up to 8 PCI devices.
3434
+ // up to 9 PCI devices.
3418
3435
assert_eq ! (
3419
3436
guest
3420
3437
. ssh_command_l2_1( "ls /sys/bus/pci/devices | wc -l" )
3421
3438
. unwrap( )
3422
3439
. trim( )
3423
3440
. parse:: <u32 >( )
3424
3441
. unwrap_or_default( ) ,
3425
- 8 ,
3442
+ 9 ,
3426
3443
) ;
3427
3444
3428
3445
// Let's now verify that we can correctly remove the virtio-net
@@ -3438,15 +3455,15 @@ mod tests {
3438
3455
thread:: sleep ( std:: time:: Duration :: new ( 10 , 0 ) ) ;
3439
3456
3440
3457
// Check the amount of PCI devices appearing in L2 VM is back down
3441
- // to 7 devices.
3458
+ // to 8 devices.
3442
3459
assert_eq ! (
3443
3460
guest
3444
3461
. ssh_command_l2_1( "ls /sys/bus/pci/devices | wc -l" )
3445
3462
. unwrap( )
3446
3463
. trim( )
3447
3464
. parse:: <u32 >( )
3448
3465
. unwrap_or_default( ) ,
3449
- 7 ,
3466
+ 8 ,
3450
3467
) ;
3451
3468
3452
3469
// Perform memory hotplug in L2 and validate the memory is showing
0 commit comments