@@ -30,6 +30,13 @@ import (
30
30
"github.com/sirupsen/logrus"
31
31
)
32
32
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
+
33
40
type virtualMachineWrapper struct {
34
41
* vz.VirtualMachine
35
42
mu sync.Mutex
@@ -434,7 +441,7 @@ func attachDisks(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineConfigura
434
441
if err = validateDiskFormat (diffDiskPath ); err != nil {
435
442
return err
436
443
}
437
- diffDiskAttachment , err := vz .NewDiskImageStorageDeviceAttachmentWithCacheAndSync (diffDiskPath , false , vz . DiskImageCachingModeAutomatic , vz .DiskImageSynchronizationModeFsync )
444
+ diffDiskAttachment , err := vz .NewDiskImageStorageDeviceAttachmentWithCacheAndSync (diffDiskPath , false , diskImageCachingMode , vz .DiskImageSynchronizationModeFsync )
438
445
if err != nil {
439
446
return err
440
447
}
@@ -465,7 +472,7 @@ func attachDisks(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineConfigura
465
472
if err = nativeimgutil .ConvertToRaw (extraDiskPath , extraDiskPath , nil , true ); err != nil {
466
473
return fmt .Errorf ("failed to convert extra disk %q to a raw disk: %w" , extraDiskPath , err )
467
474
}
468
- extraDiskPathAttachment , err := vz .NewDiskImageStorageDeviceAttachmentWithCacheAndSync (extraDiskPath , false , vz . DiskImageCachingModeAutomatic , vz .DiskImageSynchronizationModeFsync )
475
+ extraDiskPathAttachment , err := vz .NewDiskImageStorageDeviceAttachmentWithCacheAndSync (extraDiskPath , false , diskImageCachingMode , vz .DiskImageSynchronizationModeFsync )
469
476
if err != nil {
470
477
return fmt .Errorf ("failed to create disk attachment for extra disk %q: %w" , extraDiskPath , err )
471
478
}
0 commit comments