@@ -28,17 +28,32 @@ class TestEXTSRCreateDestroy:
2828 def test_create_sr_with_missing_device (self , host ):
2929 try_to_create_sr_with_missing_device ('ext' , 'EXT-local-SR-test' , host )
3030
31- def test_create_and_destroy_sr (self , host : Host , unused_512B_disks : dict [Host , list [Host .BlockDeviceInfo ]]) -> None :
31+ def test_create_and_destroy_sr (self , host : Host ,
32+ unused_512B_disks : dict [Host , list [Host .BlockDeviceInfo ]],
33+ image_format : str
34+ ) -> None :
3235 # Create and destroy tested in the same test to leave the host as unchanged as possible
3336 sr_disk = unused_512B_disks [host ][0 ]["name" ]
34- sr = host .sr_create ('ext' , "EXT-local-SR-test" , {'device' : '/dev/' + sr_disk }, verify = True )
37+ sr = host .sr_create ('ext' , "EXT-local-SR-test" ,
38+ {'device' : '/dev/' + sr_disk ,
39+ 'preferred-image-formats' : image_format }, verify = True )
3540 # import a VM in order to detect vm import issues here rather than in the vm_on_xfs_fixture used in
3641 # the next tests, because errors in fixtures break teardown
3742 vm = host .import_vm (vm_image ('mini-linux-x86_64-bios' ), sr_uuid = sr .uuid )
3843 vm .destroy (verify = True )
3944 sr .destroy (verify = True )
4045
41- @pytest .mark .usefixtures ("ext_sr" )
46+ # We want to skip class tests for qcow2 if the SM does not support qcow2
47+ @pytest .fixture (scope = "class" )
48+ def for_qcow2_vdi_image_format (vdi_on_ext_sr : VDI , image_format : str ):
49+ # only check qcow2-specific behavior
50+ if image_format != "qcow2" :
51+ return
52+ # feature-detect: if the SM doesn't report image-format, skip this check
53+ if not vdi_on_ext_sr .get_image_format ():
54+ pytest .skip ("SM does not report sm-config:image-format; skipping qcow2 format check" )
55+
56+ @pytest .mark .usefixtures ("for_qcow2_vdi_image_format" , "ext_sr" )
4257class TestEXTSR :
4358 @pytest .mark .quicktest
4459 def test_quicktest (self , ext_sr ):
0 commit comments