net/macos: implement vmnet-based network device
Subsystems (2)
PATCH v2 1/1 net/macos: implement vmnet-based network device
From: Phillip Tennen <[email protected]>
This patch implements a new netdev device, reachable via -netdev vmnet-macos, that’s backed by macOS’s vmnet framework.
The vmnet framework provides native bridging support, and its usage in this patch is intended as a replacement for attempts to use a tap device via the tuntaposx kernel extension. Notably, the tap/tuntaposx approach never would have worked in the first place, as QEMU interacts with the tap device via poll(), and macOS does not support polling device files.
vmnet requires either a special entitlement, granted via a provisioning profile, or root access. Otherwise attempts to create the virtual interface will fail with a “generic error” status code. QEMU may not currently be signed with an entitlement granted in a provisioning profile, as this would necessitate pre-signed binary build distribution, rather than source-code distribution. As such, using this netdev currently requires that qemu be run with root access. I’ve opened a feedback report with Apple to allow the use of the relevant entitlement with this use case:
https://openradar.appspot.com/radar?id=5007417364447232
vmnet offers three operating modes, all of which are supported by this patch via the “mode=host|shared|bridge” option:
* "Host" mode: Allows the vmnet interface to communicate with other
* vmnet
interfaces that are in host mode and also with the native host.
* "Shared" mode: Allows traffic originating from the vmnet interface to reach the Internet through a NAT. The vmnet interface can also communicate with the native host.
* "Bridged" mode: Bridges the vmnet interface with a physical network interface.
Each of these modes also provide some extra configuration that’s supported by this patch:
* "Bridged" mode: The user may specify the physical interface to bridge with. Defaults to en0.
* "Host" mode / "Shared" mode: The user may specify the DHCP range and subnet. Allocated by vmnet if not provided.
vmnet also offers some extra configuration options that are not supported by this patch:
* Enable isolation from other VMs using vmnet
* Port forwarding rules
* Enabling TCP segmentation offload
* Only applicable in "shared" mode: specifying the NAT IPv6 prefix
* Only available in "host" mode: specifying the IP address for the VM within an isolated network
Note that this patch requires macOS 10.15 as a minimum, as this is when bridging support was implemented in vmnet.framework.
--- configure | 2 +- net/clients.h | 6 + net/meson.build | 1 + net/net.c | 3 + net/vmnet-macos.c | 437 ++++++++++++++++++++++++++++++++++++++++++++++ qapi/net.json | 120 ++++++++++++- qemu-options.hx | 9 + 7 files changed, 575 insertions(+), 3 deletions(-) create mode 100644 net/vmnet-macos.c
configure +1 -1
@@ -778,7 +778,7 @@ Darwin) fi audio_drv_list="coreaudio try-sdl" audio_possible_drivers="coreaudio sdl" - QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS" + QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit -framework vmnet $QEMU_LDFLAGS" # Disable attempts to use ObjectiveC features in os/object.h since they # won't work when we're compiling with gcc as a C compiler. QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
net/clients.h +6 -0
@@ -63,4 +63,10 @@ int net_init_vhost_user(const Netdev *netdev, const char *name,int net_init_vhost_vdpa (const Netdev *netdev,const char *name,NetClientState *peer,Error **errp); + +#ifdef CONFIG_DARWIN +int net_init_vmnet_macos (const Netdev *netdev,const char *name, +NetClientState *peer,Error **errp); +#endif +#endif /* QEMU_NET_CLIENTS_H */
net/meson.build +1 -0
@@ -37,5 +37,6 @@ endif softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files(tap_posix)) softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('tap-win32.c')) softmmu_ss.add(when: 'CONFIG_VHOST_NET_VDPA', if_true: files('vhost-vdpa.c')) +softmmu_ss.add(when: 'CONFIG_DARWIN', if_true: files('vmnet-macos.c')) subdir('can')
net/net.c +3 -0
@@ -977,6 +977,9 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])( #ifdef CONFIG_L2TPV3 [NET_CLIENT_DRIVER_L2TPV3 ] = net_init_l2tpv3, #endif +#ifdef CONFIG_DARWIN + [NET_CLIENT_DRIVER_VMNET_MACOS] = net_init_vmnet_macos, +#endif };
net/vmnet-macos.c new file +437 -0
437 lines not on this page · raw message
qapi/net.json +118 -2
147 lines not on this page · raw message
qemu-options.hx +9 -0
@@ -2483,6 +2483,15 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, #ifdef __linux__ "-netdev vhost-vdpa,id=str,vhostdev=/path/to/dev\n" " configure a vhost-vdpa network,Establish a vhost-vdpa netdev\n" +#endif +#ifdef CONFIG_DARWIN + "-netdev vmnet-macos,id=str,mode=bridged[,ifname=ifname]\n" + " configure a macOS-provided vmnet network in \"physical interface bridge\" mode\n" + " the physical interface to bridge with defaults to en0 if unspecified\n" + "-netdev vmnet-macos,id=str,mode=host|shared\n" + " [,dhcp_start_address=addr,dhcp_end_address=addr,dhcp_subnet_mask=mask]\n" + " configure a macOS-provided vmnet network in \"host\" or \"shared\" mode\n" + " the DHCP configuration will be set automatically if unspecified\n" #endif "-netdev hubport,id=str,hubid=n[,netdev=nd]\n" " configure a hub port on the hub with ID 'n'\n", QEMU_ARCH_ALL)
Signature · 1 line
2.24.3 (Apple Git-128)
Quoted 53 lines · On Fri, Feb 5, 2021 at 5:54 PM <[email protected]> wrote:
From: Phillip Tennen <[email protected]>
This patch implements a new netdev device, reachable via -netdev vmnet-macos, that’s backed by macOS’s vmnet framework.
The vmnet framework provides native bridging support, and its usage in this patch is intended as a replacement for attempts to use a tap device via the tuntaposx kernel extension. Notably, the tap/tuntaposx approach never would have worked in the first place, as QEMU interacts with the tap device via
poll(), and macOS does not support polling device files.vmnet requires either a special entitlement, granted via a provisioning profile, or root access. Otherwise attempts to create the virtual interface will fail with a “generic error” status code. QEMU may not currently be signed with an entitlement granted in a provisioning profile, as this would necessitate pre-signed binary build distribution, rather than source-code distribution. As such, using this netdev currently requires that qemu be run with root access. I’ve opened a feedback report with Apple to allow the use of the relevant entitlement with this use case:
https://openradar.appspot.com/radar?id=5007417364447232vmnet offers three operating modes, all of which are supported by this patch via the “mode=host|shared|bridge” option:
* "Host" mode: Allows the vmnet interface to communicate with other
* vmnet
interfaces that are in host mode and also with the native host.
* "Shared" mode: Allows traffic originating from the vmnet interface to reach the Internet through a NAT. The vmnet interface can also communicate with the native host.
* "Bridged" mode: Bridges the vmnet interface with a physical network interface.Each of these modes also provide some extra configuration that’s supported by this patch:
* "Bridged" mode: The user may specify the physical interface to bridge with. Defaults to en0.
* "Host" mode / "Shared" mode: The user may specify the DHCP range and subnet. Allocated by vmnet if not provided.vmnet also offers some extra configuration options that are not supported by this patch:
* Enable isolation from other VMs using vmnet
* Port forwarding rules
* Enabling TCP segmentation offload
* Only applicable in "shared" mode: specifying the NAT IPv6 prefix
* Only available in "host" mode: specifying the IP address for the VM within an isolated network
Quoted 5 lines
Note that this patch requires macOS 10.15 as a minimum, as this is when bridging support was implemented in vmnet.framework.
Signed-off-by Phillip Tennen <[email protected]>
Hi Phillip,
Thank you very much for this patch. As you wrote it should apply from 10.15 upwards. I have no problem building on Big Sur, but Catalina stumbles. See below. Latest Xcode installed, other requirements installed through brew.
Thanks for looking into this,
Best,
Howard
[1181/2135] Compiling C object libcommon.fa.p/net_vmnet-macos.c.o
FAILED: libcommon.fa.p/net_vmnet-macos.c.o
cc -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -I../slirp -I../slirp/src -Iqapi -Itrace -Iui -Iui/shader -I/usr/local/Cellar/libffi/3.3_2/include -I/usr/local/Cellar/glib/2.66.6/include -I/usr/local/Cellar/glib/2.66.6/include/glib-2.0 -I/usr/local/Cellar/glib/2.66.6/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.44/include -I/usr/local/Cellar/glib/2.66.6/include/gio-unix-2.0 -I/usr/local/Cellar/libusb/1.0.24/include/libusb-1.0 -I/usr/local/Cellar/pixman/0.40.0/include/pixman-1 -Xclang -fcolor-diagnostics -pipe -Wall -Winvalid-pch -std=gnu99 -O2 -g -iquote . -iquote /Users/hsp/src/qemu-master -iquote /Users/hsp/src/qemu-master/include -iquote /Users/hsp/src/qemu-master/disas/libvixl -iquote /Users/hsp/src/qemu-master/tcg/i386 -iquote /Users/hsp/src/qemu-master/accel/tcg -m64 -mcx16 -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -fstack-protector-strong -DSTRUCT_IOVEC_DEFINED -MD -MQ libcommon.fa.p/net_vmnet-macos.c.o -MF libcommon.fa.p/net_vmnet-macos.c.o.d -o libcommon.fa.p/net_vmnet-macos.c.o -c ../net/vmnet-macos.c ../net/vmnet-macos.c:54:10: error: use of undeclared identifier 'VMNET_SHARING_SERVICE_BUSY'
case VMNET_SHARING_SERVICE_BUSY:
^Hi Howard,
Thanks very much for taking a look and testing it out!
This is a good catch - VMNET_SHARING_SERVICE_BUSY
was added in macOS Big Sur, and is not available in prior versions.
I'll submit a v3 of this patch that adds a compile-guard around this constant (assuming the #available macro is... available), and will validate the other vmnet symbols I reference as well.
Phillip
Quoted 107 lines · Howard Spoelstra
Quoted 53 lines · On Fri, Feb 5, 2021 at 5:54 PM <[email protected]> wrote:
From: Phillip Tennen <[email protected]>
This patch implements a new netdev device, reachable via -netdev vmnet-macos, that’s backed by macOS’s vmnet framework.
The vmnet framework provides native bridging support, and its usage in this patch is intended as a replacement for attempts to use a tap device via the tuntaposx kernel extension. Notably, the tap/tuntaposx approach never would have worked in the first place, as QEMU interacts with the tap device via
poll(), and macOS does not support polling device files.vmnet requires either a special entitlement, granted via a provisioning profile, or root access. Otherwise attempts to create the virtual interface will fail with a “generic error” status code. QEMU may not currently be signed with an entitlement granted in a provisioning profile, as this would necessitate pre-signed binary build distribution, rather than source-code distribution. As such, using this netdev currently requires that qemu be run with root access. I’ve opened a feedback report with Apple to allow the use of the relevant entitlement with this use case:
https://openradar.appspot.com/radar?id=5007417364447232vmnet offers three operating modes, all of which are supported by this patch via the “mode=host|shared|bridge” option:
* "Host" mode: Allows the vmnet interface to communicate with other
* vmnet
interfaces that are in host mode and also with the native host.
* "Shared" mode: Allows traffic originating from the vmnet interface to reach the Internet through a NAT. The vmnet interface can also communicate with the native host.
* "Bridged" mode: Bridges the vmnet interface with a physical network interface.Each of these modes also provide some extra configuration that’s supported by this patch:
* "Bridged" mode: The user may specify the physical interface to bridge with. Defaults to en0.
* "Host" mode / "Shared" mode: The user may specify the DHCP range and subnet. Allocated by vmnet if not provided.vmnet also offers some extra configuration options that are not supported by this patch:
* Enable isolation from other VMs using vmnet
* Port forwarding rules
* Enabling TCP segmentation offload
* Only applicable in "shared" mode: specifying the NAT IPv6 prefix
* Only available in "host" mode: specifying the IP address for the VM within an isolated networkQuoted 5 lines
Note that this patch requires macOS 10.15 as a minimum, as this is when bridging support was implemented in vmnet.framework.
Signed-off-by Phillip Tennen <[email protected]>Hi Phillip,
Thank you very much for this patch. As you wrote it should apply from 10.15 upwards. I have no problem building on Big Sur, but Catalina stumbles. See below. Latest Xcode installed, other requirements installed through brew.
Thanks for looking into this,
Best,
Howard[1181/2135] Compiling C object
libcommon.fa.p/net_vmnet-macos.c.o
FAILED:libcommon.fa.p/net_vmnet-macos.c.o
cc -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone(quoted diff) +0
-11-I../dtc/libfdt -I../slirp -I../slirp/src -Iqapi -Itrace -Iui -Iui/shader -I/usr/local/Cellar/libffi/3.3_2/include -I/usr/local/Cellar/glib/2.66.6/include -I/usr/local/Cellar/glib/2.66.6/include/glib-2.0 -I/usr/local/Cellar/glib/2.66.6/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.44/include -I/usr/local/Cellar/glib/2.66.6/include/gio-unix-2.0 -I/usr/local/Cellar/libusb/1.0.24/include/libusb-1.0 -I/usr/local/Cellar/pixman/0.40.0/include/pixman-1 -Xclang -fcolor-diagnostics -pipe -Wall -Winvalid-pch -std=gnu99 -O2 -g -iquote . -iquote /Users/hsp/src/qemu-master -iquote/Users/hsp/src/qemu-master/include -iquote
/Users/hsp/src/qemu-master/disas/libvixl -iquote
/Users/hsp/src/qemu-master/tcg/i386 -iquote
/Users/hsp/src/qemu-master/accel/tcg -m64 -mcx16(quoted diff) +0
-10-DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -fstack-protector-strong -DSTRUCT_IOVEC_DEFINED -MD -MQ
libcommon.fa.p/net_vmnet-macos.c.o-MF libcommon.fa.p/net_vmnet-macos.c.o.d -olibcommon.fa.p/net_vmnet-macos.c.o-c../net/vmnet-macos.c../net/vmnet-macos.c:54:10: error: use of undeclared identifier 'VMNET_SHARING_SERVICE_BUSY'case VMNET_SHARING_SERVICE_BUSY: ^
Phillip, this doesn't apply anymore. I'm reviewing the QAPI schema part anyway.
Peter, there is a question for you below. Search for "Sphinx".
Quoted 57 lines · [email protected] writes:
From: Phillip Tennen <[email protected]>
This patch implements a new netdev device, reachable via -netdev vmnet-macos, that’s backed by macOS’s vmnet framework.
The vmnet framework provides native bridging support, and its usage in this patch is intended as a replacement for attempts to use a tap device via the tuntaposx kernel extension. Notably, the tap/tuntaposx approach never would have worked in the first place, as QEMU interacts with the tap device via
poll(), and macOS does not support polling device files.vmnet requires either a special entitlement, granted via a provisioning profile, or root access. Otherwise attempts to create the virtual interface will fail with a “generic error” status code. QEMU may not currently be signed with an entitlement granted in a provisioning profile, as this would necessitate pre-signed binary build distribution, rather than source-code distribution. As such, using this netdev currently requires that qemu be run with root access. I’ve opened a feedback report with Apple to allow the use of the relevant entitlement with this use case:
https://openradar.appspot.com/radar?id=5007417364447232vmnet offers three operating modes, all of which are supported by this patch via the “mode=host|shared|bridge” option:
* "Host" mode: Allows the vmnet interface to communicate with other
* vmnet
interfaces that are in host mode and also with the native host.
* "Shared" mode: Allows traffic originating from the vmnet interface to reach the Internet through a NAT. The vmnet interface can also communicate with the native host.
* "Bridged" mode: Bridges the vmnet interface with a physical network interface.Each of these modes also provide some extra configuration that’s supported by this patch:
* "Bridged" mode: The user may specify the physical interface to bridge with. Defaults to en0.
* "Host" mode / "Shared" mode: The user may specify the DHCP range and subnet. Allocated by vmnet if not provided.vmnet also offers some extra configuration options that are not supported by this patch:
* Enable isolation from other VMs using vmnet
* Port forwarding rules
* Enabling TCP segmentation offload
* Only applicable in "shared" mode: specifying the NAT IPv6 prefix
* Only available in "host" mode: specifying the IP address for the VM within an isolated networkNote that this patch requires macOS 10.15 as a minimum, as this is when bridging support was implemented in vmnet.framework.
Signed-off-by Phillip Tennen <[email protected]>---
[...]
qapi/net.json line 457
Quoted 13 lines
qapi/net.json +5
-0@@ -450,6 +450,115 @@ '*vhostdev': 'str', '*queues': 'int' } } +## +# @VmnetOperatingMode: +# +# The operating modes in which a vmnet netdev can run +# Only available on macOS
Please end these sentences with a period.
I'm not sure we need "Only available on macOS". Rendered documentation shows the 'if' like
If
defined(CONFIG_DARWIN)
More of the same below.
Quoted 13 lines
qapi/net.json +13
-0+# +# @host: the guest may communicate with the host +# and other guest network interfaces +# +# @shared: the guest may reach the Internet through a NAT, +# and may communicate with the host and other guest +# network interfaces +# +# @bridged: the guest's traffic is bridged with a +# physical network interface of the host +# +# Since: 6.0 +##
qapi/net.json line 480
Quoted 10 lines
qapi/net.json +10
-0+{ 'enum': 'VmnetOperatingMode', + 'data': [ 'host', 'shared', 'bridged' ], + 'if': 'defined(CONFIG_DARWIN)' } + +## +# @NetdevVmnetModeOptionsBridged: +# +# Options for the vmnet-macos netdev +# that are only available in 'bridged' mode +# Only available on macOS
Likewise.
Quoted 9 lines
qapi/net.json +9
-0+# +# @ifname: the physical network interface to bridge with +# (defaults to en0 if not specified) +# +# Since: 6.0 +## +{ 'struct': 'NetdevVmnetModeOptionsBridged', + 'data': { '*ifname': 'str' }, + 'if': 'defined(CONFIG_DARWIN)' }
qapi/net.json line 499
Quoted 10 lines
qapi/net.json +10
-0+ +## +# @NetdevVmnetModeOptionsHostOrShared: +# +# Options for the vmnet-macos netdev +# that are only available in 'host' or 'shared' mode +# Only available on macOS +# +# @dhcp-start-address: the gateway address to use for the interface. +# The range to dhcp_end_address is placed in the DHCP pool.
Recommend to wrap lines around column 75.
qapi/net.json line 500
Quoted 1 line
qapi/net.json +1
-0+# (only valid with mode=host|shared)
Isn't that trivial? The type's only use is as union branch for modes host and shared.
qapi/net.json line 502
Quoted 2 lines
qapi/net.json +2
-0+# (must be specified with dhcp-end-address and +# dhcp-subnet-mask)
Does that mean you have to specify all three parameters or none?
Sphinx warns:
qapi/net.json:492:Unexpected indentation.
Known restriction of our tooling: the position is less than useful.
Unindenting the second line like
# (must be specified with dhcp-end-address and
# dhcp-subnet-mask)
here and similarly below makes Sphinx shut up.
I'm not 100% sure our tooling behaves as intended here. Peter?
qapi/net.json line 503
Quoted 1 line
qapi/net.json +1
-0+# (allocated automatically if unset)
How?
The sequence of (parenthesized sentences) looks pretty bad in rendered documentation. Please proof-read docs/manual/interop/qemu-qmp-ref.html.
Quoted 41 lines
qapi/net.json +41
-0+# +# @dhcp-end-address: the DHCP IPv4 range end address to use for the interface. +# (only valid with mode=host|shared) +# (must be specified with dhcp-start-address and +# dhcp-subnet-mask) +# (allocated automatically if unset) +# +# @dhcp-subnet-mask: the IPv4 subnet mask (string) to use on the interface. +# (only valid with mode=host|shared) +# (must be specified with dhcp-start-address and +# dhcp-end-address) +# (allocated automatically if unset) +# +# Since: 6.0 +## +{ 'struct': 'NetdevVmnetModeOptionsHostOrShared', + 'data': { + '*dhcp-start-address': 'str' , + '*dhcp-end-address': 'str', + '*dhcp-subnet-mask': 'str' }, + 'if': 'defined(CONFIG_DARWIN)' } + +## +# @NetdevVmnetModeOptions: +# +# Options specific to different operating modes of a vmnet netdev +# Only available on macOS +# +# @mode: the operating mode vmnet should run in +# +# Since: 6.0 +## +{ 'union': 'NetdevVmnetModeOptions', + 'base': { 'mode': 'VmnetOperatingMode' }, + 'discriminator': 'mode', + 'data': { + 'bridged': 'NetdevVmnetModeOptionsBridged', + 'host': 'NetdevVmnetModeOptionsHostOrShared', + 'shared': 'NetdevVmnetModeOptionsHostOrShared' }, + 'if': 'defined(CONFIG_DARWIN)' } +
qapi/net.json line 554
Quoted 10 lines
qapi/net.json +10
-0+## +# @NetdevVmnetOptions: +# +# vmnet network backend +# Only available on macOS +# +# @options: a structure specifying the mode and mode-specific options +# (once QAPI supports a union type as a branch to another union type, +# this structure can be changed to a union, and the contents of +# NetdevVmnetModeOptions moved here)
Sphinx warns:
qapi/net.json:546:Unexpected indentation.
qapi/net.json line 561
Quoted 7 lines
qapi/net.json +7
-0+# +# Since: 6.0 +## +{ 'struct': 'NetdevVmnetOptions', + 'data': {'options': 'NetdevVmnetModeOptions' }, + 'if': 'defined(CONFIG_DARWIN)' } +
Awkward.
You can't use make NetdevVmnetModeOptions a branch of union Netdev, because NetdevVmnetModeOptions is a union, and a branch must be a struct. To work around, you wrap struct NetdevVmnetOptions around union NetdevVmnetModeOptions.
NetdevVmnetModeOptions has no common members other than the union discriminator. Why not add them as three branches to Netdev?
Quoted 38 lines
qapi/net.json +9
-2## # @NetClientDriver: #@@ -458,10 +567,13 @@ # Since: 2.7 # # @vhost-vdpa since 5.1 +# +# @vmnet-macos since 6.0 (only available on macOS) ## { 'enum': 'NetClientDriver', 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', - 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa' ] } + 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa', + { 'name': 'vmnet-macos', 'if': 'defined(CONFIG_DARWIN)' } ] } ## # @Netdev:@@ -475,6 +587,8 @@ # Since: 1.2 # # 'l2tpv3' - since 2.1 +# +# 'vmnet-macos' since 6.0 (only available on macOS) ## { 'union': 'Netdev', 'base': { 'id': 'str', 'type': 'NetClientDriver' },@@ -490,7 +604,9 @@ 'hubport': 'NetdevHubPortOptions', 'netmap': 'NetdevNetmapOptions', 'vhost-user': 'NetdevVhostUserOptions', - 'vhost-vdpa': 'NetdevVhostVDPAOptions' } } + 'vhost-vdpa': 'NetdevVhostVDPAOptions', + 'vmnet-macos': { 'type': 'NetdevVmnetOptions', + 'if': 'defined(CONFIG_DARWIN)' } } } ## # @NetFilterDirection:
[...]
Markus, thanks for the review. I apologize for my lateness in getting back to you.
I've integrated most of your suggestions, and will submit a v5 that incorporates them. I've left a couple comments and questions for you below.
Aside: I haven't responded inline to emails like this before, I'm hoping it shows
up correctly for you! I appreciate how understanding everyone's been towards my
newness to this development & review format. I cut out the irrelevant bits for brevity and am unsure if that breaks anything.
Phillip
Quoted 13 lines · Markus Armbruster
Phillip, this doesn't apply anymore. I'm reviewing the QAPI schema part anyway.
Peter, there is a question for you below. Search for "Sphinx".
Quoted 5 lines · [email protected] writes:
From: Phillip Tennen <[email protected]>
This patch implements a new netdev device, reachable via -netdev vmnet-macos, that’s backed by macOS’s vmnet framework.
[...]
Quoted 19 lines
qapi/net.json line 457
Quoted 13 lines
qapi/net.json +5
-0@@ -450,6 +450,115 @@ '*vhostdev': 'str', '*queues': 'int' } } +## +# @VmnetOperatingMode: +# +# The operating modes in which a vmnet netdev can run +# Only available on macOSPlease end these sentences with a period.
I'm not sure we need "Only available on macOS". Rendered documentation shows the 'if' like
Quoted 7 lines
[...]
Quoted 1 line
+# (only valid with mode=host|shared)
Isn't that trivial? The type's only use is as union branch for modes host and shared.
True. I added comments like this for clarity, but I accept that the schema should make it clear alone.
Quoted 6 lines
qapi/net.json
Quoted 3 lines
qapi/net.json +2
-0+# (must be specified with dhcp-end-address and +# dhcp-subnet-mask)Does that mean you have to specify all three parameters or none?
That's correct. You may provide either none or all three.
[...]
Quoted 4 lines
Quoted 1 line
+# (allocated automatically if unset)
How?
vmnet automatically allocates specifics like the MAC address, DHCP pool, etc,
if not explicitly supplied. I'll add some wording to this effect. [...]
Quoted 16 lines
qapi/net.json line 561
Quoted 8 lines
qapi/net.json +7
-0+# +# Since: 6.0 +## +{ 'struct': 'NetdevVmnetOptions', + 'data': {'options': 'NetdevVmnetModeOptions' }, + 'if': 'defined(CONFIG_DARWIN)' } +Awkward.
You can't use make NetdevVmnetModeOptions a branch of union Netdev, because NetdevVmnetModeOptions is a union, and a branch must be a struct. To work around, you wrap struct NetdevVmnetOptions around union NetdevVmnetModeOptions.
Quoted 4 lines
NetdevVmnetModeOptions has no common members other than the union discriminator. Why not add them as three branches to Netdev?
Just to be sure I understand, you're proposing adding 3 new fields to
Netdev,
like so:
'vmnet-macos-bridged': { 'type': 'NetdevVmnetModeOptionsBridged',
'if': 'defined(CONFIG_DARWIN)' },
'vmnet-macos-host': { 'type': 'NetdevVmnetModeOptionsHostOrShared',
'if': 'defined(CONFIG_DARWIN)' },
'vmnet-macos-shared': { 'type': 'NetdevVmnetModeOptionsHostOrShared',
'if': 'defined(CONFIG_DARWIN)' },
... where each of those "ModeOptions" structs contains a new "mode" field extracted from the union. Did I get your intent right? I'm assuming there wouldn't be issues with "vmnet-macos" referenced elsewhere.
Thank you!
Phillip
Quoted 6 lines · Phillip Tennen
Markus, thanks for the review. I apologize for my lateness in getting back to you.
I've integrated most of your suggestions, and will submit a v5 that incorporates them. I've left a couple comments and questions for you below.
Quoted 6 lines
Aside: I haven't responded inline to emails like this before, I'm hoping it shows
up correctly for you! I appreciate how understanding everyone's been towards my
newness to this development & review format. I cut out the irrelevant bits for brevity and am unsure if that breaks anything.
We *try* not to be jerks ;)
Your reply looks fine to me.
Quoted 40 lines
Phillip
Quoted 13 lines · Markus Armbruster
Phillip, this doesn't apply anymore. I'm reviewing the QAPI schema part anyway.
Peter, there is a question for you below. Search for "Sphinx".
Quoted 5 lines · [email protected] writes:
From: Phillip Tennen <[email protected]>
This patch implements a new netdev device, reachable via -netdev vmnet-macos, that’s backed by macOS’s vmnet framework.
[...]
Quoted 20 lines
qapi/net.json line 457
Quoted 13 lines
qapi/net.json +5
-0@@ -450,6 +450,115 @@ '*vhostdev': 'str', '*queues': 'int' } } +## +# @VmnetOperatingMode: +# +# The operating modes in which a vmnet netdev can run +# Only available on macOSPlease end these sentences with a period.
I'm not sure we need "Only available on macOS". Rendered documentation shows the 'if' like
[...]
Quoted 7 lines
Quoted 5 lines
qapi/net.json line 458
Quoted 1 line
qapi/net.json +1
-0+# (only valid with mode=host|shared)Isn't that trivial? The type's only use is as union branch for modes host and shared.
True. I added comments like this for clarity, but I accept that the schema should make it clear alone.
Clarity is in the eye of the beholder. We try to find the sweet spot between bafflingly terse and tiresomely verbose.
Quoted 6 lines
Quoted 5 lines
qapi/net.json line 460
Quoted 2 lines
qapi/net.json +2
-0+# (must be specified with dhcp-end-address and +# dhcp-subnet-mask)Does that mean you have to specify all three parameters or none?
That's correct. You may provide either none or all three.
In bridged mode, none.
In host or shared mode, either all three or none.
Correct?
Quoted 30 lines
[...]
Quoted 4 lines
Quoted 1 line
+# (allocated automatically if unset)
How?
vmnet automatically allocates specifics like the MAC address, DHCP pool, etc,
if not explicitly supplied. I'll add some wording to this effect. [...]Quoted 11 lines
qapi/net.json line 561
Quoted 8 lines
qapi/net.json +7
-0+# +# Since: 6.0 +## +{ 'struct': 'NetdevVmnetOptions', + 'data': {'options': 'NetdevVmnetModeOptions' }, + 'if': 'defined(CONFIG_DARWIN)' } +Awkward.
Quoted 7 lines
You can't use make NetdevVmnetModeOptions a branch of union Netdev, because NetdevVmnetModeOptions is a union, and a branch must be a struct. To work around, you wrap struct NetdevVmnetOptions around union NetdevVmnetModeOptions.
NetdevVmnetModeOptions has no common members other than the union discriminator. Why not add them as three branches to Netdev?
Quoted 12 lines
Just to be sure I understand, you're proposing adding 3 new fields to Netdev,
like so:
'vmnet-macos-bridged': { 'type': 'NetdevVmnetModeOptionsBridged',
'if': 'defined(CONFIG_DARWIN)' },
'vmnet-macos-host': { 'type': 'NetdevVmnetModeOptionsHostOrShared',
'if': 'defined(CONFIG_DARWIN)' },
'vmnet-macos-shared': { 'type': 'NetdevVmnetModeOptionsHostOrShared',
'if': 'defined(CONFIG_DARWIN)' },
... where each of those "ModeOptions" structs contains a new "mode" field extracted from the union. Did I get your intent right? I'm assuming there wouldn't be issues with "vmnet-macos" referenced elsewhere.
Yes, except you don't need a @mode member, you can derive the mode from Netdev member @type.
Clear now?