@@ -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
@@ -295,6 +321,14 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
295321 . run ( )
296322 . with_context ( || format ! ( "Copying tmt files to {}" , workdir) ) ?;
297323
324+ // Workaround for https://github.com/bootc-dev/bcvk/issues/174
325+ // Save the container image to tar, this will be synced to tested OS
326+ if variant_id == "coreos" {
327+ cmd ! ( sh, "podman save -q -o {workdir}/tmt/tests/bootc.tar localhost/bootc-integration-coreos:latest" )
328+ . run ( )
329+ . with_context ( || format ! ( "Saving container image to tar" ) ) ?;
330+ }
331+
298332 // Change to workdir for running tmt commands
299333 let _dir = sh. push_dir ( workdir) ;
300334
@@ -387,7 +421,12 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
387421 distro
388422 ) ;
389423 }
390-
424+ // Add --filesystem=xfs by default on fedora-coreos
425+ if variant_id == "coreos" {
426+ if distro. starts_with ( "fedora" ) {
427+ opts. push ( "--filesystem=xfs" . to_string ( ) ) ;
428+ }
429+ }
391430 opts
392431 } ;
393432
@@ -406,7 +445,6 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
406445 test_results. push ( ( plan. to_string ( ) , false , None ) ) ;
407446 continue ;
408447 }
409-
410448 // Ensure VM cleanup happens even on error (unless --preserve-vm is set)
411449 let cleanup_vm = || {
412450 if preserve_vm {
0 commit comments