Skip to content

Commit f98c399

Browse files
authored
Merge pull request #2026 from AkihiroSuda/vz-cache
vz: use DiskImageCachingModeCached (rumored to fix disk corruption on ARM)
2 parents f3b4dec + 488c95c commit f98c399

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/vz/vm_darwin.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
3340
type 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

Comments
 (0)