Skip to contentSkip to conversation

net/macos: implement vmnet-based network device

PATCH Superseded [email protected] 3 participants 7 messages Feb 4, 2021 – Feb 5, 2021

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover net/macos: implement vmnet-based network device

From: Phillip Tennen <[email protected]>

This patch series 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.

This is my first QEMU contribution, so please feel free to let me know what I’ve missed or what needs improving. Thanks very much for taking a look =)

Phillip Tennen (2):
build: add configure flag to indicate when the host is Darwin
net: implement vmnet-based netdev

 configure         |   6 +-
 net/clients.h     |   6 +
 net/meson.build   |   1 +
 net/net.c         |   3 +
 net/vmnet-macos.c | 444 ++++++++++++++++++++++++++++++++++++++++++++++
 qapi/net.json     |  64 ++++++-
 qemu-options.hx   |   9 +
 7 files changed, 530 insertions(+), 3 deletions(-)
 create mode 100644 net/vmnet-macos.c
Signature · 1 line
2.24.3 (Apple Git-128)
#1 lore raw

PATCH 1/2 build: add configure flag to indicate when the host is Darwin

From: Phillip Tennen <[email protected]>

Although we already have CONFIG_BSD, I added this flag to be sure that we could rely on various macOS-specific subsystems, such as vmnet.framework.

---
 configure | 4 ++++
 1 file changed, 4 insertions(+)
configure +4 -0
index 87de49e2c2..4afd22bdf5 100755
@@ -5825,6 +5825,10 @@ if [ "$bsd" = "yes" ] ; then
   echo "CONFIG_BSD=y" >> $config_host_mak
 fi
 
+if [ "$darwin" = "yes" ] ; then
+  echo "CONFIG_DARWIN=y" >> $config_host_mak
+fi
+
 if test "$qom_cast_debug" = "yes" ; then
   echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
 fi
Signature · 1 line
2.24.3 (Apple Git-128)
#2 lore raw

Re: [PATCH 1/2] build: add configure flag to indicate when the host is Darwin

Quoted 14 lines · On 04/02/2021 17.25, [email protected] wrote:

From: Phillip Tennen <[email protected]>

Although we already have CONFIG_BSD, I added this flag to be sure that we could rely on various macOS-specific subsystems, such as vmnet.framework.

---
  configure | 4 ++++
  1 file changed, 4 insertions(+)
configure +0 -0
index 87de49e2c2..4afd22bdf5 100755

configure if [ "$bsd" = "yes" ] ; then · line 5830

Quoted 6 lines
configure +3 -0
@@ -5825,6 +5825,10 @@ if [ "$bsd" = "yes" ] ; then
    echo "CONFIG_BSD=y" >> $config_host_mak
  fi
 
+if [ "$darwin" = "yes" ] ; then
+  echo "CONFIG_DARWIN=y" >> $config_host_mak
+fi

Hi!

We already have these lines in "configure":

if test "$darwin" = "yes" ; then
echo "CONFIG_DARWIN=y" >> $config_host_mak
fi

... so your patch here looks pretty redundant?

Thomas

#3 lore raw

Re: [PATCH 1/2] build: add configure flag to indicate when the host is Darwin

Hrm, good catch. I'm not sure how I missed that.

I'm removing this patch for my next round.

Thanks!
Phillip

Quoted 36 lines · Thomas Huth
Quoted 3 lines · On 04/02/2021 17.25, [email protected] wrote:

From: Phillip Tennen <[email protected]>

Although we already have CONFIG_BSD, I added this flag to be sure that

we could rely on various macOS-specific subsystems, such as vmnet.framework.

Quoted 11 lines
---
  configure | 4 ++++
  1 file changed, 4 insertions(+)
configure +0 -0
index 87de49e2c2..4afd22bdf5 100755

configure if [ "$bsd" = "yes" ] ; then · line 5830

Quoted 6 lines
configure +3 -0
@@ -5825,6 +5825,10 @@ if [ "$bsd" = "yes" ] ; then
    echo "CONFIG_BSD=y" >> $config_host_mak
  fi
 
+if [ "$darwin" = "yes" ] ; then
+  echo "CONFIG_DARWIN=y" >> $config_host_mak
+fi

Hi!

We already have these lines in "configure":

if test "$darwin" = "yes" ; then
echo "CONFIG_DARWIN=y" >> $config_host_mak
fi

... so your patch here looks pretty redundant?

Thomas

#4 lore raw

PATCH 2/2 net: implement vmnet-based netdev

In reply to [email protected]

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.

This is my first QEMU contribution, so please feel free to let me know what I’ve missed or what needs improving. Thanks very much for taking a look =)

---
 configure         |   2 +-
 net/clients.h     |   6 +
 net/meson.build   |   1 +
 net/net.c         |   3 +
 net/vmnet-macos.c | 444 ++++++++++++++++++++++++++++++++++++++++++++++
 qapi/net.json     |  64 ++++++-
 qemu-options.hx   |   9 +
 7 files changed, 526 insertions(+), 3 deletions(-)
 create mode 100644 net/vmnet-macos.c
configure +1 -1
index 4afd22bdf5..f449198db1 100755
@@ -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
index 92f9b59aed..463a9b2f67 100644
@@ -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
index 1076b0a7ab..8c7c32f775 100644
@@ -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
index c1cd9c75f6..e68a410a89 100644
@@ -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 +444 -0

444 lines not on this page · raw message

qapi/net.json +62 -2

82 lines not on this page · raw message

qemu-options.hx +9 -0
index 9172d51659..ec6b40b079 100644
@@ -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)
#5 lore raw

Re: [PATCH 2/2] net: implement vmnet-based netdev

Quoted 12 lines · On 2/4/21 10:25 AM, [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.

Quoted 3 lines

This is my first QEMU contribution, so please feel free to let me know what I’ve missed or what needs improving. Thanks very much for taking a look =)

This paragraph would fit better...

Quoted 3 lines

---

...here, after the --- marker. It's useful to the reviewer (and welcome to the community, by the way!), but does not need to be enshrined in git history.

Quoted 7 lines
 configure         |   2 +-
 net/clients.h     |   6 +
 net/meson.build   |   1 +
 net/net.c         |   3 +
 net/vmnet-macos.c | 444 ++++++++++++++++++++++++++++++++++++++++++++++
 qapi/net.json     |  64 ++++++-
 qemu-options.hx   |   9 +

I'm focusing mainly on the UI aspects, and did not look closely at the rest.

Quoted 11 lines

+++ b/qapi/net.json

qapi/net.json +6 -0
@@ -450,6 +450,65 @@
     '*vhostdev':     'str',
     '*queues':       'int' } }
 
+##
+# @VmnetOperatingMode:
+#
+# An enumeration of the I/O operation types
+#
+# @host: the guest may communicate with the host 

qapi/net.json line 468

Quoted 10 lines
qapi/net.json +10 -0
+#        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: 5.3

The next release will be 6.0, not 5.3.

qapi/net.json line 481

Quoted 13 lines
qapi/net.json +13 -0
+##
+{ 'enum': 'VmnetOperatingMode',
+  'data': [ 'host', 'shared', 'bridged' ] }
+
+##
+# @NetdevVmnetOptions:
+#
+# vmnet network backend (only available on macOS)
+#
+# @mode: the operating mode vmnet should run in
+#
+# @ifname: the physical network interface to bridge with 
+#          (only valid with mode=bridged)

If this is only valid with bridged, then you should use a union type, where only the bridged branch supports this member. That is more typesafe than always supporting it in the schema and having to semantically filter it out after the fact.

Review line 483

Quoted 2 lines
(quoted diff) +2 -0
+#
+# @dhcp_start_address: the gateway address to use for the interface. 

New QAPI additions should favor names with '-' rather than '_', as in dhcp-start-address; the exception is if you are closely copying another older interface that already used _.

Quoted 9 lines
qapi/net.json +9 -0
+#                      The range to dhcp_end_address is placed in the DHCP pool.
+#                      (only valid with mode=host|shared)
+#                      (must be specified with dhcp_end_address and 
+#                       dhcp_subnet_mask)
+#                      (allocated automatically if unset)
+#
+# @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 

qapi/net.json line 502

Quoted 10 lines
qapi/net.json +10 -0
+#                       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: 5.3

6.0

qapi/net.json line 510

Quoted 8 lines
qapi/net.json +8 -0
+##
+{ 'struct': 'NetdevVmnetOptions',
+  'data': {
+    'mode':        'VmnetOperatingMode',
+    '*ifname':        'str',
+    '*dhcp_start_address':      'str',
+    '*dhcp_end_address':        'str',
+    '*dhcp_subnet_mask':        'str' } }

In addition to my suggestion of making this a union rather than a struct, you probably also want to include an 'if' tag so that the struct is present only on MacOS builds (it's nicer for introspection to not advertise something that won't work).

qapi/net.json line 523

Quoted 10 lines
qapi/net.json +2 -1
+
 ##
 # @NetClientDriver:
 #
@@ -461,7 +520,7 @@
 ##
 { 'enum': 'NetClientDriver',
   'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
-            'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa' ] }
+            'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa', 'vmnet-macos' ] }

Missing a doc mention that 'vmnet-macos' is new to 6.0.

qapi/net.json line 553

Quoted 10 lines
qapi/net.json +2 -1
 ##
 # @Netdev:
@@ -490,7 +549,8 @@
     'hubport':  'NetdevHubPortOptions',
     'netmap':   'NetdevNetmapOptions',
     'vhost-user': 'NetdevVhostUserOptions',
-    'vhost-vdpa': 'NetdevVhostVDPAOptions' } }
+    'vhost-vdpa': 'NetdevVhostVDPAOptions',
+    'vmnet-macos': 'NetdevVmnetOptions' } }

Adding Markus in cc; right now, I don't think QAPI supports a union type as a branch to another union type. There's nothing that technically would prevent us from doing that, just the grunt work of modifying the QAPI code generator to support it.

Quoted 24 lines
qapi/net.json +0 -0
 ##
 # @NetFilterDirection:
qemu-options.hx +9 -0
index 9172d51659..ec6b40b079 100644
@@ -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 · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#6 lore raw

Re: [PATCH 2/2] net: implement vmnet-based netdev

Thanks very much for taking a look!

As per my understanding of the submission process, I will resubmit this patchset (sans my self-introduction =) )
in a new [PATCH v2] thread, incorporating the changes you pointed out here.

Quoted 4 lines

Adding Markus in cc; right now, I don't think QAPI supports a union type as a branch to another union type. There's nothing that technically would prevent us from doing that, just the grunt work of modifying the QAPI code generator to support it.

I'm unfamiliar with the QAPI codegen and what it supports~ The mode param is shared by all three mode types. Thus, could I make the NetdevVmnetOptions contain a mode field and a mode-specific union of options, to avoid the direct union-union nesting?

Phillip

Quoted 196 lines · Eric Blake
Quoted 12 lines · On 2/4/21 10:25 AM, [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.

Quoted 3 lines

This is my first QEMU contribution, so please feel free to let me know what I’ve missed or what needs improving. Thanks very much for taking a look =)

This paragraph would fit better...

Quoted 3 lines

---

...here, after the --- marker. It's useful to the reviewer (and welcome to the community, by the way!), but does not need to be enshrined in git history.

Quoted 7 lines
 configure         |   2 +-
 net/clients.h     |   6 +
 net/meson.build   |   1 +
 net/net.c         |   3 +
 net/vmnet-macos.c | 444 ++++++++++++++++++++++++++++++++++++++++++++++
 qapi/net.json     |  64 ++++++-
 qemu-options.hx   |   9 +

I'm focusing mainly on the UI aspects, and did not look closely at the rest.

Quoted 11 lines

+++ b/qapi/net.json

qapi/net.json +6 -0
@@ -450,6 +450,65 @@
     '*vhostdev':     'str',
     '*queues':       'int' } }
 
+##
+# @VmnetOperatingMode:
+#
+# An enumeration of the I/O operation types
+#
+# @host: the guest may communicate with the host

qapi/net.json line 468

Quoted 10 lines
qapi/net.json +10 -0
+#        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: 5.3

The next release will be 6.0, not 5.3.

qapi/net.json line 481

Quoted 13 lines
qapi/net.json +13 -0
+##
+{ 'enum': 'VmnetOperatingMode',
+  'data': [ 'host', 'shared', 'bridged' ] }
+
+##
+# @NetdevVmnetOptions:
+#
+# vmnet network backend (only available on macOS)
+#
+# @mode: the operating mode vmnet should run in
+#
+# @ifname: the physical network interface to bridge with
+#          (only valid with mode=bridged)

If this is only valid with bridged, then you should use a union type, where only the bridged branch supports this member. That is more typesafe than always supporting it in the schema and having to semantically filter it out after the fact.

Review line 483

Quoted 2 lines
(quoted diff) +2 -0
+#
+# @dhcp_start_address: the gateway address to use for the interface.

New QAPI additions should favor names with '-' rather than '_', as in dhcp-start-address; the exception is if you are closely copying another older interface that already used _.

Review line 484

Quoted 1 line
(quoted diff) +1 -0
+#                      The range to dhcp_end_address is placed in the

DHCP pool.

qapi/net.json

Quoted 6 lines
qapi/net.json +6 -0
+#                      (only valid with mode=host|shared)
+#                      (must be specified with dhcp_end_address and
+#                       dhcp_subnet_mask)
+#                      (allocated automatically if unset)
+#
+# @dhcp_end_address: the DHCP IPv4 range end address to use for the

interface.

qapi/net.json

Quoted 6 lines
qapi/net.json +6 -0
+#                      (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.

qapi/net.json line 502

Quoted 6 lines
qapi/net.json +6 -0
+#                    (only valid with mode=host|shared)
+#                    (must be specified with dhcp_start_address and
+#                     dhcp_end_address)
+#                    (allocated automatically if unset)
+#
+# Since: 5.3

6.0

qapi/net.json line 510

Quoted 8 lines
qapi/net.json +8 -0
+##
+{ 'struct': 'NetdevVmnetOptions',
+  'data': {
+    'mode':        'VmnetOperatingMode',
+    '*ifname':        'str',
+    '*dhcp_start_address':      'str',
+    '*dhcp_end_address':        'str',
+    '*dhcp_subnet_mask':        'str' } }

In addition to my suggestion of making this a union rather than a struct, you probably also want to include an 'if' tag so that the struct is present only on MacOS builds (it's nicer for introspection to not advertise something that won't work).

qapi/net.json line 464

Quoted 9 lines
qapi/net.json +1 -1
+
 ##
 # @NetClientDriver:
 #
@@ -461,7 +520,7 @@
 ##
 { 'enum': 'NetClientDriver',
   'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
-            'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa' ]

}

Review line 523

Quoted 1 line
(quoted diff) +1 -0
+            'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa',

'vmnet-macos' ] }

Missing a doc mention that 'vmnet-macos' is new to 6.0.

qapi/net.json line 553

Quoted 10 lines
qapi/net.json +2 -1
 ##
 # @Netdev:
@@ -490,7 +549,8 @@
     'hubport':  'NetdevHubPortOptions',
     'netmap':   'NetdevNetmapOptions',
     'vhost-user': 'NetdevVhostUserOptions',
-    'vhost-vdpa': 'NetdevVhostVDPAOptions' } }
+    'vhost-vdpa': 'NetdevVhostVDPAOptions',
+    'vmnet-macos': 'NetdevVmnetOptions' } }

Adding Markus in cc; right now, I don't think QAPI supports a union type as a branch to another union type. There's nothing that technically would prevent us from doing that, just the grunt work of modifying the QAPI code generator to support it.

qemu-options.hx DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, · line 2485

Quoted 11 lines
qapi/net.json +0 -0
 ##
 # @NetFilterDirection:
qemu-options.hx +0 -0
index 9172d51659..ec6b40b079 100644
@@ -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"

qemu-options.hx DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,

Quoted 4 lines
qemu-options.hx +4 -0
+#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"

qemu-options.hx DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, · line 2490

Quoted 1 line
qemu-options.hx +1 -0
+    "         the physical interface to bridge with defaults to en0 if

unspecified\n"

qemu-options.hx DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, · line 2492

Quoted 2 lines
qemu-options.hx +2 -0
+    "-netdev vmnet-macos,id=str,mode=host|shared\n"
+    "

[,dhcp_start_address=addr,dhcp_end_address=addr,dhcp_subnet_mask=mask]\n"

qemu-options.hx DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, · line 2493

Quoted 1 line
qemu-options.hx +1 -0
+    "         configure a macOS-provided vmnet network in \"host\" or

\"shared\" mode\n"

qemu-options.hx DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, · line 2494

Quoted 1 line
qemu-options.hx +1 -0
+    "         the DHCP configuration will be set automatically if

unspecified\n"

qemu-options.hx DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,

Quoted 3 lines
qemu-options.hx +0 -0
 #endif
     "-netdev hubport,id=str,hubid=n[,netdev=nd]\n"
     "                configure a hub port on the hub with ID 'n'\n",

QEMU_ARCH_ALL)

Quoted 1 line

--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org