@@ -480,6 +480,38 @@ fn cleanup_domain(domain_name: &str) {
480480 }
481481}
482482
483+ /// Check if libvirt supports readonly virtiofs (requires libvirt 11.0+)
484+ /// Returns true if supported, false if not supported
485+ fn check_libvirt_supports_readonly_virtiofs ( ) -> Result < bool > {
486+ let bck = get_bck_command ( ) ?;
487+
488+ println ! ( "Checking libvirt capabilities..." ) ;
489+ let status_output = Command :: new ( & bck)
490+ . args ( & [ "libvirt" , "status" , "--format" , "json" ] )
491+ . output ( )
492+ . expect ( "Failed to get libvirt status" ) ;
493+
494+ if !status_output. status . success ( ) {
495+ let stderr = String :: from_utf8_lossy ( & status_output. stderr ) ;
496+ panic ! ( "Failed to get libvirt status: {}" , stderr) ;
497+ }
498+
499+ let status: serde_json:: Value =
500+ serde_json:: from_slice ( & status_output. stdout ) . expect ( "Failed to parse libvirt status JSON" ) ;
501+
502+ let supports_readonly = status[ "supports_readonly_virtiofs" ]
503+ . as_bool ( )
504+ . expect ( "Missing supports_readonly_virtiofs field in status output" ) ;
505+
506+ if !supports_readonly {
507+ println ! ( "Skipping test: libvirt does not support readonly virtiofs" ) ;
508+ println ! ( "libvirt version: {:?}" , status[ "version" ] ) ;
509+ println ! ( "Requires libvirt 11.0+ for readonly virtiofs support" ) ;
510+ }
511+
512+ Ok ( supports_readonly)
513+ }
514+
483515/// Wait for SSH to become available on a domain with a timeout
484516fn wait_for_ssh_available (
485517 domain_name : & str ,
@@ -636,35 +668,14 @@ static TEST_LIBVIRT_RUN_BIND_STORAGE_RO: IntegrationTest = IntegrationTest::new(
636668
637669/// Test container storage binding functionality end-to-end
638670fn test_libvirt_run_bind_storage_ro ( ) -> Result < ( ) > {
639- let bck = get_bck_command ( ) ?;
640- let test_image = get_test_image ( ) ;
641-
642- // First check if libvirt supports readonly virtiofs
643- println ! ( "Checking libvirt capabilities..." ) ;
644- let status_output = Command :: new ( & bck)
645- . args ( & [ "libvirt" , "status" , "--format" , "json" ] )
646- . output ( )
647- . expect ( "Failed to get libvirt status" ) ;
648-
649- if !status_output. status . success ( ) {
650- let stderr = String :: from_utf8_lossy ( & status_output. stderr ) ;
651- panic ! ( "Failed to get libvirt status: {}" , stderr) ;
652- }
653-
654- let status: serde_json:: Value =
655- serde_json:: from_slice ( & status_output. stdout ) . expect ( "Failed to parse libvirt status JSON" ) ;
656-
657- let supports_readonly = status[ "supports_readonly_virtiofs" ]
658- . as_bool ( )
659- . expect ( "Missing supports_readonly_virtiofs field in status output" ) ;
660-
661- if !supports_readonly {
662- println ! ( "Skipping test: libvirt does not support readonly virtiofs" ) ;
663- println ! ( "libvirt version: {:?}" , status[ "version" ] ) ;
664- println ! ( "Requires libvirt 11.0+ for readonly virtiofs support" ) ;
671+ // Check if libvirt supports readonly virtiofs (requires libvirt 11.0+)
672+ if !check_libvirt_supports_readonly_virtiofs ( ) ? {
665673 return Ok ( ( ) ) ;
666674 }
667675
676+ let bck = get_bck_command ( ) ?;
677+ let test_image = get_test_image ( ) ;
678+
668679 // Generate unique domain name for this test
669680 let domain_name = format ! (
670681 "test-bind-storage-{}" ,
@@ -1159,6 +1170,11 @@ fn test_libvirt_run_bind_mounts() -> Result<()> {
11591170 use std:: fs;
11601171 use tempfile:: TempDir ;
11611172
1173+ // Check if libvirt supports readonly virtiofs (requires libvirt 11.0+)
1174+ if !check_libvirt_supports_readonly_virtiofs ( ) ? {
1175+ return Ok ( ( ) ) ;
1176+ }
1177+
11621178 let test_image = get_test_image ( ) ;
11631179
11641180 // Generate unique domain name for this test
0 commit comments