Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2023 System Services

WWDC23 · 16 min · System Services

Create seamless experiences with Virtualization

Discover the latest updates to the Virtualization framework. We’ll show you how to configure a virtual machine (VM) to automatically resize its display, take you through saving and restoring a running VM, and explore storage and performance options for Virtualization apps running on the desktop or in the data center. To learn more about the Virtualization framework, check out “Create macOS or Linux virtual machines” from WWDC22.

Watch at developer.apple.com ↗

Transcript all transcripts

Chapters

  • 1:38 — Resize displays automatically
  • 2:33 — Save and restore virtual machines
  • 7:01 — Connect remote storage with Network Block Device
  • 10:30 — Meet the NVMe storage device
  • 11:48 — Add the Mac keyboard
  • 12:01 — Improve Rosetta 2 performance in Linux virtual machines

Code shown on screen · 5 snippets

Set display as resizable swift · at 1:58 ↗
// virtualMachine is a VZVirtualMachine.
let virtualMachineView = VZVirtualMachineView()
virtualMachineView.virtualMachine = virtualMachine

virtualMachineView.automaticallyReconfiguresDisplay = true
Save a virtual machine swift · at 4:20 ↗
// virtualMachine is a running VZVirtualMachine.
try await virtualMachine.pause()

let saveFileURL = URL(filePath: "SaveFile.vzvmsave", directoryHint: .notDirectory)
try await virtualMachine.saveMachineStateTo(url: saveFileURL)
Restore a virtual machine swift · at 4:58 ↗
let configuration = VZVirtualMachineConfiguration()
// Customize configuration.

let virtualMachine = VZVirtualMachine(configuration: configuration)

let saveFileURL = URL(filePath: "SaveFile.vzvmsave", directoryHint: .notDirectory)
try await virtualMachine.restoreMachineStateFrom(url: saveFileURL)

try await virtualMachine.resume()
Configure a Virtio block device with the NBD attachment swift · at 9:28 ↗
let url = URL(string: "nbd://localhost:10809/myDisk")!
let attachment = try VZNetworkBlockDeviceStorageDeviceAttachment(url: url)

let blockDevice = VZVirtioBlockDeviceConfiguration(attachment: attachment)
Respond to events with a delegate with the NBD attachment swift · at 10:02 ↗
let url = URL(string: "nbd://localhost:10809/myDisk")!
let attachment = try VZNetworkBlockDeviceStorageDeviceAttachment(url: url)

// NetworkBlockDeviceAttachmentDelegate implements the delegate protocol.
let delegate = NetworkBlockDeviceAttachmentDelegate()
attachment.delegate = delegate

let blockDevice = VZVirtioBlockDeviceConfiguration(attachment: attachment)

Resources