@@ -28,17 +28,33 @@ class TestLVMSRCreateDestroy:
2828 def test_create_sr_with_missing_device (self , host ):
2929 try_to_create_sr_with_missing_device ('lvm' , 'LVM-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 sr_disk = unused_512B_disks [host ][0 ]["name" ]
3336 # Create and destroy tested in the same test to leave the host as unchanged as possible
34- sr = host .sr_create ('lvm' , "LVM-local-SR-test" , {'device' : '/dev/' + sr_disk }, verify = True )
37+ sr = host .sr_create ('lvm' , "LVM-local-SR-test" , {
38+ 'device' : '/dev/' + sr_disk ,
39+ 'preferred-image-formats' : image_format
40+ }, verify = True )
3541 # import a VM in order to detect vm import issues here rather than in the vm_on_xfs_fixture used in
3642 # the next tests, because errors in fixtures break teardown
3743 vm = host .import_vm (vm_image ('mini-linux-x86_64-bios' ), sr_uuid = sr .uuid )
3844 vm .destroy (verify = True )
3945 sr .destroy (verify = True )
4046
41- @pytest .mark .usefixtures ("lvm_sr" )
47+ # We want to skip class tests for qcow2 if the SM does not support qcow2
48+ @pytest .fixture (scope = "class" )
49+ def for_qcow2_vdi_image_format (vdi_on_lvm_sr : VDI , image_format : str ):
50+ # only check qcow2-specific behavior
51+ if image_format != "qcow2" :
52+ return
53+ # feature-detect: if the SM doesn't report image-format, skip this check
54+ if not vdi_on_lvm_sr .get_image_format ():
55+ pytest .skip ("SM does not report sm-config:image-format; skipping qcow2 format check" )
56+
57+ @pytest .mark .usefixtures ("for_qcow2_vdi_image_format" , "lvm_sr" )
4258class TestLVMSR :
4359 @pytest .mark .quicktest
4460 def test_quicktest (self , lvm_sr ):
0 commit comments