init(diskImage:cachingMode:synchronizationMode:)
Initializes the attachment from a disk image.
Declaration
convenience init(diskImage: DiskImage, cachingMode: VZDiskImageCachingMode = .automatic, synchronizationMode: VZDiskImageSynchronizationMode = .full) throwsParameters
- diskImage:
A diskImage object created using the Diskimagekit framework. It supports both single and stacked disk images.
- cachingMode:
The host-level Vzdiskimagecachingmode policy for the disk image. This is independent of cache layers in the disk image stack.
- synchronizationMode:
How the disk image synchronizes with the underlying storage when the guest operating system flushes data, described by one of the available Vzdiskimagesynchronizationmode modes.
Discussion
This initializer enables the use of DiskImage objects created with the DiskImageKit framework, including stacked images with cache and overlay layers.
The following example shows how to initialize a storage attachment object using a disk image.
import Virtualization
let imageURL = // A `URL` that references a disk image.
let diskImage = try DiskImage(opening: .init(url: imageURL))
let storageAttachment = try VZDiskImageStorageDeviceAttachment(diskImage: diskImage)