From nobody Thu Mar 28 15:37:25 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 1638872480999121.60855768933868; Tue, 7 Dec 2021 02:21:20 -0800 (PST) Received: from localhost ([::1]:42704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muXb3-0004GS-1v for importer@patchew.org; Tue, 07 Dec 2021 05:21:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muXYj-0001ek-3D for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:53 -0500 Received: from [2a00:1450:4864:20::12a] (port=40546 helo=mail-lf1-x12a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muXYh-0007Cn-Li for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:52 -0500 Received: by mail-lf1-x12a.google.com with SMTP id l22so32389754lfg.7 for ; Tue, 07 Dec 2021 02:18:51 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id w10sm1629022lfn.308.2021.12.07.02.18.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Dec 2021 02:18:49 -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=ne4dK4pSqKchod/fAgvZQXc6zmed6rU6y9D/VcZSA7Z4bW4YfyYsP+5GzmK2hiNWTt wn7GByaVPBGzcwJ2NNOJkf1nqOWy8Bv44ox6dNhgpxlIHIb+kIPxxLxMCHWNF52zXcGP jg8X3M0dHnAlqW3e5fFzz10W6TOlzy78bc60gIkRihXCjVPAcfQ3tX2e7/h3bEKIZPj1 dku+nrZ7vz1E1IthJy/EMCpJNiBNA37Re+ud1IueJz743SKiG+A6yk6tdkSeVNEXBxJM 3Q9PNtVG8DmPZbFmVsibRpB3WOYqbz4L98YHirB7eMlg1nsOAg/9ZVdmuF13GcgPHqT/ WfhA== 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=kXj7FpuC0OfAJUpH18AHv2n2p/3P3a6PBugXywYSNKPOSxxkKLOy+puwfVD97i6b0H 2X9eGsjNRSy8iUmNuangdv4zKaHwIGOonU3gLwsMXBfdXXYIlD6pSvIUvS9kxEXV/R8C Ba4NsU3Anrm/Zq2HMJKze/yAxXubpfJmXJFpZ0LXSVJk520FeeczvVmS0eqV5dEUyK9F ge8xyyRb1is50tqCqB3rY4HxfttlAGIgla9vPSUjRnzU73DDi7z6hxc/eLYSvuMHb2qq 9305uk6XNxA9ovDJwheSzcf/YIONf1h0V1OliDhvidnST62NjUOvYYoHQAe9LyxgFvwc w7lQ== X-Gm-Message-State: AOAM530zQa536foPBCmH8V3mUoIkOyfh+bky09gPlVxkK7j99omRVsfy /xMzq/qxe8ksgfruGpLZbDBW78anH0S3ew== X-Google-Smtp-Source: ABdhPJz2sYzaA1+o3Mvl/L7KOby12+592i3O+x+sENwNuXAMdxOSb2fd8Bm6kRFSufSRtgGjKBPeeA== X-Received: by 2002:ac2:5d46:: with SMTP id w6mr38041539lfd.15.1638872329731; Tue, 07 Dec 2021 02:18:49 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v7 1/7] net/vmnet: add vmnet dependency and customizable option Date: Tue, 7 Dec 2021 13:18:22 +0300 Message-Id: <20211207101828.22033-2-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211207101828.22033-1-yaroshchuk2000@gmail.com> References: <20211207101828.22033-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::12a (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::12a; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x12a.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: 1638872482444100001 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 Thu Mar 28 15:37:25 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 1638872642805428.47822993297564; Tue, 7 Dec 2021 02:24:02 -0800 (PST) Received: from localhost ([::1]:51800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muXdh-0002AE-Lq for importer@patchew.org; Tue, 07 Dec 2021 05:24:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muXYl-0001it-6I for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:55 -0500 Received: from [2a00:1450:4864:20::22b] (port=40464 helo=mail-lj1-x22b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muXYi-0007Cr-IY for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:54 -0500 Received: by mail-lj1-x22b.google.com with SMTP id u22so26456612lju.7 for ; Tue, 07 Dec 2021 02:18:52 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id w10sm1629022lfn.308.2021.12.07.02.18.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Dec 2021 02:18:50 -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=JAXHEZCYYVkVsmYUyOdrGoDY3MGg1yrE9QJKCBMjAvQ+cxxMn4ShIoVeusWhxyQuM+ 755sitejBcV658jFyb+VRCpEdJDY/RGNVKPEOd+41rXIG3va4v/SjQldLtLyDfsbrhgQ TiDfp98yq+IJUT23Su9Up/V+uqNbmB4ePsAipVoR1jYG4+CPsbixZfbIDZ+/BcQPetGY 65Iu7ZU0Y6hacoJQT4WBLDXwYBK02RaHCoGbJ1bxIibt24UQu4JTOhKw3US6g07X+6JF 4zlNcJMeAPcXfnmWIGbzinJteclVjX//eoPWsDGhIEwkOk6DWSJ6YJfRANkW3lyhn6YZ 2AGQ== 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=gz67avmLppnpaMM804E7I1/biSf/yPD9/AHlac8aWWG7fvBQeRaG/f6WEbuHrrnj7e 2EbMD5KVKfLe2+dx+EGHgU+MAQmCoIIfjGthGKkkaClbqQkXkqoxweqNUNRFJFWxRaX0 r05V0GK+lcJsqbfDztLVRy6y9J/rLM6kqwmqP+J8ihhMiZ63SNhp9VVl8uBV3PJrjWOn z8PhS2zt5zdce2Jd5W5GJt4mZZkTY+WAvuXy3C8Jkd5QEA34QrY8yssIMXf9zyzZmM3R iROeuxolzqGD+ZrTRwehVDVfSSuUIkxyfSD0j2YDejxhBo/CLtzvRTrtW4J+TSawdi9A HlAg== X-Gm-Message-State: AOAM530zGj9ylMyDL4Lp8/IQNuFHuNBg+NSuxNctacSztdbeJ+K8Bda5 G3mT6nQoEMnRWT1P8pWAAhpWCJ7LFo7iOg== X-Google-Smtp-Source: ABdhPJyXyX/GTlta/j3KzmsLP6x9nR0g8wkC3p+UfRIO6/w9oG+dhJk9jWY+DLJMwY8Uh+haEQFKkw== X-Received: by 2002:a05:651c:1413:: with SMTP id u19mr40255873lje.382.1638872330530; Tue, 07 Dec 2021 02:18:50 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v7 2/7] net/vmnet: add vmnet backends to qapi/net Date: Tue, 7 Dec 2021 13:18:23 +0300 Message-Id: <20211207101828.22033-3-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211207101828.22033-1-yaroshchuk2000@gmail.com> References: <20211207101828.22033-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::22b (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::22b; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lj1-x22b.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: 1638872643994100001 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 Acked-by: Markus Armbruster --- 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 Thu Mar 28 15:37:25 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 1638872620465777.4854152970902; Tue, 7 Dec 2021 02:23:40 -0800 (PST) Received: from localhost ([::1]:50338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muXdL-0001AA-69 for importer@patchew.org; Tue, 07 Dec 2021 05:23:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muXYl-0001kL-HZ for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:55 -0500 Received: from [2a00:1450:4864:20::233] (port=45690 helo=mail-lj1-x233.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muXYj-0007D1-6i for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:55 -0500 Received: by mail-lj1-x233.google.com with SMTP id j18so26409345ljc.12 for ; Tue, 07 Dec 2021 02:18:52 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id w10sm1629022lfn.308.2021.12.07.02.18.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Dec 2021 02:18:50 -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=KKMo4uF9WVPv9U943nfRIOa+defHbVL+KOmtqNBH5p/QzRiCTZZCzybUHvpJovmPJF zLKm4Xx33bw6f09bcNq9gwSpGcLJocic3Z6qUhuIC8/Lyyy45U4x88bOvejk0yyZr7I4 2MQXor0pMmdBQGBuY/0gV0Npb1awBajK7JYqSSaxl5+k8H+f1DAyu1bfkzH0G0xSJ/1C l1TUX59C7v5EfHwvTH3MQdvuZAMVgcUvO34YLbCr97v/0DsDK1BImCAKwLfrtKAeVo1W 7S4jiO0aWGZW7S61+Ly3hL1yB4Zftu14BbuJ+16mqb1K6YS2D4Ny8lYjMfZG0UlSkiN8 akig== 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=UspJc1ooocYO2YWxNik/WVqN4EOUuHVYwgdRrO50XoR8vzVVKz9sTMj2gxGiis1z8O 8d6UAmP6EmyLRku5von3fr9lSq7umslr6avToDPSVw76+hIKnyb01SLlnmx7lQwgXLMO 9KjjWmyR01rRwBH9mO2akVTTVqWOesZy14enA0CgsMcq7achQp4eTE//yN+BW07uWxlI zE2hjFhG2mc1JuT2BVVKH/NlW/5RsLsCuD4H+P9QhatEUHJ38aCih4/8sifDr5GMUE8i f2IQKH7k5FsDg031EOx6vej0nQ95Aw44+kGfHDam6LzTF2EfgoNx3LdOPbSnaS9+/Mfb BAiQ== X-Gm-Message-State: AOAM5317IKUmtKejbldbQy/ISLTL8Mxfb14/7h0Z2i3rqTUsy1hRKoz5 y0fowWNlgixVxAPYZRhiqPm6V8XO2jXquw== X-Google-Smtp-Source: ABdhPJwGvvK8nA39UitZ0OAxEEJ/n/aNauI2XQPA6YF+IliauqXlkB6/jx3I46LwAvlBXrkgk/0iVg== X-Received: by 2002:a2e:8350:: with SMTP id l16mr39871361ljh.428.1638872331313; Tue, 07 Dec 2021 02:18:51 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v7 3/7] net/vmnet: implement shared mode (vmnet-shared) Date: Tue, 7 Dec 2021 13:18:24 +0300 Message-Id: <20211207101828.22033-4-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211207101828.22033-1-yaroshchuk2000@gmail.com> References: <20211207101828.22033-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::233 (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::233; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lj1-x233.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: 1638872622465100001 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 Thu Mar 28 15:37:25 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 1638872485999505.92714407979236; Tue, 7 Dec 2021 02:21:25 -0800 (PST) Received: from localhost ([::1]:42976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muXbA-0004Sb-Ml for importer@patchew.org; Tue, 07 Dec 2021 05:21:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muXYl-0001jm-Dt for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:55 -0500 Received: from [2a00:1450:4864:20::231] (port=36664 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 1muXYj-0007DD-Sr for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:55 -0500 Received: by mail-lj1-x231.google.com with SMTP id i63so26515985lji.3 for ; Tue, 07 Dec 2021 02:18:53 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id w10sm1629022lfn.308.2021.12.07.02.18.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Dec 2021 02:18:51 -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=VuoHco2tzeF6dNTVX1BgzhZkIIcy/dizkDAeqTrJmqKiu4JqzsqE8vKdeohkJlSbw3 1/1W5wZGX8LR+//B7piH6lsVh99qbFmiCIpPyilGOsJycPJtZlBudU21+iEejk4+18UI yr0g7b33MC+y7hNalwDtWK35M0/O7gs5TV3aMsfhGfiUVY1wWwqeuo/LCmKps9ZCsZy5 L9qeyRPbG63On6bm2N3RUS1OfBtA64s5724DQ3UP8+kRod9tTVNmZRuwib3Qs1jr7+uv XJes/+yhnK9/VY923l9b5grwvv8mlKziJIuIqkD1SuL8ii+jtpq56YQ88h9M4Dtwre6d H/uQ== 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=asIstNbCuMpqIuA9DnqhGAFKOUawgtPX7izyoJta2H/5DsLmL/KDOY5ATLhwG/7Clo UDcluQe+P9OIPozIUn8pe+3gZmqqdYw1DQJwrI4Tp0KEFctPnLez7ZSWQZuvHVFpdYeI cXweEc2sj/ZSHJ9mx+VZrzFvlZ4jifACFbd1SzYWnmVDUzSFiFMLjFrkrdBLQ9RXhOzf NF8JI3UF7gvVPJklD/hSxqPsKpBTi9NMKBp0mWYQs2Vo4Mip6fnlgXEEa+XJL+yOY5FF 2JIeuhmF+lBGF3935GmWXLzLTQI+RY5RwEf86xSI5FpneHG8mrR/xm85NdUdB5ZC7P6h 1fqQ== X-Gm-Message-State: AOAM5318V5jn9yZPb6npUVKMw01jnA2scPg7GuK2RRMFr+quCxvAjR9x LUrzMA1ioZfXqiUOvlW4Y/WX5zNJUuYqeg== X-Google-Smtp-Source: ABdhPJwncsktJ03tejW5IhBjz4nT7pHxhGXBbvjQdy0g8yQpGV2XcU8hXIijfNZF+IoyAhxqp54wPQ== X-Received: by 2002:a05:651c:1127:: with SMTP id e7mr42615975ljo.47.1638872332104; Tue, 07 Dec 2021 02:18:52 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v7 4/7] net/vmnet: implement host mode (vmnet-host) Date: Tue, 7 Dec 2021 13:18:25 +0300 Message-Id: <20211207101828.22033-5-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211207101828.22033-1-yaroshchuk2000@gmail.com> References: <20211207101828.22033-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: 1638872487709100001 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 Thu Mar 28 15:37:25 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 1638872507781813.6191434917008; Tue, 7 Dec 2021 02:21:47 -0800 (PST) Received: from localhost ([::1]:43308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muXbW-0004gu-NN for importer@patchew.org; Tue, 07 Dec 2021 05:21:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muXYm-0001n1-DK for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:56 -0500 Received: from [2a00:1450:4864:20::12b] (port=41947 helo=mail-lf1-x12b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muXYk-0007DO-M3 for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:56 -0500 Received: by mail-lf1-x12b.google.com with SMTP id z21so10306972lfu.8 for ; Tue, 07 Dec 2021 02:18:54 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id w10sm1629022lfn.308.2021.12.07.02.18.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Dec 2021 02:18:52 -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=CCQY8xItuTMpi2f9rrJPmRWskr72qJQ0ZgJsNu5CdwOPiXBNEExzsq1WjotyYcGpFU rgOBdoYE3thpbqJdBUqSet0rmmbiP4uujLNVCFU5CETjwUZFuA7ei1uE7/JvfwI9dlNd 1dSzfbHO6UlNcpfbnTzhM3uYgE5Ra24WOe14oEqjBwb1TUHu2uCIR1uYuLDzBqMc5m5m VrgnTDXeUbsE2ZC918MiCWA7/UW+1hpDQpTDCLYE+JvE3GrUsnd/EYiVf4+ZWh/QHHVw OfIMoWdO1MTSIp4EU7QWP1aMACC7JNCeSkzxMJSfABojbh4GcEoGrBE5MGUqQST/yGdH 9KKQ== 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=qsDycVRCryXX8qh7Co/BmFnwCsGtdE2MR4uczpmxNmcqku09SS5d4UGlrwNzUT4ouZ Ky8mLdTKJyB4yfTnatMKgRYSlGd7ZIAXxSh8c7o0y3C0nWipmEnYTywHwirXJP826wY+ az/CdnGRP7WB43RBTEQsW7NIGeJCrnEaCydpfVeiz7utlbPSR8s5DOFr+78L55xGIk9P yoPhrKu87VSP+4N3fo8BPzVdG1a9Gz0ZVJFzbOSkG1arMhoIW4PwdQ+S3SLWKPHqhysl X6tkYFHp/0zr0zKuWJsbdOO09WPxm12z3dAnWM75CK/lIDFpgPv1n2IIUHwkXl76JANT mpcQ== X-Gm-Message-State: AOAM532EIhWchz5edm0R+aNtSzqGp5vBlxpxMfz/aDXY4bWS3qo/N89B oesGgtJcYNMiQlh76u6pa/0tjJeFk18H/Q== X-Google-Smtp-Source: ABdhPJzOIHO91ndHSf2f2MpH237ErnAYICBeRh3g5qn+g9ukzlTtpp+4F1rkPQve/NePbn/kD3scCw== X-Received: by 2002:a05:6512:1510:: with SMTP id bq16mr38481174lfb.628.1638872332848; Tue, 07 Dec 2021 02:18:52 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v7 5/7] net/vmnet: implement bridged mode (vmnet-bridged) Date: Tue, 7 Dec 2021 13:18:26 +0300 Message-Id: <20211207101828.22033-6-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211207101828.22033-1-yaroshchuk2000@gmail.com> References: <20211207101828.22033-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::12b (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::12b; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x12b.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: 1638872509760100003 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 Thu Mar 28 15:37:25 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 1638872790629205.71262279747805; Tue, 7 Dec 2021 02:26:30 -0800 (PST) Received: from localhost ([::1]:58120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muXg5-0006ZJ-2V for importer@patchew.org; Tue, 07 Dec 2021 05:26:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muXYn-0001pu-5Y for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:57 -0500 Received: from [2a00:1450:4864:20::134] (port=38802 helo=mail-lf1-x134.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muXYl-0007Db-Jt for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:56 -0500 Received: by mail-lf1-x134.google.com with SMTP id bi37so32447243lfb.5 for ; Tue, 07 Dec 2021 02:18:55 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id w10sm1629022lfn.308.2021.12.07.02.18.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Dec 2021 02:18:53 -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=miVdJoomoVLXKpdPMc+jlhD1VTe2WW1GXyqopnEiBrK4yv41ysiLSTcIb4tZ/QQiZv bCL+a7X7C4r6i1NtRZHQ2dLlNXLrUsQIAbibLsgipOO5Z8IgfY2Cjrc43D//+DJHrenc EhsBQt7xp456mb0XjYwuUvHp9WCv/PYXxSm6i6nZluhjectoust54Qw5akvyT5QIjZAi ikjxNwXeD0ePLDvj+KIYX+CZ6GC9q/5CAXm7EtUS8GK8YzQD8yfy9WV1EtJHXCJZT/D9 VKyq5aCXWS6EtUbKjQ/5f0AM1umzrG2KanpuTv2ZzuYEwUlnaW8SAmew3znq34f4Jfeo 4rOg== 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=Kda/IrWdAk+GvmtuoryiWGeU+YUKt+tWsjDtb5ZCHSulGS1UiXYaByFpJ2LBQcHiJe 5Xy16b3cnVVKtlLOXvlqCh1v717m89jPc92B0QIzi/0/wzRupaH09Dt1X5zNloEvMTWP rnxuy+SHHiVVLcB8ng0ZomzXyLIa32N/Jtuv12kaq3Tc0youuka8A06M9tFoWl89EmMq kVwdRRCqPYVVLVxW42X1t42KlRAdDTBmAYX7gE3HYnohtLITBcFOcnUEGFB5SXIRV8xH cpXAwL5kW8ZQwFU5uAhCUUlmGiWXPnuw/N3vBMIfO+RNyep1GAOyb709wP4YbLlOdsHJ qmtw== X-Gm-Message-State: AOAM5305My+czn1aNoaoFwglbar4jLBVP/ejPQIdvLHfeZxSSc3sKO5o SuRCZAh6N6c9R5xDj3F4PiomY1Vf5CqZZA== X-Google-Smtp-Source: ABdhPJx7AsH8XRqe9rVItPMtMKCr1wIqZfstVk8GedL3aTfJ8ERGFXDxDLnz9Yqrl4nra+d4Qs3/rQ== X-Received: by 2002:a19:7512:: with SMTP id y18mr8279231lfe.236.1638872333682; Tue, 07 Dec 2021 02:18:53 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v7 6/7] net/vmnet: update qemu-options.hx Date: Tue, 7 Dec 2021 13:18:27 +0300 Message-Id: <20211207101828.22033-7-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211207101828.22033-1-yaroshchuk2000@gmail.com> References: <20211207101828.22033-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::134 (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::134; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x134.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: 1638872792484100001 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 From nobody Thu Mar 28 15:37:25 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 1638872753493274.4160502842218; Tue, 7 Dec 2021 02:25:53 -0800 (PST) Received: from localhost ([::1]:56636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muXfU-0005U9-HX for importer@patchew.org; Tue, 07 Dec 2021 05:25:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muXYn-0001s9-OC for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:57 -0500 Received: from [2a00:1450:4864:20::12e] (port=43538 helo=mail-lf1-x12e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muXYm-0007E4-A4 for qemu-devel@nongnu.org; Tue, 07 Dec 2021 05:18:57 -0500 Received: by mail-lf1-x12e.google.com with SMTP id b40so32336043lfv.10 for ; Tue, 07 Dec 2021 02:18:55 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id w10sm1629022lfn.308.2021.12.07.02.18.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Dec 2021 02:18:54 -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=wTbVbo9ur7WLaFFQEbjRi1oejMLe54z9lZ3u3znGArs=; b=lbCdXhh3u+o5rCYEedRg9y21pqHaMtBc8eLJX2WXzWuWKYu6zgj0p+72t7UjGHeGO2 T5YGz/SKDavYVyQZVhqe2sLO6tSJ+HwIH0DhhhCqTvNFEiDIm+UQa07AK5NAK+jYaCyT coIRxDHdq9EU/QepS22nw7s7yB9hZgMTYinLEqcKg7YONnbNOg5SQ3JdKW3IdnLHAZYh woztjpmOaB2wiQzCk3r2tZv6vuiL3/8xmgsTtnfIGuZk0kLbSvAv0NHIamuWuZJMUPEW dsxZYbDiwCsW58yXLqNNuQ6I+H8Q8RUydFvZQpAqdaiyMlQ2bY0p/h3JJ/C5AkEhM2Jb eKSA== 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=wTbVbo9ur7WLaFFQEbjRi1oejMLe54z9lZ3u3znGArs=; b=Ho7uQTQZ56KDnd+ieEhFjVvRFyIBDovl5OrcvgVl13SzJ7G/RXzGwWzFh2FJojGiAU h1DQqCXyLyzijL2qCyAYJ072Q2xm5UTNC0SBHNTZylSJG2bdoqju8VPoJ9s+oAj2WH+K T/kLMZ0j12fdyRW7MP9/yU5X01sDoWR6OrTcd6Rii0nfOsrq8H+SmH/x66BA3oZ3Rdfo NRlF/vrR5585iR6WuiyjQCPGLwKDNDzjkooonHtx8Ft3p6T3V0EGs7nd0nG0a4EEM5Fc IL2HR2hD4kL3eeqwvZDnGpllmjlkq0Jeu/rv+GHVNJO9LQi3eIFRoXItoG63eeIZh32Q m7rg== X-Gm-Message-State: AOAM5313iD6zl3HaHJ8l3Is3DqJQd3ph91wi/3OZc/sNVhsfkQ6VC6kH tHu959D1gqFMyXYyumTGY1m1EzQySvAjfw== X-Google-Smtp-Source: ABdhPJxPjgxsRrSqb2VpOh0zt2sSQ89GFv8b8RYQ3vADiTY5rxADjdapfVDTLO/XlJY3su0wESyjgA== X-Received: by 2002:a19:7b1b:: with SMTP id w27mr39650840lfc.379.1638872334486; Tue, 07 Dec 2021 02:18:54 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v7 7/7] net/vmnet: update MAINTAINERS list Date: Tue, 7 Dec 2021 13:18:28 +0300 Message-Id: <20211207101828.22033-8-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211207101828.22033-1-yaroshchuk2000@gmail.com> References: <20211207101828.22033-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::12e (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::12e; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x12e.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: 1638872755072100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7543eb4d59..5c696e38da 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2631,6 +2631,11 @@ W: http://info.iet.unipi.it/~luigi/netmap/ S: Maintained F: net/netmap.c =20 +Apple vmnet network backends +M: Vladislav Yaroshchuk +S: Maintained +F: net/vmnet* + Host Memory Backends M: David Hildenbrand M: Igor Mammedov --=20 2.23.0