[英]Apple Hypervisor is completely broken on MacOS Big Sur beta 11.0.1
I am trying to make a basic command-line tool that makes a VM and runs something using Apple Hypervisor.我正在尝试制作一个基本的命令行工具,该工具可以制作 VM 并使用 Apple Hypervisor 运行某些东西。
When I try to run hv_vm_create(HV_VM_DEFAULT)
it gives me an error code -85377023.当我尝试运行
hv_vm_create(HV_VM_DEFAULT)
它给了我一个错误代码 -85377023。
I tried enforcing App Sandbox and setting the entitlement accordingly for the Big Sur compile target, and now I am getting this output in the console:我尝试强制执行 App Sandbox 并相应地为 Big Sur 编译目标设置权利,现在我在控制台中得到了这个输出:
Killed
From what I understand from this, this is AMFI killing my process.据我了解,这是 AMFI 扼杀了我的进程。 Is this a bug or my problem?
这是错误还是我的问题?
When I decided to go down the rabbit hole, I found that in the MacOS Big Sur 11.0.1 beta release notes, they deprecated hv_vm_run(_:)
, while the API documentation says that this function is in beta.当我决定深入研究时,我发现在 MacOS Big Sur 11.0.1 测试版发行说明中,他们弃用了
hv_vm_run(_:)
,而 API 文档说该功能处于测试阶段。
I didn't go as far as disabling AMFI with a kernel flag, but I am almost certain that this is not expected behavior.我没有使用内核标志禁用 AMFI,但我几乎可以肯定这不是预期的行为。 And that, no matter what,
hv_vm_run(_:)
can never be deprecated OR be in beta.而且,无论如何,
hv_vm_run(_:)
永远不会被弃用或处于测试阶段。 I am sure that this function existed well before Big Sur.我确信这个功能在 Big Sur 之前就已经存在了。
If anyone can help me with this or just give a response, please do.如果有人可以帮助我解决这个问题或只是做出回应,请这样做。 Do not keep me in darkness as I don't want to waste time on something which is potentially broken.
不要让我陷入黑暗,因为我不想在可能损坏的东西上浪费时间。
Thank you.谢谢你。
PS: I know that there is already a thread in the Apple Developer forums, I am the one who posted it. PS:我知道苹果开发者论坛上已经有一个帖子了,我是发帖的人。 Though, no one is answering there because their community is not even close to being as large as Stack Overflow.
尽管如此,没有人回答那里,因为他们的社区甚至没有 Stack Overflow 那么大。
This error code you're seeing is just a poor UX on the macOS side: what it's really trying to communicate is that the com.apple.security.hypervisor
entitlement is missing.您看到的这个错误代码只是 macOS 方面的一个糟糕的用户体验:它真正想要传达的是缺少
com.apple.security.hypervisor
权利。
If you're using Xcode, you can add it like that:如果您使用的是 Xcode,则可以像这样添加它:
com.apple.security.hypervisor
and a boolean value set to YES
.com.apple.security.hypervisor
且布尔值设置为YES
的新属性。 Alternatively, you can use command line:或者,您可以使用命令行:
codesign -s - --entitlements app.entitlements --force path/to/your/binary
Where app.entitlements
contents is as follows:其中
app.entitlements
内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.hypervisor</key>
<true/>
</dict>
</plist>
The other way you to solve this is to simply set the Deployment Target to 10.13
in the Xcode's settings (props to Alexander Pinske ):解决此问题的另一种方法是简单地在 Xcode 的设置中将部署目标设置为
10.13
(支持Alexander Pinske ):
The reason this works is most likely due to backwards-compatibility, so bear in mind that this might change in the future macOS releases, or, perhaps, on newly introduced platforms like Apple Silicon.这样做的原因很可能是由于向后兼容性,因此请记住,这可能会在未来的 macOS 版本中发生变化,或者可能在 Apple Silicon 等新推出的平台上发生变化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.