From nobody Mon Feb 9 13:51:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=jetbrains.com ARC-Seal: i=1; a=rsa-sha256; t=1647385773; cv=none; d=zohomail.com; s=zohoarc; b=KwYV3NJpd98Ciui0ee+YLynEPPtf4kQK5SqKzBw/aQ+W6DLhv2Q92IPTxgAdEU48mzUafcAfkFpJ81Ag87sBGUMu4tSs7OP1xFJW8VClqVTKqL1+atN+YirRt1CYr5cKVabJjn/fQE39WM5LR4UgHHJ5qLg83OIjHkuO6wyKVfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647385773; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+rzBrFYutKd2a438vQHGSPNl6k6Hk06gpOsLPeIfyaQ=; b=avBPbZr5h7Vc5K3r2Cwj4at2wH/rABC+IyabK6kvfwh0CG0rpXx8D320hV/XQcVLkZG6ZL36hp1w80t3LgdkQ0+pDyDwtod9V2DZ20mu5poDbLawEycOqh/pErBu3KMq8hS78Ov9iAU7krJ79aw2hlLR1Au6W8Pz2q9CoeJuYCQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647385773773687.5267953858228; Tue, 15 Mar 2022 16:09:33 -0700 (PDT) Received: from localhost ([::1]:60700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUGIG-0006AH-G2 for importer@patchew.org; Tue, 15 Mar 2022 19:09:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUGGk-0003Vd-IA for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:07:58 -0400 Received: from [2a00:1450:4864:20::432] (port=40538 helo=mail-wr1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUGGi-00058N-NI for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:07:58 -0400 Received: by mail-wr1-x432.google.com with SMTP id d7so605559wrb.7 for ; Tue, 15 Mar 2022 16:07:56 -0700 (PDT) Received: from localhost.localdomain (ec2-3-121-162-165.eu-central-1.compute.amazonaws.com. [3.121.162.165]) by smtp.gmail.com with ESMTPSA id i15-20020a5d584f000000b00203ded4f92esm221195wrf.18.2022.03.15.16.07.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Mar 2022 16:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetbrains.com; s=googleapps; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+rzBrFYutKd2a438vQHGSPNl6k6Hk06gpOsLPeIfyaQ=; b=Dt0bVKqJIuDquVhZP9IJt62i5NFrHy+yTykWYgDQCb5PlOz16wcb8lUEI7T8WpRc7s KmCMliEv2KDBMIsZlJK4SwSYymAL36QQcJSeaBgYhej5Htfe2sWdN2Lk4NTVICGaXBFo GuindzKSUEk701VyA10CKrIV/TDtymABIOJVg= 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=+rzBrFYutKd2a438vQHGSPNl6k6Hk06gpOsLPeIfyaQ=; b=LLmmDmsXt/KU1L9vh5rvLm+Ccp787bMtiYtZLthHljSm9/sH/j4UCivVTXuWGtZKwJ iFuFsRrFmqBuWdyqAkJKfTJIFrEQSoy7C/G9EfCtOgP0j2Fy/o5ij8m2q+WFuu+QhTzG tUmz/KcowUVeWssjpQf/Rp0F/lV97pkZQbuA686vh/JyzHzmH0USET7Eao+laM7YjC1F HSRuhWzXNpNSUejYFprqPMpm3VkWuxeKLpvkF+WkM7Ya5F0CSvV7R/ThVmgJW+7oQkij W2jDyRJU3T6lzI3u16hNRJcCQlUZd2efH2rEM3MoYaDPKVlETfKEFk6BlmVfI+Dae0/z mm2Q== X-Gm-Message-State: AOAM532cEkUWl3iSlNu2ZYsyA4eM7t1NqR4uJMeIR+3ml2ef33FyC8K3 fj/I8T7kEriwJrVMV2HidmC6OJGdeJiGaloZ X-Google-Smtp-Source: ABdhPJyGe17RnuNqHteiftrDHVYfooDy1hY+sDaFo30FdvQoMUJAUfnPQ58caGd34aUzGyA+C37hXg== X-Received: by 2002:a5d:5105:0:b0:1f1:d115:c9f with SMTP id s5-20020a5d5105000000b001f1d1150c9fmr22907741wrt.77.1647385675062; Tue, 15 Mar 2022 16:07:55 -0700 (PDT) From: Vladislav Yaroshchuk X-Google-Original-From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, r.bolshakov@yadro.com, eblake@redhat.com, phillip.ennen@gmail.com, phillip@axleos.com, akihiko.odaki@gmail.com, armbru@redhat.com, hsp.cat7@gmail.com, hello@adns.io, roman@roolebo.dev, peter.maydell@linaro.org, dirty@apple.com, f4bug@amsat.org, agraf@csgraf.de, kraxel@redhat.com, alex.bennee@linaro.org, qemu_oss@crudebyte.com, Vladislav Yaroshchuk Subject: [PATCH v20 1/7] net/vmnet: add vmnet dependency and customizable option Date: Wed, 16 Mar 2022 02:07:35 +0300 Message-Id: <20220315230741.21578-2-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::432 (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::432; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-wr1-x432.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @jetbrains.com) X-ZM-MESSAGEID: 1647385776176100001 Content-Type: text/plain; charset="utf-8" vmnet.framework dependency is added with 'vmnet' option to enable or disable it. Default value is 'auto'. used vmnet features are available since macOS 11.0, but new backend can be built and work properly with subset of them on 10.15 too. Signed-off-by: Vladislav Yaroshchuk --- meson.build | 16 +++++++++++++++- meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 2d6601467f..806f3869f9 100644 --- a/meson.build +++ b/meson.build @@ -522,6 +522,18 @@ 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')) +if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h', + 'VMNET_BRIDGED_MODE', + dependencies: vmnet) + vmnet =3D not_found + if get_option('vmnet').enabled() + error('vmnet.framework API is outdated') + else + warning('vmnet.framework API is outdated, disabling') + endif +endif + seccomp =3D not_found if not get_option('seccomp').auto() or have_system or have_tools seccomp =3D dependency('libseccomp', version: '>=3D2.3.0', @@ -1550,6 +1562,7 @@ config_host_data.set('CONFIG_SNAPPY', snappy.found()) config_host_data.set('CONFIG_TPM', have_tpm) 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()) @@ -3588,7 +3601,8 @@ summary(summary_info, bool_yn: true, section: 'Crypto= ') # Libraries summary_info =3D {} if targetos =3D=3D 'darwin' - summary_info +=3D {'Cocoa support': cocoa} + summary_info +=3D {'Cocoa support': cocoa} + summary_info +=3D {'vmnet.framework support': vmnet} endif summary_info +=3D {'SDL support': sdl} summary_info +=3D {'SDL image support': sdl_image} diff --git a/meson_options.txt b/meson_options.txt index 52b11cead4..d2c0b6b412 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -175,6 +175,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 9ee684ef03..30946f3798 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -116,6 +116,7 @@ meson_options_help() { printf "%s\n" ' usb-redir libusbredir support' printf "%s\n" ' vde vde network backend support' printf "%s\n" ' vdi vdi image format 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' --=20 2.34.1.vfs.0.0 From nobody Mon Feb 9 13:51:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=jetbrains.com ARC-Seal: i=1; a=rsa-sha256; t=1647385952; cv=none; d=zohomail.com; s=zohoarc; b=E8ao2K9oK2imOCTCSROjfH/Q3P61UZCkXY4Mjwifd8GsebFbdKAPVC/vAyNNDnRzRgHKLkZkiZbDllHD4d8ueIqDh3jTI2ic71OPQD058A3rnNi5RY/e0SeNmbTDsqMff8tL6/vlcOx6kslUm+jSRVYDlsULm6MG9YziCc2BPBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647385952; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3/E0pPaR7leSZDVDEy5esl4CO1QXA4/GmESPC4hXFmg=; b=XETQQ6iM5UXWVJggom25S7wbd6r21ZyI2q1FfFdOiPXzckJ4idhG7iv4OyuxJe58JX3WhSNi1qibdKcq8tmgWDctSneQdXBcqTn71K1lCcrstPVQUuyBnXrX9E27r8r4M/m1N3zdlJdgXXN1vktZxhmzdDcbaCbGSidBeTnifnM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647385952011280.9945212887128; Tue, 15 Mar 2022 16:12:32 -0700 (PDT) Received: from localhost ([::1]:40950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUGL8-0003oN-V2 for importer@patchew.org; Tue, 15 Mar 2022 19:12:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUGGn-0003bn-Am for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:01 -0400 Received: from [2a00:1450:4864:20::32a] (port=46594 helo=mail-wm1-x32a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUGGk-00058e-VV for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:01 -0400 Received: by mail-wm1-x32a.google.com with SMTP id p184-20020a1c29c1000000b0037f76d8b484so447897wmp.5 for ; Tue, 15 Mar 2022 16:07:58 -0700 (PDT) Received: from localhost.localdomain (ec2-3-121-162-165.eu-central-1.compute.amazonaws.com. [3.121.162.165]) by smtp.gmail.com with ESMTPSA id i15-20020a5d584f000000b00203ded4f92esm221195wrf.18.2022.03.15.16.07.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Mar 2022 16:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetbrains.com; s=googleapps; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3/E0pPaR7leSZDVDEy5esl4CO1QXA4/GmESPC4hXFmg=; b=aZh87Nm6q/z+55OjsohFW57SskrmqlqwboMWvPbip8Jhfyu41ev7cT9UwWoJzxdsnI I3/4B0UGNkabJZBmMHXsx2pUhhyw7PU+YIBBQ5bdhGUHqEwIqW9am3nCbDmaE3JWx9sX U+14yJmpz1W/BRkXmsjSacX3nTxfmk4/7Y4EQ= 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=3/E0pPaR7leSZDVDEy5esl4CO1QXA4/GmESPC4hXFmg=; b=5CXXQtMKrc3DvUzpedV3rNsovGiyeu585Z0zDRDSqEe26r3065PPaoDBJPLgHDGjin Pr9EDFvgOq3C98Q0qRA5M/Ams/niY45tltorV5Y9Yp+QvEeie/xaK+asKfEM0thyzqtN 4yyCZazI2EHt6GjDBs50LWEyfzh2NuPqqNeNueOgOrYkFwTnFVtiVQm+Ti3DMkDCqYpv Ar2/vSYwtygj+KIkG2iMEEcSLVQ1vJQf11xBbdShyJXjmmdQ8+sOtqNfrOqTAJxnvTEc f9YRn+QsE8oQWBC9kr2/BrLwZuI4d8M6hLmPTbv4BbvO7Is1+lxG2/GE5dtNtX8QvFhG xkSg== X-Gm-Message-State: AOAM531kReEb2H+mW/eVSbDKfhMO6WB5Oih59mWMHOKhEafwx7NfEo3W YBIpSBipxdCEknDZ8Tc0F4XhcpcJSRnDx5qn X-Google-Smtp-Source: ABdhPJxi6HbieyWB8jNPW8mCcIyzTzl1ymkETIm68wAV4lAItvCcRzoQ87v3ZsUFarTsq6bOpUgVKw== X-Received: by 2002:a05:600c:2056:b0:389:736a:5631 with SMTP id p22-20020a05600c205600b00389736a5631mr5210349wmg.120.1647385677007; Tue, 15 Mar 2022 16:07:57 -0700 (PDT) From: Vladislav Yaroshchuk X-Google-Original-From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, r.bolshakov@yadro.com, eblake@redhat.com, phillip.ennen@gmail.com, phillip@axleos.com, akihiko.odaki@gmail.com, armbru@redhat.com, hsp.cat7@gmail.com, hello@adns.io, roman@roolebo.dev, peter.maydell@linaro.org, dirty@apple.com, f4bug@amsat.org, agraf@csgraf.de, kraxel@redhat.com, alex.bennee@linaro.org, qemu_oss@crudebyte.com, Vladislav Yaroshchuk Subject: [PATCH v20 2/7] net/vmnet: add vmnet backends to qapi/net Date: Wed, 16 Mar 2022 02:07:36 +0300 Message-Id: <20220315230741.21578-3-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32a (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::32a; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-wm1-x32a.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @jetbrains.com) X-ZM-MESSAGEID: 1647385953045100002 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 | 133 +++++++++++++++++++++++++++++++++++++++++++- 9 files changed, 278 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..91c1a2f2c7 --- /dev/null +++ b/net/vmnet-bridged.m @@ -0,0 +1,25 @@ +/* + * vmnet-bridged.m + * + * Copyright(c) 2022 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..06326efb1c --- /dev/null +++ b/net/vmnet-common.m @@ -0,0 +1,20 @@ +/* + * vmnet-common.m - network client wrapper for Apple vmnet.framework + * + * Copyright(c) 2022 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..a461d507c5 --- /dev/null +++ b/net/vmnet-host.c @@ -0,0 +1,24 @@ +/* + * vmnet-host.c + * + * Copyright(c) 2022 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..6dfb133a18 --- /dev/null +++ b/net/vmnet-shared.c @@ -0,0 +1,25 @@ +/* + * vmnet-shared.c + * + * Copyright(c) 2022 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..c383038a1d --- /dev/null +++ b/net/vmnet_int.h @@ -0,0 +1,25 @@ +/* + * vmnet_int.h + * + * Copyright(c) 2022 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 VmnetState { + NetClientState nc; + +} VmnetState; + + +#endif /* VMNET_INT_H */ diff --git a/qapi/net.json b/qapi/net.json index 7fab2e7cd8..4bff1c4e37 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -452,6 +452,120 @@ '*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 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. Requires at least macOS Big Sur 11.0. +# +# @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. Requires +# at least macOS Big Sur 11.0. +# +# Since: 7.1 +## +{ '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 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. Requires at least macOS Big Sur 11.0. +# +# @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.1 +## +{ '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. Requires at least macOS Big Sur 11.0. +# +# Since: 7.1 +## +{ 'struct': 'NetdevVmnetBridgedOptions', + 'data': { + 'ifname': 'str', + '*isolated': 'bool' }, + 'if': 'CONFIG_VMNET' } + ## # @NetClientDriver: # @@ -460,10 +574,16 @@ # Since: 2.7 # # @vhost-vdpa since 5.1 +# @vmnet-host since 7.1 +# @vmnet-shared since 7.1 +# @vmnet-bridged since 7.1 ## { 'enum': 'NetClientDriver', 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', - 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa' ] } + 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa', + { 'name': 'vmnet-host', 'if': 'CONFIG_VMNET' }, + { 'name': 'vmnet-shared', 'if': 'CONFIG_VMNET' }, + { 'name': 'vmnet-bridged', 'if': 'CONFIG_VMNET' }] } =20 ## # @Netdev: @@ -477,6 +597,9 @@ # Since: 1.2 # # 'l2tpv3' - since 2.1 +# 'vmnet-host' - since 7.1 +# 'vmnet-shared' - since 7.1 +# 'vmnet-bridged' - since 7.1 ## { 'union': 'Netdev', 'base': { 'id': 'str', 'type': 'NetClientDriver' }, @@ -492,7 +615,13 @@ 'hubport': 'NetdevHubPortOptions', 'netmap': 'NetdevNetmapOptions', 'vhost-user': 'NetdevVhostUserOptions', - 'vhost-vdpa': 'NetdevVhostVDPAOptions' } } + 'vhost-vdpa': 'NetdevVhostVDPAOptions', + 'vmnet-host': { 'type': 'NetdevVmnetHostOptions', + 'if': 'CONFIG_VMNET' }, + 'vmnet-shared': { 'type': 'NetdevVmnetSharedOptions', + 'if': 'CONFIG_VMNET' }, + 'vmnet-bridged': { 'type': 'NetdevVmnetBridgedOptions', + 'if': 'CONFIG_VMNET' } } } =20 ## # @RxState: --=20 2.34.1.vfs.0.0 From nobody Mon Feb 9 13:51:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=jetbrains.com ARC-Seal: i=1; a=rsa-sha256; t=1647386031; cv=none; d=zohomail.com; s=zohoarc; b=ZdZPB8PYL0dxW+54fU4vyEIqu/qUF8x5XJ57vOHN/Tw4og+AtJuS10JnnPONIvoELtPwxhY50bFKZPl0k9OIzz7Ywc6GGiToL77HPOmnC1dNXEYVR2ydoLRUIv/ZvVT/08cYxuydqNrGsZyu0CvgWQgaGYYiwYec+G7noDkNIts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647386031; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ixr5uSDJ00PPxw4NqTeX5qcyZkZNGVBvOxgSrLRglTw=; b=lIRPeP5rvWXEdWsBU+m/lgR9wGkK+ygFaBa+oz1Ss+yibZJq8fR3iSFpkh8FnRnLrlbp6qkZroEt+9bnvG6Nnn5qL56d/F0z2Rrcs9Q8+tELXZD0dkKeZaNXNQnsfBaJaVPibCHZjzklH0DdTBzsxqqvGm1Xj4ak4K4crx+o2fs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647386031513448.5570798665268; Tue, 15 Mar 2022 16:13:51 -0700 (PDT) Received: from localhost ([::1]:45608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUGMR-0006t9-G1 for importer@patchew.org; Tue, 15 Mar 2022 19:13:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUGGp-0003io-QC for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:03 -0400 Received: from [2a00:1450:4864:20::433] (port=46648 helo=mail-wr1-x433.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUGGm-000597-Pj for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:03 -0400 Received: by mail-wr1-x433.google.com with SMTP id x15so572459wru.13 for ; Tue, 15 Mar 2022 16:08:00 -0700 (PDT) Received: from localhost.localdomain (ec2-3-121-162-165.eu-central-1.compute.amazonaws.com. [3.121.162.165]) by smtp.gmail.com with ESMTPSA id i15-20020a5d584f000000b00203ded4f92esm221195wrf.18.2022.03.15.16.07.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Mar 2022 16:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetbrains.com; s=googleapps; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ixr5uSDJ00PPxw4NqTeX5qcyZkZNGVBvOxgSrLRglTw=; b=ZEOvgjj1w1IVT5L9x8GXF/jXH2v20kllCWtLKwVnSlFZZGU0nX2WKpO0y2HXifW9hi 3DthbJya9M+ZLeuxM2hhyyM0M3okWU84BJiXvmpVoLjUSBoHPxaTimq70KstLw1NomDD z2JLwZbqhtYQCkTs87xBvYkqJ2QHknPsqttew= 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=ixr5uSDJ00PPxw4NqTeX5qcyZkZNGVBvOxgSrLRglTw=; b=dgZ8kuhMWaZlLgeXr6+LnFbfx9Om4EL8voE7Qru7B0Fv5A6yDDyM1+7g89qjrtJIIR 2FyZd8WpCHFT9e/YHFYy11YrGfJmwuqBUhZU9O9IZiblT4q6YzB96fC8F+tOenPT7JV/ qAf1Uju+B+ocQQMxC8fmiqiG7ZDt6cyB+GEesbIAfyDhhCHlRUj65or1iOV/el/M73oX owIOvayCvI5+9doJFciI2B354u9+OCXLsN+KcNTiDXY31eki7WfOcnOF53SJGKQJ7zj+ Sm1tCq2/2YOOR9BeXOO8u8Wz7SCsJaLLdyZoJDqhqXENAhdv+H7x1d4ZL6llLdczx1Eq HE+g== X-Gm-Message-State: AOAM53047YUQJ5PFs8aCMUixRj4UVPFtHpJPZ8jPqGbxRzLVKSHEqdVB ZZJSA1gpUxX/LGbBp/lVAKrSRoEFnDmnfFuM X-Google-Smtp-Source: ABdhPJz5mdxCMtUl/Z7NOV/E2YvHFI5ZQeg0ig5RtHEVwQVst6K+LEKeuhcwJk/ot5DkWOi/GPDq1Q== X-Received: by 2002:a5d:6d88:0:b0:203:9397:7a08 with SMTP id l8-20020a5d6d88000000b0020393977a08mr17777059wrs.575.1647385679059; Tue, 15 Mar 2022 16:07:59 -0700 (PDT) From: Vladislav Yaroshchuk X-Google-Original-From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, r.bolshakov@yadro.com, eblake@redhat.com, phillip.ennen@gmail.com, phillip@axleos.com, akihiko.odaki@gmail.com, armbru@redhat.com, hsp.cat7@gmail.com, hello@adns.io, roman@roolebo.dev, peter.maydell@linaro.org, dirty@apple.com, f4bug@amsat.org, agraf@csgraf.de, kraxel@redhat.com, alex.bennee@linaro.org, qemu_oss@crudebyte.com, Vladislav Yaroshchuk Subject: [PATCH v20 3/7] net/vmnet: implement shared mode (vmnet-shared) Date: Wed, 16 Mar 2022 02:07:37 +0300 Message-Id: <20220315230741.21578-4-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::433 (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::433; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-wr1-x433.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @jetbrains.com) X-ZM-MESSAGEID: 1647386033497100001 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. Signed-off-by: Phillip Tennen Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-common.m | 358 +++++++++++++++++++++++++++++++++++++++++++++ net/vmnet-shared.c | 90 +++++++++++- net/vmnet_int.h | 40 ++++- 3 files changed, 483 insertions(+), 5 deletions(-) diff --git a/net/vmnet-common.m b/net/vmnet-common.m index 06326efb1c..2cb60b9ddd 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,360 @@ #include "qapi/error.h" =20 #include +#include =20 + +static void vmnet_send_completed(NetClientState *nc, ssize_t len); + + +const char *vmnet_status_map_str(vmnet_return_t status) +{ + switch (status) { + case VMNET_SUCCESS: + return "success"; + case VMNET_FAILURE: + return "general failure (possibly not enough privileges)"; + 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"; +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_VERSION_11_0 + case VMNET_SHARING_SERVICE_BUSY: + return "conflict, sharing service is in use"; +#endif + default: + return "unknown vmnet error"; + } +} + + +/** + * Write packets from QEMU to vmnet interface. + * + * 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 performance having .receive() only. + */ +ssize_t vmnet_receive_common(NetClientState *nc, + const uint8_t *buf, + size_t size) +{ + VmnetState *s =3D DO_UPCAST(VmnetState, nc, nc); + struct vmpktdesc packet; + struct iovec iov; + int pkt_cnt; + vmnet_return_t if_status; + + if (size > s->max_packet_size) { + warn_report("vmnet: packet is too big, %zu > %" PRIu64, + 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)); + return -1; + } + + if (pkt_cnt) { + return size; + } + return 0; +} + + +/** + * Read packets from vmnet interface and write them + * to temporary buffers in VmnetState. + * + * Returns read packets number (may be 0) on success, + * -1 on error + */ +static int vmnet_read_packets(VmnetState *s) +{ + assert(s->packets_send_current_pos =3D=3D s->packets_send_end_pos); + + struct vmpktdesc *packets =3D s->packets_buf; + vmnet_return_t status; + int i; + + /* Read as many packets as present */ + s->packets_send_current_pos =3D 0; + s->packets_send_end_pos =3D VMNET_PACKETS_LIMIT; + for (i =3D 0; i < s->packets_send_end_pos; ++i) { + packets[i].vm_pkt_size =3D s->max_packet_size; + packets[i].vm_pkt_iovcnt =3D 1; + packets[i].vm_flags =3D 0; + } + + status =3D vmnet_read(s->vmnet_if, packets, &s->packets_send_end_pos); + if (status !=3D VMNET_SUCCESS) { + error_printf("vmnet: read failed: %s\n", + vmnet_status_map_str(status)); + s->packets_send_current_pos =3D 0; + s->packets_send_end_pos =3D 0; + return -1; + } + return s->packets_send_end_pos; +} + + +/** + * Write packets from temporary buffers in VmnetState + * to QEMU. + */ +static void vmnet_write_packets_to_qemu(VmnetState *s) +{ + while (s->packets_send_current_pos < s->packets_send_end_pos) { + ssize_t size =3D qemu_send_packet_async(&s->nc, + s->iov_buf[s->packets_send_current_p= os].iov_base, + s->packets_buf[s->packets_send_curre= nt_pos].vm_pkt_size, + vmnet_send_completed); + + if (size =3D=3D 0) { + /* QEMU is not ready to consume more packets - + * stop and wait for completion callback call */ + return; + } + ++s->packets_send_current_pos; + } +} + + +/** + * Bottom half callback that transfers packets from vmnet interface + * to QEMU. + * + * The process of transferring packets is three-staged: + * 1. Handle vmnet event; + * 2. Read packets from vmnet interface into temporary buffer; + * 3. Write packets from temporary buffer to QEMU. + * + * QEMU may suspend this process on the last stage, returning 0 from + * qemu_send_packet_async function. If this happens, we should + * respectfully wait until it is ready to consume more packets, + * write left ones in temporary buffer and only after this + * continue reading more packets from vmnet interface. + * + * Packets to be transferred are stored into packets_buf, + * in the window [packets_send_current_pos..packets_send_end_pos) + * including current_pos, excluding end_pos. + * + * Thus, if QEMU is not ready, buffer is not read and + * packets_send_current_pos < packets_send_end_pos. + */ +static void vmnet_send_bh(void *opaque) +{ + NetClientState *nc =3D (NetClientState *) opaque; + VmnetState *s =3D DO_UPCAST(VmnetState, nc, nc); + + /* + * Do nothing if QEMU is not ready - wait + * for completion callback invocation + */ + if (s->packets_send_current_pos < s->packets_send_end_pos) { + return; + } + + /* Read packets from vmnet interface */ + if (vmnet_read_packets(s) > 0) { + /* Send them to QEMU */ + vmnet_write_packets_to_qemu(s); + } +} + + +/** + * Completion callback to be invoked by QEMU when it becomes + * ready to consume more packets. + */ +static void vmnet_send_completed(NetClientState *nc, ssize_t len) +{ + VmnetState *s =3D DO_UPCAST(VmnetState, nc, nc); + + /* Callback is invoked eq queued packet is sent */ + ++s->packets_send_current_pos; + + /* Complete sending packets left in VmnetState buffers */ + vmnet_write_packets_to_qemu(s); + + /* And read new ones from vmnet if VmnetState buffer is ready */ + if (s->packets_send_current_pos < s->packets_send_end_pos) { + qemu_bh_schedule(s->send_bh); + } +} + + +static void vmnet_bufs_init(VmnetState *s) +{ + struct vmpktdesc *packets =3D s->packets_buf; + struct iovec *iov =3D s->iov_buf; + int i; + + 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; + } +} + + +int vmnet_if_create(NetClientState *nc, + xpc_object_t if_desc, + Error **errp) +{ + VmnetState *s =3D DO_UPCAST(VmnetState, nc, nc); + dispatch_semaphore_t if_created_sem =3D dispatch_semaphore_create(0); + __block vmnet_return_t if_status; + + s->if_queue =3D dispatch_queue_create( + "org.qemu.vmnet.if_queue", + DISPATCH_QUEUE_SERIAL + ); + + xpc_dictionary_set_bool( + if_desc, + vmnet_allocate_mac_address_key, + false + ); + +#ifdef DEBUG + qemu_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); + qemu_log(" %s=3D%s\n", k, desc); + free(desc); + return true; + }); +#endif /* DEBUG */ + + s->vmnet_if =3D vmnet_start_interface( + if_desc, + s->if_queue, + ^(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; + } + +#ifdef DEBUG + qemu_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= ); + qemu_log(" %s=3D%s\n", k, desc); + free(desc); + return true; + }); +#endif /* DEBUG */ + + 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); + + dispatch_semaphore_signal(if_created_sem); + }); + + if (s->vmnet_if =3D=3D NULL) { + dispatch_release(s->if_queue); + dispatch_release(if_created_sem); + error_setg(errp, + "unable to create interface with requested params"); + return -1; + } + + dispatch_semaphore_wait(if_created_sem, DISPATCH_TIME_FOREVER); + dispatch_release(if_created_sem); + + if (if_status !=3D VMNET_SUCCESS) { + dispatch_release(s->if_queue); + error_setg(errp, + "cannot create vmnet interface: %s", + vmnet_status_map_str(if_status)); + return -1; + } + + s->send_bh =3D aio_bh_new(qemu_get_aio_context(), vmnet_send_bh, nc); + vmnet_bufs_init(s); + + s->packets_send_current_pos =3D 0; + s->packets_send_end_pos =3D 0; + + vmnet_interface_set_event_callback( + s->vmnet_if, + VMNET_INTERFACE_PACKETS_AVAILABLE, + s->if_queue, + ^(interface_event_t event_id, xpc_object_t event) { + assert(event_id =3D=3D VMNET_INTERFACE_PACKETS_AVAILABLE); + /* + * This function is being called from a non qemu thread, so + * we only schedule a BH, and do the rest of the io completion + * handling from vmnet_send_bh() which runs in a qemu context. + */ + qemu_bh_schedule(s->send_bh); + }); + + return 0; +} + + +void vmnet_cleanup_common(NetClientState *nc) +{ + VmnetState *s =3D DO_UPCAST(VmnetState, nc, nc); + dispatch_semaphore_t if_stopped_sem; + + if (s->vmnet_if =3D=3D NULL) { + return; + } + + if_stopped_sem =3D dispatch_semaphore_create(0); + vmnet_stop_interface( + s->vmnet_if, + s->if_queue, + ^(vmnet_return_t status) { + assert(status =3D=3D VMNET_SUCCESS); + dispatch_semaphore_signal(if_stopped_sem); + }); + dispatch_semaphore_wait(if_stopped_sem, DISPATCH_TIME_FOREVER); + + qemu_purge_queued_packets(nc); + + qemu_bh_delete(s->send_bh); + dispatch_release(if_stopped_sem); + dispatch_release(s->if_queue); + + 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 6dfb133a18..2ce2323bdb 100644 --- a/net/vmnet-shared.c +++ b/net/vmnet-shared.c @@ -10,16 +10,98 @@ =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 + +static bool validate_options(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetSharedOptions *options =3D &(netdev->u.vmnet_shared); + +#if !defined(MAC_OS_VERSION_11_0) || \ + MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0 + if (options->has_isolated) { + error_setg(errp, + "vmnet-shared.isolated feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } +#endif + + if ((options->has_start_address || + options->has_end_address || + options->has_subnet_mask) && + !(options->has_start_address && + options->has_end_address && + options->has_subnet_mask)) { + error_setg(errp, + "'start-address', 'end-address', 'subnet-mask' " + "should be provided together" + ); + return false; + } + + return true; +} + +static xpc_object_t build_if_desc(const Netdev *netdev) +{ + 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 + ); + + if (options->has_nat66_prefix) { + xpc_dictionary_set_string(if_desc, + vmnet_nat66_prefix_key, + options->nat66_prefix); + } + + if (options->has_start_address) { + 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); + } + +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_VERSION_11_0 + xpc_dictionary_set_bool( + if_desc, + vmnet_enable_isolation_key, + options->isolated + ); +#endif + + return if_desc; +} + +static NetClientInfo net_vmnet_shared_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_SHARED, + .size =3D sizeof(VmnetState), + .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); + if (!validate_options(netdev, errp)) { + return -1; + } + return vmnet_if_create(nc, build_if_desc(netdev), errp); } diff --git a/net/vmnet_int.h b/net/vmnet_int.h index c383038a1d..adf6e8c20d 100644 --- a/net/vmnet_int.h +++ b/net/vmnet_int.h @@ -15,11 +15,49 @@ #include "clients.h" =20 #include +#include + +/** + * From vmnet.framework documentation + * + * Each read/write call allows up to 200 packets to be + * read or written for a maximum of 256KB. + * + * Each packet written should be a complete + * ethernet frame. + * + * https://developer.apple.com/documentation/vmnet + */ +#define VMNET_PACKETS_LIMIT 200 =20 typedef struct VmnetState { - NetClientState nc; + NetClientState nc; + interface_ref vmnet_if; + + uint64_t mtu; + uint64_t max_packet_size; =20 + dispatch_queue_t if_queue; + + QEMUBH *send_bh; + + struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT]; + int packets_send_current_pos; + int packets_send_end_pos; + + struct iovec iov_buf[VMNET_PACKETS_LIMIT]; } VmnetState; =20 +const char *vmnet_status_map_str(vmnet_return_t status); + +int vmnet_if_create(NetClientState *nc, + xpc_object_t if_desc, + Error **errp); + +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.34.1.vfs.0.0 From nobody Mon Feb 9 13:51:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=jetbrains.com ARC-Seal: i=1; a=rsa-sha256; t=1647385779; cv=none; d=zohomail.com; s=zohoarc; b=RGS7CBzldjLh8FFaJH9ctNy9S/5z8Qw0JBF4THZZsWrHzPTIlfeAMJBfwshbkA76WSk5xXHhrFfdwFDi0FlXARgm9zdC40lGNgvx1xonoKx61fLnycyvKAVD4SuuM3StHNLamOFLSnK6Ik7pEkSlpED0b2x3KS6E3C74ZOyJd4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647385779; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=szCPv1NoGNHohxBCjPkor32mkqdTjZtEVZo9Krv7Wa8=; b=NwAAC3jiFBOid2oRENG2nlF3mLwWbXRpPwfMDoL/HgKFsgusEWNB6JVrhDYqym0FOQVVyiWQH8bYZB8v1hOijZ7EfCyZm+8+aFYwoNy+ytdMyeWV23Fwlb27772/cWfFr9fxExmthdD/VxAWO6CdC1ONR/AsSMPIxLE01IyvqYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647385779640496.6047528993081; Tue, 15 Mar 2022 16:09:39 -0700 (PDT) Received: from localhost ([::1]:33000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUGIM-0006WU-J8 for importer@patchew.org; Tue, 15 Mar 2022 19:09:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUGGq-0003lF-CS for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:04 -0400 Received: from [2a00:1450:4864:20::42e] (port=45635 helo=mail-wr1-x42e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUGGo-00059k-JR for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:04 -0400 Received: by mail-wr1-x42e.google.com with SMTP id p9so575796wra.12 for ; Tue, 15 Mar 2022 16:08:02 -0700 (PDT) Received: from localhost.localdomain (ec2-3-121-162-165.eu-central-1.compute.amazonaws.com. [3.121.162.165]) by smtp.gmail.com with ESMTPSA id i15-20020a5d584f000000b00203ded4f92esm221195wrf.18.2022.03.15.16.07.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Mar 2022 16:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetbrains.com; s=googleapps; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=szCPv1NoGNHohxBCjPkor32mkqdTjZtEVZo9Krv7Wa8=; b=Sfb9P5sffxo2B0ph6eQUaNfuY0DGWIctYheO22+q6VCg+NEx37FwpyN2xb2wD1D3Ij Mga0g22bd1xb1t5+pDd9bx8GD2lLa6QX8alMOmgbFUlE6/HiPF5laGLJcL/wUX68jmhx YDsADM/wLXSQMyfa3gwFHmywmg4wnZoDZDAUA= 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=szCPv1NoGNHohxBCjPkor32mkqdTjZtEVZo9Krv7Wa8=; b=ph6QkwL2xlgKRSaDGWD/7taTCkF6D1c/+nFwKTsVmcy7Lq16Pjji04pPP+EKAyM8iR 4Vq5v66Cdt+n9wtPGHnMecxJtE0ayW9jZouM8RqE2RliiMAQVAPUm3jQwHRZLIruEcyN 3THV9fUVbzd5WTL5CJvkavJiWvkYe8L4cd5lE8gcN6ApKWAEtjmjOlF6zdOEL+YkTFqD Gfe0pi59Cvmcl1nZh+ZcqY3yZiuix0bky8VxKzcZkTy+AAioeHaUySNbeB7+lSzJMFdb jlbF0y1j+mLp7xXjc2dLW6P3E9seEJHUZjUUGPtoDScx162ZRBu8QY+z9DEg33tLFHup oE6Q== X-Gm-Message-State: AOAM531jeL8tttxhHfHJJAbX1xXY9b+LSgraZEK8aFSeihiKfgRfyv38 EiwnxlH7Us251uyUp52jCSlCCbvIW4MJmcjl X-Google-Smtp-Source: ABdhPJzEZIowCzV53Z7K113KpxoD2hqxNeQLVjM2TMcIRFxxUpOwf/Y5Xsp9tRmeDQm/aj8aNyklcQ== X-Received: by 2002:adf:c5ca:0:b0:1f0:aa2:494b with SMTP id v10-20020adfc5ca000000b001f00aa2494bmr22484469wrg.275.1647385681030; Tue, 15 Mar 2022 16:08:01 -0700 (PDT) From: Vladislav Yaroshchuk X-Google-Original-From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, r.bolshakov@yadro.com, eblake@redhat.com, phillip.ennen@gmail.com, phillip@axleos.com, akihiko.odaki@gmail.com, armbru@redhat.com, hsp.cat7@gmail.com, hello@adns.io, roman@roolebo.dev, peter.maydell@linaro.org, dirty@apple.com, f4bug@amsat.org, agraf@csgraf.de, kraxel@redhat.com, alex.bennee@linaro.org, qemu_oss@crudebyte.com, Vladislav Yaroshchuk Subject: [PATCH v20 4/7] net/vmnet: implement host mode (vmnet-host) Date: Wed, 16 Mar 2022 02:07:38 +0300 Message-Id: <20220315230741.21578-5-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42e (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::42e; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @jetbrains.com) X-ZM-MESSAGEID: 1647385782061100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-host.c | 109 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 103 insertions(+), 6 deletions(-) diff --git a/net/vmnet-host.c b/net/vmnet-host.c index a461d507c5..e6d01fd65e 100644 --- a/net/vmnet-host.c +++ b/net/vmnet-host.c @@ -9,16 +9,113 @@ */ =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 + +static bool validate_options(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetHostOptions *options =3D &(netdev->u.vmnet_host); + +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_VERSION_11_0 + + QemuUUID net_uuid; + if (options->has_net_uuid && + qemu_uuid_parse(options->net_uuid, &net_uuid) < 0) { + error_setg(errp, "Invalid UUID provided in 'net-uuid'"); + return false; + } +#else + if (options->has_isolated) { + error_setg(errp, + "vmnet-host.isolated feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } + + if (options->has_net_uuid) { + error_setg(errp, + "vmnet-host.net-uuid feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } +#endif + + if ((options->has_start_address || + options->has_end_address || + options->has_subnet_mask) && + !(options->has_start_address && + options->has_end_address && + options->has_subnet_mask)) { + error_setg(errp, + "'start-address', 'end-address', 'subnet-mask' " + "should be provided together"); + return false; + } + + return true; +} + +static xpc_object_t build_if_desc(const Netdev *netdev) +{ + const NetdevVmnetHostOptions *options =3D &(netdev->u.vmnet_host); + 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); + +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_VERSION_11_0 + + xpc_dictionary_set_bool(if_desc, + vmnet_enable_isolation_key, + options->isolated); + + QemuUUID net_uuid; + if (options->has_net_uuid) { + qemu_uuid_parse(options->net_uuid, &net_uuid); + xpc_dictionary_set_uuid(if_desc, + vmnet_network_identifier_key, + net_uuid.data); + } +#endif + + if (options->has_start_address) { + 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); + } + + return if_desc; +} + +static NetClientInfo net_vmnet_host_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_HOST, + .size =3D sizeof(VmnetState), + .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 =3D qemu_new_net_client(&net_vmnet_host_info, + peer, "vmnet-host", name); + if (!validate_options(netdev, errp)) { + return -1; + } + return vmnet_if_create(nc, build_if_desc(netdev), errp); } --=20 2.34.1.vfs.0.0 From nobody Mon Feb 9 13:51:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=jetbrains.com ARC-Seal: i=1; a=rsa-sha256; t=1647386130; cv=none; d=zohomail.com; s=zohoarc; b=L4hB9GDDO3BcW07oSpHDnSzD1K1M91/Ws0H1hee8GtGLQCo9Tj+oiffu/tQwIpS1j7PS8BeAD8x2tp3vXyqJVlDXe+caXaYRA4aE/63DvDJ70gy4gBUgfSYpaXKpnerJEbtehbkry/3E5opLMFdMGTsHSv+7netTPjNuWejNlfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647386130; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PZtF1MQAa4iCSXLHpWS5V+NoLnI3TjzjClkDvwrw+iU=; b=Q1cq16zG+tbE64cGOsgA7xtiahmj9GX5q49UBzz0t1M8MjPv0b++sPk3J642+NODtGu2BXN/iSscKVFb1XPQB4xxNRalmF3RwnflP2aNu+rFX3POi0IoQvWcNrrAlAZTWZJ5iSd1tPf+wHtqYu0nJccMKrAaq7D8Cvpz1LD5N7o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647386130313376.1619445256881; Tue, 15 Mar 2022 16:15:30 -0700 (PDT) Received: from localhost ([::1]:49066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUGO1-0000m7-23 for importer@patchew.org; Tue, 15 Mar 2022 19:15:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUGGs-0003sd-B4 for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:06 -0400 Received: from [2a00:1450:4864:20::430] (port=46646 helo=mail-wr1-x430.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUGGq-0005AA-JN for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:06 -0400 Received: by mail-wr1-x430.google.com with SMTP id x15so572589wru.13 for ; Tue, 15 Mar 2022 16:08:04 -0700 (PDT) Received: from localhost.localdomain (ec2-3-121-162-165.eu-central-1.compute.amazonaws.com. [3.121.162.165]) by smtp.gmail.com with ESMTPSA id i15-20020a5d584f000000b00203ded4f92esm221195wrf.18.2022.03.15.16.08.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Mar 2022 16:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetbrains.com; s=googleapps; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PZtF1MQAa4iCSXLHpWS5V+NoLnI3TjzjClkDvwrw+iU=; b=gH/xGLGkFkbtxl13fhwkv3K3CCloWNKwAOwQyalkkclahnI0sUtsLKcqcwa8ZboeZ3 6SC/yKK3Hmfur9D/WcD25mpYoVP5irFZcOHjAAeFWkEmh1uSEvXINJhjfYxpvDmlqNa3 R7QFshWDLVWQwdbGnSib5zuLFm4Vs6KoimkN4= 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=PZtF1MQAa4iCSXLHpWS5V+NoLnI3TjzjClkDvwrw+iU=; b=w9xvavlGxNhuABLIoSb7LPH6PC2f816Gbq0DAMmYZ5UMDCLcVZeY2ARuh9F2P9NzRb qEJpcWWSV1TwZfcXavsKFVzmmf9+wpUcQOWPO0UKVy6uADxplvEdsiQfz6AZcgaXAVgC yiqN+fuHb0l/19tn+uafFwlGi/q8gLwycxgGgf4rasyAyrMS7XKc8mEDNELslqb3mpi9 HMSqupQnWPTEmCedqUwWQb7bxtggDGW+vWOtskXNzhcYbLx3XEEBTtD0nS/TE1s2S1wP zKZS0/bvL7g1EinQUjyMBR5JKYlz0HFI/eRbKAs4aiq0tkNUMZaHFZ+juNWdIcgXc/LJ FesQ== X-Gm-Message-State: AOAM530aHRd3qoVoBJJvcMupY51VMHB1tZ5WAKVj1M2/5H4TgDAt6qNB MIKjAENqGKcUTyjNM5+qS4U4m2PA38wDRCOr X-Google-Smtp-Source: ABdhPJzmY5ganksd/axas5nHJOt5NHWUsxei47vogy44LNHlgREnPWNkGD/PymELdy5cG0+9ZAOBhA== X-Received: by 2002:adf:cd87:0:b0:203:71f9:c333 with SMTP id q7-20020adfcd87000000b0020371f9c333mr22015891wrj.637.1647385683040; Tue, 15 Mar 2022 16:08:03 -0700 (PDT) From: Vladislav Yaroshchuk X-Google-Original-From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, r.bolshakov@yadro.com, eblake@redhat.com, phillip.ennen@gmail.com, phillip@axleos.com, akihiko.odaki@gmail.com, armbru@redhat.com, hsp.cat7@gmail.com, hello@adns.io, roman@roolebo.dev, peter.maydell@linaro.org, dirty@apple.com, f4bug@amsat.org, agraf@csgraf.de, kraxel@redhat.com, alex.bennee@linaro.org, qemu_oss@crudebyte.com, Vladislav Yaroshchuk Subject: [PATCH v20 5/7] net/vmnet: implement bridged mode (vmnet-bridged) Date: Wed, 16 Mar 2022 02:07:39 +0300 Message-Id: <20220315230741.21578-6-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::430 (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::430; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @jetbrains.com) X-ZM-MESSAGEID: 1647386132241100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-bridged.m | 128 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 5 deletions(-) diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m index 91c1a2f2c7..5936c87718 100644 --- a/net/vmnet-bridged.m +++ b/net/vmnet-bridged.m @@ -10,16 +10,134 @@ =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 + +static bool validate_ifname(const char *ifname) +{ + xpc_object_t shared_if_list =3D vmnet_copy_shared_interface_list(); + bool match =3D false; + if (!xpc_array_get_count(shared_if_list)) { + goto done; + } + + match =3D !xpc_array_apply( + shared_if_list, + ^bool(size_t index, xpc_object_t value) { + return strcmp(xpc_string_get_string_ptr(value), ifname) !=3D 0; + }); + +done: + xpc_release(shared_if_list); + return match; +} + + +static bool get_valid_ifnames(char *output_buf) +{ + xpc_object_t shared_if_list =3D vmnet_copy_shared_interface_list(); + __block const char *ifname =3D NULL; + __block int str_offset =3D 0; + bool interfaces_available =3D true; + + if (!xpc_array_get_count(shared_if_list)) { + interfaces_available =3D false; + goto done; + } + + xpc_array_apply( + shared_if_list, + ^bool(size_t index, xpc_object_t value) { + /* build list of strings like "en0 en1 en2 " */ + ifname =3D xpc_string_get_string_ptr(value); + strcpy(output_buf + str_offset, ifname); + strcpy(output_buf + str_offset + strlen(ifname), " "); + str_offset +=3D strlen(ifname) + 1; + return true; + }); + +done: + xpc_release(shared_if_list); + return interfaces_available; +} + + +static bool validate_options(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetBridgedOptions *options =3D &(netdev->u.vmnet_bridged= ); + char ifnames[1024]; + + if (!validate_ifname(options->ifname)) { + if (get_valid_ifnames(ifnames)) { + error_setg(errp, + "unsupported ifname '%s', expected one of [ %s]", + options->ifname, + ifnames); + return false; + } + error_setg(errp, + "unsupported ifname '%s', no supported " + "interfaces available", + options->ifname); + return false; + } + +#if !defined(MAC_OS_VERSION_11_0) || \ + MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0 + if (options->has_isolated) { + error_setg(errp, + "vmnet-bridged.isolated feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } +#endif + return true; +} + + +static xpc_object_t build_if_desc(const Netdev *netdev) +{ + 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_string(if_desc, + vmnet_shared_interface_name_key, + options->ifname); + +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_VERSION_11_0 + xpc_dictionary_set_bool(if_desc, + vmnet_enable_isolation_key, + options->isolated); +#endif + return if_desc; +} + + +static NetClientInfo net_vmnet_bridged_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_BRIDGED, + .size =3D sizeof(VmnetState), + .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); + if (!validate_options(netdev, errp)) { + return -1; + } + return vmnet_if_create(nc, build_if_desc(netdev), errp); } --=20 2.34.1.vfs.0.0 From nobody Mon Feb 9 13:51:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=jetbrains.com ARC-Seal: i=1; a=rsa-sha256; t=1647385892; cv=none; d=zohomail.com; s=zohoarc; b=Qvm8u9P31wYMe/rmTUVB6O8etDxEzX+TziDJvQ79MzQ90Lw+vaDJUfXb/PBHn0VTn7UNZq+VOIpHp9FeVjlG/ISv3jsBbwKhsxrhZeHh/uffwGm/8Nce5ZrDK3mV/yU01Nljuc1It4c+1SB83YXwDhLbwvu+gc29C/edUEldDHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647385892; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TocqvUgt8oYqDt7ijO5+PrJ/oIA8D+p+ZMbp4ehOtYs=; b=mMYQAvlcV9eliSyEuPyEBhX+yYC6aYhD6J/VF+gntkBNyFxfxhIRvnYhExdMf5wZAmBxTYotXFosOnP4VPkuddIhoxSnqmAt+UKoRDH7t8Ge9G7QWRJfMlBFjlExNlQb+4c3F2Lcrc4Vmdt9+PkwDY1r3DJonn0fYiqL2CR3l0o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647385892750294.50886909442534; Tue, 15 Mar 2022 16:11:32 -0700 (PDT) Received: from localhost ([::1]:37854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUGKB-0001aH-HY for importer@patchew.org; Tue, 15 Mar 2022 19:11:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUGGu-0003zj-5W for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:08 -0400 Received: from [2a00:1450:4864:20::431] (port=37712 helo=mail-wr1-x431.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUGGs-0005AV-IJ for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:07 -0400 Received: by mail-wr1-x431.google.com with SMTP id x13so624947wrg.4 for ; Tue, 15 Mar 2022 16:08:06 -0700 (PDT) Received: from localhost.localdomain (ec2-3-121-162-165.eu-central-1.compute.amazonaws.com. [3.121.162.165]) by smtp.gmail.com with ESMTPSA id i15-20020a5d584f000000b00203ded4f92esm221195wrf.18.2022.03.15.16.08.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Mar 2022 16:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetbrains.com; s=googleapps; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TocqvUgt8oYqDt7ijO5+PrJ/oIA8D+p+ZMbp4ehOtYs=; b=f717xkPcceJTcPJEgFLhLFFMHsb4D3jAkYdSsQbzQmH5MBYaAf0UoYiNQ8MM1YODOg nO4jhx7inUSRj5PWw7KZOgM1sgcODkPh7ZT6Ms4WoHl+mG5iX4a3KyohGE8stdNE8yv9 KQo3bsg+H2AJPgKxAPhQiNxhtouvykKyBg7Is= 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=TocqvUgt8oYqDt7ijO5+PrJ/oIA8D+p+ZMbp4ehOtYs=; b=BhZW4X5SVIi+3nTRsudec7x80p9iseJQB4rcmP3lcnbBL6YLFHtrMNjPDCVBz9USbM txL/XFoP4L0OPK5NI4ff5bf9UF/lbbIpouKEM3NzbCrGf+1YCsaaXMBfMDGP/JEUuYbk 6E6qVpVkLIM8KLC4Nv8Cp3jtShMZ+G0H/iYzcd5E3/YLME3OHgDvi2gKexMG7f7IiknA 3Rmjst4ZQbPZQzXOLWcXbmRWspq6cz7PB+Xex/vBagI/+qVv7bWEu78/Htmfh6khUyw5 2ibly+DCWAnk+jIHtD/QrnPRRhiKRvu2Rcvxlu7/5aEUPlWRgpLTBPr3mSu/dcc2QO2J SFvg== X-Gm-Message-State: AOAM533JFKZTQgoR1Zi16ooSZxYzcbnyir38ee1lHMbmhO/d8misCFBH ZcMB6Jyx00Qj/Z4+DtztxJLjOk8Si7ZAipuz X-Google-Smtp-Source: ABdhPJwzg/4bpdbpWAzV9jW+qpX+nD29aifC8wIDlg50jVdvSj+2mb9xXmf11qarE8MYl8YlNb7AYA== X-Received: by 2002:a5d:4391:0:b0:203:64c9:7e84 with SMTP id i17-20020a5d4391000000b0020364c97e84mr22431309wrq.267.1647385685046; Tue, 15 Mar 2022 16:08:05 -0700 (PDT) From: Vladislav Yaroshchuk X-Google-Original-From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, r.bolshakov@yadro.com, eblake@redhat.com, phillip.ennen@gmail.com, phillip@axleos.com, akihiko.odaki@gmail.com, armbru@redhat.com, hsp.cat7@gmail.com, hello@adns.io, roman@roolebo.dev, peter.maydell@linaro.org, dirty@apple.com, f4bug@amsat.org, agraf@csgraf.de, kraxel@redhat.com, alex.bennee@linaro.org, qemu_oss@crudebyte.com, Vladislav Yaroshchuk Subject: [PATCH v20 6/7] net/vmnet: update qemu-options.hx Date: Wed, 16 Mar 2022 02:07:40 +0300 Message-Id: <20220315230741.21578-7-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::431 (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::431; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @jetbrains.com) X-ZM-MESSAGEID: 1647385894564100001 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 5ce0ada75e..ea00d0eeb6 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2743,6 +2743,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) @@ -2762,6 +2781,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" @@ -2784,6 +2806,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.34.1.vfs.0.0 From nobody Mon Feb 9 13:51:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=jetbrains.com ARC-Seal: i=1; a=rsa-sha256; t=1647385951; cv=none; d=zohomail.com; s=zohoarc; b=KN+ocD0DGxZPAwzWIa7ScUEIxfqvpP98VKHUCxJdibMe0Q5kqhkx31Px0OaaFtvEnCSVXqFx/noGoLztsi0PcHQjagssWwbL1XTOS+0zVK1lQDicl1lQ+N5Z1YTPRTRkwuUvqA8Vnlg6b8TfUNRp5Kzzj8A5eemCA/8DoBocQR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647385951; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v0RH9VmCWPcsPrNitBQ5880IrTspVYz6x+t+QgkXXVo=; b=g6YNQ4SjltuTWToCiNmcvhGNtDclGpe9H209zFylP0n3gdDpr4Od0FH6Uq/PSxnVfa9gghlOoF6tkSx8pvRA0Ui7B3k+AT22liYO5y1c+Xbj5Fkdq/hI+fgEufl/4pvV0Ukrk/YSH7KxcK2sTa2vEk5PuJ5mXN7J4CqGdjMmPZQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1647385951396571.9681372746466; Tue, 15 Mar 2022 16:12:31 -0700 (PDT) Received: from localhost ([::1]:40876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUGL8-0003m1-4p for importer@patchew.org; Tue, 15 Mar 2022 19:12:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUGGw-000471-AU for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:10 -0400 Received: from [2a00:1450:4864:20::32f] (port=42880 helo=mail-wm1-x32f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUGGu-0005An-Sk for qemu-devel@nongnu.org; Tue, 15 Mar 2022 19:08:10 -0400 Received: by mail-wm1-x32f.google.com with SMTP id r190-20020a1c2bc7000000b0038a1013241dso468229wmr.1 for ; Tue, 15 Mar 2022 16:08:08 -0700 (PDT) Received: from localhost.localdomain (ec2-3-121-162-165.eu-central-1.compute.amazonaws.com. [3.121.162.165]) by smtp.gmail.com with ESMTPSA id i15-20020a5d584f000000b00203ded4f92esm221195wrf.18.2022.03.15.16.08.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Mar 2022 16:08:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetbrains.com; s=googleapps; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v0RH9VmCWPcsPrNitBQ5880IrTspVYz6x+t+QgkXXVo=; b=em+TXJHfI6oM1QGVO+hqJFzDNT1lVDSz6l+s674OEE95a9Ik+0RK5znSRLZ1E15XhD CeHlGoJU22ZSnM2UpxXijRApVXN85pcjjvGjJsyFY5KOSAFQ5l198wGsSI29RN3oxl1m ldNMrn/HEiUvFG1vspTNkPdfKko8cQQ3S7+Lw= 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=v0RH9VmCWPcsPrNitBQ5880IrTspVYz6x+t+QgkXXVo=; b=1Vd+6+jQdYWPSPWA2IjzPsTCVRzdYRLriIzD7hHanHbwHlFCiGH+qvZMEAHNSOuBN1 p7v+ACVcaUl755P2F2cEO+ZAyTcgUGRgqM3noS5D7zjeyrOxu5N2D9v1meak95b66MZR hAaTntf2RXlx2C47H8V3cmBEAgGbaiwiBqBT6LKMP/usSDYJwUiFjWyZtnopGGvNmRVj eg221k2cHgB7K6bcqCcejmCkCBHXkCJ2URfZ3d8zka/DA6/dK7fq7xdpFxu4vgcIgDk9 CfWzBhO+XOYje1tM5QGsJbL9OwpVuK6YsxFsL7Bail62eu5Q9RqJSkhOY9+Wh6lNYduu rJKA== X-Gm-Message-State: AOAM5302+zrT8t+T1QQl51m9UHSDsQ1Vk6PNE5Ylo5l9szGsrPwRyDmD VdViBhu6yE1pWD5y/FINcFcEV7GDqO4wdyzj X-Google-Smtp-Source: ABdhPJxjwsjqTiiQl1UcHuOJGmMoOyYM9zfrdWRWAjwD4gGqo4M7PAGiuTdXqEuwI53TUR5hcm8/fw== X-Received: by 2002:a05:600c:1c09:b0:389:d0a8:d3b7 with SMTP id j9-20020a05600c1c0900b00389d0a8d3b7mr5055357wms.92.1647385687323; Tue, 15 Mar 2022 16:08:07 -0700 (PDT) From: Vladislav Yaroshchuk X-Google-Original-From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, r.bolshakov@yadro.com, eblake@redhat.com, phillip.ennen@gmail.com, phillip@axleos.com, akihiko.odaki@gmail.com, armbru@redhat.com, hsp.cat7@gmail.com, hello@adns.io, roman@roolebo.dev, peter.maydell@linaro.org, dirty@apple.com, f4bug@amsat.org, agraf@csgraf.de, kraxel@redhat.com, alex.bennee@linaro.org, qemu_oss@crudebyte.com, Vladislav Yaroshchuk Subject: [PATCH v20 7/7] net/vmnet: update hmp-commands.hx Date: Wed, 16 Mar 2022 02:07:41 +0300 Message-Id: <20220315230741.21578-8-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220315230741.21578-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32f (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::32f; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @jetbrains.com) X-ZM-MESSAGEID: 1647385953035100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- hmp-commands.hx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 8476277aa9..8f3d78f177 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1265,7 +1265,11 @@ ERST { .name =3D "netdev_add", .args_type =3D "netdev:O", - .params =3D "[user|tap|socket|vde|bridge|hubport|netmap|vhost-= user],id=3Dstr[,prop=3Dvalue][,...]", + .params =3D "[user|tap|socket|vde|bridge|hubport|netmap|vhost-= user" +#ifdef CONFIG_VMNET + "|vmnet-host|vmnet-shared|vmnet-bridged" +#endif + "],id=3Dstr[,prop=3Dvalue][,...]", .help =3D "add host network device", .cmd =3D hmp_netdev_add, .command_completion =3D netdev_add_completion, --=20 2.34.1.vfs.0.0