From nobody Mon Feb 9 18:02:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731134027; cv=none; d=zohomail.com; s=zohoarc; b=GkW3MrllS8qhGI9DKbNeIcPSZhYlZ7VyiFO9KV6uT7cMod1g3K1CGAYOc7yMFxBNvCrUx3BB/KtJjnFG1yKv8eswg35gmsHmGVCuv36l741VWq5BnbPT88BY+YeccfV00lIVrJT/9jed7Mv8QhEoMHUN1aCk57JSZ1quwCwPeck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731134027; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=C23bQJG+w7eBnG9DkbQIapfoPSgTaqpmSilfkoSHNVQ=; b=IxzydY2hNnj0vm5OkmBbVXjgdbsfUdKgl8QL4JQtbYgq4hKV36JufMDzVzmO6W4rmR0pwt6ip6EQDb60feELZToBAcxuWvcNVl2T4bULNHrsh/97/JLYZ1m4Z1TLfIeYWsMKcL3KWybDjJtbCFxIpwk79JUZinNQ9l1MgrWZrF4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731134027051367.4613121296193; Fri, 8 Nov 2024 22:33:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9f1s-0007Xv-45; Sat, 09 Nov 2024 01:33:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f1q-0007XI-5Q for qemu-devel@nongnu.org; Sat, 09 Nov 2024 01:33:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f1o-0001TS-Nd for qemu-devel@nongnu.org; Sat, 09 Nov 2024 01:33:01 -0500 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-Qi-9dOElNFKC7gi3VZ44Xg-1; Sat, 09 Nov 2024 01:32:55 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4BDE119560AE for ; Sat, 9 Nov 2024 06:32:54 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 85291195E480; Sat, 9 Nov 2024 06:32:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731133979; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C23bQJG+w7eBnG9DkbQIapfoPSgTaqpmSilfkoSHNVQ=; b=LvclEtJTpcIrh+50kU2frE2Vb1J7EV8ePD/Hs5Gje2tWaOTGlKfbXu8kpfA4e+8oxRaZaW baZWvM6glLNaw9yJA+SG8vfABGAEayzEs0K3/sYyHqZZBRuoE30XH61jrIDVeHnWItARRP pA9gypkcaE23xy4NbfLetVEcYV788tA= X-MC-Unique: Qi-9dOElNFKC7gi3VZ44Xg-1 X-Mimecast-MFC-AGG-ID: Qi-9dOElNFKC7gi3VZ44Xg From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v4 1/4] vhost_vdpa : Add a new parameter to enable check mac address Date: Sat, 9 Nov 2024 14:31:23 +0800 Message-ID: <20241109063241.1039433-2-lulu@redhat.com> In-Reply-To: <20241109063241.1039433-1-lulu@redhat.com> References: <20241109063241.1039433-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=170.10.133.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1731134027685116600 Content-Type: text/plain; charset="utf-8" When using a VDPA device, it's important to ensure that the MAC address is correctly set. Add a new parameter in qemu cmdline to enable this check, default value is false The usage is: .... -netdev type=3Dvhost-vdpa,vhostdev=3D/dev/vhost-vdpa-0,id=3Dvhost-vdpa0,che= ck-mac=3Dtrue\ -device virtio-net-pci,netdev=3Dvhost-vdpa0\ .... Signed-off-by: Cindy Lu --- include/net/net.h | 1 + net/vhost-vdpa.c | 4 ++++ qapi/net.json | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index cdd5b109b0..fac1951b6e 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -112,6 +112,7 @@ struct NetClientState { bool is_netdev; bool do_not_pad; /* do not pad to the minimum ethernet frame length */ bool is_datapath; + bool check_mac; QTAILQ_HEAD(, NetFilterState) filters; }; =20 diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 231b45246c..4826b2da97 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -1859,6 +1859,8 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, iova_range, features, shared, errp); if (!ncs[i]) goto err; + + ncs[i]->check_mac =3D opts->check_mac; } =20 if (has_cvq) { @@ -1871,6 +1873,8 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, errp); if (!nc) goto err; + + nc->check_mac =3D opts->check_mac; } =20 return 0; diff --git a/qapi/net.json b/qapi/net.json index 2739a2f423..9a46aa61bd 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -510,6 +510,10 @@ # @queues: number of queues to be created for multiqueue vhost-vdpa # (default: 1) # +# @check-mac: Enable the check for whether the device's MAC address +# and the MAC in QEMU command line are acceptable for booting. +# (default: false) +# # @x-svq: Start device with (experimental) shadow virtqueue. (Since # 7.1) (default: false) # @@ -524,6 +528,7 @@ '*vhostdev': 'str', '*vhostfd': 'str', '*queues': 'int', + '*check-mac': 'bool', '*x-svq': {'type': 'bool', 'features' : [ 'unstable'] } } } =20 ## --=20 2.45.0 From nobody Mon Feb 9 18:02:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731134046; cv=none; d=zohomail.com; s=zohoarc; b=UlXnkVi+GeEi96pQfxq2xahl1jMydI5hVoQ7wqBIs1SensGquozy7xkGlsKmYBTB1j4gTGhi4/wm2fhS6Wi1oHpb5mzyCuCi925qHAGss8CEvjDk/rE9eSXmdJMmAk5yhxPYI5LQCfomqO+fLSuJmzovjXpyiZW4GRgegijV0+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731134046; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Y8z9wo9GjSCi2vpRA4wJX7bcmkka5LZmLGi5vdzojx0=; b=EFW67065RscULvFxAEANx7IGFn6HrLbZ7RQnSnq3fxYCdNxWOYn7hlGbR7tZzzhALUeJDWvbEmMtwXgz9MV2qmm6APt9ni8o579kW13O5+fhnIwUgMWi9WcRni7R0zwrtk5pMK2CaftB/Y4M17K3rEbpJz6aeDnEtDFf6wZTuDA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731134046400887.6341234897034; Fri, 8 Nov 2024 22:34:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9f1t-0007YX-8T; Sat, 09 Nov 2024 01:33:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f1r-0007Xe-Ty for qemu-devel@nongnu.org; Sat, 09 Nov 2024 01:33:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f1q-0001TX-BR for qemu-devel@nongnu.org; Sat, 09 Nov 2024 01:33:03 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-522-bLe7SrhCMWKHmFaF7siUfw-1; Sat, 09 Nov 2024 01:32:59 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A1E3F1956096 for ; Sat, 9 Nov 2024 06:32:58 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 23A47195E480; Sat, 9 Nov 2024 06:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731133980; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y8z9wo9GjSCi2vpRA4wJX7bcmkka5LZmLGi5vdzojx0=; b=bOtb/O4yItMmOwKNnrzRRl/DhGxds0127NqnoY0e2w+hhK5gGI7oXIFZHzPNHINZVpf3rk PIvSPjIj7ZUrsIYFHQoNy5tPfnxkJfSce3oX+sfbaDoApYR3zLiiKh//OOUQI3FAUygqlr C3JQD8wm2Xa8Ns0U8Vh5SubmycfmQ3k= X-MC-Unique: bLe7SrhCMWKHmFaF7siUfw-1 X-Mimecast-MFC-AGG-ID: bLe7SrhCMWKHmFaF7siUfw From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v4 2/4] virtio_net: Add the check for vdpa's mac address Date: Sat, 9 Nov 2024 14:31:24 +0800 Message-ID: <20241109063241.1039433-3-lulu@redhat.com> In-Reply-To: <20241109063241.1039433-1-lulu@redhat.com> References: <20241109063241.1039433-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=170.10.133.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1731134047771116600 Content-Type: text/plain; charset="utf-8" When using a VDPA device, it is important to ensure that the MAC address is correctly set. The MAC address in the hardware should match the MAC address from the QEMU command line. This is a recommended configuration and will allow the system to boot. Signed-off-by: Cindy Lu Tested-by: Lei Yang --- hw/net/virtio-net.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f2104ed364..01cac20d92 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3594,12 +3594,43 @@ static bool failover_hide_primary_device(DeviceList= ener *listener, /* failover_primary_hidden is set during feature negotiation */ return qatomic_read(&n->failover_primary_hidden); } +static bool virtio_net_check_vdpa_mac(NetClientState *nc, VirtIONet *n, + MACAddr *cmdline_mac, Error **errp) +{ + struct virtio_net_config hwcfg =3D {}; + static const MACAddr zero =3D { .a =3D { 0, 0, 0, 0, 0, 0 } }; + + vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&hwcfg, ETH_A= LEN); + + /*For VDPA device following situations are acceptable:*/ + + if (memcmp(&hwcfg.mac, &zero, sizeof(MACAddr)) !=3D 0) { + /* + * 1.The hardware MAC address is the same as the QEMU command line= MAC + * address, and both of them are not 0. + */ + if ((memcmp(&hwcfg.mac, cmdline_mac, sizeof(MACAddr)) =3D=3D 0)) { + return true; + } + } =20 + error_setg(errp, + "vDPA device's mac %02x:%02x:%02x:%02x:%02x:%02x" + "not same with the cmdline's mac %02x:%02x:%02x:%02x:%02x:%= 02x," + "Please check.", + hwcfg.mac[0], hwcfg.mac[1], hwcfg.mac[2], hwcfg.mac[3], + hwcfg.mac[4], hwcfg.mac[5], cmdline_mac->a[0], cmdline_mac-= >a[1], + cmdline_mac->a[2], cmdline_mac->a[3], cmdline_mac->a[4], + cmdline_mac->a[5]); + + return false; +} static void virtio_net_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIONet *n =3D VIRTIO_NET(dev); NetClientState *nc; + MACAddr macaddr_cmdline; int i; =20 if (n->net_conf.mtu) { @@ -3707,6 +3738,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) virtio_net_add_queue(n, 0); =20 n->ctrl_vq =3D virtio_add_queue(vdev, 64, virtio_net_handle_ctrl); + memcpy(&macaddr_cmdline, &n->nic_conf.macaddr, sizeof(n->mac)); qemu_macaddr_default_if_unset(&n->nic_conf.macaddr); memcpy(&n->mac[0], &n->nic_conf.macaddr, sizeof(n->mac)); n->status =3D VIRTIO_NET_S_LINK_UP; @@ -3753,7 +3785,13 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) nc =3D qemu_get_queue(n->nic); nc->rxfilter_notify_enabled =3D 1; =20 - if (nc->peer && nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDP= A) { + if (nc->peer && (nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_V= DPA)) { + if (nc->peer->check_mac) { + if (!virtio_net_check_vdpa_mac(nc, n, &macaddr_cmdline, errp))= { + virtio_cleanup(vdev); + return; + } + } struct virtio_net_config netcfg =3D {}; memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN); vhost_net_set_config(get_vhost_net(nc->peer), --=20 2.45.0 From nobody Mon Feb 9 18:02:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731134006; cv=none; d=zohomail.com; s=zohoarc; b=Y9F8tGEo7kkAGU0FnBLrtepShz4v7K1osxqs282Rd4dro3cPCPodLNbU38frwA33lkte49OjE+YPf5zx6fY/648MPeqZmZfY+9lL0q1BViRFrRq/QUhgmAXk3ezX6W+L+arH2KwQG+e2DdwmdJtPLWA9t0chpVAoSVuAuflbIbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731134006; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=A4VNHmUiIa21a929R2Y1nHP51u+LIhF20n26bB3YK0w=; b=GzqxMfHcryrJAN4f62AWj72apExSPmJKSfYZD644vd9qhOnEbxqc1+y8U4dYyXKx9+pn04h2DZH8L0k3nIvNG2dWN7nWNhnf9nepJMPzudHDJzQcPdlg8/lHRL0Lx1NNX7bz6cSkYt2PRMnHRZDTPDBNgPf4atDv/NP82Aoah5g= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731134006770670.389006821957; Fri, 8 Nov 2024 22:33:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9f1w-0007Yj-KU; Sat, 09 Nov 2024 01:33:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f1v-0007Yb-QP for qemu-devel@nongnu.org; Sat, 09 Nov 2024 01:33:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f1u-0001U0-GJ for qemu-devel@nongnu.org; Sat, 09 Nov 2024 01:33:07 -0500 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-HRzcUnunMX63lQk5fZDv-g-1; Sat, 09 Nov 2024 01:33:04 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E81841955EE9 for ; Sat, 9 Nov 2024 06:33:02 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7A13A195E480; Sat, 9 Nov 2024 06:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731133986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A4VNHmUiIa21a929R2Y1nHP51u+LIhF20n26bB3YK0w=; b=NUWSuPXXokBGG0vqSwcNFn0ke+LrGt55InsoIoB4sjWVkfJMRgKSQdRnh8R4wArW7vlErF cSZw9xXV9S5EtPNQaaWjuhm3Q8TRkAouNS1+PxpuEbQIEVMKf6k0bXuUaKhXE17WnBoMwq qX3jowAVRb9cN1tLoLrxxAaASeccXrs= X-MC-Unique: HRzcUnunMX63lQk5fZDv-g-1 X-Mimecast-MFC-AGG-ID: HRzcUnunMX63lQk5fZDv-g From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v4 3/4] virtio_net: Add second acceptable configuration for MAC setup Date: Sat, 9 Nov 2024 14:31:25 +0800 Message-ID: <20241109063241.1039433-4-lulu@redhat.com> In-Reply-To: <20241109063241.1039433-1-lulu@redhat.com> References: <20241109063241.1039433-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=170.10.133.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1731134007708116600 Content-Type: text/plain; charset="utf-8" For VDPA devices, Allow configurations where the hardware MAC address is non-zero while the MAC address in the QEMU command line is zero. Signed-off-by: Cindy Lu --- hw/net/virtio-net.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 01cac20d92..f74aa4f8db 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3612,6 +3612,20 @@ static bool virtio_net_check_vdpa_mac(NetClientState= *nc, VirtIONet *n, if ((memcmp(&hwcfg.mac, cmdline_mac, sizeof(MACAddr)) =3D=3D 0)) { return true; } + /* + * 2.The hardware MAC address is NOT 0, + * and the MAC address in the QEMU command line is 0. + * In this situation, Here we use the hardware MAC address overwr= ite + * the QEMU command line address(is 0) in VirtIONet->mac[0]. + * in the follwoing process, QEMU will use this mac in VirtIONet = and + * finish the bring up + */ + if (memcmp(cmdline_mac, &zero, sizeof(MACAddr)) =3D=3D 0) { + /* overwrite the mac address with hardware address*/ + memcpy(&n->mac[0], &hwcfg.mac, sizeof(n->mac)); + memcpy(&n->nic_conf.macaddr, &hwcfg.mac, sizeof(n->mac)); + return true; + } } =20 error_setg(errp, --=20 2.45.0 From nobody Mon Feb 9 18:02:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1731134042; cv=none; d=zohomail.com; s=zohoarc; b=Jnk/SlIt16VJ+UgQQlkk2ttAvfsnkjD5xiWE8ju7Fd1qWYUSXalhFyLS4FG75qmBfFCvpuJYplaVzMLsSUED5jbVxV/tLNGwAvJ+MF1JAZOSj5lUwaTSipW3TWvk46oF6FbQz34fE/evjkzUyWUfF+sabQMoKJ6rmaRikiat/+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731134042; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=0tiPZPS6Shh5GDPNeFDtpssQLVwX/B4YuknKiDeV/Uc=; b=TdIytTbzRvFW2wlLM4dCwboj1aEUl3oez9w4DkjEFrXO2lIpECcJPgt3K4/yCButGSgpY64Ew77UYJKHBlfAuUv9M8djVOk4ej2anugzathS7FZzT7zLsENBwBIVo6M86jaT8DbxhME0NZjaMZQiYsmTw5bLgZZ+iSGr3qfN1p0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731134042375417.1563749162283; Fri, 8 Nov 2024 22:34:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9f2N-00086Y-Ch; Sat, 09 Nov 2024 01:33:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f2L-000829-AE for qemu-devel@nongnu.org; Sat, 09 Nov 2024 01:33:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f2J-0001Uw-VZ for qemu-devel@nongnu.org; Sat, 09 Nov 2024 01:33:33 -0500 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-KxE2G5asOoixBymEnIfiTA-1; Sat, 09 Nov 2024 01:33:29 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CC2F519560AD for ; Sat, 9 Nov 2024 06:33:28 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.21]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D310D300019E; Sat, 9 Nov 2024 06:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731134011; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0tiPZPS6Shh5GDPNeFDtpssQLVwX/B4YuknKiDeV/Uc=; b=fKSdM3wK6qZtlejA0NvbODGfOGo8KK30hm17mxfU1b7vr0md9gpZtZVczqtvzN8hb0K0j6 /iMEuI0FTw8voLEa13VsddNNMgI2qc1dYh3OKecHf0kG+52EVr5u33w80minBsyFJYuFCW S/yodCK496MjK4P81J9NMa1h4jEtjRU= X-MC-Unique: KxE2G5asOoixBymEnIfiTA-1 X-Mimecast-MFC-AGG-ID: KxE2G5asOoixBymEnIfiTA From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v4 4/4] virtio_net: Add third acceptable configuration for MAC setup. Date: Sat, 9 Nov 2024 14:31:26 +0800 Message-ID: <20241109063241.1039433-5-lulu@redhat.com> In-Reply-To: <20241109063241.1039433-1-lulu@redhat.com> References: <20241109063241.1039433-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=lulu@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1731134044050116600 Content-Type: text/plain; charset="utf-8" For VDPA devices, Allow configurations where both the hardware MAC address and QEMU command line MAC address are zero. Signed-off-by: Cindy Lu --- hw/net/virtio-net.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f74aa4f8db..66f21f74f4 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3627,6 +3627,19 @@ static bool virtio_net_check_vdpa_mac(NetClientState= *nc, VirtIONet *n, return true; } } + /* + * 3.The hardware MAC address is 0, + * and the MAC address in the QEMU command line is also 0. + * In this situation, qemu will generate a random mac address + * QEMU will try to use CVQ/set_config to set this address to + * device + */ + if ((memcmp(&hwcfg.mac, &zero, sizeof(MACAddr)) =3D=3D 0) && + (memcmp(cmdline_mac, &zero, sizeof(MACAddr)) =3D=3D 0)) { + memcpy(&n->mac[0], &n->nic_conf.macaddr, sizeof(n->mac)); + + return true; + } =20 error_setg(errp, "vDPA device's mac %02x:%02x:%02x:%02x:%02x:%02x" --=20 2.45.0