Skip to content

apple: adopt DiskImageKit and add disposable mode on macOS 27 - #7880

Merged
osy merged 2 commits into
mainfrom
apple/diskimagekit
Sep 20, 2026
Merged

osy merged 2 commits into
mainfrom
apple/diskimagekit

Conversation

@osy

@osy osy commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Two commits that move Apple Virtualization drives onto DiskImageKit and use it to add "Run without saving changes" for Apple VMs on macOS 27.

asif: use DiskImageKit on macOS 27. ASIF drives were created, inspected and resized through the private DiskImages2 framework, loaded by path and called via NSInvocation. macOS 27 ships DiskImageKit, a public Swift-only framework that covers the same operations. A new UTMAppleDiskImage wrapper uses DiskImageKit on macOS 27 and later and falls back to the existing UTMASIFImage helper on macOS 13 through 26. The legacy path is confined to one private extension so it can be deleted together with UTMASIFImage once the minimum host is macOS 27. DiskImageKit is weak linked because the deployment target is below macOS 27.

apple: run without saving changes on macOS 27. Disposable mode was QEMU only (-snapshot). DiskImageKit can stack a copy-on-write layer on top of an image and Virtualization accepts the stacked image as a storage attachment. When started with the disposable option, the Apple backend creates a temporary directory in the sandbox and gives every writable drive an ephemeral ASIF overlay there; the base image is opened read-only and never touched. The EFI variable store and the macOS auxiliary storage are cloned into the same directory so firmware settings are not persisted either. The directory is deleted when the guest stops or start fails, leftovers are discarded before the next start, and directories orphaned by a crash are swept at launch. Removable drives attached at start or hot-plugged during the run are covered too. A disposable run boots fresh, leaves any saved suspend state alone, and reports save/restore as unsupported so closing the window offers to kill the VM instead of suspending it, matching QEMU. The context menu, the Start intent and the menu bar extra check the backend capability instead of assuming QEMU; AppleScript start … saving false and utmctl start --disposable work unchanged.

Resolves #4201
Resolves #7326

Testing

Testing: Tested by a human on macOS 27.0 (26A428), MacBook Air. The author acknowledges that this change has been tested and/or reviewed by a human in accordance with UTM's AI contribution guidelines.

Exercised on that machine: ASIF info, resize and creation through the drive settings; a disposable run of a macOS guest with the base image checksum, auxiliary storage and a pre-existing saved state left untouched; the kill-on-close dialog; overlay cleanup on stop; the launch-time sweep; a normal run restoring the saved state afterwards; the context menu entry and AppleScript start on an Apple VM. The macOS 26 fallback path was not exercised.

🤖 Generated with Claude Code

@osy osy added this to the v5.0 milestone Sep 18, 2026
osy added 2 commits September 19, 2026 10:49
ASIF drives for Apple Virtualization are created, inspected and resized
through the private DiskImages2 framework, loaded by path and called via
NSInvocation. macOS 27 ships DiskImageKit, a public Swift-only framework
that covers the same operations and is what Virtualization.framework now
consumes directly.

Add UTMAppleDiskImage, a Swift wrapper that uses DiskImageKit on macOS 27
and later and falls back to the existing UTMASIFImage helper on macOS 13
through 26. The legacy path is confined to one private extension so it
can be deleted together with UTMASIFImage once the minimum host is
macOS 27. DiskImageKit is weak linked because the deployment target is
below macOS 27.

Callers switch to the wrapper; the resize path no longer force-unwraps
the helper.

Assisted-by: Claude:claude-fable-5-1
"Run without saving changes" has only been available for QEMU, where it
maps to `-snapshot`. Apple Virtualization has no such option, but
DiskImageKit on macOS 27 can stack a copy-on-write layer on top of an
image and Virtualization accepts the stacked image as a storage
attachment.

When started with the disposable option, the Apple backend now creates a
temporary directory in the sandbox and gives every writable drive an
ephemeral ASIF overlay there. The base image is opened read-only and is
never touched. The EFI variable store and the macOS auxiliary storage are
cloned into the same directory so firmware settings are not persisted
either. The directory is deleted when the guest stops or when start
fails, any leftover from a previous start is discarded before the next
start, and directories orphaned by a crash are swept at app launch.
Removable drives attached at start or hot-plugged during the run are
covered as well.

A disposable run boots fresh and leaves any saved suspend state and the
modification date alone, and reports the save/restore path as
unsupported so closing the window offers to kill the VM instead of
suspending it, matching the QEMU behaviour. The stop paths that delete a
saved suspend state skip that while running disposably.

The context menu, the Start intent and the menu bar extra now check the
backend capability instead of assuming QEMU, and the Apple display window
shows the same "Disposable Mode" subtitle as QEMU.

Assisted-by: Claude:claude-fable-5-1
@osy
osy force-pushed the apple/diskimagekit branch from de1c416 to 3b0da37 Compare September 19, 2026 15:52
@osy
osy merged commit b58ac6b into main Sep 20, 2026
54 checks passed
@osy
osy deleted the apple/diskimagekit branch September 20, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apple backend does not support "without saving" option Run without saving changes does not work for Apple VM

1 participant