Live data from Hacker News

Apple Virtualization Framework

developer.apple.com

91–100 of 127 posts

Re: Apple Virtualization Framework

#91
post #57

Earlier quoted context omitted.

Mach was designed to run multiple OS interfaces in the same way that Windows NT was - multiple compatibility layers on top of a common kernel (e.g. WSL1). What is being discussed here is virtualization, for which Mach is no more suited than Linux, Windows, Sys V Unix etc.

Mach was designed to make clean separation between operating systems and hardware. Notice how easily Apple moves between hardware? The unsung hero is Mach and the design patterns that NeXT/Apple framework built on top of it.

There is nothing special about Mach/xnu here and it is not helping anything.

Re: Apple Virtualization Framework

#92
post #57

Earlier quoted context omitted.

Mach was designed to run multiple OS interfaces in the same way that Windows NT was - multiple compatibility layers on top of a common kernel (e.g. WSL1). What is being discussed here is virtualization, for which Mach is no more suited than Linux, Windows, Sys V Unix etc.

Mach was designed to make clean separation between operating systems and hardware. Notice how easily Apple moves between hardware? The unsung hero is Mach and the design patterns that NeXT/Apple framework built on top of it.

That is largely due to a mix of Apple's investment in emulation technologies, and Apple's ability to exert influence on third party developers and vendors to keep up with their latest tooling. Very little to do with the Mach kernel.

The ability to move between hardware platforms also has very little do with the ability to run operating systems in virtualization. Case in point is that Apple is one of the last major OSes to include a hypervisor in the OS.

Re: Apple Virtualization Framework

#93
Apple Virtualization Framework is a nice tool (option offered in particular by the UTM application in addition to Qemu option). And I hope it will improve with the release of the successor to Ventura and offer, for example, nested virtualization.

The only concern currently, besides for virtualized macOS the lack of support for iCloud accounts, is that it contains a number of bugs which make it difficult to use as is for non-English/US configurations.

Thus, there is a bug with ISO keyboards, which are recognized by Apple virtualization framework as ANSI keyboards, which shifts or even makes a certain number of keys disappear (different depending on the language: French, German, Danish, etc.).

Re: Apple Virtualization Framework

#94
post #24

Earlier quoted context omitted.

"Being done", I'm not sure anything is happening here other than a happy user pointing out that Apple have some advances in this area, but .. your point is that this has been there all along. Alas, if only there were the hardware at scale which supported Apples' Mach implementation, at favourable economies. One way this is favourable to this dev is if Apple finally give me a machine which I can use to Build All the T…

When Mach was defined it was considered a centralized campus computer that could run all the needed operating systems on top of centralized memory and processing using IPC. https://en.wikipedia.org/wiki/Mach_%28kernel%29

Sure, Mach is great. No argument from me here.

Well except that, a new developer-focused Mac Pro with that centralized campus feeling, sounds great to me.

I can only wish it would have both x86 and ARM cores onboard, though, to get that true all-round Mach prowess...

Re: Apple Virtualization Framework

#95
post #72
post #66

Been using vftool to host docker instead of Docker.app. It's been alright so far, got rosetta set up inside to run x86 images. All it takes is a little startup script and some up front work to prepare a disk image with Ubuntu server. Every once in a while, the guest Ubuntu kernel will oops about smp related things. Every time it boots its clock is reset almost a month in the past and I have to force sntp to correct i…

Does vftool use https://developer.apple.com/documentation/virtualization or https://developer.apple.com/documentation/hypervisor ? https://github.com/evansm7/vftool appears to indicate the former, but I thought the latter was required for rosetta so interested to try this. EDIT - looks like I had this backwards, vftool indeed supports https://developer.apple.com/documentation/virtualization which is the newer framewo…

Right, it uses Virtualization Framework. I forked vftool [0] and added direct Rosetta support which was trivial to do according to the Apple documentation; just had to convert Swift example code to Obj-C.

Have had a PR open for several months with no attention from the author. I almost forgot about it until seeing this HN headline.

[0] https://github.com/JamesDunne/vftool-rosetta

The Rosetta support is surprisingly trivial to use. The virtualization framework exposes a mountable volume containing a single `rosetta` executable. In the Linux guest, you just register binfmt_misc support that recognizes an x86 ELF image and point it at the `rosetta` binary. It works for docker too so you can run arm64 and amd64 images.

Re: Apple Virtualization Framework

#96

Earlier quoted context omitted.

Yeaahhh ... the secure enclave seems to have pooched the idea of a USB stick booter. Restore Mode works fine. I used to use CCC (Carbon Copy Cloner) to make a mirror, but it doesn't like to boot from the mirror (it does, but I can't use any of the secure stuff). Also CCC destabilizes my system. If I have it running all the time, I crash -a lot-. Since I yanked it, I haven't had a hard system crash in months. These da…

Yeaahhh ... the secure enclave seems to have pooched the idea of a USB stick booter. Restore Mode works fine. Maybe I misunderstood you, but you can make a bootable USB stick from the installer app: https://support.apple.com/en-us/HT201372

Nah. That's not the issue. The issue is cloning my system, so I can basically have a portable workstation on a USB stick.

It's been a while, since that was possible.

The M-series just basically put a fork in it.

That, and CCC kept crashing the machine.

Re: Apple Virtualization Framework

#97
post #6

Has there been a significant development? Been using it with https://mac.getutm.app/ for a while

How does one actually enable AVF on UTM?

I've got some Ubuntu VMs set up already, and as per [0] I cannot find an option called "Use Apple Virtualization" neither in UTM, nor in the VM settings.

I am on Intel Mac.

[0] https://www.jamesarmes.com/2022/12/linux-mac-utm.html#once-m...

Re: Apple Virtualization Framework

#98

It's kind of wild that Apple provides code samples you can use to directly create your own VMs. Has ended up being the most straightforward way to run virtualized macOS on a macOS host that I've found, and comes with the nice benefit that your can read the code yourself and fiddle with the knobs. https://developer.apple.com/documentation/virtualization/run...

I can't upvote this enough: just take the sample code and build on it.

I tired of evaluating and learning various wrappers and helpful virtualization applications. Being able to configure directly in a normal language is great, and it eliminates software supply chain concerns.

Plus, I'm finding programs are running faster in my virtualized ubuntu than on macOS "bare metal" (still on Intel, where big memory is cheap)

Re: Apple Virtualization Framework

#99
I use Virtualization.framework for OrbStack (https://orbstack.dev), which is a Docker Desktop and WSL alternative.

It's great overall, and fairly convenient, but it has a fair share of bugs and limitations. The Virtualization service crashes with various combinations of Linux kernel version, macOS version, and architecture (ARM/Intel), so making it stable in each setup takes quite a bit of work. Device support is limited (no USB, etc.), and workarounds have other limitations. Rosetta is really buggy.

The popular belief is that Virtualization.framework is inherently faster/lighter than other VMMs like QEMU, but I haven't found evidence to back it up. I spent a day prototyping a custom VMM (with an open-source base) and was able to get dynamic memory allocation working [1], as well as faster file sharing in some cases. There's a lot of other things I could do better (faster, simpler, more reliable) with a custom, tightly-integrated replacement.

But unfortunately, that's not an option. Apple doesn't allow third-party VMMs to set the necessary CPU flags for Rosetta. There are too many users relying on Rosetta for fast x86 emulation for me to ditch it, despite all its bugs.

So yes, I still use Virtualization.framework, but only because I have no choice.

Happy to answer other questions about the framework!

[1] https://twitter.com/kdrag0n/status/1645645284721184768

Re: Apple Virtualization Framework

#100
post #98

It's kind of wild that Apple provides code samples you can use to directly create your own VMs. Has ended up being the most straightforward way to run virtualized macOS on a macOS host that I've found, and comes with the nice benefit that your can read the code yourself and fiddle with the knobs. https://developer.apple.com/documentation/virtualization/run...

I can't upvote this enough: just take the sample code and build on it. I tired of evaluating and learning various wrappers and helpful virtualization applications. Being able to configure directly in a normal language is great, and it eliminates software supply chain concerns. Plus, I'm finding programs are running faster in my virtualized ubuntu than on macOS "bare metal" (still on Intel, where big memory is cheap)

> Plus, I'm finding programs are running faster in my virtualized ubuntu than on macOS "bare metal" (still on Intel, where big memory is cheap)

Can you explain more? Sounds like you are saying your Ubuntu (guest) VM reacts faster to your actions than the underlying (host) macOS?

Post reply on HN