apple: adopt DiskImageKit and add disposable mode on macOS 27 - #7880
Merged
Merged
Conversation
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
force-pushed
the
apple/diskimagekit
branch
from
September 19, 2026 15:52
de1c416 to
3b0da37
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 newUTMAppleDiskImagewrapper uses DiskImageKit on macOS 27 and later and falls back to the existingUTMASIFImagehelper on macOS 13 through 26. The legacy path is confined to one private extension so it can be deleted together withUTMASIFImageonce 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; AppleScriptstart … saving falseandutmctl start --disposablework 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