From patchwork Thu Mar 17 10:28:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Yaroshchuk X-Patchwork-Id: 1606495 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=jetbrains.com header.i=@jetbrains.com header.a=rsa-sha256 header.s=googleapps header.b=XsncbXR2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KK3Nt6f9wz9s75 for ; Thu, 17 Mar 2022 21:32:14 +1100 (AEDT) Received: from localhost ([::1]:39364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUnQS-0007in-Gq for incoming@patchwork.ozlabs.org; Thu, 17 Mar 2022 06:32:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUnNp-0007UO-TM for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:29 -0400 Received: from [2a00:1450:4864:20::12e] (port=34552 helo=mail-lf1-x12e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUnNn-0007BS-LU for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:29 -0400 Received: by mail-lf1-x12e.google.com with SMTP id p6so1025894lfh.1 for ; Thu, 17 Mar 2022 03:29:27 -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=XsncbXR2vLWNBhxdRTbYAl0diAK3OBppjk+thUPojENsh6aF3t0RiCemgh+BmFtzHD uGVZyhf0eDLvfCBbcFFFEC5pveKSAv5cW4NqB8+sgjVEMORjwi8uu3v+A/WX8SAo/BF2 28M8W5ct0t2XIr/txdprEQFGHI3PMqIDXSSTs= 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=QVT6IRHEhIELzVy5+dY0ir1ziqUdUUqcRQI/q7NwaZGtRiokqjLdjErHhfQeoZ4idT ZwLK1nX7JNSFx3EqrSTymdIKaUh8w9D/pKHd0vS/XPs6DQQri1anGg9i8w0H2cOKNSro SrZuTwAatOqtukuni8Cz1rsRUbFYbn+y8teTxDbkg+yHPkgrp3Of/UKi10gUd7C6wOV9 X7VhyuRVL7I8PE8hFk0O0ivp9Yo0fvbxz8kGNZlAB1pN5QIn5aPEASAn2PmhmOPSdyzn mMKQCjQQtBKtGfC5baoldJEGOpRY1XDMXMkqupL0lIjOwdElc2isP5iHH9RIuekvgx4g FBpA== X-Gm-Message-State: AOAM530bj1zYYkfykztSiLCbkLmZPqr74W+CzXnOYndgTZ5mm39BaiGd gwoB6A6pGPfSPpiwIdCXVEzy2xxiS04ItbgA X-Google-Smtp-Source: ABdhPJyegbcf3bXh/IWGrtZwDhfHsOY78s6JQeE35A699wqsz2Wuo8Gj2we3gXN+6zJJhY3fDekJNQ== X-Received: by 2002:a05:6512:15a0:b0:448:3bea:3e9c with SMTP id bp32-20020a05651215a000b004483bea3e9cmr2365061lfb.551.1647512965641; Thu, 17 Mar 2022 03:29:25 -0700 (PDT) Received: from UNIT-808.labs.intellij.net ([91.132.204.20]) by smtp.gmail.com with ESMTPSA id m21-20020a197115000000b0044895f0608asm413437lfc.37.2022.03.17.03.29.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 03:29:25 -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 v21 1/7] net/vmnet: add vmnet dependency and customizable option Date: Thu, 17 Mar 2022 13:28:27 +0300 Message-Id: <20220317102833.20775-2-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::12e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-lf1-x12e.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 +vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet')) +if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h', + 'VMNET_BRIDGED_MODE', + dependencies: vmnet) + vmnet = not_found + if get_option('vmnet').enabled() + error('vmnet.framework API is outdated') + else + warning('vmnet.framework API is outdated, disabling') + endif +endif + seccomp = not_found if not get_option('seccomp').auto() or have_system or have_tools seccomp = dependency('libseccomp', version: '>=2.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_server) 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 = {} if targetos == 'darwin' - summary_info += {'Cocoa support': cocoa} + summary_info += {'Cocoa support': cocoa} + summary_info += {'vmnet.framework support': vmnet} endif summary_info += {'SDL support': sdl} summary_info += {'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' From patchwork Thu Mar 17 10:28:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Yaroshchuk X-Patchwork-Id: 1606501 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=jetbrains.com header.i=@jetbrains.com header.a=rsa-sha256 header.s=googleapps header.b=D25jfI6b; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KK3kD15vzz9s75 for ; Thu, 17 Mar 2022 21:47:16 +1100 (AEDT) Received: from localhost ([::1]:35162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUnez-0007pd-CL for incoming@patchwork.ozlabs.org; Thu, 17 Mar 2022 06:47:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUnO0-0007Yp-Os for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:43 -0400 Received: from [2a00:1450:4864:20::134] (port=34558 helo=mail-lf1-x134.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUnNp-0007Bl-JC for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:31 -0400 Received: by mail-lf1-x134.google.com with SMTP id p6so1026022lfh.1 for ; Thu, 17 Mar 2022 03:29:29 -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=D25jfI6bLjj9GZCfyF9qcXac4tuD5ASf6xlSUc6XATlF2FWitDU013UqtilX0cd9Lm qP/i/vMxYEFdxkcVkTLigzde+kzzdRrkZS1diosQQRCUCMoQWYS/Q1+oYT90q1z1EFbs cYjC4VcYMuX+fpvZ38qArH8OD0apziiUAB2rw= 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=5fbtNiidIFEXUPwPzbMsPqxiq09Ka9LN9N9zDBI0rSApAQzYXhZZE0GkhF10vJtO3k n5CJSDBqMjopGfXs20qA+I3v33KYB7xonu0BWu5Ks8BUlbvM/sONLn/0RBq3anA00IOb rXDn995zheYNsG7wJd2c7SgCoCAuSwqCZZthvpSrBKpvq4FWUAWj1EUSwR49A4CnO4KL +0von9C68TYDeDFK5lILnonFmB0vi109H1UmMcch3DdikOpFeDHTGpvTCh+s82t0Zoxk DbuySDzm0YRnpPCtJmmuA0E/aMChFEMe01ps2fIAHShl17misESi++CgM5J7cofgRM99 Y71w== X-Gm-Message-State: AOAM532fWwMVsTb+uKHrkMLUaOyI/J73IrPLMwn2rgPMT68R7tk6XSgx YhQRmwbnwMSIQG+jWopHlnMRr4EjLT5VaAmY X-Google-Smtp-Source: ABdhPJxSXPvNFR3duRmGkLwuiJYPjX9hAgCRRzdqDP4W5T5ozP5NRlGRhgtBZ/4GmCujGZ7AF5JR4Q== X-Received: by 2002:a05:6512:3984:b0:447:6097:fb8f with SMTP id j4-20020a056512398400b004476097fb8fmr2524179lfu.166.1647512967576; Thu, 17 Mar 2022 03:29:27 -0700 (PDT) Received: from UNIT-808.labs.intellij.net ([91.132.204.20]) by smtp.gmail.com with ESMTPSA id m21-20020a197115000000b0044895f0608asm413437lfc.37.2022.03.17.03.29.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 03:29:27 -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 v21 2/7] net/vmnet: add vmnet backends to qapi/net Date: Thu, 17 Mar 2022 13:28:28 +0300 Message-Id: <20220317102833.20775-3-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::134 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-lf1-x134.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Create separate netdevs for each vmnet operating mode: - vmnet-host - vmnet-shared - vmnet-bridged Acked-by: Markus Armbruster Signed-off-by: Vladislav Yaroshchuk --- net/clients.h | 11 ++++ net/meson.build | 7 +++ net/net.c | 10 ++++ net/vmnet-bridged.m | 25 +++++++++ net/vmnet-common.m | 20 +++++++ net/vmnet-host.c | 24 ++++++++ net/vmnet-shared.c | 25 +++++++++ net/vmnet_int.h | 25 +++++++++ qapi/net.json | 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, 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')) +vmnet_files = 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_DRIVER__MAX])( #ifdef CONFIG_L2TPV3 [NET_CLIENT_DRIVER_L2TPV3] = net_init_l2tpv3, #endif +#ifdef CONFIG_VMNET + [NET_CLIENT_DRIVER_VMNET_HOST] = net_init_vmnet_host, + [NET_CLIENT_DRIVER_VMNET_SHARED] = net_init_vmnet_shared, + [NET_CLIENT_DRIVER_VMNET_BRIDGED] = net_init_vmnet_bridged, +#endif /* CONFIG_VMNET */ }; @@ -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 }; 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 later. + * 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 later. + * 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 later. + * 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 later. + * 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 later. + * 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' } } +## +# @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-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. +# +# @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' }] } ## # @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' } } } ## # @RxState: From patchwork Thu Mar 17 10:28:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Yaroshchuk X-Patchwork-Id: 1606503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=jetbrains.com header.i=@jetbrains.com header.a=rsa-sha256 header.s=googleapps header.b=brbJaJY6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KK3pF1ttyz9s75 for ; Thu, 17 Mar 2022 21:50:42 +1100 (AEDT) Received: from localhost ([::1]:39896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUniJ-0002i8-4y for incoming@patchwork.ozlabs.org; Thu, 17 Mar 2022 06:50:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUnOA-0007aF-Ef for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:52 -0400 Received: from [2a00:1450:4864:20::12d] (port=37805 helo=mail-lf1-x12d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUnO0-0007Bz-7r for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:42 -0400 Received: by mail-lf1-x12d.google.com with SMTP id b28so8230839lfc.4 for ; Thu, 17 Mar 2022 03:29:30 -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=brbJaJY6W5RWaiBeodj53MSq1qMO1P6mgACN48mrf44rhcJjoLWhYXr8ls/C3nfKyY JXXoBFQsXLRU4SlBbbtN2CQ+9qO3MsSRHa5etK0GstzJxunmB3K0WmWndQxDegxt5Q2V +J/g2YMy2sWIRLwf5KVaI6w9M7HWqZMrToNZg= 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=PwWqj1oyOxJxXxJEpofynQJarEqNiSaZB5/xrOEI1XK7G59QF5YyC71ZxYri5QySux y5dbTve/mnCfoIOni8wfS3rHu8TzGMpABEblLIz4QivF4qio9sgmHshU5OY5fySLN+Xi 5OOQoxrBoJaZky5aKm2nXXlbHgsl4lwNumyIT1gFB25vE1yfrpQLbJfyl6mrtBsKHi1C Cgbj7Ea+MPxtmgGn5kS1bloZlq3AdMMcGjJsHDKsNVYZz53jGBLjN7IlMCl1PzSzhnw6 U2+99p9xdABBFBNPNYuMOzJM/n/SVHEugER351vbjbfIyFZF9ktpnWaiBRrF3H1G/4uU ZQPw== X-Gm-Message-State: AOAM530m0MMklYpvIoonQkN50oefH0Gr5qeIWQ3pZlnpAeUI3mPrpfTU dNtjgi285MbOcQ7HloCQY234oDQOZ6uG+fb/ X-Google-Smtp-Source: ABdhPJx0NeNpWmUzLovptpb6bjoqoMoadAZVJ8V2q5g8DeBaYjSUwfn++9xSvm/qjK8CdzRMTo3tUA== X-Received: by 2002:ac2:5def:0:b0:448:294e:df56 with SMTP id z15-20020ac25def000000b00448294edf56mr2440796lfq.421.1647512968743; Thu, 17 Mar 2022 03:29:28 -0700 (PDT) Received: from UNIT-808.labs.intellij.net ([91.132.204.20]) by smtp.gmail.com with ESMTPSA id m21-20020a197115000000b0044895f0608asm413437lfc.37.2022.03.17.03.29.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 03:29:28 -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 v21 3/7] net/vmnet: implement shared mode (vmnet-shared) Date: Thu, 17 Mar 2022 13:28:29 +0300 Message-Id: <20220317102833.20775-4-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::12d (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::12d; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-lf1-x12d.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 @@ */ #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" #include +#include + +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 >= 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 = 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 = (char *) buf; + iov.iov_len = size; + + packet.vm_pkt_iovcnt = 1; + packet.vm_flags = 0; + packet.vm_pkt_size = size; + packet.vm_pkt_iov = &iov; + pkt_cnt = 1; + + if_status = vmnet_write(s->vmnet_if, &packet, &pkt_cnt); + if (if_status != 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 == s->packets_send_end_pos); + + struct vmpktdesc *packets = s->packets_buf; + vmnet_return_t status; + int i; + + /* Read as many packets as present */ + s->packets_send_current_pos = 0; + s->packets_send_end_pos = VMNET_PACKETS_LIMIT; + for (i = 0; i < s->packets_send_end_pos; ++i) { + packets[i].vm_pkt_size = s->max_packet_size; + packets[i].vm_pkt_iovcnt = 1; + packets[i].vm_flags = 0; + } + + status = vmnet_read(s->vmnet_if, packets, &s->packets_send_end_pos); + if (status != VMNET_SUCCESS) { + error_printf("vmnet: read failed: %s\n", + vmnet_status_map_str(status)); + s->packets_send_current_pos = 0; + s->packets_send_end_pos = 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 = qemu_send_packet_async(&s->nc, + s->iov_buf[s->packets_send_current_pos].iov_base, + s->packets_buf[s->packets_send_current_pos].vm_pkt_size, + vmnet_send_completed); + + if (size == 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 = (NetClientState *) opaque; + VmnetState *s = 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 = 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 = s->packets_buf; + struct iovec *iov = s->iov_buf; + int i; + + for (i = 0; i < VMNET_PACKETS_LIMIT; ++i) { + iov[i].iov_len = s->max_packet_size; + iov[i].iov_base = g_malloc0(iov[i].iov_len); + packets[i].vm_pkt_iov = iov + i; + } +} + + +int vmnet_if_create(NetClientState *nc, + xpc_object_t if_desc, + Error **errp) +{ + VmnetState *s = DO_UPCAST(VmnetState, nc, nc); + dispatch_semaphore_t if_created_sem = dispatch_semaphore_create(0); + __block vmnet_return_t if_status; + + s->if_queue = 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 = xpc_copy_description(v); + qemu_log(" %s=%s\n", k, desc); + free(desc); + return true; + }); +#endif /* DEBUG */ + + s->vmnet_if = vmnet_start_interface( + if_desc, + s->if_queue, + ^(vmnet_return_t status, xpc_object_t interface_param) { + if_status = status; + if (status != 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 = xpc_copy_description(v); + qemu_log(" %s=%s\n", k, desc); + free(desc); + return true; + }); +#endif /* DEBUG */ + + s->mtu = xpc_dictionary_get_uint64( + interface_param, + vmnet_mtu_key); + s->max_packet_size = xpc_dictionary_get_uint64( + interface_param, + vmnet_max_packet_size_key); + + dispatch_semaphore_signal(if_created_sem); + }); + + if (s->vmnet_if == 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 != 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 = aio_bh_new(qemu_get_aio_context(), vmnet_send_bh, nc); + vmnet_bufs_init(s); + + s->packets_send_current_pos = 0; + s->packets_send_end_pos = 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 == 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 = DO_UPCAST(VmnetState, nc, nc); + dispatch_semaphore_t if_stopped_sem; + + if (s->vmnet_if == NULL) { + return; + } + + if_stopped_sem = dispatch_semaphore_create(0); + vmnet_stop_interface( + s->vmnet_if, + s->if_queue, + ^(vmnet_return_t status) { + assert(status == 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 = 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 @@ #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" #include + +static bool validate_options(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetSharedOptions *options = &(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 = &(netdev->u.vmnet_shared); + xpc_object_t if_desc = 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 >= 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 = { + .type = NET_CLIENT_DRIVER_VMNET_SHARED, + .size = sizeof(VmnetState), + .receive = vmnet_receive_common, + .cleanup = 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 = 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" #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 typedef struct VmnetState { - NetClientState nc; + NetClientState nc; + interface_ref vmnet_if; + + uint64_t mtu; + uint64_t max_packet_size; + 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; +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); #endif /* VMNET_INT_H */ From patchwork Thu Mar 17 10:28:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Yaroshchuk X-Patchwork-Id: 1606504 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=jetbrains.com header.i=@jetbrains.com header.a=rsa-sha256 header.s=googleapps header.b=fhf2jRol; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KK3sK3P5hz9s75 for ; Thu, 17 Mar 2022 21:53:25 +1100 (AEDT) Received: from localhost ([::1]:44296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUnkx-0005rG-FH for incoming@patchwork.ozlabs.org; Thu, 17 Mar 2022 06:53:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUnOA-0007aG-2k for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:52 -0400 Received: from [2a00:1450:4864:20::230] (port=38506 helo=mail-lj1-x230.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUnO0-0007C9-Fl for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:41 -0400 Received: by mail-lj1-x230.google.com with SMTP id s25so6612148lji.5 for ; Thu, 17 Mar 2022 03:29:31 -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=fhf2jRol7Vxlq/eainUtjF2qM5zcEYLTYBK4afx7Mq0xsNW/ztWLQG6WjMR2iFOa6p gwAgUPVMfQdag7Rxt/eIOFBB4OdPf2eUMiBXMoYYtV1MG1YBkz5V1G9eG+QYKRge0ZFc REnPf0qCZphbnq2d3U25lJafXBpghP4LT4YZ4= 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=pD2ngCOI6Nh9qLysrvieJMg8qHbHdKvnVJiU2eme329WtfwIeGD+OGdoT8+SMz1uQx ISx+w2RjhRPfgnBZr6sGHa2tkGnjarqyMx4NQue1RsThKe0xVuJlYazrOrj0gZTFAoDS abwBz3oYRvHUvlqo+x5L53SWm39qQra9FR/aI6zWaJFD180DOcG59nAi4fCBQZMOG+et Bsk8uKY4OBz6nvTVnbOX1/V9doJUCBJXD+5miNLtkmZVgK2/HJ2XJzRSTNUueywCegoi sVJH7IMK48/uksskfzmajjYf4mkGySfi6hLwP2ruOPF13Ujrui4XNh2+ZBUGfM/X1JOH YzsQ== X-Gm-Message-State: AOAM531eVMVDBKN0x/KQS+1GYaJ/x7O9kfVt4GKxpf1RxyCvdyMCEf0S 6mKqBpwtw3RgXyRB19dXrpqucxYf+aPWmHM0 X-Google-Smtp-Source: ABdhPJwAXZZPGt/tFXn/z6kVZGTaQMyXdZhuZrLzavwMkBAeMuq/vJHHxsyCw2z2KfYSc0CKc92tUQ== X-Received: by 2002:a2e:8708:0:b0:246:12b7:e67d with SMTP id m8-20020a2e8708000000b0024612b7e67dmr2429087lji.24.1647512970222; Thu, 17 Mar 2022 03:29:30 -0700 (PDT) Received: from UNIT-808.labs.intellij.net ([91.132.204.20]) by smtp.gmail.com with ESMTPSA id m21-20020a197115000000b0044895f0608asm413437lfc.37.2022.03.17.03.29.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 03:29:29 -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 v21 4/7] net/vmnet: implement host mode (vmnet-host) Date: Thu, 17 Mar 2022 13:28:30 +0300 Message-Id: <20220317102833.20775-5-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::230 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-lj1-x230.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 @@ */ #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" #include + +static bool validate_options(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetHostOptions *options = &(netdev->u.vmnet_host); + +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >= 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 = &(netdev->u.vmnet_host); + xpc_object_t if_desc = 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 >= 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 = { + .type = NET_CLIENT_DRIVER_VMNET_HOST, + .size = sizeof(VmnetState), + .receive = vmnet_receive_common, + .cleanup = 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 = 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); } From patchwork Thu Mar 17 10:28:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Yaroshchuk X-Patchwork-Id: 1606505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=jetbrains.com header.i=@jetbrains.com header.a=rsa-sha256 header.s=googleapps header.b=JJgtVLlH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KK3w04f9Hz9s75 for ; Thu, 17 Mar 2022 21:55:43 +1100 (AEDT) Received: from localhost ([::1]:49210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUnnA-0000lh-OP for incoming@patchwork.ozlabs.org; Thu, 17 Mar 2022 06:55:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUnOA-0007aJ-Jw for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:53 -0400 Received: from [2a00:1450:4864:20::229] (port=37508 helo=mail-lj1-x229.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUnO0-0007CM-FU for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:43 -0400 Received: by mail-lj1-x229.google.com with SMTP id r22so6626985ljd.4 for ; Thu, 17 Mar 2022 03:29:33 -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=kFQF/s0PHcJKQu5NMQl2S+TebRUYeZokmleaW/O43uQ=; b=JJgtVLlHwkmbWNQzO+D1EjOEeJarTd+/9DrASQoK4wypjhE9zINBXBg2CouNLZHeJ/ KwBkc6I46hpP4J6/sYmK+W6w40vqmfSkoP1RE2tk/5AlUeQXoYft363mTeFi9UKognXc 3iBIUZLOI4xcDu9V1joDhUti+OLmr4gPCOwz0= 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=kFQF/s0PHcJKQu5NMQl2S+TebRUYeZokmleaW/O43uQ=; b=Rnr776XAGJB1WwiM3DKnPgLYophc0IJWY/Fem8VoTdBMFt36I55kdsKVxW47isgWpr L0OOTL0H91jVrJR5Ze0SHorT2z16t7i3q9qhY8pZ4a8+rFj2e5UVb1xwr8kofhDegRRv Z8E4IkD3LpxUMyYgSS8+hNqAc8eIXRYe1VZcT3yVTGJ05sn1y3S2jQV7FKAyMjNKxLd8 vVHJhMc5pNUqEbAXm7QYFhAS1AHN+hLTjL+nYMgnzzbekjviYuFOsF+KQ8Vu9VNya19y IrZXiWVG+uEEmFjKbudCE2pexSXTnpAvJ8MK4mtOTwhGYwfNBI02rrbXwyO1P+5XC81l ztAA== X-Gm-Message-State: AOAM530ej80MglIQAm8dnMYJGf5CBrYNUMzUcjBEvanVT8vpLqkskbcM rscjXOq2j039Vsh8qOslAPBsNy6CckEt4afl X-Google-Smtp-Source: ABdhPJw3RF6zqJXaUJ0CwaBCACLD3XCPeCLToWmoRU1+IMiSy/98PQ8Wut7SBMGqnrc1b/Y6N2TnRQ== X-Received: by 2002:a2e:b754:0:b0:247:eb1b:9370 with SMTP id k20-20020a2eb754000000b00247eb1b9370mr2495911ljo.302.1647512971924; Thu, 17 Mar 2022 03:29:31 -0700 (PDT) Received: from UNIT-808.labs.intellij.net ([91.132.204.20]) by smtp.gmail.com with ESMTPSA id m21-20020a197115000000b0044895f0608asm413437lfc.37.2022.03.17.03.29.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 03:29:31 -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 v21 5/7] net/vmnet: implement bridged mode (vmnet-bridged) Date: Thu, 17 Mar 2022 13:28:31 +0300 Message-Id: <20220317102833.20775-6-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::229 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::229; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-lj1-x229.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-bridged.m | 130 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 125 insertions(+), 5 deletions(-) diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m index 91c1a2f2c7..6970c7d17b 100644 --- a/net/vmnet-bridged.m +++ b/net/vmnet-bridged.m @@ -10,16 +10,136 @@ #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" #include + +static bool validate_ifname(const char *ifname) +{ + xpc_object_t shared_if_list = vmnet_copy_shared_interface_list(); + bool match = false; + if (!xpc_array_get_count(shared_if_list)) { + goto done; + } + + match = !xpc_array_apply( + shared_if_list, + ^bool(size_t index, xpc_object_t value) { + return strcmp(xpc_string_get_string_ptr(value), ifname) != 0; + }); + +done: + xpc_release(shared_if_list); + return match; +} + + +static char* get_valid_ifnames() +{ + xpc_object_t shared_if_list = vmnet_copy_shared_interface_list(); + __block char *if_list = NULL; + __block char *if_list_prev = 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 = g_strconcat(xpc_string_get_string_ptr(value), + " ", + if_list_prev, + NULL); + g_free(if_list_prev); + if_list_prev = 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 = &(netdev->u.vmnet_bridged); + char* if_list; + + if (!validate_ifname(options->ifname)) { + if_list = 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 = &(netdev->u.vmnet_bridged); + xpc_object_t if_desc = 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 >= 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 = { + .type = NET_CLIENT_DRIVER_VMNET_BRIDGED, + .size = sizeof(VmnetState), + .receive = vmnet_receive_common, + .cleanup = 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 = 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); } From patchwork Thu Mar 17 10:28:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Yaroshchuk X-Patchwork-Id: 1606500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=jetbrains.com header.i=@jetbrains.com header.a=rsa-sha256 header.s=googleapps header.b=c800GVuU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KK3hT4Rpjz9s75 for ; Thu, 17 Mar 2022 21:45:45 +1100 (AEDT) Received: from localhost ([::1]:59258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUndX-00051t-JD for incoming@patchwork.ozlabs.org; Thu, 17 Mar 2022 06:45:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUnOA-0007aH-JZ for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:53 -0400 Received: from [2a00:1450:4864:20::232] (port=46662 helo=mail-lj1-x232.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUnO0-0007CR-G2 for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:43 -0400 Received: by mail-lj1-x232.google.com with SMTP id bx44so96835ljb.13 for ; Thu, 17 Mar 2022 03:29:34 -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=c800GVuUFj1q/or9q2roLdXTWKTPf6K+xfCWKE32Dqm2/0JjjcMlwdafDnNs1gFrkR XkqIlSyw8r2ctiJfuxweEzF4WnwL1XTQlWKjFU87YjgGm5JRJ8JURSS1L8XcOmbLlScr NguZtuQRXAFuzdUKi4nDoG+1vqExYecPD5S+o= 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=4o5Wezkix+Db5eYFjqhVoOtW9j0x2sCQeLDdIBWDurlWZWDzwxUFNDe11KiMbea5jf mF9NriLkmk2mwVu6M3ZdVVhutQH3agKC1UyJlX/7h9lgCcgMY4BxE7+JBDoI0BtJ02r0 wsC4/43VVBCyvwKqR5bz2ZcujFIGxrx6+qKKbwQ6vLQZknPXeeGZN7UIMI3odDi3HuUO OBnrHa6BYoWv53nvEbSavJfowa9ePFCNsvculBFlNkDm+fQAyFXMAewRRgzWRcJFce77 ldywBU7vKrZ3JVbdLXPpojb3P9ClSlRJmKPCWH41akOZsTRIFp996dJwuszqlzFSx+HU bcIw== X-Gm-Message-State: AOAM532tYej73EazmG25hVFubM4kH2/CScUgzpddJWzSig9Fyy1+S5HZ ciRr3RHZSdkSCCfhTKMyfyiEWfktiJgtvIv1 X-Google-Smtp-Source: ABdhPJyYKDF2oixzwHufYyYWpQrqG/ALP+Cd8ceuKYnlXQz5Ju1f00Bzes7yEDHMqweQcQkX8TPDmQ== X-Received: by 2002:a2e:97c8:0:b0:248:542:6a2f with SMTP id m8-20020a2e97c8000000b0024805426a2fmr2411803ljj.417.1647512973469; Thu, 17 Mar 2022 03:29:33 -0700 (PDT) Received: from UNIT-808.labs.intellij.net ([91.132.204.20]) by smtp.gmail.com with ESMTPSA id m21-20020a197115000000b0044895f0608asm413437lfc.37.2022.03.17.03.29.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 03:29:33 -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 v21 6/7] net/vmnet: update qemu-options.hx Date: Thu, 17 Mar 2022 13:28:32 +0300 Message-Id: <20220317102833.20775-7-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::232 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-lj1-x232.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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=str,vhostdev=/path/to/dev\n" " configure a vhost-vdpa network,Establish a vhost-vdpa netdev\n" +#endif +#ifdef CONFIG_VMNET + "-netdev vmnet-host,id=str[,isolated=on|off][,net-uuid=uuid]\n" + " [,start-address=addr,end-address=addr,subnet-mask=mask]\n" + " configure a vmnet network backend in host mode with ID '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 interact with\n" + " vmnet-host interfaces within this isolated network\n" + "-netdev vmnet-shared,id=str[,isolated=on|off][,nat66-prefix=addr]\n" + " [,start-address=addr,end-address=addr,subnet-mask=mask]\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 internal network,\n" + " isolate this interface from others with 'isolated'\n" + "-netdev vmnet-bridged,id=str,ifname=name[,isolated=on|off]\n" + " configure a vmnet network backend in bridged mode with ID 'str',\n" + " use 'ifname=name' to select a physical network interface to be bridged,\n" + " isolate this interface from others with 'isolated'\n" #endif "-netdev hubport,id=str,hubid=n[,netdev=nd]\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=macaddr]\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" From patchwork Thu Mar 17 10:28:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Yaroshchuk X-Patchwork-Id: 1606496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=jetbrains.com header.i=@jetbrains.com header.a=rsa-sha256 header.s=googleapps header.b=cVHD0gqr; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KK3RK3dPyz9s75 for ; Thu, 17 Mar 2022 21:34:19 +1100 (AEDT) Received: from localhost ([::1]:42212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUnSS-0001PJ-Mi for incoming@patchwork.ozlabs.org; Thu, 17 Mar 2022 06:34:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUnOA-0007aI-JC for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:52 -0400 Received: from [2a00:1450:4864:20::12b] (port=42803 helo=mail-lf1-x12b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUnO0-0007CX-Hd for qemu-devel@nongnu.org; Thu, 17 Mar 2022 06:29:43 -0400 Received: by mail-lf1-x12b.google.com with SMTP id w12so8200317lfr.9 for ; Thu, 17 Mar 2022 03:29:36 -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=cVHD0gqrlf2lZCOhSj5xk1xvq55hJsAYKHZSnWl8hCTPmIuou59G5q3MyJGPw7OBpd BvIkeqSWagz+poxPVbM24Sq4Xc6LkSWuM6Wp5dNA+fVKJeCUYathjUxPwpum5f2BfkhV yJCDlcl7RJaugn7iNcrNg9fkWduMH4F3dsDcc= 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=Qg1R+0kvCjv/TnrXrvZchH9Xvf70pYAaoEoQMWFlPY8o3oeNJ0NdX6aJeNYgQpjSdX zoe++U/0FqlF764P9G3tKougiTBf2l76uTvYlPOnvx4W90fWuTrzXGdUSBBXhAwX210x A9aGTHDp9emdhUMu5R8rDZo61+0RXFqSrh5wg9U5Hw0DsWIHvJ2Bn64xIONg9gRkLHc4 0bl5bQQLBYkTjqhLa/CjIx+qpMGwT59CSjuS0J4SXgrP3ycuwscpHyWvHvQpL3rvRbxL Y1O52j8ntYIlff5Wz+PSqXUVZVSuOuRykHmXfOKMdSGYLvtzEEHHrn1s/v9iNgafqUM/ M4NA== X-Gm-Message-State: AOAM530SmSMJiWZGGtjEqi65mgmxJ3iutXpWYVCYrgR6Z330mrFsgtMF e995MWlkcZVS/Gwr+eDEf3439I3jqwoZDPA1 X-Google-Smtp-Source: ABdhPJxIPlo/8kyAX5Ry1QdW3h+k2GN2gKYpPcymnudDiKUyycql8wJsCvJFGz2LOQtWaMEk1Y9hTQ== X-Received: by 2002:a05:6512:683:b0:448:6a0b:da42 with SMTP id t3-20020a056512068300b004486a0bda42mr2372266lfe.223.1647512975056; Thu, 17 Mar 2022 03:29:35 -0700 (PDT) Received: from UNIT-808.labs.intellij.net ([91.132.204.20]) by smtp.gmail.com with ESMTPSA id m21-20020a197115000000b0044895f0608asm413437lfc.37.2022.03.17.03.29.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Mar 2022 03:29:34 -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 v21 7/7] net/vmnet: update hmp-commands.hx Date: Thu, 17 Mar 2022 13:28:33 +0300 Message-Id: <20220317102833.20775-8-Vladislav.Yaroshchuk@jetbrains.com> X-Mailer: git-send-email 2.34.1.vfs.0.0 In-Reply-To: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> References: <20220317102833.20775-1-Vladislav.Yaroshchuk@jetbrains.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::12b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=vladislav.yaroshchuk@jetbrains.com; helo=mail-lf1-x12b.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 = "netdev_add", .args_type = "netdev:O", - .params = "[user|tap|socket|vde|bridge|hubport|netmap|vhost-user],id=str[,prop=value][,...]", + .params = "[user|tap|socket|vde|bridge|hubport|netmap|vhost-user" +#ifdef CONFIG_VMNET + "|vmnet-host|vmnet-shared|vmnet-bridged" +#endif + "],id=str[,prop=value][,...]", .help = "add host network device", .cmd = hmp_netdev_add, .command_completion = netdev_add_completion,