Open
Conversation
We need to tell macOS the emulated drive is an SSD *and* run `trimforce enable` in the guest because we can't emulate a specific (i.e. Apple-approved) drive.
To prevent the `qcow2` image file from inevitably ballooning or expanding on the host, we need to tell qcow2 image format block driver to unmap on discard/TRIM. Due to how `qcow2` sparse images integrate with SSD TRIM (a.k.a. "`discard`"), we also must set `discard=unmap`, and `detect-zeroes=unmap`. However, these parameters are usually specified on the block device, so we must fallback to the more declarative `-blockdev ...` + `-device ...` form of QEMU CLI args to specify them [^1]. For example: ```console # need to specify 'discard=unmap, detect-zeroes=unmap' on blockdev -blockdev driver=qcow2,node-name=MacHDD,file.driver=file,file.filename="$REPO_PATH/mac_hdd_ng.img",file.aio=threads,discard=unmap,detect-zeroes=unmap -device ide-hd,bus=sata.4,drive=MacHDD,id=macssd,rotation_rate=1 ``` [^1]: See: [_QEMU User Documentation: Block device options_][1] or `man qemu` "_Block device options_" section: > The most explicit way to describe disks is to use a combination of > `-device` to specify the hardware device and `-blockdev` to describe the > backend. The device defines what the guest sees and the backend describes how > QEMU handles the data. _**It is the only guaranteed stable interface for > describing block devices and as such is recommended for management tools and scripting**_. > The `-drive` option combines the device and backend into a single command line > option which is a more human friendly. There is however > _no interface stability guarantee_ although some older board models still need > updating to work with the modern `blockdev` forms. Signed-off-by: James Cuzella <james.cuzella@lyraphase.com> Suggested-by: Daniel Collins <solemnwarning@solemnwarning.net>
Signed-off-by: James Cuzella <james.cuzella@lyraphase.com>
Signed-off-by: James Cuzella <james.cuzella@lyraphase.com>
Contributor
|
@kholia is there a reason this wasn't merged? |
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.
This PR incorporates and supercedes #259
Changes