From 27e486255265729ab4c322cae76abae3acfe2b7b Mon Sep 17 00:00:00 2001 From: MarvinDontPanic Date: Sat, 28 Mar 2026 11:12:31 -0400 Subject: [PATCH] fix: use cached disk mode for macOS guests to prevent APFS corruption The else branch for macOS guests was using the default cachingMode (.automatic), which causes APFS space manager corruption under heavy I/O. Apply the same .cached + .fsync fix that PR #332 applied to Linux guests. Fixes filesystem corruption where write() returns EILSEQ (errno 92) after sustained I/O workloads in macOS guest VMs. --- .../Helpers/VirtualMachineConfigurationHelper.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/VirtualCore/Source/Virtualization/Helpers/VirtualMachineConfigurationHelper.swift b/VirtualCore/Source/Virtualization/Helpers/VirtualMachineConfigurationHelper.swift index e600687e..773ec6b4 100644 --- a/VirtualCore/Source/Virtualization/Helpers/VirtualMachineConfigurationHelper.swift +++ b/VirtualCore/Source/Virtualization/Helpers/VirtualMachineConfigurationHelper.swift @@ -32,7 +32,9 @@ func createVZDiskImageStorageDeviceAttachment(url: URL, readOnly: Bool, guestTyp // fixes this IO errors and disk corruption issues for Linux guest. return try VZDiskImageStorageDeviceAttachment(url: url, readOnly: readOnly, cachingMode: .cached, synchronizationMode: .fsync) } else { - return try VZDiskImageStorageDeviceAttachment(url: url, readOnly: readOnly) + // macOS guests also need cached mode to prevent APFS corruption under heavy I/O. + // See: UTM #4840, Lima VM #1957 + return try VZDiskImageStorageDeviceAttachment(url: url, readOnly: readOnly, cachingMode: .cached, synchronizationMode: .fsync) } }