Contents

DiskImage

The representation of an open disk image

Declaration

class DiskImage

Overview

To use a disk image as storage for virtual machine, use this object with the Virtualization API method init(diskImage:cachingMode:synchronizationMode:). In addition, it contains properties that describe the disk image and operations to manipulate it.

An image can either be standalone or part of a stack. For more information on stacked disk image, see StackedImage.

The following example demonstrates how to create a stacked disk image with 3 layers:

// Open the base image.
let baseImage = try DiskImage(opening: .open(url: baseImageURL))

// Append a new cache layer,
var stackedImage = try baseImage.appending(.asifLayer(url: cacheURL, type: .cache))

// Append an existing overlay layer,
let overlayImage = try DiskImage(opening: .open(url: overlayURL))
stackedImage = try stackedImage.appending(overlayImage)

// Append a new overlay layer.
stackedImage = try stackedImage.appending(.asifLayer(url: overlayURL, type: .overlay))

The example demonstrates how to create a standalone, 512 GB (1 billion block) ASIF disk image:

_ = try DiskImage(creating: .asif(url: imageURL, blockCount: 1000000000, blockSize: .bytes512))

Topics

Protocols

Structures

Initializers

Instance Properties

Instance Methods

Enumerations

See Also

Essential Types