@@ -30,6 +30,13 @@ import (
3030 "github.com/sirupsen/logrus"
3131)
3232
33+ // diskImageCachingMode is set to DiskImageCachingModeCached so as to avoid disk corruption on ARM:
34+ // - https://github.com/utmapp/UTM/issues/4840#issuecomment-1824340975
35+ // - https://github.com/utmapp/UTM/issues/4840#issuecomment-1824542732
36+ //
37+ // Eventually we may bring this back to DiskImageCachingModeAutomatic when the corruption issue is properly fixed.
38+ const diskImageCachingMode = vz .DiskImageCachingModeCached
39+
3340type virtualMachineWrapper struct {
3441 * vz.VirtualMachine
3542 mu sync.Mutex
@@ -434,7 +441,7 @@ func attachDisks(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineConfigura
434441 if err = validateDiskFormat (diffDiskPath ); err != nil {
435442 return err
436443 }
437- diffDiskAttachment , err := vz .NewDiskImageStorageDeviceAttachmentWithCacheAndSync (diffDiskPath , false , vz . DiskImageCachingModeAutomatic , vz .DiskImageSynchronizationModeFsync )
444+ diffDiskAttachment , err := vz .NewDiskImageStorageDeviceAttachmentWithCacheAndSync (diffDiskPath , false , diskImageCachingMode , vz .DiskImageSynchronizationModeFsync )
438445 if err != nil {
439446 return err
440447 }
@@ -465,7 +472,7 @@ func attachDisks(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineConfigura
465472 if err = nativeimgutil .ConvertToRaw (extraDiskPath , extraDiskPath , nil , true ); err != nil {
466473 return fmt .Errorf ("failed to convert extra disk %q to a raw disk: %w" , extraDiskPath , err )
467474 }
468- extraDiskPathAttachment , err := vz .NewDiskImageStorageDeviceAttachmentWithCacheAndSync (extraDiskPath , false , vz . DiskImageCachingModeAutomatic , vz .DiskImageSynchronizationModeFsync )
475+ extraDiskPathAttachment , err := vz .NewDiskImageStorageDeviceAttachmentWithCacheAndSync (extraDiskPath , false , diskImageCachingMode , vz .DiskImageSynchronizationModeFsync )
469476 if err != nil {
470477 return fmt .Errorf ("failed to create disk attachment for extra disk %q: %w" , extraDiskPath , err )
471478 }
0 commit comments