Skip to content

Commit 64885b6

Browse files
RoyLinRoyLin
authored andcommitted
fix(macos): gate no_fsync field and initializers for macOS only
The no_fsync feature is specific to macOS HVF framework. This commit: 1. Gates the no_fsync field in FsDeviceConfig with #[cfg(target_os = "macos")] 2. Updates all FsDeviceConfig initializers to conditionally set no_fsync 3. Gates the set_no_fsync method for macOS only 4. Gates the call site in builder.rs for macOS only This fixes Linux build failures where no_fsync field doesn't exist in the Linux Config struct.
1 parent 43be2f0 commit 64885b6

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/libkrun/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ pub unsafe extern "C" fn krun_set_root(ctx_id: u32, c_root_path: *const c_char)
667667
shared_dir,
668668
// Default to a conservative 512 MB window.
669669
shm_size: Some(1 << 29),
670+
#[cfg(target_os = "macos")]
670671
no_fsync: false,
671672
});
672673
}
@@ -700,6 +701,7 @@ pub unsafe extern "C" fn krun_add_virtiofs(
700701
fs_id: tag.to_string(),
701702
shared_dir: path.to_string(),
702703
shm_size: None,
704+
#[cfg(target_os = "macos")]
703705
no_fsync: false,
704706
});
705707
}
@@ -734,6 +736,7 @@ pub unsafe extern "C" fn krun_add_virtiofs2(
734736
fs_id: tag.to_string(),
735737
shared_dir: path.to_string(),
736738
shm_size: Some(shm_size.try_into().unwrap()),
739+
#[cfg(target_os = "macos")]
737740
no_fsync: false,
738741
});
739742
}
@@ -2543,6 +2546,8 @@ pub unsafe extern "C" fn krun_set_root_disk_remount(
25432546
shared_dir: empty_root.to_string_lossy().into(),
25442547
// Default to a conservative 512 MB window.
25452548
shm_size: Some(1 << 29),
2549+
#[cfg(target_os = "macos")]
2550+
no_fsync: false,
25462551
});
25472552

25482553
ctx_cfg.set_block_root(device, fstype, options);

src/vmm/src/vmm_config/fs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ pub struct FsDeviceConfig {
33
pub fs_id: String,
44
pub shared_dir: String,
55
pub shm_size: Option<usize>,
6+
#[cfg(target_os = "macos")]
67
pub no_fsync: bool,
78
}

0 commit comments

Comments
 (0)