From nobody Mon Feb 9 09:34:20 2026 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 16388092524211009.4741531133594; Mon, 6 Dec 2021 08:47:32 -0800 (PST) Received: from localhost ([::1]:40874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muH9H-0003Lg-A3 for importer@patchew.org; Mon, 06 Dec 2021 11:47:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muH4c-0004hC-5b for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:42 -0500 Received: from [2a00:1450:4864:20::231] (port=41529 helo=mail-lj1-x231.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muH4a-00074v-9w for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:41 -0500 Received: by mail-lj1-x231.google.com with SMTP id d11so22071462ljg.8 for ; Mon, 06 Dec 2021 08:42:39 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id e11sm1401809lfq.65.2021.12.06.08.42.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Dec 2021 08:42:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jtMW004Au7CrDB93vS6nalJFyRXcqbDatoHFcN9NphY=; b=G/ONeS0iCk8QSf0NMvvxod6cpPM6dnqcHLe/r7ndquAZG1MiPfWI/1TXgGh7tXoq4J cn5IDSzngZaKPj4wdzJS71JPQVuiUbCT0guiNASB6y2/rB+ru0p8WmEVdnv5PGFbzBsN RliWBhriPdLYMFWaDItQFTg3Q++2CfIuaKv1N2LwytccmsDFLvcjDxSFAmLZUEHCh8Bx EWe8OCqQ/ONS3HVA0piiPhWMb0MPf/I20kW4h2eXXyuLikX9xprqOrlYJaWpxur95PDz /Ah5WeaFw0spHSMiIrAX9vGgA3yLU3SAZvTUb02t43qT+8e0WSYnwGshnunCRcvh7gXQ Aulg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jtMW004Au7CrDB93vS6nalJFyRXcqbDatoHFcN9NphY=; b=THbdKZLocZhpFuQ1c38gu9YhJo4swKHsTxpBe1NR97NLGBOrYyI693J6Jrn3+GgDa5 1J95NwWBOwlSdpw4kaXAd3FiZG6Qgj2fYwiTYdVYotpxy9n5jsZkAdDpmgkTkz1WmGRk 4Dru1/nV/X2OsNPYaCWv8Byhx6S2eyM5bgo2M1+WQADzKzdHd3merkW1qDsLEfP057Lp +J1I50gAHWf96ga21YXQGgDQJ+994ltl6DV3v+6J8ah/6Wc2eyMvCURRdnWX5MznEqkY 7CDhblEHscp0NiYJj9vGo5P3880743YRn+K32xA+cqjaj7xC1pI+wu6IR7Q+BvDI9tHQ 4VWg== X-Gm-Message-State: AOAM530UocsbIDJta/h8o1SCES4TyhulDBjSOATPcNu8/LseNCDu5oz+ 9B8LUnlAdCps3ajbXjFP5XkMh+hI46r3IZSi X-Google-Smtp-Source: ABdhPJw2eBPZ6vTozPWOEkDRPMFYZYtrv3YpiLSPPHOxAA0Gtkj+mJzav+A8pJBdsPix+ii3n4saHg== X-Received: by 2002:a2e:b894:: with SMTP id r20mr38488994ljp.304.1638808958123; Mon, 06 Dec 2021 08:42:38 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v6 4/6] net/vmnet: implement host mode (vmnet-host) Date: Mon, 6 Dec 2021 19:42:20 +0300 Message-Id: <20211206164222.11027-5-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211206164222.11027-1-yaroshchuk2000@gmail.com> References: <20211206164222.11027-1-yaroshchuk2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::231 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lj1-x231.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladislav Yaroshchuk , jasowang@redhat.com, phillip.ennen@gmail.com, armbru@redhat.com, r.bolshakov@yadro.com, phillip@axleos.com, akihiko.odaki@gmail.com, hsp.cat7@gmail.com, hello@adns.io, eblake@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1638809254058100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladislav Yaroshchuk --- net/vmnet-host.c | 93 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 6 deletions(-) diff --git a/net/vmnet-host.c b/net/vmnet-host.c index 4a5ef99dc7..9c2e760ed1 100644 --- a/net/vmnet-host.c +++ b/net/vmnet-host.c @@ -9,16 +9,97 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/uuid.h" #include "qapi/qapi-types-net.h" -#include "vmnet_int.h" -#include "clients.h" -#include "qemu/error-report.h" #include "qapi/error.h" +#include "clients.h" +#include "vmnet_int.h" =20 #include =20 +typedef struct VmnetHostState { + VmnetCommonState cs; + QemuUUID network_uuid; +} VmnetHostState; + +static xpc_object_t create_if_desc(const Netdev *netdev, + NetClientState *nc, + Error **errp) +{ + const NetdevVmnetHostOptions *options =3D &(netdev->u.vmnet_host); + VmnetCommonState *cs =3D DO_UPCAST(VmnetCommonState, nc, nc); + VmnetHostState *hs =3D DO_UPCAST(VmnetHostState, cs, cs); + + xpc_object_t if_desc =3D xpc_dictionary_create(NULL, NULL, 0); + + xpc_dictionary_set_uint64( + if_desc, + vmnet_operation_mode_key, + VMNET_HOST_MODE + ); + + xpc_dictionary_set_bool( + if_desc, + vmnet_enable_isolation_key, + options->isolated + ); + + if (options->has_net_uuid) { + if (qemu_uuid_parse(options->net_uuid, &hs->network_uuid) < 0) { + error_setg(errp, "Invalid UUID provided in 'net-uuid'"); + } + + xpc_dictionary_set_uuid( + if_desc, + vmnet_network_identifier_key, + hs->network_uuid.data + ); + } + + if (options->has_start_address || + options->has_end_address || + options->has_subnet_mask) { + + if (options->has_start_address && + options->has_end_address && + options->has_subnet_mask) { + + xpc_dictionary_set_string(if_desc, + vmnet_start_address_key, + options->start_address); + xpc_dictionary_set_string(if_desc, + vmnet_end_address_key, + options->end_address); + xpc_dictionary_set_string(if_desc, + vmnet_subnet_mask_key, + options->subnet_mask); + } else { + error_setg( + errp, + "'start-address', 'end-address', 'subnet_mask' " + "should be provided together" + ); + } + } + + return if_desc; +} + +static NetClientInfo net_vmnet_host_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_HOST, + .size =3D sizeof(VmnetHostState), + .receive =3D vmnet_receive_common, + .cleanup =3D vmnet_cleanup_common, +}; + int net_init_vmnet_host(const Netdev *netdev, const char *name, - NetClientState *peer, Error **errp) { - error_setg(errp, "vmnet-host is not implemented yet"); - return -1; + NetClientState *peer, Error **errp) +{ + NetClientState *nc; + xpc_object_t if_desc; + + nc =3D qemu_new_net_client(&net_vmnet_host_info, + peer, "vmnet-host", name); + if_desc =3D create_if_desc(netdev, nc, errp); + return vmnet_if_create(nc, if_desc, errp, NULL); } --=20 2.23.0