-
-
Notifications
You must be signed in to change notification settings - Fork 75
feat: add VZVmnetNetworkDeviceAttachment support (macOS 26.0)
#205
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
base: main
Are you sure you want to change the base?
feat: add VZVmnetNetworkDeviceAttachment support (macOS 26.0)
#205
Conversation
VmnetNetworkDeviceAttachment support (macOS 26.0)VZVmnetNetworkDeviceAttachment support (macOS 26.0)
6617c8f to
6a1f741
Compare
Based on `VMNET_SHARED_MODE`, and `VMNET_HOST_MODE` ```yaml networks: - vzShared: true - vzHost: true ``` But, to sharing network between multiple VMs, `VZVmnetNetworkDeviceAttachment` requires VMs are launched by same process. It depends on Code-Hex/vz#205 Signed-off-by: Norio Nomura <[email protected]>
vmnet.go
Outdated
| const ( | ||
| HostMode VmnetMode = C.VMNET_HOST_MODE | ||
| SharedMode VmnetMode = C.VMNET_SHARED_MODE | ||
| // Deprecated: BridgedMode is not supported by NewVmnetNetworkConfiguration |
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.
Do you know why not supported?
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 don't know. It's documented on:
https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_create(_:_:)?language=objc
Parameters
mode
Shared mode or host-only mode.
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.
Why BridgedMode is Deprecated? Can you link to the docs about this?
Since it is not supported we should not include it, marking it as Deprecated look wrong.
|
This can be used by multiple processes like this:
|
5a7a116 to
72cc1d4
Compare
In this procedure, I confirmed that VMs launched from multiple processes can share networks with each other. 👍🏻 |
72cc1d4 to
9506cbd
Compare
Added unit test and |
I'll try this added xpc package with lima to make it work. Until then, it's a draft. |
7bf24c1 to
007c2a5
Compare
Based on `VMNET_SHARED_MODE`, and `VMNET_HOST_MODE` ```yaml networks: - vzShared: true - vzHost: true ``` But, to sharing network between multiple VMs, `VZVmnetNetworkDeviceAttachment` requires VMs are launched by same process. It depends on Code-Hex/vz#205 Signed-off-by: Norio Nomura <[email protected]>
aba95bd to
ba619f5
Compare
d3fad75 to
7a58378
Compare
Based on `VMNET_SHARED_MODE`, and `VMNET_HOST_MODE` ```yaml networks: - vzShared: true - vzHost: true ``` But, to sharing network between multiple VMs, `VZVmnetNetworkDeviceAttachment` requires VMs are launched by same process. It depends on Code-Hex/vz#205 Signed-off-by: Norio Nomura <[email protected]>
7a58378 to
33858c0
Compare
nirs
left a comment
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 did not review most of this change, just the stange part of about marking bridged mode as depracated.
pkg/xpc/xpc.m
Outdated
|
|
||
| // xpc_object_t | ||
|
|
||
| void *xpcRetain(void *o) |
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.
No way to use xpc_object_t?
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.
It seemed that it could be used if it was not exposed outside the package, but I wanted to expose it outside the package, so I used a method using void *.
vmnet.go
Outdated
| const ( | ||
| HostMode VmnetMode = C.VMNET_HOST_MODE | ||
| SharedMode VmnetMode = C.VMNET_SHARED_MODE | ||
| // Deprecated: BridgedMode is not supported by NewVmnetNetworkConfiguration |
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.
Why BridgedMode is Deprecated? Can you link to the docs about this?
Since it is not supported we should not include it, marking it as Deprecated look wrong.
vmnet.go
Outdated
| BridgedMode VmnetMode = C.VMNET_BRIDGED_MODE | ||
| // BridgedMode is not supported by NewVmnetNetworkConfiguration | ||
| // - https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_create(_:_:)?language=objc#parameters | ||
| // BridgedMode VmnetMode = C.VMNET_BRIDGED_MODE |
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.
Since this package doe not use BridgedMode and it cannot be used with it we can drop the commented constants. The comment explaining why we don't include this more is good.
f048f6e to
3b512d7
Compare
Based on `VMNET_SHARED_MODE`, and `VMNET_HOST_MODE` ```yaml networks: - vzShared: true - vzHost: true ``` But, to sharing network between multiple VMs, `VZVmnetNetworkDeviceAttachment` requires VMs are launched by same process. It depends on Code-Hex/vz#205 Signed-off-by: Norio Nomura <[email protected]>
|
lima-vm/lima#4394, which relied on this PR, will now do the desired action when starting this PR.
I don't think there will be any more additional functions for this PR. By the way, should I include the correction of macOS 13 runner's retirement from GitHub Actions in this PR? |
Can be a separate PR |
| // see: https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_create(_:_:)?language=objc | ||
| void *VZVmnetNetworkConfigurationCreate(uint32_t mode, uint32_t *status) | ||
| { | ||
| #ifdef INCLUDE_TARGET_OSX_26 |
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.
Can we test this on GHA with macos-26 ?
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 can only try the build.
The macos-26, which only has arm64, does not support Nested Virtualization yet, so the unit test does not work.
opened #208 |
3b512d7 to
0ef8850
Compare
`VZVmnetNetworkDeviceAttachment` does not require the `com.apple.vm.networking` entitlement nor root privileges. `HostMode` and `SharedMode` are supported. In order for multiple VMs to communicate with each other in SharedMode, they must be started in the same process and the same `VmnetNetwork` must be passed to `NewVmnetNetworkDeviceAttachment()` to create an attachment. Add: - `VmnetReturn`: - `ErrVmnetSuccess` - ... - `VmnetMode`: - `HostMode` - `SharedMode` - `BridgedMode`(definition only since not supported. marked as deprecated) - `VmnetNetworkConfiguration`: `NewVmnetNetworkConfiguration()`, The use of the instance method group is still unknown. Setting subnet seems to trigger disabling DHCP, etc. - `VmnetNetwork`: `NewVmnetNetwork()`, some APIs which using `xpc_object_t` are not implemented. - `VmnetNetworkDeviceAttachment`: `NewVmnetNetworkDeviceAttachment()` see: https://developer.apple.com/documentation/virtualization/vzvmnetnetworkdeviceattachment?language=objc change `MACAddress.EthernetAddress()` to `MACAddress.ethernetAddress()` to avoid export C type from Go Signed-off-by: Norio Nomura <[email protected]>
Add: - `TestVmnetSharedModeAllowsCommunicationBetweenMultipleVMs()` - `Container.DetectIPv4()` Move `Container.exec()` from `shared_directory_arm64_test.go` to `virtualization_test.go` Signed-off-by: Norio Nomura <[email protected]>
Signed-off-by: Norio Nomura <[email protected]>
Signed-off-by: Norio Nomura <[email protected]> Stop using CFTypeRef Signed-off-by: Norio Nomura <[email protected]>
change `VmnetNetworkConfiguration.SetIPv4Subnet()` Signed-off-by: Norio Nomura <[email protected]>
Signed-off-by: Norio Nomura <[email protected]>
- Add `TestVmnetNetworkShareModeSharingOverXpc` to `vmnet_test.go` `TestVmnetNetworkShareModeSharingOverXpc` tests sharing `VmnetNetwork` in `SharedMode` over XPC communication. This test registers test executable as an Mach service and launches it using `launchctl`. The launched Mach service provides `VmnetNetwork` serialization to clients upon request, after booting a VM using the provided `VmnetNetwork` to ensure the network is functional on the server side. The client boots VM using the provided `VmnetNetwork` serialization. This test uses `pkg/xpc` package to implement XPC communication. - Add `pkg/xpc` package that providing `<xpc/xpc.h>` APIs to support implementing Mach service server and client Signed-off-by: Norio Nomura <[email protected]>
- Remove `BridgedMode` definition - Add more documentation to `VmnetMode` Signed-off-by: Norio Nomura <[email protected]>
0ef8850 to
19f23c6
Compare
feat: add
VZVmnetNetworkDeviceAttachmentsupport (macOS 26.0)VmnetNetworkDeviceAttachmentdoes not require thecom.apple.vm.networkingentitlement nor root privileges.HostModeandSharedModeare supported.In order for multiple VMs to communicate with each other in SharedMode, they must be started in the same process and the same
VmnetNetworkmust be passed toNewVmnetNetworkDeviceAttachment()to create an attachment.Add:
VmnetReturn:ErrVmnetSuccessVmnetMode:HostModeSharedModeBridgedMode(definition only since not supported. marked as deprecated)VmnetNetworkConfiguration:NewVmnetNetworkConfiguration(),The use of the instance method group is still unknown. Setting subnet seems to trigger disabling DHCP, etc.VmnetNetwork:NewVmnetNetwork(), some APIs which usingxpc_object_tare not implemented.VmnetNetworkDeviceAttachment:NewVmnetNetworkDeviceAttachment()see: https://developer.apple.com/documentation/virtualization/vzvmnetnetworkdeviceattachment?language=objc
Which issue(s) this PR fixes:
Mentioned in #198 (comment)