From nobody Sat May 18 13:16:34 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 163880906531474.77991749786747; Mon, 6 Dec 2021 08:44:25 -0800 (PST) Received: from localhost ([::1]:34310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muH6G-0007Nt-83 for importer@patchew.org; Mon, 06 Dec 2021 11:44:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muH4a-0004gr-Jh for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:40 -0500 Received: from [2a00:1450:4864:20::230] (port=39794 helo=mail-lj1-x230.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muH4Y-00074e-9q for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:40 -0500 Received: by mail-lj1-x230.google.com with SMTP id m12so22093805ljj.6 for ; Mon, 06 Dec 2021 08:42:37 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id e11sm1401809lfq.65.2021.12.06.08.42.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Dec 2021 08:42:35 -0800 (PST) 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=jzagFbFv8aWqFMmnjN+mFUbWJgK6HuzCVGpplDCxWYQ=; b=otcnre+QNC6k7azBPvAsU5kH52rWteAAnApPNh/L8fr1pJghf0Gzt2TO7+NSUaoRGq J07MmIchZwBgHNv41qr2f4rgaWB1KZVMuBROerZY0fzh7XOArnNIXRTAQ2uXnN8G8LG8 Auw++qOcTv96G3jnp2I8iInIjXCHRxsKOFdEtZkAfPuyTQlO3E08dBm7BPCNsq0zveQg TD3Cjy8M1XdbHPB2YTHwXO9UJhHJuJq5/fMJtJYwp46bfPVOUnzfeVP+DPJoDpfTNZzQ o5iF9VLxfqmU6n/PVOF3KVnWMdgIg+YNuSos/9v0RRXaY6nobzdzg076xHmzJzTjImk7 xVxA== 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=jzagFbFv8aWqFMmnjN+mFUbWJgK6HuzCVGpplDCxWYQ=; b=N5/U2P4XlmAHxO/yDGEaxutvUQXSb7iNZgqvuwVzLTiVtiKsOc7wSFuMmDzpKtggWj UXkzeb9qixt1oTRvuk2tTm49y3toB/QI75ImFYWL0GzYDRWvL/eg9u4XOJ1WRPmL+PaK bGctlJGG1lK5jcgBmKpDmxqbnlgjYgPqn3NgfvFRODrSnq5rCk2IjI3Jda8UN07Mv4wl pXXXnIy2Xs+0nRp3ZBfIxy6LMm3tvmrgljMYnIPmvYlvVJ3Pus+adRgfIBEzjCxB9VTw W+lXD60//oIlfqUfPmKIMwrMyOvB4tpbPJHGZ9Whdafa5B5q0VAlBAMgMvXuIu2g9V19 H99g== X-Gm-Message-State: AOAM532/vgRXKM1SEdbcS0XJp4N/TnxxLbWUpziJYXkw0/2PbVj0CSa/ T1Z26VR+5onGYcT4oV8AacxpnbZTczZMQ0mD X-Google-Smtp-Source: ABdhPJwXKlX7fBU6NdpDDr64F2eR1Di1H9i5qpukZfzPXBbbM3Lbc/QR1H4Irzjp6TQ1pa+o2p7pxQ== X-Received: by 2002:a2e:a594:: with SMTP id m20mr35498223ljp.332.1638808955821; Mon, 06 Dec 2021 08:42:35 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v6 1/6] net/vmnet: add vmnet dependency and customizable option Date: Mon, 6 Dec 2021 19:42:17 +0300 Message-Id: <20211206164222.11027-2-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211206164222.11027-1-yaroshchuk2000@gmail.com> References: <20211206164222.11027-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::230 (failed) 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::230; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladislav Yaroshchuk , jasowang@redhat.com, phillip.ennen@gmail.com, armbru@redhat.com, r.bolshakov@yadro.com, phillip@axleos.com, akihiko.odaki@gmail.com, hsp.cat7@gmail.com, hello@adns.io, eblake@redhat.com 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: 1638809066321100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- meson.build | 4 ++++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 3 files changed, 9 insertions(+) diff --git a/meson.build b/meson.build index 96de1a6ef9..ce8acf6ada 100644 --- a/meson.build +++ b/meson.build @@ -481,6 +481,8 @@ if cocoa.found() and get_option('gtk').enabled() error('Cocoa and GTK+ cannot be enabled at the same time') endif =20 +vmnet =3D dependency('appleframeworks', modules: 'vmnet', required: get_op= tion('vmnet')) + seccomp =3D not_found if not get_option('seccomp').auto() or have_system or have_tools seccomp =3D dependency('libseccomp', version: '>=3D2.3.0', @@ -1461,6 +1463,7 @@ config_host_data.set('CONFIG_SECCOMP', seccomp.found(= )) config_host_data.set('CONFIG_SNAPPY', snappy.found()) config_host_data.set('CONFIG_USB_LIBUSB', libusb.found()) config_host_data.set('CONFIG_VDE', vde.found()) +config_host_data.set('CONFIG_VMNET', vmnet.found()) config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_s= erver) config_host_data.set('CONFIG_VNC', vnc.found()) config_host_data.set('CONFIG_VNC_JPEG', jpeg.found()) @@ -3397,6 +3400,7 @@ endif summary_info +=3D {'JACK support': jack} summary_info +=3D {'brlapi support': brlapi} summary_info +=3D {'vde support': vde} +summary_info +=3D {'vmnet.framework support': vmnet} summary_info +=3D {'netmap support': have_netmap} summary_info +=3D {'l2tpv3 support': have_l2tpv3} summary_info +=3D {'Linux AIO support': libaio} diff --git a/meson_options.txt b/meson_options.txt index e392323732..0538d48a85 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -147,6 +147,8 @@ option('netmap', type : 'feature', value : 'auto', description: 'netmap network backend support') option('vde', type : 'feature', value : 'auto', description: 'vde network backend support') +option('vmnet', type : 'feature', value : 'auto', + description: 'vmnet.framework network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') option('vnc', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 7a17ff4218..13da30f018 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -82,6 +82,7 @@ meson_options_help() { printf "%s\n" ' u2f U2F emulation support' printf "%s\n" ' usb-redir libusbredir support' printf "%s\n" ' vde vde network backend support' + printf "%s\n" ' vmnet vmnet.framework network backend support' printf "%s\n" ' vhost-user-blk-server' printf "%s\n" ' build vhost-user-blk server' printf "%s\n" ' virglrenderer virgl rendering support' @@ -242,6 +243,8 @@ _meson_option_parse() { --disable-usb-redir) printf "%s" -Dusb_redir=3Ddisabled ;; --enable-vde) printf "%s" -Dvde=3Denabled ;; --disable-vde) printf "%s" -Dvde=3Ddisabled ;; + --enable-vmnet) printf "%s" -Dvmnet=3Denabled ;; + --disable-vmnet) printf "%s" -Dvmnet=3Ddisabled ;; --enable-vhost-user-blk-server) printf "%s" -Dvhost_user_blk_server=3D= enabled ;; --disable-vhost-user-blk-server) printf "%s" -Dvhost_user_blk_server= =3Ddisabled ;; --enable-virglrenderer) printf "%s" -Dvirglrenderer=3Denabled ;; --=20 2.23.0 From nobody Sat May 18 13:16:34 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 1638809405567381.68115334299; Mon, 6 Dec 2021 08:50:05 -0800 (PST) Received: from localhost ([::1]:45268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muHBk-0006Or-0Q for importer@patchew.org; Mon, 06 Dec 2021 11:50:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muH4c-0004ho-DX for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:42 -0500 Received: from [2a00:1450:4864:20::131] (port=45049 helo=mail-lf1-x131.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muH4Y-00074i-Td for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:42 -0500 Received: by mail-lf1-x131.google.com with SMTP id z7so26744566lfi.11 for ; Mon, 06 Dec 2021 08:42:38 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id e11sm1401809lfq.65.2021.12.06.08.42.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Dec 2021 08:42:36 -0800 (PST) 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=oK7Dcl8KiGDMV00K11CYBL+HNLJkgh6OyOufnt40n1g=; b=D5ZyHZvDLmZMDPJxShqu075T1qCTezegAYQb+jqI4M4Z1tSNrbaki2vDhEaHJD8jja Bhy9GKckPQn8UVnvG3Zh2eVWhuCPcP1RfTO6D4pzsLeaUuV9x+C+ibWgn05JBM2sDdr+ Vlk+k2nqFfllPzTUH2so43MjG0qtHBnx3NhuXWhQyTM3NjPO4cteOEe3VqIuP7eOVWad 2Pj6SOeaADkIYUt8iCADBmYiLnccNzgl9yV3nrhQ3xL+U7bxuYm5xlr1bZ5g0ApgGt51 0AH1ZdBDgD+88V26NfB+O1O/wx6FhnHUsQmNALf3xOPRrwOGgKKoQ6oIOgD5aAYpkz/i Vf1w== 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=oK7Dcl8KiGDMV00K11CYBL+HNLJkgh6OyOufnt40n1g=; b=a+OD9I9alIFPSSJehIBvX4ssFvP0Do8GD+NQRIvYEQ0iyZiELnU/Ew171V2Mirfw+W DzsNQaob1S5MYsPdAhAd+JmMM+kn5OIzh/9mduBhJQMVzEVKd5UEGlnYr/lqxJA2p8A7 05MjSfre4xEt7SIpM1WVTpilsc7Xm6PVCnsHg4E3B8/GgBBgGkMYWLPNavw4uiVCJPpG IM/KmnECmCSg255w8oFVEUI1phzU/AkIPAe+93tSYac8PHOXb8g9nC2sxJfi6eP4hNAg ODTqqcv/dcVqmI+GfzhcdJ05fmuiKMT0XQfh/CcXDCq3+tZKb+TlI7/DL2HMILfs2fl7 ewlA== X-Gm-Message-State: AOAM533HK/yq9OlM/sgBqXIlaMx9nPHQCMxTqPWLnXUVMOfaVjfKh/o4 TvNlbOBeqLXcHnqNUBwvl9cjX3BgvGn4OdzF X-Google-Smtp-Source: ABdhPJzq+NjV3pzKBu1xNLB7kq5xgO1H4szoRCxVvMK8/vZX1MDKOEVBgQkDC41PCz3TTLu3LLdykQ== X-Received: by 2002:a05:6512:23a4:: with SMTP id c36mr35871168lfv.634.1638808956575; Mon, 06 Dec 2021 08:42:36 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v6 2/6] net/vmnet: add vmnet backends to qapi/net Date: Mon, 6 Dec 2021 19:42:18 +0300 Message-Id: <20211206164222.11027-3-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211206164222.11027-1-yaroshchuk2000@gmail.com> References: <20211206164222.11027-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::131 (failed) 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::131; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x131.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladislav Yaroshchuk , jasowang@redhat.com, phillip.ennen@gmail.com, armbru@redhat.com, r.bolshakov@yadro.com, phillip@axleos.com, akihiko.odaki@gmail.com, hsp.cat7@gmail.com, hello@adns.io, eblake@redhat.com 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: 1638809406746100001 Content-Type: text/plain; charset="utf-8" Create separate netdevs for each vmnet operating mode: - vmnet-host - vmnet-shared - vmnet-bridged Signed-off-by: Vladislav Yaroshchuk --- net/clients.h | 11 ++++ net/meson.build | 7 +++ net/net.c | 10 ++++ net/vmnet-bridged.m | 25 +++++++++ net/vmnet-common.m | 20 +++++++ net/vmnet-host.c | 24 ++++++++ net/vmnet-shared.c | 25 +++++++++ net/vmnet_int.h | 25 +++++++++ qapi/net.json | 132 +++++++++++++++++++++++++++++++++++++++++++- 9 files changed, 277 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 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 847bc2ac85..00a88c4951 100644 --- a/net/meson.build +++ b/net/meson.build @@ -42,4 +42,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 +vmnet_files =3D files( + 'vmnet-common.m', + 'vmnet-bridged.m', + 'vmnet-host.c', + 'vmnet-shared.c' +) +softmmu_ss.add(when: vmnet, if_true: vmnet_files) subdir('can') diff --git a/net/net.c b/net/net.c index f0d14dbfc1..1dbb64b935 100644 --- a/net/net.c +++ b/net/net.c @@ -1021,6 +1021,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 @@ -1106,6 +1111,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-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_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 */ diff --git a/qapi/net.json b/qapi/net.json index 7fab2e7cd8..8ed7bf0c04 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -452,6 +452,122 @@ '*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. +# +# @start-address: The starting IPv4 address to use for the interface. +# Must be in the private IP range (RFC 1918). Must be +# specified along with @end-address and @subnet-mask. +# This address is used as the gateway address. The +# subsequent address up to and including end-address are +# placed in the DHCP pool. +# +# @end-address: 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 @start-address and +# @subnet-mask. +# +# @subnet-mask: The IPv4 subnet mask to use on the interface. Must +# be specified along with @start-address and @subnet-mask. +# +# @isolated: Enable isolation for this interface. Interface isolation +# ensures that vmnet interface is not able to communicate +# with any other vmnet interfaces. Only communication with +# host is allowed. +# +# @net-uuid: The identifier (UUID) to uniquely identify the isolated +# network vmnet interface should be added to. If +# set, no DHCP service is provided for this interface and +# network communication is allowed only with other interfaces +# added to this network identified by the UUID. +# +# Since: 7.0 +## +{ 'struct': 'NetdevVmnetHostOptions', + 'data': { + '*start-address': 'str', + '*end-address': 'str', + '*subnet-mask': 'str', + '*isolated': 'bool', + '*net-uuid': '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 communicate with the native host and with +# other shared mode interfaces on the same subnet. If no DHCP +# settings, subnet mask and IPv6 prefix specified, the interface can +# communicate with any of other interfaces in shared mode. +# +# @start-address: The starting IPv4 address to use for the interface. +# Must be in the private IP range (RFC 1918). Must be +# specified along with @end-address and @subnet-mask. +# This address is used as the gateway address. The +# subsequent address up to and including end-address are +# placed in the DHCP pool. +# +# @end-address: 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 @start-address and @subnet-ma= sk. +# +# @subnet-mask: The IPv4 subnet mask to use on the interface. Must +# be specified along with @start-address and @subnet-mask. +# +# @isolated: Enable isolation for this interface. Interface isolation +# ensures that vmnet interface is not able to communicate +# with any other vmnet interfaces. Only communication with +# host is allowed. +# +# @nat66-prefix: The IPv6 prefix to use into guest network. Must be a +# unique local address i.e. start with fd00::/8 and have +# length of 64. +# +# Since: 7.0 +## +{ 'struct': 'NetdevVmnetSharedOptions', + 'data': { + '*start-address': 'str', + '*end-address': 'str', + '*subnet-mask': 'str', + '*isolated': 'bool', + '*nat66-prefix': '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. +# +# @isolated: Enable isolation for this interface. Interface isolation +# ensures that vmnet interface is not able to communicate +# with any other vmnet interfaces. Only communication with +# host is allowed. +# +# Since: 7.0 +## +{ 'struct': 'NetdevVmnetBridgedOptions', + 'data': { + 'ifname': 'str', + '*isolated': 'str' + }, + 'if': 'CONFIG_VMNET' } + ## # @NetClientDriver: # @@ -460,10 +576,16 @@ # Since: 2.7 # # @vhost-vdpa since 5.1 +# @vmnet-host since 7.0 +# @vmnet-shared since 7.0 +# @vmnet-bridged since 7.0 ## { '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 +599,9 @@ # Since: 1.2 # # 'l2tpv3' - since 2.1 +# 'vmnet-host' - since 7.0 +# 'vmnet-shared' - since 7.0 +# 'vmnet-bridged' - since 7.0 ## { 'union': 'Netdev', 'base': { 'id': 'str', 'type': 'NetClientDriver' }, @@ -492,7 +617,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 May 18 13:16:34 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 1638809066767326.6645180233246; Mon, 6 Dec 2021 08:44:26 -0800 (PST) Received: from localhost ([::1]:34420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muH6H-0007SU-LB for importer@patchew.org; Mon, 06 Dec 2021 11:44:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muH4b-0004h6-VL for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:41 -0500 Received: from [2a00:1450:4864:20::22c] (port=40941 helo=mail-lj1-x22c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muH4Z-00074o-6l for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:41 -0500 Received: by mail-lj1-x22c.google.com with SMTP id u22so22082819lju.7 for ; Mon, 06 Dec 2021 08:42:38 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id e11sm1401809lfq.65.2021.12.06.08.42.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Dec 2021 08:42:36 -0800 (PST) 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=UooPoY0MVV/Y1dF1WCBxe5LUUmT/aqG+eGQmvWF3yb0=; b=e6AeLuAePwWJjEBa2gKiCVT4B8gE+25Om2ypO5ZR/52pCatY2f+CuW8lC7YKAs7hG8 b1wVydlcqI6xCj6DgdPBExussyFlpXVr8L/YqMyJ07OFuSj9eOHs0CMcFN/cUaB8G5wi ZD2t4LBXJ664RcJ1k9mUa47vOgBmkJHZxKkh7NUivZ5M7sI+TI5jBsujOqAT5eQKLGvv 6qc3rMxrPkc57UDZttxW+8BAa9mws7TtaAlxG85Em1JiNlrJEdcM3yhI1eMPgJR1WVNU nfnkD31clcQVmM5/Ztz5zpXUqkdnxZonTzqqIIjv2iZUi+aJLwh9ipBODYLo83lOSh2y zBaA== 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=UooPoY0MVV/Y1dF1WCBxe5LUUmT/aqG+eGQmvWF3yb0=; b=SSNe8Rnq2zDKSxTf6yGvaOmdfc9OxoAmk/3kwp9LWMDJ7tOzD5TIFbiAYUlj2g+443 ZE5Jtotm7P6eSi64IIaW2JAELrbMnj0IzW24Pj0oXXGQ7wUpQXkstjJnvAc+axM0NLCg KYg1Ij37n/u0uHEKJ6WWL3g79mLfNNVN06wJ1lkXMUSPDNondSdHeR0U4buPOHsctzys D56q+/e0M0VpeYsBSLCbMPjwZvHQv9GYhMnc9A3+d5VtURVIxzK3wmlxHhehDErIN1Li 5khrfhghPGVIvM4cpkup63B2lklIAo2nHUP1RzMooUXIqZbIMPRVve12r6vADImVciWE ygbg== X-Gm-Message-State: AOAM531n3/OKFgD3BErDRr0WOWKv8f3gniawr24Mx+YIPMbselru/zIi dEv8D6J1949Gn2wCw9gZpSKsUzz+Z3m/YXyr X-Google-Smtp-Source: ABdhPJxEl7TjqjOKEvLufALpji6RKwonpYABp85G3ig8s4g4MlJQ4/6OCaDSn530MlPDNorlNIjFHw== X-Received: by 2002:a2e:a407:: with SMTP id p7mr35915789ljn.468.1638808957292; Mon, 06 Dec 2021 08:42:37 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v6 3/6] net/vmnet: implement shared mode (vmnet-shared) Date: Mon, 6 Dec 2021 19:42:19 +0300 Message-Id: <20211206164222.11027-4-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211206164222.11027-1-yaroshchuk2000@gmail.com> References: <20211206164222.11027-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::22c (failed) 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::22c; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lj1-x22c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladislav Yaroshchuk , jasowang@redhat.com, phillip.ennen@gmail.com, armbru@redhat.com, r.bolshakov@yadro.com, phillip@axleos.com, akihiko.odaki@gmail.com, hsp.cat7@gmail.com, hello@adns.io, eblake@redhat.com 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: 1638809067824100005 Content-Type: text/plain; charset="utf-8" Interaction with vmnet.framework in different modes differs only on configuration stage, so we can create common `send`, `receive`, etc. procedures and reuse them. vmnet.framework supports iov, but writing more than one iov into vmnet interface fails with 'VMNET_INVALID_ARGUMENT'. Collecting provided iovs into one and passing it to vmnet works fine. That's the reason why receive_iov() left unimplemented. But it still works with good enough performance having .receive() implemented only. Also, there is no way to unsubscribe from vmnet packages receiving except registering and unregistering event callback or simply drop packages just ignoring and not processing them when related flag is set. Here we do using the second way. Signed-off-by: Phillip Tennen Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-common.m | 310 +++++++++++++++++++++++++++++++++++++++++++++ net/vmnet-shared.c | 75 ++++++++++- net/vmnet_int.h | 23 ++++ 3 files changed, 404 insertions(+), 4 deletions(-) diff --git a/net/vmnet-common.m b/net/vmnet-common.m index 532d152840..6d474af4be 100644 --- a/net/vmnet-common.m +++ b/net/vmnet-common.m @@ -10,6 +10,8 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/main-loop.h" +#include "qemu/log.h" #include "qapi/qapi-types-net.h" #include "vmnet_int.h" #include "clients.h" @@ -17,4 +19,312 @@ #include "qapi/error.h" =20 #include +#include =20 +#ifdef DEBUG +#define D(x) x +#define D_LOG(...) qemu_log(__VA_ARGS__) +#else +#define D(x) do { } while (0) +#define D_LOG(...) do { } while (0) +#endif + +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"; + case VMNET_SHARING_SERVICE_BUSY: + return "conflict, sharing service is in use"; + 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); + + xpc_dictionary_set_bool( + if_desc, + vmnet_allocate_mac_address_key, + false + ); + + D(D_LOG("vmnet.start.interface_desc:\n"); + xpc_dictionary_apply(if_desc, + ^bool(const char *k, xpc_object_t v) { + char *desc =3D xpc_copy_description(v); + D_LOG(" %s=3D%s\n", k, desc); + free(desc); + return true; + })); + + 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; + } + + D(D_LOG("vmnet.start.interface_param:\n"); + xpc_dictionary_apply(interface_param, + ^bool(const char *k, xpc_object_t v) { + char *desc =3D xpc_copy_description= (v); + D_LOG(" %s=3D%s\n", k, desc); + free(desc); + return true; + })); + + 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, + "cannot create vmnet interface: %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..08f7004427 100644 --- a/net/vmnet-shared.c +++ b/net/vmnet-shared.c @@ -10,16 +10,83 @@ =20 #include "qemu/osdep.h" #include "qapi/qapi-types-net.h" +#include "qapi/error.h" #include "vmnet_int.h" #include "clients.h" -#include "qemu/error-report.h" -#include "qapi/error.h" =20 #include =20 +typedef struct VmnetSharedState { + VmnetCommonState cs; +} VmnetSharedState; + + +static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetSharedOptions *options =3D &(netdev->u.vmnet_shared); + xpc_object_t 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_enable_isolation_key, + options->isolated + ); + + if (options->has_nat66_prefix) { + xpc_dictionary_set_string(if_desc, + vmnet_nat66_prefix_key, + options->nat66_prefix); + } + + if (options->has_start_address || + options->has_end_address || + options->has_subnet_mask) { + + if (options->has_start_address && + options->has_end_address && + options->has_subnet_mask) { + + xpc_dictionary_set_string(if_desc, + vmnet_start_address_key, + options->start_address); + xpc_dictionary_set_string(if_desc, + vmnet_end_address_key, + options->end_address); + xpc_dictionary_set_string(if_desc, + vmnet_subnet_mask_key, + options->subnet_mask); + } else { + error_setg( + errp, + "'start-address', 'end-address', 'subnet_mask' " + "should be provided together" + ); + } + } + + return if_desc; +} + +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 =3D qemu_new_net_client(&net_vmnet_shared_info, + peer, "vmnet-shared", name); + xpc_object_t if_desc =3D create_if_desc(netdev, errp); + + return vmnet_if_create(nc, if_desc, errp, NULL); } + 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 May 18 13:16:34 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 16388092524211009.4741531133594; Mon, 6 Dec 2021 08:47:32 -0800 (PST) Received: from localhost ([::1]:40874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muH9H-0003Lg-A3 for importer@patchew.org; Mon, 06 Dec 2021 11:47:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muH4c-0004hC-5b for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:42 -0500 Received: from [2a00:1450:4864:20::231] (port=41529 helo=mail-lj1-x231.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muH4a-00074v-9w for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:41 -0500 Received: by mail-lj1-x231.google.com with SMTP id d11so22071462ljg.8 for ; Mon, 06 Dec 2021 08:42:39 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id e11sm1401809lfq.65.2021.12.06.08.42.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Dec 2021 08:42:37 -0800 (PST) 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=jtMW004Au7CrDB93vS6nalJFyRXcqbDatoHFcN9NphY=; b=G/ONeS0iCk8QSf0NMvvxod6cpPM6dnqcHLe/r7ndquAZG1MiPfWI/1TXgGh7tXoq4J cn5IDSzngZaKPj4wdzJS71JPQVuiUbCT0guiNASB6y2/rB+ru0p8WmEVdnv5PGFbzBsN RliWBhriPdLYMFWaDItQFTg3Q++2CfIuaKv1N2LwytccmsDFLvcjDxSFAmLZUEHCh8Bx EWe8OCqQ/ONS3HVA0piiPhWMb0MPf/I20kW4h2eXXyuLikX9xprqOrlYJaWpxur95PDz /Ah5WeaFw0spHSMiIrAX9vGgA3yLU3SAZvTUb02t43qT+8e0WSYnwGshnunCRcvh7gXQ Aulg== 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=jtMW004Au7CrDB93vS6nalJFyRXcqbDatoHFcN9NphY=; b=THbdKZLocZhpFuQ1c38gu9YhJo4swKHsTxpBe1NR97NLGBOrYyI693J6Jrn3+GgDa5 1J95NwWBOwlSdpw4kaXAd3FiZG6Qgj2fYwiTYdVYotpxy9n5jsZkAdDpmgkTkz1WmGRk 4Dru1/nV/X2OsNPYaCWv8Byhx6S2eyM5bgo2M1+WQADzKzdHd3merkW1qDsLEfP057Lp +J1I50gAHWf96ga21YXQGgDQJ+994ltl6DV3v+6J8ah/6Wc2eyMvCURRdnWX5MznEqkY 7CDhblEHscp0NiYJj9vGo5P3880743YRn+K32xA+cqjaj7xC1pI+wu6IR7Q+BvDI9tHQ 4VWg== X-Gm-Message-State: AOAM530UocsbIDJta/h8o1SCES4TyhulDBjSOATPcNu8/LseNCDu5oz+ 9B8LUnlAdCps3ajbXjFP5XkMh+hI46r3IZSi X-Google-Smtp-Source: ABdhPJw2eBPZ6vTozPWOEkDRPMFYZYtrv3YpiLSPPHOxAA0Gtkj+mJzav+A8pJBdsPix+ii3n4saHg== X-Received: by 2002:a2e:b894:: with SMTP id r20mr38488994ljp.304.1638808958123; Mon, 06 Dec 2021 08:42:38 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v6 4/6] net/vmnet: implement host mode (vmnet-host) Date: Mon, 6 Dec 2021 19:42:20 +0300 Message-Id: <20211206164222.11027-5-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211206164222.11027-1-yaroshchuk2000@gmail.com> References: <20211206164222.11027-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::231 (failed) 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::231; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lj1-x231.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladislav Yaroshchuk , jasowang@redhat.com, phillip.ennen@gmail.com, armbru@redhat.com, r.bolshakov@yadro.com, phillip@axleos.com, akihiko.odaki@gmail.com, hsp.cat7@gmail.com, hello@adns.io, eblake@redhat.com 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: 1638809254058100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-host.c | 93 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 6 deletions(-) diff --git a/net/vmnet-host.c b/net/vmnet-host.c index 4a5ef99dc7..9c2e760ed1 100644 --- a/net/vmnet-host.c +++ b/net/vmnet-host.c @@ -9,16 +9,97 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/uuid.h" #include "qapi/qapi-types-net.h" -#include "vmnet_int.h" -#include "clients.h" -#include "qemu/error-report.h" #include "qapi/error.h" +#include "clients.h" +#include "vmnet_int.h" =20 #include =20 +typedef struct VmnetHostState { + VmnetCommonState cs; + QemuUUID network_uuid; +} VmnetHostState; + +static xpc_object_t create_if_desc(const Netdev *netdev, + NetClientState *nc, + Error **errp) +{ + const NetdevVmnetHostOptions *options =3D &(netdev->u.vmnet_host); + VmnetCommonState *cs =3D DO_UPCAST(VmnetCommonState, nc, nc); + VmnetHostState *hs =3D DO_UPCAST(VmnetHostState, cs, cs); + + xpc_object_t 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_enable_isolation_key, + options->isolated + ); + + if (options->has_net_uuid) { + if (qemu_uuid_parse(options->net_uuid, &hs->network_uuid) < 0) { + error_setg(errp, "Invalid UUID provided in 'net-uuid'"); + } + + xpc_dictionary_set_uuid( + if_desc, + vmnet_network_identifier_key, + hs->network_uuid.data + ); + } + + if (options->has_start_address || + options->has_end_address || + options->has_subnet_mask) { + + if (options->has_start_address && + options->has_end_address && + options->has_subnet_mask) { + + xpc_dictionary_set_string(if_desc, + vmnet_start_address_key, + options->start_address); + xpc_dictionary_set_string(if_desc, + vmnet_end_address_key, + options->end_address); + xpc_dictionary_set_string(if_desc, + vmnet_subnet_mask_key, + options->subnet_mask); + } else { + error_setg( + errp, + "'start-address', 'end-address', 'subnet_mask' " + "should be provided together" + ); + } + } + + return if_desc; +} + +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, nc, errp); + return vmnet_if_create(nc, if_desc, errp, NULL); } --=20 2.23.0 From nobody Sat May 18 13:16:34 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 1638809251777368.50430899436753; Mon, 6 Dec 2021 08:47:31 -0800 (PST) Received: from localhost ([::1]:40850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muH9G-0003Ki-Cj for importer@patchew.org; Mon, 06 Dec 2021 11:47:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muH4d-0004iS-OZ for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:43 -0500 Received: from [2a00:1450:4864:20::12f] (port=40500 helo=mail-lf1-x12f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muH4a-000757-RE for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:42 -0500 Received: by mail-lf1-x12f.google.com with SMTP id l22so26782292lfg.7 for ; Mon, 06 Dec 2021 08:42:40 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id e11sm1401809lfq.65.2021.12.06.08.42.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Dec 2021 08:42:38 -0800 (PST) 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=vlN7d0rtidqdQWLCIgN5N1fcLK+0qLzuCPNMY3+d1oo=; b=guGl7Rr1HQhzJcLXAdBPJV6r0ume2Q09bg2AhZfSF9VVF7Vj8QWVY7/EeSfuSakT1v SIEr6Yd1D4gPqCHnndmVWJRXQSxw84elcMUCPlVxG0fUnMvhh2JDD3z5e5vhg0xGUcq5 widQWr0UgL1NfmJeZwVD4HpwxXnIofUhRFdUmBLbJf7/A6QI+yMdzXWWShym+2Qwzno4 SfzP+Iafaof2a1mSclO2GBYCIoY59psMLgbJrTMAfEkEOfZ7PlhYqid0Y79ZcP94b73W dd8HTXp8umvoh1eHGhgO7TrKW/OERbnV1peevNC0qVUpPsns2kBjO1ecvk8MeRIBEKLL vIxA== 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=vlN7d0rtidqdQWLCIgN5N1fcLK+0qLzuCPNMY3+d1oo=; b=0xal/GK1xSLrI15qZJFNpwh6MfiKoYHqdXVZEtDETPd5nn6ftGD6j+n2rxeFD0aOo0 Xnveo+3n2bJPJxXCHkL1d7Fn5PMPDfrP4tYtvn1XU1Vfkjk5kGz5FR1dn94lfoCkrB70 5WfYDFWsWi51tdwhqFWJMrRn9E4B+6oGVO9iXD9kkN1Szp+h97mo2pVxrcSI+I4iRfoj 8TutvGkYyr/b23XBnDd8l2N2SAHtCQHtAEnUHaAhEyF9FHfW1XMKVoluvT3r7jlz8uA6 bGTeUwzo0q6UBFFcLfmehK+jcZ3l78J+pgWG30EEePOdZFDESHJ91/axqcMnVj3Q+80I hPHg== X-Gm-Message-State: AOAM531EFWypA2N/E4xM2hixfJWbpce+ClXTj3vpg87LEFZk66ylbYix pUS7v81wm6iuah6EaTNXfB2AjYeluUbKVy4o X-Google-Smtp-Source: ABdhPJwIpbWQnaV/J4wy8rPwFkjklamnumUNCYGfIXgAxYpL8FU2rH4NN6sw+eAeAhENKcK71qcxFQ== X-Received: by 2002:a05:6512:2201:: with SMTP id h1mr36716622lfu.264.1638808959044; Mon, 06 Dec 2021 08:42:39 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v6 5/6] net/vmnet: implement bridged mode (vmnet-bridged) Date: Mon, 6 Dec 2021 19:42:21 +0300 Message-Id: <20211206164222.11027-6-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211206164222.11027-1-yaroshchuk2000@gmail.com> References: <20211206164222.11027-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::12f (failed) 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::12f; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x12f.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladislav Yaroshchuk , jasowang@redhat.com, phillip.ennen@gmail.com, armbru@redhat.com, r.bolshakov@yadro.com, phillip@axleos.com, akihiko.odaki@gmail.com, hsp.cat7@gmail.com, hello@adns.io, eblake@redhat.com 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: 1638809253729100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-bridged.m | 98 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 6 deletions(-) diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m index 4e42a90391..3c9da9dc8b 100644 --- a/net/vmnet-bridged.m +++ b/net/vmnet-bridged.m @@ -10,16 +10,102 @@ =20 #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 "clients.h" +#include "vmnet_int.h" =20 #include =20 +typedef struct VmnetBridgedState { + VmnetCommonState cs; +} VmnetBridgedState; + +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]"; +} + +static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetBridgedOptions *options =3D &(netdev->u.vmnet_bridged= ); + xpc_object_t 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_enable_isolation_key, + options->isolated + ); + + 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 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, +}; + 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 =3D qemu_new_net_client(&net_vmnet_bridged_info, + peer, "vmnet-bridged", name); + xpc_object_t 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); +} \ No newline at end of file --=20 2.23.0 From nobody Sat May 18 13:16:34 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 1638809066105589.1353358529309; Mon, 6 Dec 2021 08:44:26 -0800 (PST) Received: from localhost ([::1]:34382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muH6G-0007Qz-Sk for importer@patchew.org; Mon, 06 Dec 2021 11:44:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muH4d-0004iw-8G for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:43 -0500 Received: from [2a00:1450:4864:20::230] (port=37808 helo=mail-lj1-x230.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muH4b-00075I-QR for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:43 -0500 Received: by mail-lj1-x230.google.com with SMTP id k2so22144774lji.4 for ; Mon, 06 Dec 2021 08:42:41 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id e11sm1401809lfq.65.2021.12.06.08.42.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Dec 2021 08:42:39 -0800 (PST) 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=KxyIn3tzuHg3Cc5smDSxhuZu5Nmeg1/uO+PyEusnahs=; b=Pz0DBo/+AIonKSgZnbfylmT8pmeehB0bu6xj07lVmYiqZoc1PcmR3A0VVSqdeMXhjV k3Ehms5B96ReJHyndux3ye9VF840FcF4fffi1HldNJfjk7BHvK/keyoPYRIwGuGEwvq9 99ciyWUS5QtJhKmv0hB3VDS2awimeyyKPGFZqDHKNLY1nrGyngYfISP95QewdGhcDv/o 2vdAmQYeyGi49SAFM/DIef2WuKxXXUDVD9hDCdgSl+GoHgXE4h42ttFdvfQiLzFBZpXL YzrnF7TDAOKnw2MP1TcHqG2TFlZsVlR16kl6UKfdjTRk9KXu/lSWcWc9YMiQ2ILMBSMi aZCg== 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=KxyIn3tzuHg3Cc5smDSxhuZu5Nmeg1/uO+PyEusnahs=; b=L4mW1DHAEYfyouTNFe2xv/3WL6rdVuUys6UBbxNZChol7vSTLtPemCuwz0NZm0Xa4h N9ADCU98EisTnWVGNR/iJZzWR6OeAX81OLoMvP0wVwa2WZoqeQ2eZ1dF8FXx0GisTjQR 0PxEgzXLh+adV0mAzJgH299apd14tVtsvrz7HZkP7GBj1B3zya9T2g4uYbZwC/n3DWl2 /N6wh4zFuwp9+gTgMKW1f/yUr47M9Ha1euWzS9lH0jfwady2ATOopLbeRy/pP9fYphWC A5hiHmI9bT3Os9QRQyrSyNaMBTFlfKiFzVEfG9UtPL1Fppj1ASSBpjGwOMMOeApUbwog 8zXA== X-Gm-Message-State: AOAM5328drsNByZ8GC2pprdlrLq92UK2zdGM+ei0bkub5FIHX9ptSVy+ btqkZPru3ZgxAa1sPaIfJTUXRimn4MZf7ifF X-Google-Smtp-Source: ABdhPJwZ6DnSoQPS1fOIkq7D1xyMA6oEynZo7Lh1PA6uYU4zpYhaFhbllu7NzeZoq7wLM6b6tBjO/Q== X-Received: by 2002:a2e:b816:: with SMTP id u22mr37472918ljo.51.1638808959938; Mon, 06 Dec 2021 08:42:39 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v6 6/6] net/vmnet: update qemu-options.hx Date: Mon, 6 Dec 2021 19:42:22 +0300 Message-Id: <20211206164222.11027-7-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211206164222.11027-1-yaroshchuk2000@gmail.com> References: <20211206164222.11027-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::230 (failed) 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::230; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladislav Yaroshchuk , jasowang@redhat.com, phillip.ennen@gmail.com, armbru@redhat.com, r.bolshakov@yadro.com, phillip@axleos.com, akihiko.odaki@gmail.com, hsp.cat7@gmail.com, hello@adns.io, eblake@redhat.com 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: 1638809066645100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- qemu-options.hx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index ae2c6dbbfc..1ffa5eedd5 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2677,6 +2677,25 @@ 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[,isolated=3Don|off][,net-uuid=3Duuid]\n" + " [,start-address=3Daddr,end-address=3Daddr,subnet-mask=3Dmask= ]\n" + " configure a vmnet network backend in host mode with I= D 'str',\n" + " isolate this interface from others with 'isolated',\n" + " configure the address range and choose a subnet mask,= \n" + " specify network UUID 'uuid' to disable DHCP and inter= act with\n" + " vmnet-host interfaces within this isolated network\n" + "-netdev vmnet-shared,id=3Dstr[,isolated=3Don|off][,nat66-prefix=3Dadd= r]\n" + " [,start-address=3Daddr,end-address=3Daddr,subnet-mask=3Dmask= ]\n" + " configure a vmnet network backend in shared mode with= ID 'str',\n" + " configure the address range and choose a subnet mask,= \n" + " set IPv6 ULA prefix (of length 64) to use for interna= l network,\n" + " isolate this interface from others with 'isolated'\n" + "-netdev vmnet-bridged,id=3Dstr,ifname=3Dname[,isolated=3Don|off]\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" + " isolate this interface from others with 'isolated'\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 +2715,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 +2740,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