1313
1414if TYPE_CHECKING :
1515 from lib .host import Host
16+ from lib .vdi import VDI
1617
1718# Requirements:
1819# - one XCP-ng host >= 8.2 with an additional unused disk for the SR
@@ -27,15 +28,19 @@ class TestXFSSRCreateDestroy:
2728
2829 def test_create_xfs_sr_without_xfsprogs (self ,
2930 host : Host ,
30- unused_512B_disks : dict [Host , list [Host .BlockDeviceInfo ]]
31+ unused_512B_disks : dict [Host , list [Host .BlockDeviceInfo ]],
32+ image_format : str
3133 ) -> None :
3234 # This test must be the first in the series in this module
3335 assert not host .file_exists ('/usr/sbin/mkfs.xfs' ), \
3436 "xfsprogs must not be installed on the host at the beginning of the tests"
3537 sr_disk = unused_512B_disks [host ][0 ]["name" ]
3638 sr = None
3739 try :
38- sr = host .sr_create ('xfs' , "XFS-local-SR-test" , {'device' : '/dev/' + sr_disk })
40+ sr = host .sr_create ('xfs' , "XFS-local-SR-test" , {
41+ 'device' : '/dev/' + sr_disk ,
42+ 'preferred-image-formats' : image_format
43+ })
3944 except Exception :
4045 logging .info ("SR creation failed, as expected." )
4146 if sr is not None :
@@ -56,7 +61,17 @@ def test_create_and_destroy_sr(self,
5661 vm .destroy (verify = True )
5762 sr .destroy (verify = True )
5863
59- @pytest .mark .usefixtures ("xfs_sr" )
64+ # We want to skip class tests for qcow2 if the SM does not support qcow2
65+ @pytest .fixture (scope = "class" )
66+ def for_qcow2_vdi_image_format (vdi_on_xfs_sr : VDI , image_format : str ):
67+ # only check qcow2-specific behavior
68+ if image_format != "qcow2" :
69+ return
70+ # feature-detect: if the SM doesn't report image-format, skip this check
71+ if not vdi_on_xfs_sr .get_image_format ():
72+ pytest .skip ("SM does not report sm-config:image-format; skipping qcow2 format check" )
73+
74+ @pytest .mark .usefixtures ("for_qcow2_vdi_image_format" , "xfs_sr" )
6075class TestXFSSR :
6176 @pytest .mark .quicktest
6277 def test_quicktest (self , xfs_sr ):
0 commit comments