Add vmnet.framework based network backend
Subsystems (2)
cover Add vmnet.framework based network backend
macOS provides networking API for VMs called vmnet.framework. I tried to add it as a network backend. All three modes are supported:
-shared:
allows the guest to comminicate with other guests in shared mode and also with external network (Internet) via NAT
-host:
allows the guest to communicate with other guests in host mode
-bridged:
bridges the guest with a physical network interface
Separate netdev for each vmnet mode was created because they use quite different settings, especially since macOS 11.0 when vmnet.framework gets a lot of updates.
Not sure that I use qemu_mutex_lock_iothread() and qemu_mutex_unlock_iothread() in correct way while sending packet from vmnet interface to QEMU. I'll be happy to receive recomendations how to make this thing better if I done sth wrong.
Also vmnet.framework requires com.apple.vm.networking entitlement to run without root priveledges. Ad-hoc signing does not fit there, so I didn't touch anything related to signing. As a result we should run qemu-system by a priviledged user:$ sudo qemu-system-x86_64 -nic vmnet-shared
otherwise vmnet fails with 'general failure'.
But in any way it seems working now,
I tested it within qemu-system-x86-64 on macOS 10.15.7 host, with nic models:
- e1000-82545em
- virtio-net-pci
and having such guests:
- macOS 10.15.7
- Ubuntu Bionic (server cloudimg)
Vladislav Yaroshchuk (7):
net/vmnet: dependencies setup, initial preparations net/vmnet: add new netdevs to qapi/net net/vmnet: create common netdev state structure net/vmnet: implement shared mode (vmnet-shared) net/vmnet: implement host mode (vmnet-host) net/vmnet: implement bridged mode (vmnet-bridged) net/vmnet: update qemu-options.hx
configure | 31 +++++ meson.build | 5 + net/clients.h | 11 ++ net/meson.build | 7 ++ net/net.c | 10 ++ net/vmnet-bridged.m | 123 ++++++++++++++++++ net/vmnet-common.m | 294 ++++++++++++++++++++++++++++++++++++++++++++ net/vmnet-host.c | 93 ++++++++++++++ net/vmnet-shared.c | 94 ++++++++++++++ net/vmnet_int.h | 48 ++++++++ qapi/net.json | 99 ++++++++++++++- qemu-options.hx | 17 +++ 12 files changed, 830 insertions(+), 2 deletions(-) create mode 100644 net/vmnet-bridged.m create mode 100644 net/vmnet-common.m create mode 100644 net/vmnet-host.c create mode 100644 net/vmnet-shared.c create mode 100644 net/vmnet_int.h
Signature · 1 line
2.23.0
PATCH 1/7 net/vmnet: dependencies setup, initial preparations
Add 'vmnet' customizable option and 'vmnet.framework' probe into configure;
Create source files for network client driver, update meson.build;
Add 'vmnet' into qapi::net::NetClientDriver options list.
--- configure | 31 +++++++++++++++++++++++++++++++ meson.build | 5 +++++ net/clients.h | 4 ++++ net/meson.build | 1 + net/net.c | 6 ++++++ net/vmnet.c | 22 ++++++++++++++++++++++ qapi/net.json | 3 ++- 7 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 net/vmnet.c
configure +31 -0
@@ -307,6 +307,7 @@ mpath="auto" vnc="enabled" sparse="auto" vde="$default_feature" +vmnet="auto" vnc_sasl="auto" vnc_jpeg="auto" vnc_png="auto"
@@ -1059,6 +1060,10 @@ for opt do ;; --enable-vde) vde="yes" ;; + --disable-vmnet) vmnet="no" + ;; + --enable-vmnet) vmnet="yes" + ;; --disable-netmap) netmap="no" ;; --enable-netmap) netmap="yes"
@@ -1871,6 +1876,7 @@ disabled with --disable-FEATURE, default is enabled if available rdma Enable RDMA-based migration pvrdma Enable PVRDMA support vde support for vde network + vmnet vmnet.framework support (macOS) netmap support for netmap network linux-aio Linux AIO support linux-io-uring Linux io_uring support
@@ -3157,6 +3163,28 @@ EOF fi fi +########################################## +# vmnet.framework probe +if test "$vmnet" != "no" ; then + vmnet_flags="-framework vmnet" + cat > $TMPC << EOF +#include <vmnet/vmnet.h> +int main(void) +{ + (void) vmnet_allocate_mac_address_key; + return 0; +} +EOF + if compile_prog "" "$vmnet_flags" ; then + vmnet=yes + else + if test "$vmnet" = "yes" ; then + feature_not_found "vmnet" "'vmnet.framework' in unsupported in this build" + fi + vmnet=no + fi +fi + ########################################## # netmap support probe # Apart from looking for netmap headers, we make sure that the host API version
@@ -5559,6 +5587,9 @@ if test "$vde" = "yes" ; then echo "CONFIG_VDE=y" >> $config_host_mak echo "VDE_LIBS=$vde_libs" >> $config_host_mak fi +if test "$vmnet" = "yes" ; then + echo "CONFIG_VMNET=y" >> $config_host_mak +fi if test "$netmap" = "yes" ; then echo "CONFIG_NETMAP=y" >> $config_host_mak fi
meson.build +5 -0
@@ -173,6 +173,7 @@ iokit = [] emulator_link_args = [] nvmm =not_found hvf = not_found +vmnet = not_found if targetos == 'windows' socket = cc.find_library('ws2_32') winmm = cc.find_library('winmm')
@@ -184,6 +185,9 @@ if targetos == 'windows' elif targetos == 'darwin' coref = dependency('appleframeworks', modules: 'CoreFoundation') iokit = dependency('appleframeworks', modules: 'IOKit') + if config_host.has_key('CONFIG_VMNET') + vmnet = dependency('appleframeworks', modules: 'vmnet') + endif elif targetos == 'sunos' socket = [cc.find_library('socket'), cc.find_library('nsl'),
@@ -2522,6 +2526,7 @@ summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')} summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server} summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')} summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')} +summary_info += {'vmnet support': vmnet.found()} summary_info += {'build guest agent': config_host.has_key('CONFIG_GUEST_AGENT')} summary(summary_info, bool_yn: true, section: 'Configurable features')
net/clients.h +4 -0
@@ -63,4 +63,8 @@ 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_VMNET +int net_init_vmnet (const Netdev *netdev,const char *name, +NetClientState *peer,Error **errp); +#endif #endif /* QEMU_NET_CLIENTS_H */
net/meson.build +1 -0
@@ -38,4 +38,5 @@ 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_VMNET', vmnet], if_true: files('vmnet.c')) subdir('can')
net/net.c +6 -0
@@ -1001,6 +1001,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_VMNET + [NET_CLIENT_DRIVER_VMNET] = net_init_vmnet, +#endif };
@@ -1086,6 +1089,9 @@ void show_netdevs(void)#endif #ifdef CONFIG_VHOST_VDPA "vhost-vdpa", +#endif +#ifdef CONFIG_VMNET + "vmnet",#endif };
net/vmnet.c new file +22 -0
@@ -0,0 +1,22 @@ +/* +* vmnet.c - network client wrapper for Apple vmnet.framework +* +* Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include <vmnet/vmnet.h> + +int net_init_vmnet (const Netdev *netdev,const char *name, +NetClientState *peer,Error **errp) { +error_setg (errp,"vmnet is not implemented yet" ); +return -1 ; +}
qapi/net.json +2 -1
@@ -460,10 +460,11 @@ # Since: 2.7 # # @vhost-vdpa since 5.1 +# @vmnet since 6.1 ## { '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' ] } ## # @Netdev:
Signature · 1 line
2.23.0
Re: [PATCH 1/7] net/vmnet: dependencies setup, initial preparations
Quoted 2 lines · Vladislav Yaroshchuk
Add 'vmnet' customizable option and 'vmnet.framework' probe into configure;
I'm sorry no one else has taken time to review this yet; thanks for your ping. I'm not the network maintainer, and I don't develop on Mac, so I'm uncomfortable doing a full review myself, but I can at least point out:
Quoted 10 lines
Create source files for network client driver, update meson.build;
Add 'vmnet' into
qapi::net::NetClientDriveroptions list.Signed-off-by Vladislav Yaroshchuk <[email protected]>---
+++
b/qapi/net.json
qapi/net.json line 463
Quoted 4 lines
qapi/net.json +1
-0@@ -460,10 +460,11 @@ # Since: 2.7 # # @vhost-vdpa since 5.1 +# @vmnet since 6.1
Sadly, since no one reviewed, it has missed the 6.1 boat, and you'll have to respin this to call out 6.2 (no need to do that until you have other review comments to address).
qapi/net.json line 467
Quoted 5 lines
qapi/net.json +1
-1## { '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' ] }
Long line; please wrap to keep under 80 columns.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 2/7 net/vmnet: add new netdevs to qapi/net
In reply to Vladislav YaroshchukCreated separate netdev per each vmnet operating mode because they use quite different settings. Especially since macOS 11.0 (vmnet.framework API gets lots of updates)
Three new netdevs are added:
- vmnet-host
- vmnet-shared
- vmnet-bridged
--- net/clients.h | 11 +++++- net/net.c | 10 +++-- net/vmnet.c | 14 ++++++- qapi/net.json | 100 ++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 126 insertions(+), 9 deletions(-)
net/clients.h +9 -2
@@ -64,7 +64,14 @@ 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_VMNET -int net_init_vmnet (const Netdev *netdev,const char *name, +int net_init_vmnet_host (const Netdev *netdev,const char *name,NetClientState *peer,Error **errp); -#endif + +int net_init_vmnet_shared (const Netdev *netdev,const char *name, +NetClientState *peer,Error **errp); + +int net_init_vmnet_bridged (const Netdev *netdev,const char *name, +NetClientState *peer,Error **errp); +#endif /* CONFIG_VMNET */ +#endif /* QEMU_NET_CLIENTS_H */
net/net.c +7 -3
@@ -1002,8 +1002,10 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])( [NET_CLIENT_DRIVER_L2TPV3] = net_init_l2tpv3, #endif #ifdef CONFIG_VMNET - [NET_CLIENT_DRIVER_VMNET] = net_init_vmnet, -#endif + [NET_CLIENT_DRIVER_VMNET_HOST] = net_init_vmnet_host, + [NET_CLIENT_DRIVER_VMNET_SHARED] = net_init_vmnet_shared, + [NET_CLIENT_DRIVER_VMNET_BRIDGED] = net_init_vmnet_bridged, +#endif /* CONFIG_VMNET */ };
@@ -1091,7 +1093,9 @@ void show_netdevs(void) "vhost-vdpa",#endif #ifdef CONFIG_VMNET - "vmnet", +"vmnet-host" , +"vmnet-shared" , + "vmnet-bridged", #endif };
net/vmnet.c +13 -1
@@ -15,7 +15,19 @@#include <vmnet/vmnet.h> -int net_init_vmnet (const Netdev *netdev,const char *name, +int net_init_vmnet_host (const Netdev *netdev,const char *name, +NetClientState *peer,Error **errp) { +error_setg (errp,"vmnet is not implemented yet" ); +return -1 ; +} + +int net_init_vmnet_shared (const Netdev *netdev,const char *name, +NetClientState *peer,Error **errp) { +error_setg (errp,"vmnet is not implemented yet" ); +return -1 ; +} + +int net_init_vmnet_bridged (const Netdev *netdev,const char *name,NetClientState *peer,Error **errp) {error_setg (errp,"vmnet is not implemented yet" );return -1 ;
qapi/net.json +97 -3
127 lines not on this page · raw message
Signature · 1 line
2.23.0
Re: [PATCH 2/7] net/vmnet: add new netdevs to qapi/net
Quoted 31 lines · Vladislav Yaroshchuk
Created separate netdev per each vmnet operating mode because they use quite different settings. Especially since macOS 11.0 (vmnet.framework API gets lots of updates)
Three new netdevs are added:
- vmnet-host
- vmnet-shared
- vmnet-bridgedSigned-off-by Vladislav Yaroshchuk <[email protected]>---
+++
b/qapi/net.jsonqapi/net.json +14
-0@@ -452,6 +452,89 @@ '*vhostdev': 'str', '*queues': 'int' } } +## +# @NetdevVmnetHostOptions: +# +# vmnet (host mode) network backend. +# +# Allows the vmnet interface to communicate with +# other vmnet interfaces that are in host mode and also with the native host. +# +# @dhcpstart: The starting IPv4 address to use for the interface. Must be in the +# private IP range (RFC 1918). Must be specified along +# with @dhcpend and @subnetmask. +# This address is used as the gateway address. The subsequent address +# up to and including dhcpend are placed in the DHCP pool. +#
qapi/net.json line 478
Quoted 10 lines
qapi/net.json +10
-0+# @dhcpend: The DHCP IPv4 range end address to use for the interface. Must be in +# the private IP range (RFC 1918). Must be specified along +# with @dhcpstart and @subnetmask. +# +# @subnetmask: The IPv4 subnet mask to use on the interface. Must be specified +# along with @dhcpstart and @subnetmask. +# +# +# Since: 6.1, +##
Same comments about 6.1 vs. 6.2 as before (I'll quit pointing it out). Spurious trailing comma.
qapi/net.json line 483
Quoted 5 lines
qapi/net.json +5
-0+{ 'struct': 'NetdevVmnetHostOptions', + 'data': { + '*dhcpstart': 'str', + '*dhcpend': 'str', + '*subnetmask': 'str'
Hmm. You listed all three as optional, but document that they must all be specified together. Why not just make them all required, and simplify the documentation?
Quoted 10 lines
qapi/net.json +10
-0+ }, + 'if': 'defined(CONFIG_VMNET)' } + +## +# @NetdevVmnetSharedOptions: +# +# vmnet (shared mode) network backend. +# +# Allows traffic originating from the vmnet interface to reach the +# Internet through a network address translator (NAT). The vmnet interface
qapi/net.json line 503
Quoted 10 lines
qapi/net.json +10
-0+# can also communicate with the native host. By default, the vmnet interface +# is able to communicate with other shared mode interfaces. If a subnet range +# is specified, the vmnet interface can communicate with other shared mode +# interfaces on the same subnet. +# +# @dhcpstart: The starting IPv4 address to use for the interface. Must be in the +# private IP range (RFC 1918). Must be specified along +# with @dhcpend and @subnetmask. +# This address is used as the gateway address. The subsequent address +# up to and including dhcpend are placed in the DHCP pool.
Spurious double space.
Quoted 38 lines
qapi/net.json +34
-0+# +# @dhcpend: The DHCP IPv4 range end address to use for the interface. Must be in +# the private IP range (RFC 1918). Must be specified along +# with @dhcpstart and @subnetmask. +# +# @subnetmask: The IPv4 subnet mask to use on the interface. Must be specified +# along with @dhcpstart and @subnetmask. +# +# +# Since: 6.1, +## +{ 'struct': 'NetdevVmnetSharedOptions', + 'data': { + '*dhcpstart': 'str', + '*dhcpend': 'str', + '*subnetmask': 'str' + }, + 'if': 'defined(CONFIG_VMNET)' } + +## +# @NetdevVmnetBridgedOptions: +# +# vmnet (bridged mode) network backend. +# +# Bridges the vmnet interface with a physical network interface. +# +# @ifname: The name of the physical interface to be bridged. +# +# Since: 6.1 +## +{ 'struct': 'NetdevVmnetBridgedOptions', + 'data': { 'ifname': 'str' }, + 'if': 'defined(CONFIG_VMNET)' } + ## # @NetClientDriver: #
qapi/net.json line 463
Quoted 4 lines
qapi/net.json +0
-1@@ -460,11 +543,16 @@ # Since: 2.7 # # @vhost-vdpa since 5.1 -# @vmnet since 6.1
Why are you dropping vmnet? Especially since you just added it in the previous patch? That feels like needless churn.
Quoted 11 lines
qapi/net.json +7
-1+# @vmnet-host since 6.1 +# @vmnet-shared since 6.1 +# @vmnet-bridged since 6.1 ## { 'enum': 'NetClientDriver', 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', - 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa', 'vmnet' ] } + 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa', + { 'name': 'vmnet-host', 'if': 'defined(CONFIG_VMNET)' }, + { 'name': 'vmnet-shared', 'if': 'defined(CONFIG_VMNET)' }, + { 'name': 'vmnet-bridged', 'if': 'defined(CONFIG_VMNET)' }] }
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH 2/7] net/vmnet: add new netdevs to qapi/net
Hi Eric,
Thank you for your review.
сб, 7 авг. 2021 г. в 00:19, Eric Blake <[email protected]>:
Quoted 57 lines · Vladislav Yaroshchuk
Quoted 14 lines
Created separate netdev per each vmnet operating mode because they use quite different settings. Especially since macOS 11.0 (vmnet.framework API gets lots of updates)
Three new netdevs are added:
- vmnet-host
- vmnet-shared
- vmnet-bridgedSigned-off-by Vladislav Yaroshchuk <[email protected]>---
+++
b/qapi/net.jsonqapi/net.json line 461
Quoted 10 lines
qapi/net.json +7
-0@@ -452,6 +452,89 @@ '*vhostdev': 'str', '*queues': 'int' } } +## +# @NetdevVmnetHostOptions: +# +# vmnet (host mode) network backend. +# +# Allows the vmnet interface to communicate with +# other vmnet interfaces that are in host mode and also with the nativehost.
Review line 463
Quoted 2 lines
(quoted diff) +2
-0+# +# @dhcpstart: The starting IPv4 address to use for the interface. Mustbe in the
qapi/net.json
Quoted 3 lines
qapi/net.json +3
-0+# private IP range (RFC 1918). Must be specified along +# with @dhcpend and @subnetmask. +# This address is used as the gateway address. Thesubsequent address
qapi/net.json
Quoted 3 lines
qapi/net.json +3
-0+# up to and including dhcpend are placed in the DHCP pool. +# +# @dhcpend: The DHCP IPv4 range end address to use for the interface.Must be in
qapi/net.json
Quoted 4 lines
qapi/net.json +4
-0+# the private IP range (RFC 1918). Must be specified along +# with @dhcpstart and @subnetmask. +# +# @subnetmask: The IPv4 subnet mask to use on the interface. Must bespecified
qapi/net.json line 478
Quoted 5 lines
qapi/net.json +5
-0+# along with @dhcpstart and @subnetmask. +# +# +# Since: 6.1, +##Same comments about 6.1 vs. 6.2 as before (I'll quit pointing it out). Spurious trailing comma.
qapi/net.json line 483
Quoted 5 lines
qapi/net.json +5
-0+{ 'struct': 'NetdevVmnetHostOptions', + 'data': { + '*dhcpstart': 'str', + '*dhcpend': 'str', + '*subnetmask': 'str'
Quoted 5 lines
Hmm. You listed all three as optional, but document that they must all be specified together. Why not just make them all required, and simplify the documentation?
All three options can be not specified at all, or, if specified, must be
used all together. It's the user's choice to adjust DHCP settings or leave it for vmnet.framework.-netdev vmnet-host is correct and -netdev vmnet-host,dhcpstart="..",dhcpend="..",subnetmask=".." is correct too. So we can't make all the options required
Quoted 77 lines
qapi/net.json
Quoted 10 lines
qapi/net.json +10
-0+ }, + 'if': 'defined(CONFIG_VMNET)' } + +## +# @NetdevVmnetSharedOptions: +# +# vmnet (shared mode) network backend. +# +# Allows traffic originating from the vmnet interface to reach the +# Internet through a network address translator (NAT). The vmnetinterface
Review line 494
Quoted 1 line
(quoted diff) +1
-0+# can also communicate with the native host. By default, the vmnetinterface
Review line 495
Quoted 1 line
(quoted diff) +1
-0+# is able to communicate with other shared mode interfaces. If a subnetrange
Review line 496
Quoted 1 line
(quoted diff) +1
-0+# is specified, the vmnet interface can communicate with other sharedmode
qapi/net.json
Quoted 3 lines
qapi/net.json +3
-0+# interfaces on the same subnet. +# +# @dhcpstart: The starting IPv4 address to use for the interface. Mustbe in the
qapi/net.json
Quoted 3 lines
qapi/net.json +3
-0+# private IP range (RFC 1918). Must be specified along +# with @dhcpend and @subnetmask. +# This address is used as the gateway address. Thesubsequent address
Review line 503
Quoted 1 line
(quoted diff) +1
-0+# up to and including dhcpend are placed in the DHCP pool.Spurious double space.
Review line 505
Quoted 2 lines
(quoted diff) +2
-0+# +# @dhcpend: The DHCP IPv4 range end address to use for the interface.Must be in
qapi/net.json
Quoted 4 lines
qapi/net.json +4
-0+# the private IP range (RFC 1918). Must be specified along +# with @dhcpstart and @subnetmask. +# +# @subnetmask: The IPv4 subnet mask to use on the interface. Must bespecified
Quoted 32 lines
qapi/net.json +28
-0+# along with @dhcpstart and @subnetmask. +# +# +# Since: 6.1, +## +{ 'struct': 'NetdevVmnetSharedOptions', + 'data': { + '*dhcpstart': 'str', + '*dhcpend': 'str', + '*subnetmask': 'str' + }, + 'if': 'defined(CONFIG_VMNET)' } + +## +# @NetdevVmnetBridgedOptions: +# +# vmnet (bridged mode) network backend. +# +# Bridges the vmnet interface with a physical network interface. +# +# @ifname: The name of the physical interface to be bridged. +# +# Since: 6.1 +## +{ 'struct': 'NetdevVmnetBridgedOptions', + 'data': { 'ifname': 'str' }, + 'if': 'defined(CONFIG_VMNET)' } + ## # @NetClientDriver: #qapi/net.json line 463
Quoted 4 lines
qapi/net.json +0
-1@@ -460,11 +543,16 @@ # Since: 2.7 # # @vhost-vdpa since 5.1 -# @vmnet since 6.1Why are you dropping vmnet? Especially since you just added it in the previous patch? That feels like needless churn.
Quoted 1 line
Yep, that was my mistake, on that stage I decided to create separate
backends for each vmnet operational mode. Will remove redundant change the next series.
Quoted 12 lines
+# @vmnet-host since 6.1
qapi/net.json
Quoted 6 lines
qapi/net.json +2
-1+# @vmnet-shared since 6.1 +# @vmnet-bridged since 6.1 ## { 'enum': 'NetClientDriver', 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', - 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa','vmnet' ] }
qapi/net.json
Quoted 4 lines
qapi/net.json +4
-0+ 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa', + { 'name': 'vmnet-host', 'if': 'defined(CONFIG_VMNET)' }, + { 'name': 'vmnet-shared', 'if': 'defined(CONFIG_VMNET)' }, + { 'name': 'vmnet-bridged', 'if': 'defined(CONFIG_VMNET)' }]
Quoted 8 lines
}
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
Will fix all other issues asap, thank you!
Regards,
Vladislav
PATCH 3/7 net/vmnet: create common netdev state structure
In reply to Vladislav Yaroshchuk--- net/meson.build | 8 +++++++- net/vmnet-bridged.c | 25 +++++++++++++++++++++++++ net/vmnet-common.c | 20 ++++++++++++++++++++ net/vmnet-host.c | 24 ++++++++++++++++++++++++ net/vmnet-shared.c | 25 +++++++++++++++++++++++++ net/vmnet.c | 34 ---------------------------------- net/vmnet_int.h | 25 +++++++++++++++++++++++++ 7 files changed, 126 insertions(+), 35 deletions(-) create mode 100644 net/vmnet-bridged.c create mode 100644 net/vmnet-common.c create mode 100644 net/vmnet-host.c create mode 100644 net/vmnet-shared.c delete mode 100644 net/vmnet.c create mode 100644 net/vmnet_int.h
net/meson.build +7 -1
@@ -38,5 +38,11 @@ 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_VMNET', vmnet], if_true: files('vmnet.c')) +vmnet_files = files( + 'vmnet-common.c', + 'vmnet-bridged.c', + 'vmnet-host.c', + 'vmnet-shared.c' +) +softmmu_ss.add(when: ['CONFIG_VMNET', vmnet], if_true: vmnet_files) subdir('can')
net/vmnet-bridged.c new file +25 -0
@@ -0,0 +1,25 @@ +/* +* vmnet-bridged.c +* +* Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include <vmnet/vmnet.h> + +int net_init_vmnet_bridged (const Netdev *netdev,const char *name, +NetClientState *peer,Error **errp) +{ +error_setg (errp,"vmnet-bridged is not implemented yet" ); +return -1 ; +}
net/vmnet-common.c new file +20 -0
@@ -0,0 +1,20 @@ +/* +* vmnet.c - network client wrapper for Apple vmnet.framework +* +* Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]> +* Copyright(c) 2021 Phillip Tennen <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include <vmnet/vmnet.h> +
net/vmnet-host.c new file +24 -0
@@ -0,0 +1,24 @@ +/* +* vmnet-host.c +* +* Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include <vmnet/vmnet.h> + +int net_init_vmnet_host (const Netdev *netdev,const char *name, +NetClientState *peer,Error **errp) { +error_setg (errp,"vmnet-host is not implemented yet" ); +return -1 ; +}
net/vmnet-shared.c new file +25 -0
@@ -0,0 +1,25 @@ +/* +* vmnet-shared.c +* +* Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include <vmnet/vmnet.h> + +int net_init_vmnet_shared (const Netdev *netdev,const char *name, +NetClientState *peer,Error **errp) +{ +error_setg (errp,"vmnet-shared is not implemented yet" ); +return -1 ; +}
net/vmnet.c deleted +0 -34
@@ -1,34 +0,0 @@ -/* -* vmnet.c - network client wrapper for Apple vmnet.framework -* -* Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -* -*/ - -#include "qemu/osdep.h" -#include "clients.h" -#include "qemu/error-report.h" -#include "qapi/error.h" - -#include <vmnet/vmnet.h> - -int net_init_vmnet_host (const Netdev *netdev,const char *name, -NetClientState *peer,Error **errp) { -error_setg (errp,"vmnet is not implemented yet" ); -return -1 ; -} - -int net_init_vmnet_shared (const Netdev *netdev,const char *name, -NetClientState *peer,Error **errp) { -error_setg (errp,"vmnet is not implemented yet" ); -return -1 ; -} - -int net_init_vmnet_bridged (const Netdev *netdev,const char *name, -NetClientState *peer,Error **errp) { -error_setg (errp,"vmnet is not implemented yet" ); -return -1 ; -}
net/vmnet_int.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* vmnet_int.h +* +* Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ +#ifndef VMNET_INT_H +#define VMNET_INT_H + +#include "qemu/osdep.h" +#include "vmnet_int.h" +#include "clients.h" + +#include <vmnet/vmnet.h> + +typedef struct VmnetCommonState { +NetClientState nc; + +}VmnetCommonState ; + + +#endif /* VMNET_INT_H */
Signature · 1 line
2.23.0
PATCH 4/7 net/vmnet: implement shared mode (vmnet-shared)
In reply to Vladislav YaroshchukStill not implemented:
- port forwarding
- ipv6 prefix setting
--- net/meson.build | 2 +- net/vmnet-common.c | 20 --- net/vmnet-common.m | 294 +++++++++++++++++++++++++++++++++++++++++++++ net/vmnet-shared.c | 73 ++++++++++- net/vmnet_int.h | 23 ++++ 5 files changed, 389 insertions(+), 23 deletions(-) delete mode 100644 net/vmnet-common.c create mode 100644 net/vmnet-common.m
net/meson.build +1 -1
@@ -39,7 +39,7 @@ 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')) vmnet_files = files( - 'vmnet-common.c', + 'vmnet-common.m', 'vmnet-bridged.c', 'vmnet-host.c', 'vmnet-shared.c'
net/vmnet-common.c deleted +0 -20
@@ -1,20 +0,0 @@ -/* -* vmnet.c - network client wrapper for Apple vmnet.framework -* -* Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]> -* Copyright(c) 2021 Phillip Tennen <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -* -*/ - -#include "qemu/osdep.h" -#include "qapi-types-net.h" -#include "vmnet_int.h" -#include "clients.h" -#include "qemu/error-report.h" -#include "qapi/error.h" - -#include <vmnet/vmnet.h> -
net/vmnet-common.m new file +294 -0
294 lines not on this page · raw message
net/vmnet-shared.c +71 -2
80 lines not on this page · raw message
net/vmnet_int.h +23 -0
@@ -16,10 +16,33 @@#include <vmnet/vmnet.h> +#define VMNET_PACKETS_LIMIT 50 +typedef struct VmnetCommonState {NetClientState nc; +interface_ref vmnet_if; + +bool send_enabled; + +uint64_t mtu; +uint64_t max_packet_size; + +struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT ]; +struct iovec iov_buf[VMNET_PACKETS_LIMIT ]; }VmnetCommonState ; +const char *vmnet_status_map_str (vmnet_return_t status); + +int vmnet_if_create (NetClientState *nc, +xpc_object_t if_desc, +Error **errp, +void (*completion_callback)(xpc_object_t interface_param)); + +ssize_t vmnet_receive_common (NetClientState *nc, +const uint8_t *buf, +size_t size); + +void vmnet_cleanup_common (NetClientState *nc);#endif /* VMNET_INT_H */
Signature · 1 line
2.23.0
PATCH 5/7 net/vmnet: implement host mode (vmnet-host)
In reply to Vladislav YaroshchukStill not implemented:
- port forwarding
--- net/vmnet-host.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 3 deletions(-)
net/vmnet-host.c +72 -3
@@ -17,8 +17,77 @@#include <vmnet/vmnet.h> +typedef struct VmnetHostState { +VmnetCommonState common; + +}VmnetHostState ; + +static xpc_object_t create_if_desc (const Netdev *netdev,Error **errp); + +static NetClientInfo net_vmnet_host_info = { + .type =NET_CLIENT_DRIVER_VMNET_HOST , + .size =sizeof (VmnetHostState), + .receive = vmnet_receive_common, + .cleanup = vmnet_cleanup_common, +}; +int net_init_vmnet_host (const Netdev *netdev,const char *name, -NetClientState *peer,Error **errp) { -error_setg (errp,"vmnet-host is not implemented yet" ); -return -1 ; +NetClientState *peer,Error **errp) +{ +NetClientState *nc; +xpc_object_t if_desc; + + nc =qemu_new_net_client (&net_vmnet_host_info, + peer,"vmnet-host" , name); + if_desc =create_if_desc (netdev, errp); +return vmnet_if_create (nc, if_desc, errp,NULL ); +} + +static xpc_object_t create_if_desc (const Netdev *netdev,Error **errp) +{ +const NetdevVmnetHostOptions *options; +xpc_object_t if_desc; + + if_desc =xpc_dictionary_create (NULL ,NULL ,0 ); +xpc_dictionary_set_uint64 ( + if_desc, + vmnet_operation_mode_key, +VMNET_HOST_MODE + ); + +xpc_dictionary_set_bool ( + if_desc, + vmnet_allocate_mac_address_key, + false + ); + + options = &(netdev->u.vmnet_host); + +if (options->has_dhcpstart || + options->has_dhcpend || + options->has_subnetmask) { + +if (options->has_dhcpstart && + options->has_dhcpend && + options->has_subnetmask) { + +xpc_dictionary_set_string (if_desc, + vmnet_start_address_key, + options->dhcpstart); +xpc_dictionary_set_string (if_desc, + vmnet_end_address_key, + options->dhcpend); +xpc_dictionary_set_string (if_desc, + vmnet_subnet_mask_key, + options->subnetmask); + }else { +error_setg ( + errp, +"'dhcpstart', 'dhcpend', 'subnetmask' " +"must be provided together" + ); + } + } + +return if_desc; }
Signature · 1 line
2.23.0
PATCH 6/7 net/vmnet: implement bridged mode (vmnet-bridged)
In reply to Vladislav Yaroshchuk--- net/meson.build | 2 +- net/vmnet-bridged.c | 25 --------- net/vmnet-bridged.m | 123 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 26 deletions(-) delete mode 100644 net/vmnet-bridged.c create mode 100644 net/vmnet-bridged.m
net/meson.build +1 -1
@@ -40,7 +40,7 @@ softmmu_ss.add(when: 'CONFIG_VHOST_NET_VDPA', if_true: files('vhost-vdpa.c')) vmnet_files = files( 'vmnet-common.m', - 'vmnet-bridged.c', + 'vmnet-bridged.m', 'vmnet-host.c', 'vmnet-shared.c' )
net/vmnet-bridged.c deleted +0 -25
@@ -1,25 +0,0 @@ -/* -* vmnet-bridged.c -* -* Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -* -*/ - -#include "qemu/osdep.h" -#include "qapi-types-net.h" -#include "vmnet_int.h" -#include "clients.h" -#include "qemu/error-report.h" -#include "qapi/error.h" - -#include <vmnet/vmnet.h> - -int net_init_vmnet_bridged (const Netdev *netdev,const char *name, -NetClientState *peer,Error **errp) -{ -error_setg (errp,"vmnet-bridged is not implemented yet" ); -return -1 ; -}
net/vmnet-bridged.m new file +123 -0
123 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH 7/7 net/vmnet: update qemu-options.hx
In reply to Vladislav Yaroshchuk--- qemu-options.hx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
qemu-options.hx +17 -0
@@ -2582,6 +2582,17 @@ 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_VMNET + "-netdev vmnet-host,id=str,[dhcpstart=addr,dhcpend=addr,subnetmask=mask]\n" + " configure a vmnet network backend in host mode with ID 'str',\n" + " configure its DHCP server and choose a subnet\n" + "-netdev vmnet-shared,id=str,[dhcpstart=addr,dhcpend=addr,subnetmask=mask]\n" + " configure a vmnet network backend in shared mode with ID 'str',\n" + " configure its DHCP server and choose a subnet\n" + "-netdev vmnet-bridged,id=str,ifname=name\n" + " configure a vmnet network backend in bridged mode with ID 'str'\n" + " use 'ifname=name' to select a physical network interface to be bridged\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)
@@ -2601,6 +2612,9 @@ DEF("nic", HAS_ARG, QEMU_OPTION_nic, #endif #ifdef CONFIG_POSIX "vhost-user|" +#endif +#ifdef CONFIG_VMNET + "vmnet-host|vmnet-shared|vmnet-bridged|" #endif "socket][,option][,...][mac=macaddr]\n" " initialize an on-board / default host NIC (using MAC address\n"
@@ -2623,6 +2637,9 @@ DEF("net", HAS_ARG, QEMU_OPTION_net, #endif #ifdef CONFIG_NETMAP "netmap|" +#endif +#ifdef CONFIG_VMNET + "vmnet-host|vmnet-shared|vmnet-bridged|" #endif "socket][,option][,option][,...]\n" " old way to initialize a host network interface\n"
Signature · 1 line
2.23.0
ping
https://patchew.org/QEMU/[email protected]/
чт, 17 июн. 2021 г. в 17:33, Vladislav Yaroshchuk <[email protected]
Quoted 73 lines
:
macOS provides networking API for VMs called vmnet.framework. I tried to add it as a network backend. All three modes are supported:
(quoted diff) +0
-3-shared: allows the guest to comminicate with other guests in shared mode and also with external network (Internet) via NAT -host: allows the guest to communicate with other guests in host mode -bridged: bridges the guest with a physical network interfaceSeparate netdev for each vmnet mode was created because they use quite different settings, especially since macOS 11.0 when vmnet.framework gets a lot of updates.
Not sure that I use
qemu_mutex_lock_iothread()andqemu_mutex_unlock_iothread()in correct way while sending packet from vmnet interface to QEMU. I'll be happy to receive recomendations how to make this thing better if I done sth wrong.Also vmnet.framework requires com.apple.vm.networking entitlement to run without root priveledges. Ad-hoc signing does not fit there, so I didn't touch anything related to signing. As a result we should run qemu-system by a priviledged user:
$ sudo qemu-system-x86_64 -nic vmnet-shared
otherwise vmnet fails with 'general failure'.But in any way it seems working now,
I tested it within qemu-system-x86-64 on macOS 10.15.7 host, with nic models:
- e1000-82545em
- virtio-net-pciand having such guests:
- macOS 10.15.7
- Ubuntu Bionic (server cloudimg)Vladislav Yaroshchuk (7):
net/vmnet: dependencies setup, initial preparations net/vmnet: add new netdevs to qapi/net net/vmnet: create common netdev state structure net/vmnet: implement shared mode (vmnet-shared) net/vmnet: implement host mode (vmnet-host) net/vmnet: implement bridged mode (vmnet-bridged) net/vmnet: update qemu-options.hxconfigure | 31 +++++ meson.build | 5 + net/clients.h | 11 ++ net/meson.build | 7 ++ net/net.c | 10 ++ net/vmnet-bridged.m | 123 ++++++++++++++++++ net/vmnet-common.m | 294 ++++++++++++++++++++++++++++++++++++++++++++ net/vmnet-host.c | 93 ++++++++++++++ net/vmnet-shared.c | 94 ++++++++++++++ net/vmnet_int.h | 48 ++++++++ qapi/net.json | 99 ++++++++++++++- qemu-options.hx | 17 +++ 12 files changed, 830 insertions(+), 2 deletions(-) create mode 100644 net/vmnet-bridged.m create mode 100644 net/vmnet-common.m create mode 100644 net/vmnet-host.c create mode 100644 net/vmnet-shared.c create mode 100644 net/vmnet_int.h--
2.23.0
Quoted 2 lines · Vladislav Yaroshchuk
ping
https://patchew.org/QEMU/[email protected]/ <https://patchew.org/QEMU/[email protected]/>
Will review this week.
Thanks
Quoted 74 lines
чт, 17 июн. 2021 г. в 17:33, Vladislav Yaroshchuk <[email protected] <mailto:[email protected]>>:
macOS provides networking API for VMs called vmnet.framework. I tried to add it as a network backend. All three modes are supported:
-shared:
allows the guest to comminicate with other guests in shared mode and also with external network (Internet) via NAT-host:
allows the guest to communicate with other guests in host mode-bridged:
bridges the guest with a physical network interfaceSeparate netdev for each vmnet mode was created because they use quite different settings, especially since macOS 11.0 when vmnet.framework gets a lot of updates.
Not sure that I use
qemu_mutex_lock_iothread()andqemu_mutex_unlock_iothread()in correct way while sending packet from vmnet interface to QEMU. I'll be happy to receive recomendations how to make this thing better if I done sth wrong.Also vmnet.framework requires com.apple.vm.networking entitlement to run without root priveledges. Ad-hoc signing does not fit there, so I didn't touch anything related to signing. As a result we should run qemu-system by a priviledged user:
$ sudo qemu-system-x86_64 -nic vmnet-shared
otherwise vmnet fails with 'general failure'.But in any way it seems working now,
I tested it within qemu-system-x86-64 on macOS 10.15.7 host, with nic models:
- e1000-82545em
- virtio-net-pciand having such guests:
- macOS 10.15.7
- Ubuntu Bionic (server cloudimg)Vladislav Yaroshchuk (7):
net/vmnet: dependencies setup, initial preparations net/vmnet: add new netdevs to qapi/net net/vmnet: create common netdev state structure net/vmnet: implement shared mode (vmnet-shared) net/vmnet: implement host mode (vmnet-host) net/vmnet: implement bridged mode (vmnet-bridged) net/vmnet: update qemu-options.hxconfigure | 31 +++++ meson.build | 5 +
net/clients.h | 11 ++ net/meson.build | 7 ++
net/net.c | 10 ++net/vmnet-bridged.m| 123 ++++++++++++++++++ net/vmnet-common.m | 294
++++++++++++++++++++++++++++++++++++++++++++
net/vmnet-host.c | 93 ++++++++++++++ net/vmnet-shared.c | 94 ++++++++++++++ net/vmnet_int.h | 48 ++++++++ qapi/net.json | 99 ++++++++++++++- qemu-options.hx | 17 +++
12 files changed, 830 insertions(+), 2 deletions(-) create mode 100644net/vmnet-bridged.mcreate mode 100644net/vmnet-common.mcreate mode 100644net/vmnet-host.c
create mode 100644net/vmnet-shared.ccreate mode 100644net/vmnet_int.h--
2.23.0
Quoted 35 lines · Vladislav Yaroshchuk
macOS provides networking API for VMs called vmnet.framework. I tried to add it as a network backend. All three modes are supported:
(quoted diff) +0
-3-shared: allows the guest to comminicate with other guests in shared mode and also with external network (Internet) via NAT -host: allows the guest to communicate with other guests in host mode -bridged: bridges the guest with a physical network interfaceSeparate netdev for each vmnet mode was created because they use quite different settings, especially since macOS 11.0 when vmnet.framework gets a lot of updates.
Not sure that I use
qemu_mutex_lock_iothread()andqemu_mutex_unlock_iothread()in correct way while sending packet from vmnet interface to QEMU. I'll be happy to receive recomendations how to make this thing better if I done sth wrong.Also vmnet.framework requires com.apple.vm.networking entitlement to run without root priveledges. Ad-hoc signing does not fit there, so I didn't touch anything related to signing. As a result we should run qemu-system by a priviledged user:
$ sudo qemu-system-x86_64 -nic vmnet-shared
otherwise vmnet fails with 'general failure'.But in any way it seems working now,
I tested it within qemu-system-x86-64 on macOS 10.15.7 host, with nic models:
- e1000-82545em
- virtio-net-pci
Quoted 4 lines
and having such guests:
- macOS 10.15.7
- Ubuntu Bionic (server cloudimg)
Hi Vladislav,
I appreciate the efforts and I'm sorry I didn't look into it yet, lack of time :(
To all: earlier this year another series was sent by Phillip Tennen to add vmnet.framework and some comments were provided:
https://mail.gnu.org/archive/html/qemu-devel/2021-02/msg05874.html
I'm not sure how to proceed with arbitration which of the series is preferred. FIFO or LIFO?
Regards,
Roman
Quoted 31 lines
Vladislav Yaroshchuk (7):
net/vmnet: dependencies setup, initial preparations net/vmnet: add new netdevs to qapi/net net/vmnet: create common netdev state structure net/vmnet: implement shared mode (vmnet-shared) net/vmnet: implement host mode (vmnet-host) net/vmnet: implement bridged mode (vmnet-bridged) net/vmnet: update qemu-options.hxconfigure | 31 +++++ meson.build | 5 + net/clients.h | 11 ++ net/meson.build | 7 ++ net/net.c | 10 ++ net/vmnet-bridged.m | 123 ++++++++++++++++++ net/vmnet-common.m | 294 ++++++++++++++++++++++++++++++++++++++++++++ net/vmnet-host.c | 93 ++++++++++++++ net/vmnet-shared.c | 94 ++++++++++++++ net/vmnet_int.h | 48 ++++++++ qapi/net.json | 99 ++++++++++++++- qemu-options.hx | 17 +++ 12 files changed, 830 insertions(+), 2 deletions(-) create mode 100644 net/vmnet-bridged.m create mode 100644 net/vmnet-common.m create mode 100644 net/vmnet-host.c create mode 100644 net/vmnet-shared.c create mode 100644 net/vmnet_int.hSignature · 1 line
2.23.0
Hi Roman,
Sorry for the late reply. In my series of patches I partially reuse Phillip Tennen's work that you have mentioned
https://mail.gnu.org/archive/html/qemu-devel/2021-02/msg05874.html. The main idea and provided feature is the same, so please select the series on your choice. I just can say that I'm ready to update/improve my patches asap, make them ready to be merged. Can't say anything about Phillip, is he ready too or not.
Regards,
Vladislav
чт, 12 авг. 2021 г. в 09:01, Roman Bolshakov <[email protected]>:
Quoted 88 lines · Vladislav Yaroshchuk
Quoted 35 lines
macOS provides networking API for VMs called vmnet.framework. I tried to add it as a network backend. All three modes are supported:
(quoted diff) +0
-3-shared: allows the guest to comminicate with other guests in shared mode and also with external network (Internet) via NAT -host: allows the guest to communicate with other guests in host mode -bridged: bridges the guest with a physical network interfaceSeparate netdev for each vmnet mode was created because they use quite different settings, especially since macOS 11.0 when vmnet.framework gets a lot of updates.
Not sure that I use
qemu_mutex_lock_iothread()andqemu_mutex_unlock_iothread()in correct way while sending packet from vmnet interface to QEMU. I'll be happy to receive recomendations how to make this thing better if I done sth wrong.Also vmnet.framework requires com.apple.vm.networking entitlement to run without root priveledges. Ad-hoc signing does not fit there, so I didn't touch anything related to signing. As a result we should run qemu-system by a priviledged user:
$ sudo qemu-system-x86_64 -nic vmnet-shared
otherwise vmnet fails with 'general failure'.But in any way it seems working now,
I tested it within qemu-system-x86-64 on macOS 10.15.7 host, with nic models:
- e1000-82545em
- virtio-net-pciQuoted 4 lines
and having such guests:
- macOS 10.15.7
- Ubuntu Bionic (server cloudimg)Hi Vladislav,
I appreciate the efforts and I'm sorry I didn't look into it yet, lack of time :(
To all: earlier this year another series was sent by Phillip Tennen to add vmnet.framework and some comments were provided:
https://mail.gnu.org/archive/html/qemu-devel/2021-02/msg05874.htmlI'm not sure how to proceed with arbitration which of the series is preferred. FIFO or LIFO?
Regards,
RomanQuoted 31 lines
Vladislav Yaroshchuk (7):
net/vmnet: dependencies setup, initial preparations net/vmnet: add new netdevs to qapi/net net/vmnet: create common netdev state structure net/vmnet: implement shared mode (vmnet-shared) net/vmnet: implement host mode (vmnet-host) net/vmnet: implement bridged mode (vmnet-bridged) net/vmnet: update qemu-options.hxconfigure | 31 +++++ meson.build | 5 + net/clients.h | 11 ++ net/meson.build | 7 ++ net/net.c | 10 ++ net/vmnet-bridged.m | 123 ++++++++++++++++++ net/vmnet-common.m | 294 ++++++++++++++++++++++++++++++++++++++++++++ net/vmnet-host.c | 93 ++++++++++++++ net/vmnet-shared.c | 94 ++++++++++++++ net/vmnet_int.h | 48 ++++++++ qapi/net.json | 99 ++++++++++++++- qemu-options.hx | 17 +++ 12 files changed, 830 insertions(+), 2 deletions(-) create mode 100644 net/vmnet-bridged.m create mode 100644 net/vmnet-common.m create mode 100644 net/vmnet-host.c create mode 100644 net/vmnet-shared.c create mode 100644 net/vmnet_int.h--
2.23.0