From nobody Wed Apr 24 03:02:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16420865759031002.5662136738221; Thu, 13 Jan 2022 07:09:35 -0800 (PST) Received: from localhost ([::1]:49600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n81jK-0004Ds-D7 for importer@patchew.org; Thu, 13 Jan 2022 10:09:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n81bd-0002Ha-Sn for qemu-devel@nongnu.org; Thu, 13 Jan 2022 10:01:37 -0500 Received: from [2a00:1450:4864:20::135] (port=44930 helo=mail-lf1-x135.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n81ba-0003dR-OA for qemu-devel@nongnu.org; Thu, 13 Jan 2022 10:01:37 -0500 Received: by mail-lf1-x135.google.com with SMTP id o15so20406743lfo.11 for ; Thu, 13 Jan 2022 07:01:34 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.20]) by smtp.gmail.com with ESMTPSA id w25sm314278lfl.155.2022.01.13.07.01.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jan 2022 07:01:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IkPXEz8qpzqIp0kfjAIIcFQxyVE4Fbb7yQ0pwXlGHj8=; b=IEi04oX0p8pDgk+KKysKPdJ5ojOL1aizCnP2ccrvQPaEM6GpICrJk66UNqICrvVmd+ DuTtto4Aav94TGYrVvQfLqmMx+5IgD8CX4ZGtj9Uf42lNoQ1sY/2mS7277rufwzlg3Bu eeG44zCWwrVbUAiOVHfC12hLRVqOXW4hbN17e+oUxsQ66Ao9Qcbrh9HEX5+cdVrBgm4v OnFlOfEk+5rSwfZndEHl55UK3bhexK0vblnXkiFcnklfGQVFSbLmTcTUAPzpsg+0BrJf gzyYNrg8yhIk6VDt1kSOsL4ALxnUqqsUHlvZLbgYJ3AftEgko780Lfqtoi4FE+EFRvSm /Fkw== 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=IkPXEz8qpzqIp0kfjAIIcFQxyVE4Fbb7yQ0pwXlGHj8=; b=b3yfgYYgyZo0VrsTyTiBA2nUwFMwNHuXRvovBbwK5CocXNDChqLU0/dXHl3BSE0EX0 x4m/b6l0+11mzhEyNacnzB0PlS0fKXCyIzj12LrUl9L/sLBaR2qB5DnN32kPtGSy00u7 RmOj+2Ij2pgsYrJQOuEiU+eiPx0mgpB12Ev6rLTERudO3TqWykPH9Ov3PQOhJ7g4BAjH /71/QIpXiMVGuunsvwLG7mDKliK/rKe7mZ23Ky0AsuAYI7orambWAJcIje+oudk9GhZR rOARk7RNcszh4xyukhMWGt6QDJ3AG717cQvg4u1DImNj30fgr4UQSG3dT2dAjMWj3qn7 3IMw== X-Gm-Message-State: AOAM533PXJqs0g5G8gkv2v96cnWCBnKrcsrS/RVmB9IqOI7GFLmkuRRb 4qdO+g4O09y2rSFK9cWkk5HbVFwNDuR3YThL X-Google-Smtp-Source: ABdhPJzaBwLNNLeeq/CWYTmbfPwFonV3vm91sth3nv6WMs87BZS/rsY/lVbGIWl9Mn0PqfdKPh6BgA== X-Received: by 2002:a05:6512:168b:: with SMTP id bu11mr3838928lfb.664.1642086092916; Thu, 13 Jan 2022 07:01:32 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v12 4/7] net/vmnet: implement host mode (vmnet-host) Date: Thu, 13 Jan 2022 18:01:10 +0300 Message-Id: <20220113150113.58437-5-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220113150113.58437-1-yaroshchuk2000@gmail.com> References: <20220113150113.58437-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::135 (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::135; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lf1-x135.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladislav Yaroshchuk , jasowang@redhat.com, phillip.ennen@gmail.com, armbru@redhat.com, r.bolshakov@yadro.com, phillip@axleos.com, akihiko.odaki@gmail.com, hsp.cat7@gmail.com, hello@adns.io, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1642086576898100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-host.c | 110 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 6 deletions(-) diff --git a/net/vmnet-host.c b/net/vmnet-host.c index 4a5ef99dc7..90430dcb1a 100644 --- a/net/vmnet-host.c +++ b/net/vmnet-host.c @@ -9,16 +9,114 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/uuid.h" #include "qapi/qapi-types-net.h" -#include "vmnet_int.h" -#include "clients.h" -#include "qemu/error-report.h" #include "qapi/error.h" +#include "clients.h" +#include "vmnet_int.h" =20 #include =20 +typedef struct VmnetHostState { + VmnetCommonState cs; + QemuUUID network_uuid; +} VmnetHostState; + +static xpc_object_t create_if_desc(const Netdev *netdev, + NetClientState *nc, + Error **errp) +{ + const NetdevVmnetHostOptions *options =3D &(netdev->u.vmnet_host); + + 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_MAX_ALLOWED >=3D MAC_OS_VERSION_11_0 + + VmnetCommonState *cs =3D DO_UPCAST(VmnetCommonState, nc, nc); + VmnetHostState *hs =3D DO_UPCAST(VmnetHostState, cs, cs); + + xpc_dictionary_set_bool( + if_desc, + vmnet_enable_isolation_key, + options->isolated + ); + + if (options->has_net_uuid) { + if (qemu_uuid_parse(options->net_uuid, &hs->network_uuid) < 0) { + error_setg(errp, "Invalid UUID provided in 'net-uuid'"); + } + + xpc_dictionary_set_uuid( + if_desc, + vmnet_network_identifier_key, + hs->network_uuid.data + ); + } +#else + if (options->has_isolated) { + error_setg(errp, + "vmnet-host.isolated feature is " + "unavailable: outdated vmnet.framework API"); + } + + if (options->has_net_uuid) { + error_setg(errp, + "vmnet-host.net-uuid feature is " + "unavailable: outdated vmnet.framework API"); + } +#endif + + if (options->has_start_address || + options->has_end_address || + options->has_subnet_mask) { + + if (options->has_start_address && + options->has_end_address && + options->has_subnet_mask) { + + xpc_dictionary_set_string(if_desc, + vmnet_start_address_key, + options->start_address); + xpc_dictionary_set_string(if_desc, + vmnet_end_address_key, + options->end_address); + xpc_dictionary_set_string(if_desc, + vmnet_subnet_mask_key, + options->subnet_mask); + } else { + error_setg( + errp, + "'start-address', 'end-address', 'subnet-mask' " + "should be provided together" + ); + } + } + + return if_desc; +} + +static NetClientInfo net_vmnet_host_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_HOST, + .size =3D sizeof(VmnetHostState), + .receive =3D vmnet_receive_common, + .cleanup =3D vmnet_cleanup_common, +}; + int net_init_vmnet_host(const Netdev *netdev, const char *name, - NetClientState *peer, Error **errp) { - error_setg(errp, "vmnet-host is not implemented yet"); - return -1; + NetClientState *peer, Error **errp) +{ + NetClientState *nc; + xpc_object_t if_desc; + + nc =3D qemu_new_net_client(&net_vmnet_host_info, + peer, "vmnet-host", name); + if_desc =3D create_if_desc(netdev, nc, errp); + return vmnet_if_create(nc, if_desc, errp, NULL); } --=20 2.23.0