@@ -137,6 +137,25 @@ fn build_firmware_args(sh: &Shell, image: &str) -> Result<Vec<String>> {
137137 Ok ( r)
138138}
139139
140+ /// Detect VARIANT_ID from container image by reading os-release
141+ /// Returns string like "coreos" or empty
142+ #[ context( "Detecting distro from image" ) ]
143+ fn detect_variantid_from_image ( sh : & Shell , image : & str ) -> Result < Option < String > > {
144+ let variant_id = cmd ! (
145+ sh,
146+ "podman run --rm {image} bash -c '. /usr/lib/os-release && echo $VARIANT_ID'"
147+ )
148+ . read ( )
149+ . context ( "Failed to run image as container to detect distro" ) ?;
150+
151+ let variant_id = variant_id. trim ( ) ;
152+ if variant_id. is_empty ( ) {
153+ return Ok ( None ) ;
154+ }
155+
156+ Ok ( Some ( variant_id. to_string ( ) ) )
157+ }
158+
140159/// Check if a distro supports --bind-storage-ro
141160/// CentOS 9 lacks systemd.extra-unit.* support required for bind-storage-ro
142161fn distro_supports_bind_storage_ro ( distro : & str ) -> bool {
@@ -269,18 +288,25 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
269288
270289 // Detect distro from the image
271290 let distro = detect_distro_from_image ( sh, image) ?;
291+ // Detect VARIANT_ID from the image
292+ // As this can not be empty value in context, use "unknown" instead
293+ let variant_id = detect_variantid_from_image ( sh, image) ?. unwrap_or ( "unknown" . to_string ( ) ) ;
272294
273295 let context = args
274296 . context
275297 . iter ( )
276298 . map ( |v| format ! ( "--context={}" , v) )
277299 . chain ( std:: iter:: once ( format ! ( "--context=running_env=image_mode" ) ) )
278300 . chain ( std:: iter:: once ( format ! ( "--context=distro={}" , distro) ) )
301+ . chain ( std:: iter:: once ( format ! (
302+ "--context=VARIANT_ID={variant_id}"
303+ ) ) )
279304 . collect :: < Vec < _ > > ( ) ;
280305 let preserve_vm = args. preserve_vm ;
281306
282307 println ! ( "Using bcvk image: {}" , image) ;
283308 println ! ( "Detected distro: {}" , distro) ;
309+ println ! ( "Detected VARIANT_ID: {variant_id}" ) ;
284310
285311 let firmware_args = build_firmware_args ( sh, image) ?;
286312
@@ -387,7 +413,16 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
387413 distro
388414 ) ;
389415 }
390-
416+ // Add --filesystem=xfs by default on fedora-coreos
417+ // Add --bind-storage-ro if supported
418+ if variant_id == "coreos" {
419+ if distro. starts_with ( "fedora" ) {
420+ opts. push ( "--filesystem=xfs" . to_string ( ) ) ;
421+ }
422+ if supports_bind_storage_ro {
423+ opts. push ( BCVK_OPT_BIND_STORAGE_RO . to_string ( ) ) ;
424+ }
425+ }
391426 opts
392427 } ;
393428
0 commit comments