From nobody Sat Apr 27 01:05:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634037506501657.7184853397597; Tue, 12 Oct 2021 04:18:26 -0700 (PDT) Received: from localhost ([::1]:37950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maFnd-00020k-BZ for importer@patchew.org; Tue, 12 Oct 2021 07:18:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maFSR-00037m-1i for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:31 -0400 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]:35748) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maFSO-0003wo-CU for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:30 -0400 Received: by mail-lf1-x130.google.com with SMTP id p16so15391134lfa.2 for ; Tue, 12 Oct 2021 03:56:27 -0700 (PDT) Received: from localhost.localdomain ([77.234.205.3]) by smtp.gmail.com with ESMTPSA id p16sm995361lfe.166.2021.10.12.03.56.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 03:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vNoOLOdIrGzTMMgslM7i2dGMuAA3TZhPZ95Q3DnwTKk=; b=SeD9wZ9+FZmM8hIrK/+c0AkazgVvh6nj46nE1zE/8d2zzziw48o6doMhOuYt9z8Dxu HYyIWDGKgS0C+MKXsFkpvx5vVT4LiGEH2v/9yd3InPRgUmR08JHifNG1e+v2L0INtXOW 0+8HUZtB7sLeRCyvmad8rwr7GuROQs1rrUIyvA76zETKwiMVJVU0PRAbcPL3QsRsaORe jUlGnlbP5jrx0GHAo5CFaDC671FfO/otn3f0BJQz1I72VZGhOlqaKQsas0C3UTAieleY XzuJScWb5s9EJFzYi5+zKt7fqToWR49YsyHASa8qic94s0Rcft8RFR07UR2YE5oBs752 yPkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vNoOLOdIrGzTMMgslM7i2dGMuAA3TZhPZ95Q3DnwTKk=; b=jQwX0oxvnlgFyOBRFW2gy4GEP0257tU9+sgTKD9a5S1mEdVi1J7C6UAimMhcU4NaIu 1cWLxwhm2G2ZwnVrl3cvk/jtgMRgIuhAl93XgD2yy9acxm/htdDQWT1vUxUs30KNJWVG nQgLeBJx8uKXsTH0jwB94r0MKBxq2NsnvjHDDFbQmLlP0IbdktbbTVr7wISVsVCC5Z/D rA3Be3Xk/s/PY3o2QjgNhOEHkDG7YGcVOj7hZZ8QQIfRI8tsxrzpDl4asmw3cp7WPfd7 i+fwYnfkWznr8t2aA9mZkt7D3K7I0RIWgH7zWr++DvI+deYc2lSIiWWD/IopbgApm+ji 3rZQ== X-Gm-Message-State: AOAM531AgfQl+IokmyLGEkSjCLWthqsRRkxn0QdnhEksGV3zkyIMF7rs VNrGgZBcawNSdsL08sOgmnCui+PVB06Z+dGI X-Google-Smtp-Source: ABdhPJy+cxCe36CPR217pO0LP4i+a0ra9XhYO67/RIr2BxRW0NzvpLKvrv7H6VREaY95NrWErCNjQg== X-Received: by 2002:a2e:9d8e:: with SMTP id c14mr29165395ljj.207.1634036185881; Tue, 12 Oct 2021 03:56:25 -0700 (PDT) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v3 1/6] net/vmnet: dependencies setup, initial preparations Date: Tue, 12 Oct 2021 13:55:53 +0300 Message-Id: <20211012105558.21530-2-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211012105558.21530-1-yaroshchuk2000@gmail.com> References: <20211012105558.21530-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x130.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jasowang@redhat.com, eblake@redhat.com, r.bolshakov@yadro.com, Vladislav Yaroshchuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634037507581100001 Content-Type: text/plain; charset="utf-8" Add 'vmnet' customizable option and 'vmnet.framework' probe into configure; Create 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) Create source files for network client driver, update meson.build; Three new netdevs are added: - vmnet-host - vmnet-shared - vmnet-bridged Signed-off-by: Vladislav Yaroshchuk --- configure | 31 ++++++++++++++++ meson.build | 5 +++ net/clients.h | 11 ++++++ net/meson.build | 1 + net/net.c | 10 +++++ net/vmnet.c | 34 +++++++++++++++++ qapi/net.json | 99 ++++++++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 net/vmnet.c diff --git a/configure b/configure index 877bf3d76a..4e7324d20f 100755 --- a/configure +++ b/configure @@ -308,6 +308,7 @@ mpath=3D"auto" vnc=3D"auto" sparse=3D"auto" vde=3D"$default_feature" +vmnet=3D"auto" vnc_sasl=3D"auto" vnc_jpeg=3D"auto" vnc_png=3D"auto" @@ -1069,6 +1070,10 @@ for opt do ;; --enable-vde) vde=3D"yes" ;; + --disable-vmnet) vmnet=3D"no" + ;; + --enable-vmnet) vmnet=3D"yes" + ;; --disable-netmap) netmap=3D"no" ;; --enable-netmap) netmap=3D"yes" @@ -1893,6 +1898,7 @@ disabled with --disable-FEATURE, default is enabled i= f 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 @@ -2958,6 +2964,28 @@ EOF fi fi =20 +########################################## +# vmnet.framework probe +if test "$vmnet" !=3D "no" ; then + vmnet_flags=3D"-framework vmnet" + cat > $TMPC << EOF +#include +int main(void) +{ + (void) vmnet_allocate_mac_address_key; + return 0; +} +EOF + if compile_prog "" "$vmnet_flags" ; then + vmnet=3Dyes + else + if test "$vmnet" =3D "yes" ; then + feature_not_found "vmnet" "'vmnet.framework' in unsupported in this = build" + fi + vmnet=3Dno + fi +fi + ########################################## # netmap support probe # Apart from looking for netmap headers, we make sure that the host API ve= rsion @@ -4532,6 +4560,9 @@ if test "$vde" =3D "yes" ; then echo "CONFIG_VDE=3Dy" >> $config_host_mak echo "VDE_LIBS=3D$vde_libs" >> $config_host_mak fi +if test "$vmnet" =3D "yes" ; then + echo "CONFIG_VMNET=3Dy" >> $config_host_mak +fi if test "$netmap" =3D "yes" ; then echo "CONFIG_NETMAP=3Dy" >> $config_host_mak fi diff --git a/meson.build b/meson.build index 99a0a3e689..d10a3b299d 100644 --- a/meson.build +++ b/meson.build @@ -183,6 +183,7 @@ iokit =3D [] emulator_link_args =3D [] nvmm =3Dnot_found hvf =3D not_found +vmnet =3D not_found if targetos =3D=3D 'windows' socket =3D cc.find_library('ws2_32') winmm =3D cc.find_library('winmm') @@ -194,6 +195,9 @@ if targetos =3D=3D 'windows' elif targetos =3D=3D 'darwin' coref =3D dependency('appleframeworks', modules: 'CoreFoundation') iokit =3D dependency('appleframeworks', modules: 'IOKit', required: fals= e) + if config_host.has_key('CONFIG_VMNET') + vmnet =3D dependency('appleframeworks', modules: 'vmnet') + endif elif targetos =3D=3D 'sunos' socket =3D [cc.find_library('socket'), cc.find_library('nsl'), @@ -2899,6 +2903,7 @@ summary_info +=3D {'vhost-user support': config_host.= has_key('CONFIG_VHOST_USER')} summary_info +=3D {'vhost-user-blk server support': have_vhost_user_blk_se= rver} summary_info +=3D {'vhost-user-fs support': config_host.has_key('CONFIG_VH= OST_USER_FS')} summary_info +=3D {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST= _VDPA')} +summary_info +=3D {'vmnet support': vmnet.found()} summary_info +=3D {'build guest agent': config_host.has_key('CONFIG_GUEST_= AGENT')} summary(summary_info, bool_yn: true, section: 'Configurable features') =20 diff --git a/net/clients.h b/net/clients.h index 92f9b59aed..c9157789f2 100644 --- a/net/clients.h +++ b/net/clients.h @@ -63,4 +63,15 @@ int net_init_vhost_user(const Netdev *netdev, const char= *name, =20 int net_init_vhost_vdpa(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); +#ifdef CONFIG_VMNET +int net_init_vmnet_host(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp); + +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 */ diff --git a/net/meson.build b/net/meson.build index 1076b0a7ab..196cf321a2 100644 --- a/net/meson.build +++ b/net/meson.build @@ -38,4 +38,5 @@ softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files(tap_p= osix)) 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= ')) =20 +softmmu_ss.add(when: ['CONFIG_VMNET', vmnet], if_true: files('vmnet.c')) subdir('can') diff --git a/net/net.c b/net/net.c index 52c99196c6..11bc6d289c 100644 --- a/net/net.c +++ b/net/net.c @@ -1003,6 +1003,11 @@ static int (* const net_client_init_fun[NET_CLIENT_D= RIVER__MAX])( #ifdef CONFIG_L2TPV3 [NET_CLIENT_DRIVER_L2TPV3] =3D net_init_l2tpv3, #endif +#ifdef CONFIG_VMNET + [NET_CLIENT_DRIVER_VMNET_HOST] =3D net_init_vmnet_host, + [NET_CLIENT_DRIVER_VMNET_SHARED] =3D net_init_vmnet_shared, + [NET_CLIENT_DRIVER_VMNET_BRIDGED] =3D net_init_vmnet_bridged, +#endif /* CONFIG_VMNET */ }; =20 =20 @@ -1088,6 +1093,11 @@ void show_netdevs(void) #endif #ifdef CONFIG_VHOST_VDPA "vhost-vdpa", +#endif +#ifdef CONFIG_VMNET + "vmnet-host", + "vmnet-shared", + "vmnet-bridged", #endif }; =20 diff --git a/net/vmnet.c b/net/vmnet.c new file mode 100644 index 0000000000..3f25afd7e8 --- /dev/null +++ b/net/vmnet.c @@ -0,0 +1,34 @@ +/* + * vmnet.c - network client wrapper for Apple vmnet.framework + * + * Copyright(c) 2021 Vladislav Yaroshchuk + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * 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 + +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; +} diff --git a/qapi/net.json b/qapi/net.json index 7fab2e7cd8..a0d7dc3b7d 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -452,6 +452,89 @@ '*vhostdev': 'str', '*queues': 'int' } } =20 +## +# @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. +# +# @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.2 +## +{ 'struct': 'NetdevVmnetHostOptions', + 'data': { + '*dhcpstart': 'str', + '*dhcpend': 'str', + '*subnetmask': 'str' + }, + 'if': '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 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. +# +# @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.2 +## +{ 'struct': 'NetdevVmnetSharedOptions', + 'data': { + '*dhcpstart': 'str', + '*dhcpend': 'str', + '*subnetmask': 'str' + }, + 'if': '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.2 +## +{ 'struct': 'NetdevVmnetBridgedOptions', + 'data': { 'ifname': 'str' }, + 'if': 'CONFIG_VMNET' } + ## # @NetClientDriver: # @@ -460,10 +543,16 @@ # Since: 2.7 # # @vhost-vdpa since 5.1 +# @vmnet-host since 6.2 +# @vmnet-shared since 6.2 +# @vmnet-bridged since 6.2 ## { '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-host', 'if': 'CONFIG_VMNET' }, + { 'name': 'vmnet-shared', 'if': 'CONFIG_VMNET' }, + { 'name': 'vmnet-bridged', 'if': 'CONFIG_VMNET' }] } =20 ## # @Netdev: @@ -477,6 +566,9 @@ # Since: 1.2 # # 'l2tpv3' - since 2.1 +# 'vmnet-host' - since 6.2 +# 'vmnet-shared' - since 6.2 +# 'vmnet-bridged' - since 6.2 ## { 'union': 'Netdev', 'base': { 'id': 'str', 'type': 'NetClientDriver' }, @@ -492,7 +584,10 @@ 'hubport': 'NetdevHubPortOptions', 'netmap': 'NetdevNetmapOptions', 'vhost-user': 'NetdevVhostUserOptions', - 'vhost-vdpa': 'NetdevVhostVDPAOptions' } } + 'vhost-vdpa': 'NetdevVhostVDPAOptions', + 'vmnet-host': 'NetdevVmnetHostOptions', + 'vmnet-shared': 'NetdevVmnetSharedOptions', + 'vmnet-bridged': 'NetdevVmnetBridgedOptions' } } =20 ## # @RxState: --=20 2.23.0 From nobody Sat Apr 27 01:05:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634037218369533.3283483257536; Tue, 12 Oct 2021 04:13:38 -0700 (PDT) Received: from localhost ([::1]:50888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maFiz-0008Oa-3c for importer@patchew.org; Tue, 12 Oct 2021 07:13:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maFSR-0003A9-NX for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:32 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:38589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maFSO-0003xB-F7 for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:31 -0400 Received: by mail-lf1-x12e.google.com with SMTP id x27so86254912lfu.5 for ; Tue, 12 Oct 2021 03:56:28 -0700 (PDT) Received: from localhost.localdomain ([77.234.205.3]) by smtp.gmail.com with ESMTPSA id p16sm995361lfe.166.2021.10.12.03.56.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 03:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2rOAinE0BNop+OBOUb1GJ2NIo3qa6aePfog4NtPiGQI=; b=o4i8N+Ssinp4RIytI1NWBmZcp/eUUSao74gLgtLjt/15cdTE6I7XdqMIdOhUIEnppe Gvb0q5cOUC0D5pC5i3EHyKk19ULl0MjjDiJAA7C05IJzOMJGHgOtjR1Ymqetk2O9d0UK WnaXf4Dt5R4liTA4Ms4KpbDw0ITmxd8kEdYQmnBm2vgEKjeX+dovub23N/xaAEA/dUhk Mn1pHplJYlKUmIjnZD7UUKonX3KiK/i6XolQO1r61+G7lQcH/kuGnKz4ceKBWeH3OxTr KPvpA4qUUue2oIiDMiCDt1Oq8wvGQ4vDSI2yX85m+sqJyrj2GMVEXNmdmB02gGMaatWK TRMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2rOAinE0BNop+OBOUb1GJ2NIo3qa6aePfog4NtPiGQI=; b=57xuw1sdMzL5039yugv/7fwaoedxW9ADY2yn1revzkCLbWDl7Rs/DMO8tV3UOnYG8b Ov0jcNooj3bkmYd+cbRxdPrUzCsgy7qXJ80QGJqJfJFElzH3noO891QJEoaoby0+mko1 /QODArER6Kf1OK+F6kzWcLLt1E7m4hGzMom3X5SuT3z9Sd1AoyucN3b/nWWZAHtobD35 2fn0F2Fow2JXvQkTw9E2Y3KJdHUypoOQS3FRAFhdUr4KqhlMgb1qJDl+q8akqITFWdsM EINVS1i4nKD8Y4BqQ7JRlPg8WhQh4dbJlArcqu2aXJ1yCWo0T4eSMzU39nyGoqscu6gX 8umA== X-Gm-Message-State: AOAM531hHo3otZqEJoXdwEo7DphR2VwiH+E0KzwV6XS5TXCFXLFOhxLZ oXvrnQ8936HG3qcaNofSWHKzKBX0XfJq6p1Y X-Google-Smtp-Source: ABdhPJyL6HyLH09T9kOeTgp46P/ztptWmZ+w+l/4w56rKGmVgCFtzfpx2njLf16QYMOE5ey1JMi12A== X-Received: by 2002:a19:6742:: with SMTP id e2mr3475182lfj.568.1634036186505; Tue, 12 Oct 2021 03:56:26 -0700 (PDT) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v3 2/6] net/vmnet: create common netdev state structure Date: Tue, 12 Oct 2021 13:55:54 +0300 Message-Id: <20211012105558.21530-3-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211012105558.21530-1-yaroshchuk2000@gmail.com> References: <20211012105558.21530-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x12e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jasowang@redhat.com, eblake@redhat.com, r.bolshakov@yadro.com, Vladislav Yaroshchuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634037219072100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- net/meson.build | 8 +++++++- net/vmnet-bridged.m | 25 +++++++++++++++++++++++++ net/vmnet-common.m | 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.m create mode 100644 net/vmnet-common.m 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 diff --git a/net/meson.build b/net/meson.build index 196cf321a2..495419e964 100644 --- a/net/meson.build +++ b/net/meson.build @@ -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= ')) =20 -softmmu_ss.add(when: ['CONFIG_VMNET', vmnet], if_true: files('vmnet.c')) +vmnet_files =3D files( + 'vmnet-common.m', + 'vmnet-bridged.m', + 'vmnet-host.c', + 'vmnet-shared.c' +) +softmmu_ss.add(when: ['CONFIG_VMNET', vmnet], if_true: vmnet_files) subdir('can') diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m new file mode 100644 index 0000000000..4e42a90391 --- /dev/null +++ b/net/vmnet-bridged.m @@ -0,0 +1,25 @@ +/* + * vmnet-bridged.m + * + * Copyright(c) 2021 Vladislav Yaroshchuk + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include + +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; +} diff --git a/net/vmnet-common.m b/net/vmnet-common.m new file mode 100644 index 0000000000..532d152840 --- /dev/null +++ b/net/vmnet-common.m @@ -0,0 +1,20 @@ +/* + * vmnet-common.m - network client wrapper for Apple vmnet.framework + * + * Copyright(c) 2021 Vladislav Yaroshchuk + * Copyright(c) 2021 Phillip Tennen + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include + diff --git a/net/vmnet-host.c b/net/vmnet-host.c new file mode 100644 index 0000000000..4a5ef99dc7 --- /dev/null +++ b/net/vmnet-host.c @@ -0,0 +1,24 @@ +/* + * vmnet-host.c + * + * Copyright(c) 2021 Vladislav Yaroshchuk + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include + +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; +} diff --git a/net/vmnet-shared.c b/net/vmnet-shared.c new file mode 100644 index 0000000000..f8c4a4f3b8 --- /dev/null +++ b/net/vmnet-shared.c @@ -0,0 +1,25 @@ +/* + * vmnet-shared.c + * + * Copyright(c) 2021 Vladislav Yaroshchuk + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include + +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; +} diff --git a/net/vmnet.c b/net/vmnet.c deleted file mode 100644 index 3f25afd7e8..0000000000 --- a/net/vmnet.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * vmnet.c - network client wrapper for Apple vmnet.framework - * - * Copyright(c) 2021 Vladislav Yaroshchuk - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * 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 - -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; -} diff --git a/net/vmnet_int.h b/net/vmnet_int.h new file mode 100644 index 0000000000..c5982259a4 --- /dev/null +++ b/net/vmnet_int.h @@ -0,0 +1,25 @@ +/* + * vmnet_int.h + * + * Copyright(c) 2021 Vladislav Yaroshchuk + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * 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 + +typedef struct VmnetCommonState { + NetClientState nc; + +} VmnetCommonState; + + +#endif /* VMNET_INT_H */ --=20 2.23.0 From nobody Sat Apr 27 01:05:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634037764949198.8531997145268; Tue, 12 Oct 2021 04:22:44 -0700 (PDT) Received: from localhost ([::1]:46776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maFrn-00087U-R9 for importer@patchew.org; Tue, 12 Oct 2021 07:22:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maFSS-0003Ax-V5 for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:33 -0400 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]:44574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maFSP-0003xY-65 for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:31 -0400 Received: by mail-lf1-x135.google.com with SMTP id y26so86830294lfa.11 for ; Tue, 12 Oct 2021 03:56:28 -0700 (PDT) Received: from localhost.localdomain ([77.234.205.3]) by smtp.gmail.com with ESMTPSA id p16sm995361lfe.166.2021.10.12.03.56.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 03:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PrGCu710IIABYJFz1IMbvOBoMmjn1Fmj6xfk0JNLi54=; b=KreyB1/fPpyRK2WJWk1CtJOivyKsC+jgfGrWCpphZQPqKYdMKRzmGeHMHEMl1rShLG pbv0qo4N9XBvX8iSwllWymyCbdgPbgWAoCQ5xOdfC7pZM/yAM8TnnMiy/Kjw0y2ms+CW XABODh88JSqGU2jJq2fiWoWeZaD3/joQTqBspexzLCIvINXjU7JY8NSypsTgk0XeYmgk jp5niTAXYPy9Yc/oI7yBxLULuYg5uABMq0QJMlrg+PZtaQ57Qw9a8GSCunWCLZD7qmpR 9ROj5iY1IUGVQwT4JRQ95/bwj5fZ21Fis6srwH+GgGh1l+owmgj5BwtbWTwrGY3AqfYu RwqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PrGCu710IIABYJFz1IMbvOBoMmjn1Fmj6xfk0JNLi54=; b=NW9wYar4E2z8FAPTlmKDikqDVt56l0Nyg+inOZo6FwizgEzkpJS3fQ2ZJJSlX4UMXF F038RVP5tIqovCMUTWQjD99F8Vj+9XWl0PmIH714oLYUZqrXmLdq4cFFPnLyLuFsbacd y1wUnysAXbKwYkJI8KfdcX0mKR9J76yOecs2YEQyJNwueVcZBNLQCNkOA7Mmyw55POsf qbi+7zc9DRL7yDenBJNzj5o3kosq0khW9VKdFU8vV6audmNBTv+cCzbPoPR1i3NjIfVO Gt2Ipt/LCbA/BD5GoYGvhQ+1elVhch6WztK6HZAaaCQdZNszS66rDPBKfONmMFazY82N RKCQ== X-Gm-Message-State: AOAM5314VKZaiFXf8keQuxrrIqLj2BqDoCR6rzFOoELjEPJMTdvvVnJQ CmrwVYTrCwouJo7rtIxQuSdP3fAdnt9CUCRs X-Google-Smtp-Source: ABdhPJzNZSNgdY0e55y3uxTy3Veszg4NC8WNutWNlUO2CSyaJf3zGlF4aC5UKewXbNRzagI5D778NA== X-Received: by 2002:a05:651c:1596:: with SMTP id h22mr28333325ljq.405.1634036187423; Tue, 12 Oct 2021 03:56:27 -0700 (PDT) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v3 3/6] net/vmnet: implement shared mode (vmnet-shared) Date: Tue, 12 Oct 2021 13:55:55 +0300 Message-Id: <20211012105558.21530-4-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211012105558.21530-1-yaroshchuk2000@gmail.com> References: <20211012105558.21530-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::135; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x135.google.com X-Spam_score_int: 1 X-Spam_score: 0.1 X-Spam_bar: / X-Spam_report: (0.1 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jasowang@redhat.com, eblake@redhat.com, r.bolshakov@yadro.com, Vladislav Yaroshchuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634037765596100001 Content-Type: text/plain; charset="utf-8" Still not implemented: - port forwarding - ipv6 prefix setting Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-common.m | 275 +++++++++++++++++++++++++++++++++++++++++++++ net/vmnet-shared.c | 73 +++++++++++- net/vmnet_int.h | 23 ++++ 3 files changed, 369 insertions(+), 2 deletions(-) diff --git a/net/vmnet-common.m b/net/vmnet-common.m index 532d152840..caaf3cfa6d 100644 --- a/net/vmnet-common.m +++ b/net/vmnet-common.m @@ -10,6 +10,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "qapi/qapi-types-net.h" #include "vmnet_int.h" #include "clients.h" @@ -17,4 +18,278 @@ #include "qapi/error.h" =20 #include +#include =20 +typedef struct vmpktdesc vmpktdesc_t; +typedef struct iovec iovec_t; + +static void vmnet_set_send_enabled(VmnetCommonState *s, bool enable) +{ + s->send_enabled =3D enable; +} + + +static void vmnet_send_completed(NetClientState *nc, ssize_t len) +{ + VmnetCommonState *s =3D DO_UPCAST(VmnetCommonState, nc, nc); + vmnet_set_send_enabled(s, true); +} + + +static void vmnet_send(NetClientState *nc, + interface_event_t event_id, + xpc_object_t event) +{ + assert(event_id =3D=3D VMNET_INTERFACE_PACKETS_AVAILABLE); + + VmnetCommonState *s; + uint64_t packets_available; + + struct iovec *iov; + struct vmpktdesc *packets; + int pkt_cnt; + int i; + + vmnet_return_t if_status; + ssize_t size; + + s =3D DO_UPCAST(VmnetCommonState, nc, nc); + + packets_available =3D xpc_dictionary_get_uint64( + event, + vmnet_estimated_packets_available_key + ); + + pkt_cnt =3D (packets_available < VMNET_PACKETS_LIMIT) ? + packets_available : + VMNET_PACKETS_LIMIT; + + + iov =3D s->iov_buf; + packets =3D s->packets_buf; + + for (i =3D 0; i < pkt_cnt; ++i) { + packets[i].vm_pkt_size =3D s->max_packet_size; + packets[i].vm_pkt_iovcnt =3D 1; + packets[i].vm_flags =3D 0; + } + + if_status =3D vmnet_read(s->vmnet_if, packets, &pkt_cnt); + if (if_status !=3D VMNET_SUCCESS) { + error_printf("vmnet: read failed: %s\n", + vmnet_status_map_str(if_status)); + } + qemu_mutex_lock_iothread(); + for (i =3D 0; i < pkt_cnt; ++i) { + size =3D qemu_send_packet_async(nc, + iov[i].iov_base, + packets[i].vm_pkt_size, + vmnet_send_completed); + if (size =3D=3D 0) { + vmnet_set_send_enabled(s, false); + } else if (size < 0) { + break; + } + } + qemu_mutex_unlock_iothread(); + +} + + +static void vmnet_register_event_callback(VmnetCommonState *s) +{ + dispatch_queue_t avail_pkt_q =3D dispatch_queue_create( + "org.qemu.vmnet.if_queue", + DISPATCH_QUEUE_SERIAL + ); + + vmnet_interface_set_event_callback( + s->vmnet_if, + VMNET_INTERFACE_PACKETS_AVAILABLE, + avail_pkt_q, + ^(interface_event_t event_id, xpc_object_t event) { + if (s->send_enabled) { + vmnet_send(&s->nc, event_id, event); + } + }); +} + + +static void vmnet_bufs_init(VmnetCommonState *s) +{ + int i; + struct vmpktdesc *packets; + struct iovec *iov; + + packets =3D s->packets_buf; + iov =3D s->iov_buf; + + for (i =3D 0; i < VMNET_PACKETS_LIMIT; ++i) { + iov[i].iov_len =3D s->max_packet_size; + iov[i].iov_base =3D g_malloc0(iov[i].iov_len); + packets[i].vm_pkt_iov =3D iov + i; + } +} + + +const char *vmnet_status_map_str(vmnet_return_t status) +{ + switch (status) { + case VMNET_SUCCESS: + return "success"; + case VMNET_FAILURE: + return "general failure"; + case VMNET_MEM_FAILURE: + return "memory allocation failure"; + case VMNET_INVALID_ARGUMENT: + return "invalid argument specified"; + case VMNET_SETUP_INCOMPLETE: + return "interface setup is not complete"; + case VMNET_INVALID_ACCESS: + return "invalid access, permission denied"; + case VMNET_PACKET_TOO_BIG: + return "packet size is larger than MTU"; + case VMNET_BUFFER_EXHAUSTED: + return "buffers exhausted in kernel"; + case VMNET_TOO_MANY_PACKETS: + return "packet count exceeds limit"; + default: + return "unknown vmnet error"; + } +} + + +int vmnet_if_create(NetClientState *nc, + xpc_object_t if_desc, + Error **errp, + void (*completion_callback)(xpc_object_t interface_par= am)) +{ + VmnetCommonState *s; + + dispatch_queue_t if_create_q; + dispatch_semaphore_t if_created_sem; + + __block vmnet_return_t if_status; + + if_create_q =3D dispatch_queue_create("org.qemu.vmnet.create", + DISPATCH_QUEUE_SERIAL); + if_created_sem =3D dispatch_semaphore_create(0); + + s =3D DO_UPCAST(VmnetCommonState, nc, nc); + s->vmnet_if =3D vmnet_start_interface( + if_desc, + if_create_q, + ^(vmnet_return_t status, xpc_object_t interface_param) { + if_status =3D status; + if (status !=3D VMNET_SUCCESS || !interface_param) { + dispatch_semaphore_signal(if_created_sem); + return; + } + + s->mtu =3D xpc_dictionary_get_uint64( + interface_param, + vmnet_mtu_key); + s->max_packet_size =3D xpc_dictionary_get_uint64( + interface_param, + vmnet_max_packet_size_key); + + if (completion_callback) { + completion_callback(interface_param); + } + dispatch_semaphore_signal(if_created_sem); + }); + + if (s->vmnet_if =3D=3D NULL) { + error_setg(errp, "unable to create interface with requested params= "); + return -1; + } + + dispatch_semaphore_wait(if_created_sem, DISPATCH_TIME_FOREVER); + dispatch_release(if_create_q); + + if (if_status !=3D VMNET_SUCCESS) { + error_setg(errp, + "interface creation error: %s", + vmnet_status_map_str(if_status)); + return -1; + } + + vmnet_register_event_callback(s); + vmnet_bufs_init(s); + vmnet_set_send_enabled(s, true); + + return 0; +} + + +ssize_t vmnet_receive_common(NetClientState *nc, + const uint8_t *buf, + size_t size) +{ + VmnetCommonState *s; + vmpktdesc_t packet; + iovec_t iov; + int pkt_cnt; + vmnet_return_t if_status; + + s =3D DO_UPCAST(VmnetCommonState, nc, nc); + + if (size > s->max_packet_size) { + warn_report("vmnet: packet is too big, %zu > %llu\n", + packet.vm_pkt_size, + s->max_packet_size); + return -1; + } + + iov.iov_base =3D (char *) buf; + iov.iov_len =3D size; + + packet.vm_pkt_iovcnt =3D 1; + packet.vm_flags =3D 0; + packet.vm_pkt_size =3D size; + packet.vm_pkt_iov =3D &iov; + + pkt_cnt =3D 1; + if_status =3D vmnet_write(s->vmnet_if, &packet, &pkt_cnt); + + if (if_status !=3D VMNET_SUCCESS) { + error_report("vmnet: write error: %s\n", + vmnet_status_map_str(if_status)); + } + + if (if_status =3D=3D VMNET_SUCCESS && pkt_cnt) { + return size; + } + return 0; +} + + +void vmnet_cleanup_common(NetClientState *nc) +{ + VmnetCommonState *s; + dispatch_queue_t if_destroy_q; + + s =3D DO_UPCAST(VmnetCommonState, nc, nc); + + qemu_purge_queued_packets(nc); + vmnet_set_send_enabled(s, false); + + if (s->vmnet_if =3D=3D NULL) { + return; + } + + if_destroy_q =3D dispatch_queue_create( + "org.qemu.vmnet.destroy", + DISPATCH_QUEUE_SERIAL + ); + + vmnet_stop_interface( + s->vmnet_if, + if_destroy_q, + ^(vmnet_return_t status) { + }); + + for (int i =3D 0; i < VMNET_PACKETS_LIMIT; ++i) { + g_free(s->iov_buf[i].iov_base); + } +} diff --git a/net/vmnet-shared.c b/net/vmnet-shared.c index f8c4a4f3b8..e8d142c9b0 100644 --- a/net/vmnet-shared.c +++ b/net/vmnet-shared.c @@ -17,9 +17,78 @@ =20 #include =20 +typedef struct VmnetSharedState { + VmnetCommonState common; + +} VmnetSharedState; + +static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp); + +static NetClientInfo net_vmnet_shared_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_SHARED, + .size =3D sizeof(VmnetSharedState), + .receive =3D vmnet_receive_common, + .cleanup =3D vmnet_cleanup_common, +}; + 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; + NetClientState *nc; + xpc_object_t if_desc; + + nc =3D qemu_new_net_client(&net_vmnet_shared_info, + peer, "vmnet-shared", name); + if_desc =3D 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 NetdevVmnetSharedOptions *options; + xpc_object_t if_desc; + + if_desc =3D xpc_dictionary_create(NULL, NULL, 0); + xpc_dictionary_set_uint64( + if_desc, + vmnet_operation_mode_key, + VMNET_SHARED_MODE + ); + + xpc_dictionary_set_bool( + if_desc, + vmnet_allocate_mac_address_key, + false + ); + + options =3D &(netdev->u.vmnet_shared); + + 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; } + diff --git a/net/vmnet_int.h b/net/vmnet_int.h index c5982259a4..3979fe4678 100644 --- a/net/vmnet_int.h +++ b/net/vmnet_int.h @@ -16,10 +16,33 @@ =20 #include =20 +#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]; =20 } VmnetCommonState; =20 +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_par= am)); + +ssize_t vmnet_receive_common(NetClientState *nc, + const uint8_t *buf, + size_t size); + +void vmnet_cleanup_common(NetClientState *nc); =20 #endif /* VMNET_INT_H */ --=20 2.23.0 From nobody Sat Apr 27 01:05:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634038561389767.4696518634463; Tue, 12 Oct 2021 04:36:01 -0700 (PDT) Received: from localhost ([::1]:52716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maG4e-000620-Ae for importer@patchew.org; Tue, 12 Oct 2021 07:36:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maFST-0003BC-09 for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:33 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:42524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maFSQ-0003yR-PI for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:32 -0400 Received: by mail-lf1-x134.google.com with SMTP id x27so85836740lfa.9 for ; Tue, 12 Oct 2021 03:56:29 -0700 (PDT) Received: from localhost.localdomain ([77.234.205.3]) by smtp.gmail.com with ESMTPSA id p16sm995361lfe.166.2021.10.12.03.56.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 03:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XvbfWANzOylVPbjFB39mnB/oU0QzTY2VWLyPIZOBoOk=; b=pIW8OzZdopdxGrXGzIrwOWdmqGbHWavuQsGROVla3rEoNRV7oW3wTBS0xI7gtGPz5Y GjM8jCYAqSg8fM1nNT901FptxFJO+8ceTtnCopHBShqmGUjDRcxGTCoNZtzhxfrIbak2 cNmlwDphln+FEV8ke7eHBE2fL3QUWBs8sTE85ugwfdwfpnIQSn7tZeEiqKvAGw3tsRiF sc/Yg6g6d6b/cTlYTzANridIHrk50Zb78Fk3Ci8DmlV9pWnKHiL6UFLS6j3cHO8Lszl8 GBIFsHoIiWqckzmdk9ew3IqpOp2VIvg/dNBwXNc5KBFlMXyDZMYAXUYCLn70sy5LbZTh Y0dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XvbfWANzOylVPbjFB39mnB/oU0QzTY2VWLyPIZOBoOk=; b=YqnVKVZn3s5SqJBGpfcxOf/QVClZq6NrEQmFNG3p+KXEEPhLxvGi3Jzr8fZ5MUKVJ7 CsQJBuNlfitnfFZDu24ZkAxCSNJ8Wsol1wAG42/233ErUlkFYvuGauw5VxPtOqye7yAN 9YJ8nqnIY7tGUzxXQWZBVxEAnJm640Ev3N0zm9spbhs4p9/u/T5HGA1MQa0TQwPwfjui NdQYuNiddZLrtpGhyLGbLE1a63HsNTtjm0xndgVDG1SAijdXzwgmRmey36iv4aPdwW29 ztOFObKZSVO6U9AHKf33TCqKMDrN9ORJAp+BNipi9CPRA7EK4FyF6Bw5Yf5K6uUz11OL FIjQ== X-Gm-Message-State: AOAM531H4Y8mxUuPGXSQXTxc5u9IKD3BCSwlkEkS41e3UTTrYIL2eCJP 04ryHxTl30jMIAivIj49jcVMjq+7Hb2NSU6H X-Google-Smtp-Source: ABdhPJxWGQYq8AdNW3pMhQBD2JbQgO2D/isrvwPdN3j4QcITygTkY8HmLKOb1x8K2VkRgwxyQJi/FA== X-Received: by 2002:a05:6512:12d3:: with SMTP id p19mr33967427lfg.280.1634036188087; Tue, 12 Oct 2021 03:56:28 -0700 (PDT) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v3 4/6] net/vmnet: implement host mode (vmnet-host) Date: Tue, 12 Oct 2021 13:55:56 +0300 Message-Id: <20211012105558.21530-5-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211012105558.21530-1-yaroshchuk2000@gmail.com> References: <20211012105558.21530-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x134.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jasowang@redhat.com, eblake@redhat.com, r.bolshakov@yadro.com, Vladislav Yaroshchuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634038563640100001 Content-Type: text/plain; charset="utf-8" Still not implemented: - port forwarding Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-host.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/net/vmnet-host.c b/net/vmnet-host.c index 4a5ef99dc7..fe7211d61b 100644 --- a/net/vmnet-host.c +++ b/net/vmnet-host.c @@ -17,8 +17,77 @@ =20 #include =20 +typedef struct VmnetHostState { + VmnetCommonState common; + +} VmnetHostState; + +static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp); + +static NetClientInfo net_vmnet_host_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_HOST, + .size =3D sizeof(VmnetHostState), + .receive =3D vmnet_receive_common, + .cleanup =3D 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 =3D qemu_new_net_client(&net_vmnet_host_info, + peer, "vmnet-host", name); + if_desc =3D 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 =3D 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 =3D &(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; } --=20 2.23.0 From nobody Sat Apr 27 01:05:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634038298783359.5425037536596; Tue, 12 Oct 2021 04:31:38 -0700 (PDT) Received: from localhost ([::1]:43976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maG0P-0008GP-N1 for importer@patchew.org; Tue, 12 Oct 2021 07:31:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maFSS-0003Ay-Ul for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:32 -0400 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]:34492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maFSQ-0003yX-PQ for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:32 -0400 Received: by mail-lf1-x12a.google.com with SMTP id t9so84638333lfd.1 for ; Tue, 12 Oct 2021 03:56:30 -0700 (PDT) Received: from localhost.localdomain ([77.234.205.3]) by smtp.gmail.com with ESMTPSA id p16sm995361lfe.166.2021.10.12.03.56.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 03:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8kKTJD6wLIaHfuJugchUxmyTTpfbII7eu8WMvF57C64=; b=IKw48IlNOR9TxZoZd1rSeUPKbG7fEzBRMA1hDYYD5DqmQ2Mrp4uIL88KdzwcWUDUDq a+5EF4fZ5TFCNQ7FbaG2ZlpDpxTw/YduhCFRrWhern+6PVqAEA2NHTgrRoLGANXKRcAG JNJkE/4mUoN2xdpbeY9AOUvEkNB0OfBaufVYo63Fksa7INNLL8Kx3vKRlLozzuqJl2og dGWJtXp1iZCyIQizNm4eKaffpLiA3U8OlDsQpajcB79SseOOTPIrJypPtKhCfTFbsu8L YlgxOnA9ih1MMPVtR7sbu9jzdnBygfMvnVS+vbvt9TS0CV0RqbvwmP6yfMIGjtKLqBgi Yckw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8kKTJD6wLIaHfuJugchUxmyTTpfbII7eu8WMvF57C64=; b=czoQ3eX4/lWS+/Ho7FL3ZcrioHT1XqQqbveIXOVsNVeMjgke/h+Q8Mn25KuMjejE8r kQqI2ygTcntowwQfipUfvZ4kraagt3wCXQy3xQ/coGFPZQyJJ5Z8tw1nqX0C9g6V4tZ2 DN3Oo+V0tP098Xfi0laW6AxliSWIxqzZxKMdxvGmnmS/HLizHE6hXQSigEVceyQJLI9/ rSXmLUH5LaBOAreYaHOCveZEYVerCvMmHZsnzXpkOAAeIdHf3oHXVMGuckDpdAHpb2a3 /1BpK0C/DT1xzIPIWYPaqZuZ8NsaSw4pJM1pHUzanxWPWAO8ZqLqqYr6tnxQqc+wTUGl epmA== X-Gm-Message-State: AOAM5330V2TmaGqyyMXXYJcXzLCWa1j+ORDCm3En6ddfH7yw3T1Wrgr9 Pf6u0pGW+1U946clfw0iyvAWmnFmYIJDn0UJ X-Google-Smtp-Source: ABdhPJzLCZkWklqfpY6hZYjBxc6Bw69yj8lKAkTSQ/KDmulutmo3YMAhuJQOPIUp55cLzQJKliCnJw== X-Received: by 2002:a2e:92ce:: with SMTP id k14mr27153002ljh.27.1634036188732; Tue, 12 Oct 2021 03:56:28 -0700 (PDT) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v3 5/6] net/vmnet: implement bridged mode (vmnet-bridged) Date: Tue, 12 Oct 2021 13:55:57 +0300 Message-Id: <20211012105558.21530-6-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211012105558.21530-1-yaroshchuk2000@gmail.com> References: <20211012105558.21530-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x12a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jasowang@redhat.com, eblake@redhat.com, r.bolshakov@yadro.com, Vladislav Yaroshchuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634038299840100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-bridged.m | 102 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 2 deletions(-) diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m index 4e42a90391..9097181841 100644 --- a/net/vmnet-bridged.m +++ b/net/vmnet-bridged.m @@ -17,9 +17,107 @@ =20 #include =20 +typedef struct VmnetBridgedState { + VmnetCommonState common; + +} VmnetBridgedState; + +static NetClientInfo net_vmnet_bridged_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_BRIDGED, + .size =3D sizeof(VmnetBridgedState), + .receive =3D vmnet_receive_common, + .cleanup =3D vmnet_cleanup_common, +}; + +static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp); + +static bool validate_ifname(const char *ifname); + +static const char *get_valid_ifnames(void); + 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; + NetClientState *nc; + xpc_object_t if_desc; + + nc =3D qemu_new_net_client(&net_vmnet_bridged_info, + peer, "vmnet-bridged", name); + if_desc =3D create_if_desc(netdev, errp); + if (!if_desc) { + error_setg(errp, + "unsupported ifname, should be one of: %s", + get_valid_ifnames()); + return -1; + } + + return vmnet_if_create(nc, if_desc, errp, NULL); +} + +static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetBridgedOptions *options; + xpc_object_t if_desc; + + if_desc =3D xpc_dictionary_create(NULL, NULL, 0); + xpc_dictionary_set_uint64( + if_desc, + vmnet_operation_mode_key, + VMNET_BRIDGED_MODE + ); + + xpc_dictionary_set_bool( + if_desc, + vmnet_allocate_mac_address_key, + false + ); + + options =3D &(netdev->u.vmnet_bridged); + if (validate_ifname(options->ifname)) { + xpc_dictionary_set_string(if_desc, + vmnet_shared_interface_name_key, + options->ifname); + } else { + return NULL; + } + return if_desc; +} + +static bool validate_ifname(const char *ifname) +{ + xpc_object_t shared_if_list =3D vmnet_copy_shared_interface_list(); + __block bool match =3D false; + + xpc_array_apply( + shared_if_list, + ^bool(size_t index, xpc_object_t value) { + if (strcmp(xpc_string_get_string_ptr(value), ifname) =3D=3D 0) { + match =3D true; + return false; + } + return true; + }); + + return match; +} + +static const char *get_valid_ifnames(void) +{ + xpc_object_t shared_if_list =3D vmnet_copy_shared_interface_list(); + __block char *if_list =3D NULL; + + xpc_array_apply( + shared_if_list, + ^bool(size_t index, xpc_object_t value) { + if_list =3D g_strconcat(xpc_string_get_string_ptr(value), + " ", + if_list, + NULL); + return true; + }); + + if (if_list) { + return if_list; + } + return "[no interfaces]"; } --=20 2.23.0 From nobody Sat Apr 27 01:05:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634037510851709.5282409994019; Tue, 12 Oct 2021 04:18:30 -0700 (PDT) Received: from localhost ([::1]:38374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maFnh-0002Hi-Tl for importer@patchew.org; Tue, 12 Oct 2021 07:18:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maFSU-0003G9-5l for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:34 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:42525) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maFSS-0003zJ-MG for qemu-devel@nongnu.org; Tue, 12 Oct 2021 06:56:33 -0400 Received: by mail-lf1-x134.google.com with SMTP id x27so85837036lfa.9 for ; Tue, 12 Oct 2021 03:56:31 -0700 (PDT) Received: from localhost.localdomain ([77.234.205.3]) by smtp.gmail.com with ESMTPSA id p16sm995361lfe.166.2021.10.12.03.56.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Oct 2021 03:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d2IilJ9aFwnwmu8bHPjzRz8xaSfqsClKPRVXjgKSjMA=; b=faI4B1rEd0EkoGRt9frTZyue4V9mOVufpYj86G2Dkq/I7JWTzFfZ+KzFBgRaQXTVgd YOWQsQcLkaJvyS2m+HmB56GA+Mdy4gRF0S/wIy8jdN6d898PrGkDytsfSOtfBaCrlfNZ MWq3E05p22Wkp4QOLbMwF7joSxmoKo4MKIn75hlHQZ89aV3JegQ0gLBfv8si0sZMak3p ltrhEuD6dGHdjAG8Ol2tv1sBQLINKqKQ4+6aKh2+HkynULb4Dul7FlnHFyDzGRz0+Kbo FUvWDT2EPHOt1JFbVxa7IhNnzhe6q1O0AlevRYA3QeuzW2836RSIj8r7FqfCOtJVMmaj IPjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d2IilJ9aFwnwmu8bHPjzRz8xaSfqsClKPRVXjgKSjMA=; b=tz57VrC+IbCfKtfsvVLpOhKFB38K00V0n9SwU7GjomhFzU6JiDhn92NUOnyQSpeG8z R7o2/BrkphY0uTRoWnzT8JEgXDf3UnG5xD43QMBxh0AsXQxXE3hN5TpWl4TvXgC8A43E 9XUTPykdvNvybhHQu6Zhah7PSVxxBWDFRAWzyIzXwti63KUzuyGe7TSzCK7deA41xoKi o4y/gG7AsGXILW4J0WVlRu2aG/pUWasdgy9lwtCWV8ZeA5V5a2MZn+YHSWL8qU8zCCJq cEoZ4WlXcowh4rlXl5wx9LcYi8ZuJWuEwnxLMQjjpzNmb8LBex5FQzYhyAuoBaCvYJZu diHQ== X-Gm-Message-State: AOAM533nfcsbv3QFW2OceCj0f3NvkkJ29xsCs/XWMJQyl0r4+8NVVySh tpVzTf+VyiWM3VNvkDzdURcSzyp7oVIGeyr5 X-Google-Smtp-Source: ABdhPJwz/HSQb+4jStj4D2eXm1zh4NW9+OovH5KmPOsB6Vk9iYgcHX8t25dAbg4Ml+lZM5crBvwmSw== X-Received: by 2002:a2e:b7c8:: with SMTP id p8mr29568607ljo.154.1634036189913; Tue, 12 Oct 2021 03:56:29 -0700 (PDT) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v3 6/6] net/vmnet: update qemu-options.hx Date: Tue, 12 Oct 2021 13:55:58 +0300 Message-Id: <20211012105558.21530-7-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211012105558.21530-1-yaroshchuk2000@gmail.com> References: <20211012105558.21530-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x134.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jasowang@redhat.com, eblake@redhat.com, r.bolshakov@yadro.com, Vladislav Yaroshchuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634037511942100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- qemu-options.hx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 5f375bbfa6..2aaa7a0782 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2677,6 +2677,17 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, #ifdef __linux__ "-netdev vhost-vdpa,id=3Dstr,vhostdev=3D/path/to/dev\n" " configure a vhost-vdpa network,Establish a vhost-vdpa= netdev\n" +#endif +#ifdef CONFIG_VMNET + "-netdev vmnet-host,id=3Dstr,[dhcpstart=3Daddr,dhcpend=3Daddr,subnetma= sk=3Dmask]\n" + " configure a vmnet network backend in host mode with I= D 'str',\n" + " configure its DHCP server and choose a subnet\n" + "-netdev vmnet-shared,id=3Dstr,[dhcpstart=3Daddr,dhcpend=3Daddr,subnet= mask=3Dmask]\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=3Dstr,ifname=3Dname\n" + " configure a vmnet network backend in bridged mode wit= h ID 'str'\n" + " use 'ifname=3Dname' to select a physical network inte= rface to be bridged\n" #endif "-netdev hubport,id=3Dstr,hubid=3Dn[,netdev=3Dnd]\n" " configure a hub port on the hub with ID 'n'\n", QEMU_= ARCH_ALL) @@ -2696,6 +2707,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=3Dmacaddr]\n" " initialize an on-board / default host NIC (using MAC = address\n" @@ -2718,6 +2732,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" --=20 2.23.0