From nobody Sun Apr 28 19:14:23 2024 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=1647538392; cv=none; d=zohomail.com; s=zohoarc; b=F7HiCyqwQ16b/YyZd9ZoSgZ0swsdERrvzkA8d4cxhm3ZeXCoVPy4724ep05tZuVih2BBDz+poDYpeYIlVC8SpJMVpYwFJaPPCKcXXNZv2emWwAhCggDtQDQUGylMSJggyJ+Hb8o9UgJZG7UTvP3Ray6wctC/C+NHkI1MD+/bV8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647538392; 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=V3DpNUVgHW4Z5WzdMyiq6qNwV1DN9sIcYevDhktoLK23+vBno9HSdZ4XEcgkfDhy5afSOAzTzy9rHZNkVVR+XhdckYUjoqR4VhqGXdSWmdPIcPiibbqoh/1VdAuiiqRNv0z9CqbRFWLRIeJ7qLrAGM65Hqd6MwzM70FnwyaIUVM= 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 1647538392579866.9666130439513; Thu, 17 Mar 2022 10:33:12 -0700 (PDT) Received: from localhost ([::1]:40284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUtzs-0007qY-9z for importer@patchew.org; Thu, 17 Mar 2022 13:33:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUtvh-00052Z-FW for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:28:53 -0400 Received: from [2a00:1450:4864:20::432] (port=33404 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 1nUtvf-0005oY-VM for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:28:53 -0400 Received: by mail-wr1-x432.google.com with SMTP id j17so8417240wrc.0 for ; Thu, 17 Mar 2022 10:28:51 -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 2-20020a1c1902000000b00380d3873d6asm4890702wmz.43.2022.03.17.10.28.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 10:28:48 -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=C1o9+FtlNuRWXtLVywViUQXLxKKd73Vub8vhCv7u/M62CJfF8lx0oTLm2G9j1g8UY1 gTfgmfMNfeU+gJO+pwZ/m72JCcJ4Xao35xtpYHxntdr8PoI9a4K4PHR32EHuApGgMhQL M/B3xW201Mq9WUC9UAigSFbQHqtnJQJ87M3bs= 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=Jses3y33TrFSV0iYnR3C/XTvvon/Z1WHlI7gG9ArPrIjFb7YvVsWxuMnirgecPQRzK 3SWyVOBadHSgK6GbgdghoyIXOTORUBSl4JZardjg+w6GRye0u6QfSqjFohMpMQhUPx7y iSOwlCN2kjgr/twPeLQs6j4sQjva1jEHYTgPaisxjGX9GtKh4jJ/k3DtalCVzI9apic7 dp9Emv9lyyvGXriPyYt4lXzpNzBSqeUrpqJy14a0uktSvrZxSOM19Mx0JBgK6PjAPxgs 6GUBbM6QBRz21+b14uelCNFb6829n6BpZpODkztKq+GMp5zPGvmfKJs6aBnpqAcyKdow 6/0g== X-Gm-Message-State: AOAM5338XMPIctamp4FVej35fcyp+dgFQ3Rbfutfcxn46/Zk34txyM/M 8yPMtZ1mWmBnfjkFdp9UMA1P8GoeUQ9jzmzAgAA= X-Google-Smtp-Source: ABdhPJynAGUdu3zGuTUjJMTB2yrLzcPc4afU82uiwcIqb4/1nGgWkRJv4Qr46UC0ceZNT2qsX9SjAw== X-Received: by 2002:adf:c5ca:0:b0:1f0:aa2:494b with SMTP id v10-20020adfc5ca000000b001f00aa2494bmr5121514wrg.275.1647538129427; Thu, 17 Mar 2022 10:28:49 -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 v22 1/7] net/vmnet: add vmnet dependency and customizable option Date: Thu, 17 Mar 2022 20:28:33 +0300 Message-Id: <20220317172839.28984-2-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317172839.28984-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317172839.28984-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: 1647538398882100001 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 Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki --- 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 Sun Apr 28 19:14:23 2024 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=1647538403; cv=none; d=zohomail.com; s=zohoarc; b=mBv6M0QfiJeIp5rGKEqeULw/mm/dl4UhZc4XqW05xiyjLPPd/ES+nb+FeX/CWlg7OC9DXsYpM/L6j5BrO7icMroPk7Wdcgo4hp51I4/fOdiH3C55Le22E5o6gGwovif+Tr9R4+Ce48BSFdKu/gWzOeWS6OOP2ndqpd1qiVR0lu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647538403; 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=LsjBoUyOEw9TXTyGMzgsRSPmeKf/VWC0ByQUtxEeO0g=; b=GVVUi3e6g9lpZSUs7Obs+LL98y7rR/5AVsDK4X2KXRd7771UnkIeZk2zYoHflOILpFWyeRukOsHi8P8PtB/5h8aeBgNIvA0D4ThGXiBCK1A2SKS3ccZKr2HWQV8QM43LI1qhCS4Bt20NkB/dEGE5cXVCuzsM8rDHGF3tBp7dsoI= 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 1647538403519902.6289121946205; Thu, 17 Mar 2022 10:33:23 -0700 (PDT) Received: from localhost ([::1]:40614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUu02-00083y-6E for importer@patchew.org; Thu, 17 Mar 2022 13:33:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUtvk-00055r-0D for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:28:56 -0400 Received: from [2a00:1450:4864:20::433] (port=44849 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 1nUtvh-0005oi-7G for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:28:55 -0400 Received: by mail-wr1-x433.google.com with SMTP id b19so8302940wrh.11 for ; Thu, 17 Mar 2022 10:28:52 -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 2-20020a1c1902000000b00380d3873d6asm4890702wmz.43.2022.03.17.10.28.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 10:28:51 -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=LsjBoUyOEw9TXTyGMzgsRSPmeKf/VWC0ByQUtxEeO0g=; b=M/wkrHqltJpU7pMezFgCYPSjKBR0CI4uiDH1HGJUkbBiPmew2OtrnPqNUEG1dhBq8X o4r5tleG3l3CQk9HnJbVklbTwhSEvxB8zAlMk8VqQ2c6DOEXLM/bCC00A4QeUFKc7nFU HW0GN1KAJg6ix93cyVw0nUvRW8Dg/EAT7PtXw= 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=LsjBoUyOEw9TXTyGMzgsRSPmeKf/VWC0ByQUtxEeO0g=; b=w4oFZk2OZLrkF/2k+K0B5kfvBSu0ugTw1omBgr8U9kA/nGVIJZt0gjaMH8GeMU67aH l4Wj1aAo+ajONWwJAgrGOGcmknt3+i+OGVAZbHENejZy93b7bFVvUV8QgKxBs+JArTQU gJBsNmAawHlhVYdLJ7RvBZm2RdTE+fMPTFXiVuH1g9MB+PL3GxjzpVPbJkIvea3MgYXR IBvXmqdcq39lvzNGyH4l4lUsz8vF56Rhw9lqnIXgsIsokFBhcV8rLkxpxu1VEkB8N9Ij +v8AHNQc8x0hADQAXT7v0qYt2npabXW76VzsVhgr/iN0zHXlJJNuSjpNej/5o9DCoAsA tskQ== X-Gm-Message-State: AOAM532HBnqGUF45QrOlNhxXt+ManTshiVXSIdcyjBlZYPZMkeHmHAva fE7sC+JbM/8H8DcrAaJ7E/A8882JZO5ooBxtydM= X-Google-Smtp-Source: ABdhPJzovYj/9AEt4LxwAPr9SlNRTCf78mrkXhxuqaQOS3zBdBAeac2iAaQE5cWXtB4/Mu74wAyabA== X-Received: by 2002:a05:6000:11c8:b0:1f0:d64:fb0c with SMTP id i8-20020a05600011c800b001f00d64fb0cmr5086874wrx.279.1647538131519; Thu, 17 Mar 2022 10:28:51 -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 v22 2/7] net/vmnet: add vmnet backends to qapi/net Date: Thu, 17 Mar 2022 20:28:34 +0300 Message-Id: <20220317172839.28984-3-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317172839.28984-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317172839.28984-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: 1647538405537100001 Content-Type: text/plain; charset="utf-8" Create separate netdevs for each vmnet operating mode: - vmnet-host - vmnet-shared - vmnet-bridged Acked-by: Markus Armbruster Signed-off-by: Vladislav Yaroshchuk Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki --- 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 Sun Apr 28 19:14:23 2024 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=1647538544; cv=none; d=zohomail.com; s=zohoarc; b=az3wttaUD6iDaYh8ETI1/aLD0QyHvU0ZJ8e4D7eitnuU6oqoPF4Z6I9pqIfAhwhufd4f8iyn3Ek3TLYdR8Gy5n+p6PPHBrNyCloh8f4qOHzEO+Dgud0+eUg5ZLSnoqpcfoBW2YwiDt1WR9cuCGZYrdVZfPhiptoX1qnSq4HcOxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647538544; 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=+4P4Nnok2evD5i1OwbFOY8DPb8hB3pqeeCgXAmN2izo=; b=I+kYCAK6rEjftPfAZ0IJgJI/1GVkbqpgG0XSoSOZF0c8jJeOJMUQjSeCWllQ5EQJdDVILkDspNsdZqr5FkzqxyLhTbq2mwW8LSQpZheWxwGVvCEV6Mrl0c7PS9sW8Lgaggwk1LIS6Yp2vpMYW5mrcLuRUKLTT6HydoCfMRgGDmY= 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 1647538544293573.8808826768329; Thu, 17 Mar 2022 10:35:44 -0700 (PDT) Received: from localhost ([::1]:47970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUu2J-0004Xd-7J for importer@patchew.org; Thu, 17 Mar 2022 13:35:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUtvm-0005Bo-Aw for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:28:58 -0400 Received: from [2a00:1450:4864:20::433] (port=37631 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 1nUtvj-0005p0-Ei for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:28:58 -0400 Received: by mail-wr1-x433.google.com with SMTP id u16so7327825wru.4 for ; Thu, 17 Mar 2022 10:28:55 -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 2-20020a1c1902000000b00380d3873d6asm4890702wmz.43.2022.03.17.10.28.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 10:28:53 -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=+4P4Nnok2evD5i1OwbFOY8DPb8hB3pqeeCgXAmN2izo=; b=N0KJNTWvWIoqBC7GdXNQf8Nrq0UmEXN1tVfdW5JybHoBJt8pYvHL2cNZeWJfSH6wfS rk4fULDiaRv6bmNaxeR/M7QrpcsBpJ7RBaRAACbPA3lvszDo4TYAM9DhNMok4excxxm4 8+V01U33lzh2mgOQoute/1+9qLCjxbVYhHhPw= 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=+4P4Nnok2evD5i1OwbFOY8DPb8hB3pqeeCgXAmN2izo=; b=PpT4UsUVjAppxBnT8DcDd1Lp/v5UJ2+HMPv6hj985kOvXXLu3QZtyXEPahjbiqZbXj BLIuGMb2QbOW1VppytWtwWkmVCNk8DIZUT8BiIVbKkkLsqdcLR/p12WdJ4Vj11xgNpPk 2IIDfQxFgoeDLn/w0L/tVDSwle0iAjg9OsBepVll3AXFuvBQayLKOYdGKMQH8e7miGvN h0Hka1mQRjeW7HvoEpAXjrT6cpTyzZ2BNUExIjwxPQ0y/Dqg4KRMXuhJvKFTbO1KXTi/ QgqDCc8uQZBG3xsOTsiTzgXpb4ZGf5eEwhq3yucK/X3PqdvzAREpfG+hcLjdWdFeFcTW NgiA== X-Gm-Message-State: AOAM532DbSu7n7d9pvx5QHeRYpvFbh6M4yv8VcXuDRYIMmGrq1c8rxOO rxK6q55ZI1iYtFhSPBry2BQRG9zWWxT3d19WVAM= X-Google-Smtp-Source: ABdhPJyMstXjLKkgDBoOrQtDw9KrxC4RqIIrQU+JJkCGeLLeunTV7LZi3m86dH9IY6C4luJM7tHTZQ== X-Received: by 2002:adf:fc4b:0:b0:203:ddac:4467 with SMTP id e11-20020adffc4b000000b00203ddac4467mr4956761wrs.111.1647538133625; Thu, 17 Mar 2022 10:28:53 -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 v22 3/7] net/vmnet: implement shared mode (vmnet-shared) Date: Thu, 17 Mar 2022 20:28:35 +0300 Message-Id: <20220317172839.28984-4-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317172839.28984-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317172839.28984-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: 1647538546277100001 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 Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki --- net/vmnet-common.m | 358 +++++++++++++++++++++++++++++++++++++++++++++ net/vmnet-shared.c | 97 +++++++++++- net/vmnet_int.h | 40 ++++- 3 files changed, 490 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..18cadc72bd 100644 --- a/net/vmnet-shared.c +++ b/net/vmnet-shared.c @@ -10,16 +10,105 @@ =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); + xpc_object_t if_desc; + int result =3D -1; + + if (!validate_options(netdev, errp)) { + return result; + } + + if_desc =3D build_if_desc(netdev); + result =3D vmnet_if_create(nc, if_desc, errp); + xpc_release(if_desc); + return result; } 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 Sun Apr 28 19:14:23 2024 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=1647538407; cv=none; d=zohomail.com; s=zohoarc; b=FlDEhQv+iltszo/piGWEJ73GprigJ4z2pduuzO1VABcvdHRFkhFIHytFTpxlDU42zW0RwWSqBZg+Knk5+7OC4i4NOyTZoxkjWdcEl0GcJ6zcdvXiRW5oaIMiBMk7fqhhuE2Nui3F+BMvXySu5UeZqt0esWUh0Zkx11KrMaglDQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647538407; 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=N7jxl9IJabQb5RHI342NB+w46lkSKPcHwI1FMg6qPKY=; b=JX8WiVXytM+ifXleA9ihbd7De/m2SyJYF1+wY4iE19DMEeeuI+ggoJxZZp9xveiVxemYejko7ZvZmJCU+TbL6/fJWoJLwt2X1O3m0HDwjiEngYOsVlvbo3z35Ipr8W33+h7ZcVH2sL4unmiI7McE0u25KjZGM+Kv+4BUvu/yM+o= 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 16475384073221003.4283434214245; Thu, 17 Mar 2022 10:33:27 -0700 (PDT) Received: from localhost ([::1]:40858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUu05-0008Db-WA for importer@patchew.org; Thu, 17 Mar 2022 13:33:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUtvn-0005EU-J6 for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:28:59 -0400 Received: from [2a00:1450:4864:20::42e] (port=38718 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 1nUtvl-0005pG-MM for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:28:59 -0400 Received: by mail-wr1-x42e.google.com with SMTP id t11so8349206wrm.5 for ; Thu, 17 Mar 2022 10:28: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 2-20020a1c1902000000b00380d3873d6asm4890702wmz.43.2022.03.17.10.28.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 10:28:55 -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=N7jxl9IJabQb5RHI342NB+w46lkSKPcHwI1FMg6qPKY=; b=SAYW2HMkfVM6ClvbXdkQYipJybsMxb4euXzwcrh7Xc/ru183nbYGxxHMT3UzQv2Kwy SUoooyVsPHzNE19k0pwX7nZ62FtIYd9IPDo4380lhHdiT8/PJdZESr27mi+DrWpQ1b7d ggk49QZn4ewHnu6X+PNn1kucGtj9gBxP+QZmY= 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=N7jxl9IJabQb5RHI342NB+w46lkSKPcHwI1FMg6qPKY=; b=PUtYI6r+sRLt9i2IwBlrhUGLpOUA+C5FTvLms5eMPK2EmuDiXQKzB3n5Y+keN2zhc3 F4VzZ0oCnCGdcvG9IFZ0Pqb4HBE8lz0uWa4hBIpMKRAZygUxXFvjdji3KSxRcruNyrRq Emnzs792HhqR9tkAf5VkMikbjcYNWYSYf6MOlkRVLb9+42mO3yPLlAOvvgOzaKtGf6Yh hdfrkLux+L8QTs2+9K9uEtTy6VG4dNJXM22ye99Do3gJnNCsIH1QfWdr71wPp3DsipXy /92GKYAvwsiv5A9uAz02tmO1IU5wO/cMj5tZRnRnU4rE2jJynX9KP8wCK2vfgkwpBjAM UXcQ== X-Gm-Message-State: AOAM531LOOEPzPdBlwlhHQZTu91w1yHomYWGHlf5y3VMVB9vc7zMoNaj qKWDr0pbEEKzoBOOwBdsYRipgbxqN9Xeni7PrlU= X-Google-Smtp-Source: ABdhPJxBXgh3tNerl9A9LRai6KUA1Ksqs0/j35g9YZ2lGIQKX1FGJQIi0h0/qvgZI650C9F+GxkQNA== X-Received: by 2002:a5d:64e6:0:b0:203:731b:c2d0 with SMTP id g6-20020a5d64e6000000b00203731bc2d0mr5108559wri.607.1647538135636; Thu, 17 Mar 2022 10:28: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 v22 4/7] net/vmnet: implement host mode (vmnet-host) Date: Thu, 17 Mar 2022 20:28:36 +0300 Message-Id: <20220317172839.28984-5-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317172839.28984-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317172839.28984-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: 1647538409190100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki --- net/vmnet-host.c | 116 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 110 insertions(+), 6 deletions(-) diff --git a/net/vmnet-host.c b/net/vmnet-host.c index a461d507c5..05f8d78864 100644 --- a/net/vmnet-host.c +++ b/net/vmnet-host.c @@ -9,16 +9,120 @@ */ =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); + xpc_object_t if_desc; + int result =3D -1; + + if (!validate_options(netdev, errp)) { + return result; + } + + if_desc =3D build_if_desc(netdev); + result =3D vmnet_if_create(nc, if_desc, errp); + xpc_release(if_desc); + return result; } --=20 2.34.1.vfs.0.0 From nobody Sun Apr 28 19:14:23 2024 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=1647538539; cv=none; d=zohomail.com; s=zohoarc; b=GZaDmDymKPce9rWG3+J8eQ+ideTxRkZM5GZzXH1DPqWFSalCfBGn8wIU9VanoyxzGFlY+MxzTP6xmRcn91i3ZsODVsE21cD13h2/D7wR8nqzTRaOyHLsFbeVJLCH+8H2Ap5uhNkDKTU6038k36L2xZCFsWOdRs6R7azRLAKdgCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647538539; 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=R0CdD7C6TpsG19EAdUyMnd8ks0l2mSTC3DZoTnD40ao=; b=cuqfc8cWfIRNqxNQyXYZNcea579SAme1WZvdb+9Wja14ubmYnS7iEXU/GyuTuzww0KgV/Z6gB6vf/3nWSvqFFNGnIcsegl8UFLY3j4KuccVxNllqaVCye99ry6XvHIepgRe+5d0htQEFpMyNE/NbnEoK0rW4RPlff3wxZ2/oPr0= 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 1647538539758318.40202846762065; Thu, 17 Mar 2022 10:35:39 -0700 (PDT) Received: from localhost ([::1]:47616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUu2E-0004Iy-Ov for importer@patchew.org; Thu, 17 Mar 2022 13:35:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUtvp-0005JP-3A for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:29:01 -0400 Received: from [2a00:1450:4864:20::332] (port=38455 helo=mail-wm1-x332.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUtvn-0005pY-A4 for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:29:00 -0400 Received: by mail-wm1-x332.google.com with SMTP id m42-20020a05600c3b2a00b00382ab337e14so5332000wms.3 for ; Thu, 17 Mar 2022 10:28: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 2-20020a1c1902000000b00380d3873d6asm4890702wmz.43.2022.03.17.10.28.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 10:28:57 -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=R0CdD7C6TpsG19EAdUyMnd8ks0l2mSTC3DZoTnD40ao=; b=JkaHpjQjbNJ6ANwvHXzXbxkbpQwRQnID8NdOxy0O4NbXbyqpcqOZZp4gD2cPoBwvY/ G6hL/Vr5sHW5vEm14w2IDBzpmx/uGyPurF6ou7eUnAZ79XIj/hVv4deYjzF7W+UwQCzS 4AmOY0wZmTUXG5WtdaiaFAoMUpJ5Y//gJXe4Y= 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=R0CdD7C6TpsG19EAdUyMnd8ks0l2mSTC3DZoTnD40ao=; b=x9bGEqR/+ME4umJnePe/4TAT7zdONIAO4QAhRJHMnlFoEgioRDhRwh8DP0J2dTotG9 90mr/jvM6hYPkWf2AQl3xXRf0neH3nXegvIFffCzqIX+LyEK/Jp0DhtUPfAe+KwgOobl K+n7diY4YYFj50KFT4Yl9rkRH9sqzzRdAdczwO/K/QT7vNUEg+SAaVutmXQ+tIqHOdly yCDjUMcmQVI9z5DtA6ty7DaH638SNxVq4yeh5ua9u+pmROsJEVmDvCGj9Gd8s+zOq7UT 12lZmojYZ0wPhlq1eHE5g3+xcD2OjtZIAnALdjaNqrgeD8HEYVjpQOYIG5ReL6ojq4Gg pPpA== X-Gm-Message-State: AOAM5305yGMId3d2rQKjW3eFrq1By3O4BN8t89Tf+gjcbxYrujFQOylq HVYvzK1BcoNvo7/OX9x9vvqYrwf+u77eOsXKR8A= X-Google-Smtp-Source: ABdhPJzqhQDE4/7YEX1cHrHp+i4Yjqq518PYNXgt7upVxaHsIQ27pmV7/YV2Ct7uhnXF6s70rm8Rpg== X-Received: by 2002:a1c:7518:0:b0:381:c77:ceec with SMTP id o24-20020a1c7518000000b003810c77ceecmr4974554wmc.57.1647538137659; Thu, 17 Mar 2022 10:28: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 v22 5/7] net/vmnet: implement bridged mode (vmnet-bridged) Date: Thu, 17 Mar 2022 20:28:37 +0300 Message-Id: <20220317172839.28984-6-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317172839.28984-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317172839.28984-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::332 (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::332; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-wm1-x332.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: 1647538540314100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki --- net/vmnet-bridged.m | 137 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 132 insertions(+), 5 deletions(-) diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m index 91c1a2f2c7..46d2282863 100644 --- a/net/vmnet-bridged.m +++ b/net/vmnet-bridged.m @@ -10,16 +10,143 @@ =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 char* get_valid_ifnames() +{ + xpc_object_t shared_if_list =3D vmnet_copy_shared_interface_list(); + __block char *if_list =3D NULL; + __block char *if_list_prev =3D NULL; + + if (!xpc_array_get_count(shared_if_list)) { + goto done; + } + + xpc_array_apply( + shared_if_list, + ^bool(size_t index, xpc_object_t value) { + /* build list of strings like "en0 en1 en2 " */ + if_list =3D g_strconcat(xpc_string_get_string_ptr(value), + " ", + if_list_prev, + NULL); + g_free(if_list_prev); + if_list_prev =3D if_list; + return true; + }); + +done: + xpc_release(shared_if_list); + return if_list; +} + + +static bool validate_options(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetBridgedOptions *options =3D &(netdev->u.vmnet_bridged= ); + char* if_list; + + if (!validate_ifname(options->ifname)) { + if_list =3D get_valid_ifnames(); + if (if_list) { + error_setg(errp, + "unsupported ifname '%s', expected one of [ %s]", + options->ifname, + if_list); + g_free(if_list); + } else { + 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); + xpc_object_t if_desc; + int result =3D -1; + + if (!validate_options(netdev, errp)) { + return result; + } + + if_desc =3D build_if_desc(netdev); + result =3D vmnet_if_create(nc, if_desc, errp); + xpc_release(if_desc); + return result; } --=20 2.34.1.vfs.0.0 From nobody Sun Apr 28 19:14:23 2024 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=1647538656; cv=none; d=zohomail.com; s=zohoarc; b=iHfW23qwZACs2qeX54JVNl5bFJZfS4WUuFIKSz+q6ulRGCEux5OYMD//cYltyCmPnCq3TOh3yno+bQCjz0pWgMcHqskTFwq+tA4J8OYwKKytUboShkXRQ/JWUwyRJ838eLEpJ2EOhni8RfxiRk9MeF1fl1CSLCD9sfrmN5pGIb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647538656; 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=KB3kfGygSvXhef69T1yp8rAUEii8J4OZC2cRwA4ylPEAnwSBhBeQGzubmO7stPV8mxQXwqKJdJMSFosdxJLymcCksSgfEwReH95j1Gj2kmKGem0TYKzqYkYtSUBcwvOSKDsF2zi2eQ+DOpSWr6G7yEBS4bf4Y4ZUYxKWktkngQ8= 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 164753865642675.67323705106776; Thu, 17 Mar 2022 10:37:36 -0700 (PDT) Received: from localhost ([::1]:53498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUu47-0008NY-Dt for importer@patchew.org; Thu, 17 Mar 2022 13:37:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUtvq-0005O7-OA for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:29:03 -0400 Received: from [2a00:1450:4864:20::430] (port=46941 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 1nUtvp-0005pk-6q for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:29:02 -0400 Received: by mail-wr1-x430.google.com with SMTP id x15so8298024wru.13 for ; Thu, 17 Mar 2022 10:29: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 2-20020a1c1902000000b00380d3873d6asm4890702wmz.43.2022.03.17.10.28.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 10:28:59 -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=Y0YxftjcXBaLVQ7Tdvp8hPzonz5ovqoleuk9t1R5VNT8URNlbBUF1/tvT9rWPss8bk wNOO1ZKzIfcoCIC8UwsB9E0wlWPQGV1Xwa9N/r6AAxf/8cAxRWNu2zPBxWKMVvB32Qva 9fIbxfd1aCmy3gxD646HytsqqXGTxLK2Zh3a0= 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=EMHUBiG3IR+44itRcRNX6EeWBykvK/QvHwVsVZUaBoq82PreA+0PVxj3SxT+s5fe1c +gLGD89Oi3+xzxbkxz9x7u8kuJuqpzn9HOcwDCUlDQx5PHCxMwGLvbpcJNoYj5lpV6y+ sMyWDh4KHeB4xvJBuvQ6pbCdhpkVqX/F/BGPz6w79A0at9IyqrC2RCkYftt8b6MJI9zo Z+L7VUmTIFkkfzLly1mMWuSA/UABk++7/0N0rEb8CWvVFVQ0fgj8IuEYAplrigRopw33 J9mhWQv3e7EQ79PU0KRkTGRbAtcT8qWWhZ8dGv7/Gu1lkZ6Nqo5QqqowNdnW4KRBgO2c cMyA== X-Gm-Message-State: AOAM532mhpbvM/1nVHKngooFMZDfa6B/ewzapdA51X/btioIgKKa/flo 9QJhCCnv5KWmBhlE4TffohTSOi61xsSq/ILahys= X-Google-Smtp-Source: ABdhPJyLBJMHYAGh2CBKJbIu+1FWNOpfwNaZMJHiqwtwBAZy6qTDoimMYGzik6NG8Cy1Gpkbka+uVg== X-Received: by 2002:adf:d08f:0:b0:1f0:7eaa:e541 with SMTP id y15-20020adfd08f000000b001f07eaae541mr4979487wrh.372.1647538139667; Thu, 17 Mar 2022 10:28: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 v22 6/7] net/vmnet: update qemu-options.hx Date: Thu, 17 Mar 2022 20:28:38 +0300 Message-Id: <20220317172839.28984-7-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317172839.28984-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317172839.28984-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: 1647538658222100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki --- 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 Sun Apr 28 19:14:23 2024 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=1647538616; cv=none; d=zohomail.com; s=zohoarc; b=Fd9tBu5LycCDMaRdnkFC59Sz1x7DsFILovDKnzBOA1Gc3G+7d61yWeGngNM1xbnIpMOUWk5l8uUCDE69PLTNfS7HDtj3MY6r2kJZWTEz3OEpPzbEefNkosm7CD9GDcKUj6jG3+wPl8VsLhajsKt/YmSsMhCaVX6/cDDMHSmulS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647538616; 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=faTkIiYQePJqsaWeiiwToMihn258/oJhMpcJ2Kg15WEyU1+k/Qc3rJWtVQoGjc7JPnlIAi1SSUvA1JbMWo3ScMERYLUPd+fRV7nrCeICya5WmcLyptv7d3P8ASn879rNjBfkE64XZ+wofKP118j91ADykS90hVVJta+OlLyJkWk= 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 1647538616451269.9069045860697; Thu, 17 Mar 2022 10:36:56 -0700 (PDT) Received: from localhost ([::1]:50406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUu3T-0006Ia-6d for importer@patchew.org; Thu, 17 Mar 2022 13:36:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUtvs-0005S8-Vi for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:29:05 -0400 Received: from [2a00:1450:4864:20::429] (port=39566 helo=mail-wr1-x429.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUtvr-0005q0-E9 for qemu-devel@nongnu.org; Thu, 17 Mar 2022 13:29:04 -0400 Received: by mail-wr1-x429.google.com with SMTP id h15so8335277wrc.6 for ; Thu, 17 Mar 2022 10:29: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 2-20020a1c1902000000b00380d3873d6asm4890702wmz.43.2022.03.17.10.28.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 10:29:01 -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=Hctd6SFSyLdRJsrpNuuQ8Ts34qQZHtt3Hbg6+flmhXlCacxlVOf3SIh89uEyYq5YDr JVRehB4wV18ht02+TAt0yORe1QcFPC49f2pV9HI4gSn49CKxXs1bJ5aBaSb54uD4evEk 5gqqdDVKQHY6FKsJSBXGzjOm9rUNYntiNk74U= 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=XeWWvNGyO+l5b09XAriROMTaht2sp5XAjyNHt3rFjYFD4y5PnOd0JT76G2ZQd92CT/ bUffr3TyteXfFjULyu0auGKo3MfOnb4ruXKgjletoNHbZUAYfvmM9jkypV13UInINF/R r89WOXTuzwuADIkeg6dQ+WpDmj18B+FYUmD1Hb/J4U42R+AQWI6vZmQCSan+f4FO5iN4 DuYflZ24pWk+LUdXn2F7i0LUCMPVxiAs/hVHUYLDrGJftK7XoZp8jbQ/wpy0K+uSxVQQ g6uwy+bqUHpHMN/dfSbSNTNSGKaYKHHy37MS/rHvuFPJ9YlDJTJy/UX+w6OhJfmEP7CD VwnQ== X-Gm-Message-State: AOAM530mgzUQa5y+LT9O/Uy9Y1uhsGbeAi7c8WjGrlF2KShbc5X8xl7l YrklLktmt4QuPTTvrQNmolvgxQ9gtLeXwqwP41k= X-Google-Smtp-Source: ABdhPJxz1FwA9zCUVxpfWogDD5zAyrpFbjO0xiGofiivsB37u7lgdCtc0Zdcj8zn4zzmRz5ujDhZBA== X-Received: by 2002:a5d:52ca:0:b0:203:db2f:2a47 with SMTP id r10-20020a5d52ca000000b00203db2f2a47mr5013122wrv.580.1647538141683; Thu, 17 Mar 2022 10:29: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 v22 7/7] net/vmnet: update hmp-commands.hx Date: Thu, 17 Mar 2022 20:28:39 +0300 Message-Id: <20220317172839.28984-8-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317172839.28984-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317172839.28984-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::429 (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::429; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-wr1-x429.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: 1647538616912100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki --- 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