-
-
Notifications
You must be signed in to change notification settings - Fork 73
feat: add ASIF support (macOS 26.0) #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! I've only made one comment. It's mostly LGTM.
| // | ||
| // Note that ASIF is only available from macOS Tahoe, so the function will return error | ||
| // on earlier versions. | ||
| func CreateSparseDiskImage(ctx context.Context, pathname string, size int64) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nagypeterjob Could you add test for this function?
A simple test to verify these points is sufficient:
- Whether a disk image file is created
- Whether the format is ASIF
- Whether it is created at the specified size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will do it in a day or two 🙇🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There you go @Code-Hex, let me know if you need any changes 🙇🏻
|
|
||
| var sizeStr string | ||
| for _, line := range strings.Split(string(output), "\n") { | ||
| if strings.Contains(line, "Total Bytes") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to get the total "logical" size from the diskutil image info <image_path> output, otherwise stat.Size and even syscall.Stat_t returns the "real" size of the disk, which is close to 0 given currently empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left 1 comment 🙇
| path := filepath.Join(dir, "sparse_disk.img") | ||
|
|
||
| ctx := context.Background() | ||
| size := int64(1024 * 1024 * 1024) // 1 GiB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Occupying 1 GB for testing is not good - can't you do something like 1 KB, 1 MB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The image is supposed to be sparse, so I’d expect it will use a few MBs on disk at most.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cfergeau thats right, de "real" disk size the image claims is negligible, given its empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nagypeterjob I see Thanks!
|
I merge this PR. Thanks! @nagypeterjob |
Which issue(s) this PR fixes:
Not an issue but discussion:
#189
Additional documentation
The PR adds support for the new Apple Sparse Image Format introduced by Tahoe (still beta). Currently the only known way of creating ASIF images is via
diskutil.Tested on:
Testing evidence:
The VM runs with ASIF disk as well:

I don't think we need to update any header files, as the
VZDiskImageStorageDeviceAttachmentandVZVirtioBlockDeviceConfigurationinterfaces did not change.Let me know if you need anything else to accept the PR 🙇🏻