apple: let virtual machines connect to each other - #7865
Conversation
|
@osy Could you take a look? It's the last missing piece for many users. |
|
Patience, there's like a dozen things I have to review. |
Apple Virtualization's existing Shared Network uses a separate NAT attachment per VM, so guests cannot use it to reach each other. macOS 26 adds VZVmnetNetworkDeviceAttachment, which lets multiple VMs attach to the same process-owned vmnet network. Add two macOS 26+ modes: - "Shared Network (VM to VM)": guests share a NAT-backed vmnet network and can reach each other, the host, and external networks. - "Host Only": guests share a host-only vmnet network and can reach each other and the host without external routing. UTMAppleVmnetNetworkManager keeps a weak attachment cache per mode while Virtualization configuration and runtime objects own the attachment and its native network. The network therefore follows the actual VZ object lifetime rather than UTM's presentation state, including failure paths where a VZ VM can remain alive after UTM reports it stopped. Configuration validation uses a side-effect-free placeholder so saving a VM does not create a live vmnet network. Hide both modes before macOS 26 and add matching scripting enumerators and round-trip parsing. Resolves utmapp#6975. Related to utmapp#7418 and utmapp#7380. Assisted-by: Claude:claude-fable-5-1 Assisted-by: ChatGPT:GPT-6-Pro Assisted-by: ChatGPT:GPT-5.6-Sol
No delegate callback follows a failed start, restore, or install, so the VZVirtualMachine created for the attempt was kept until the next start and the serial port PTYs stayed open and advertised for a stopped VM. With vmnet networking this also kept the network and its subnet reserved with nothing running. Drop the virtual machine and close the serial ports in that case, unless the guest is still alive and will report its own stop. Assisted-by: Claude:claude-fable-5-1
8fad0e4 to
155ad87
Compare
|
@ttc0419 I've made some changes and synced with the latest HEAD. Can you re-test? |
|
@osy Thank you for the review and the cleanup here! I retested The short version is that vmnet treats the address we pass as the host/router address for that I confirmed the two-line Otherwise, the networking and lifecycle paths I retested looked good. |
Follow-up to the vmnet networking modes: - Rename "Shared Network (VM to VM)" to "NAT Network" (config value "NATNetwork", scripting term "nat network") so the picker does not offer two "Shared" modes that differ only by a suffix. - Request a fixed subnet per mode outside of the ranges vmnet hands out by default. Those ranges are also used by NAT attachments and QEMU, so guest addresses depended on what else was running whenever the network was (re)created. Fall back to a vmnet chosen subnet when ours is taken. - Show the mode description with DetailedSection. The bare Text row widened the form and clipped the labels and controls in the settings window. - Only require macOS 26 when a network is actually created, so a VM using one of these modes can still be edited and saved on older hosts. - Do not apply locale digit grouping to the vmnet error code. - Fold the validation flag into the existing one that skipped drives and leave the device unattached instead of using a NAT placeholder, remove the unused reverse mapping, key the networks by vmnet_mode_t, and isolate the manager to the main actor in place of a lock with no concurrent users. Use .1 as the host-side address within each preferred /24. As reproduced in PR utmapp#7865, vmnet accepts .0 during network creation but the interface fails later at startup. Assisted-by: Claude:claude-fable-5-1 Assisted-by: ChatGPT:GPT-6-Astra-Pro
155ad87 to
47eadda
Compare
|
PS: I went ahead and pushed the two-line |
Summary
Add two Apple Virtualization networking modes on macOS 26 and later using
VZVmnetNetworkDeviceAttachment:The vmnet manager weakly caches one attachment per mode while Virtualization objects own its actual lifetime. Configuration validation stays side-effect-free, so saving a VM does not create a live vmnet network. The new modes also round-trip through UTM's scripting interface and are hidden on older macOS versions.
Resolves #6975.
Related to #7418 and #7380.
Testing
I tested this change on MacBook Pro with Apple M5 Pro running macOS 26.4.1.
I confirm that this change has been tested and reviewed in accordance with UTM's AI contribution guidelines.
Additional automated application-level verification covered pause/resume, first-user stop/restart, final network release, saved-state restore, concurrent configuration saves, scripting round-trips, network-creation errors without NAT fallback, and the post-start external-drive failure lifetime case.