From nobody Mon Feb 9 15:53:04 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1744092899; cv=none; d=zohomail.com; s=zohoarc; b=njfOtnT13M5srGgB402CncaOxKcpNJ04AJ9y8+QrgYPzMHIRXrmT+a8C6Njvdlq1uGY3t8aW2mKfCjzBKIFGrvSL6cuKYQc/2W2l/x5ZltN9ph9OM5hOXlfJ7164qv8R2QPKgi7fOeoWMcp7ZT+G4rw7X151dbJ5iRTma4GY+e0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744092899; 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=CDklKuC5L3JF0nZoxxdQAyPqUBGCqrBeyCpp179htLk=; b=PUp9WbP4jIqq4TNooefE6I35X0ETKJftZI0+d6l/Ho9YvD1GlAO8+qyrI2JgeurVAYI0G75/qFD43LOyjzCQhCB8H/KlDPM+WZwTiYTj9GURq/GijTK+dD8UQpSGFyLYiV7nv1n/UJOeU3X5z7ngRWYZIhks/+rBlHQVJQeatQs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17440928999621010.2508870791949; Mon, 7 Apr 2025 23:14:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u22Da-0007Cu-FB; Tue, 08 Apr 2025 02:13:54 -0400 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 1u22DX-0007BZ-Ip for qemu-devel@nongnu.org; Tue, 08 Apr 2025 02:13:51 -0400 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 1u22DV-0001wE-7g for qemu-devel@nongnu.org; Tue, 08 Apr 2025 02:13:50 -0400 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-653-ZrCQxjzUODG19RUkM-lmTg-1; Tue, 08 Apr 2025 02:13:41 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 CFF4E19560B8 for ; Tue, 8 Apr 2025 06:13:39 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.41]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E104C180AF7C; Tue, 8 Apr 2025 06:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744092827; 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=CDklKuC5L3JF0nZoxxdQAyPqUBGCqrBeyCpp179htLk=; b=g3hF7zMusJ5DmOfiR3fuTVsD3yEZT8qaNtNCTFCQgIEQ8GUyT5k7dUuQRAtkuz/93OwmVX ua4t1VDJ5dHThJ5X+39eiVNofV2fVrpBJNi+vm4DKD8g3b7ipBjCTOHg/fLqckarfS+oKt g56KgnFkZj7LzlL53kNqfeSdRhf6wNE= X-MC-Unique: ZrCQxjzUODG19RUkM-lmTg-1 X-Mimecast-MFC-AGG-ID: ZrCQxjzUODG19RUkM-lmTg_1744092820 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v6 1/4] vhost_vdpa : Add a new parameter to enable check mac address Date: Tue, 8 Apr 2025 14:12:43 +0800 Message-ID: <20250408061327.2590372-2-lulu@redhat.com> In-Reply-To: <20250408061327.2590372-1-lulu@redhat.com> References: <20250408061327.2590372-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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.32, 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_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: 1744092900946019100 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 7ca8b46eee..ba1da31741 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -1870,6 +1870,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) { @@ -1882,6 +1884,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 310cc4fd19..a5c70d1df8 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 15:53:04 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1744092884; cv=none; d=zohomail.com; s=zohoarc; b=kg9eoUaJiKxQssI2lXkSSiEMUK06IWoSrAYTefK+/cba3ZG49M182/g3gkn+vfVMM+OEXzsFboYOLGyydaoSnm2G+ej1RQfBkEQ5UCA7q/8farCWaJR5KhA4P/VyQqLVmMOyXxeA453tLZu9/U6+t5OSmobe0a2kKYHE0JkPAyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744092884; 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=NLjF1iN1UpW3TqnujNqRsnMeCWMXGCyRQljHuUDZUKI=; b=jNLZdwZTwyM8zfOmCSrU0WoXJZKk9QV1sYaMRujo5thGEPxcjTLFsMysuJ1KvaFx89rtPuL4TA03W9+u6pliYnDwVO6ZfFSPSERR9VOOEGz0hfziGR4N8rn0LsMnqu1ivTrw8kGDeIJwZ2gty7lWDWAPbCa8y/FeK5U5v+OryRI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1744092884352276.72328875329356; Mon, 7 Apr 2025 23:14:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u22Db-0007Di-F4; Tue, 08 Apr 2025 02:13:56 -0400 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 1u22DX-0007BY-IE for qemu-devel@nongnu.org; Tue, 08 Apr 2025 02:13:51 -0400 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 1u22DT-0001vv-FS for qemu-devel@nongnu.org; Tue, 08 Apr 2025 02:13:50 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-PCATy8tDN_myHsMTmCKhlg-1; Tue, 08 Apr 2025 02:13:43 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DD5CC1800361 for ; Tue, 8 Apr 2025 06:13:42 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.41]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6E5D2180B486; Tue, 8 Apr 2025 06:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744092825; 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=NLjF1iN1UpW3TqnujNqRsnMeCWMXGCyRQljHuUDZUKI=; b=hV/YOTHYq58MXT/KAnhQlOEiuSgZC+CN4nR/7GkBxOzkrQM5rgdIPy5OmTMPWmrundvnXX tbT5FiGyrDDIvJfebHlsGFAABvY9sgj14NNeIuSiiiQ6GHu/9hrt2VjOZ7zySVFybKMMGC 5sab461EYr5/RXhnonxZdC/UDbx8Bwo= X-MC-Unique: PCATy8tDN_myHsMTmCKhlg-1 X-Mimecast-MFC-AGG-ID: PCATy8tDN_myHsMTmCKhlg_1744092823 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v6 2/4] virtio_net: Add the check for vdpa's mac address Date: Tue, 8 Apr 2025 14:12:44 +0800 Message-ID: <20250408061327.2590372-3-lulu@redhat.com> In-Reply-To: <20250408061327.2590372-1-lulu@redhat.com> References: <20250408061327.2590372-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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.32, 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_H5=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: 1744092885048019000 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 --- 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 340c6b6422..94ee21d1fc 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3751,12 +3751,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: */ =20 + if (memcmp(&hwcfg.mac, &zero, sizeof(MACAddr)) !=3D 0) { + /* + * 1. The hardware MAC address is the same as the QEMU command lin= e MAC + * address, and both of them are not 0. + */ + if ((memcmp(&hwcfg.mac, cmdline_mac, sizeof(MACAddr)) =3D=3D 0)) { + return true; + } + } + error_setg(errp, + "vDPA device's MAC address %02x:%02x:%02x:%02x:%02x:%02x " + "is not the same as the QEMU command line MAC address " + "%02x:%02x:%02x:%02x:%02x:%02x," + "Initialization failed.", + 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) { @@ -3864,6 +3895,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; @@ -3910,7 +3942,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 15:53:04 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1744092883; cv=none; d=zohomail.com; s=zohoarc; b=YfYFlc5k7kF79uQOsnxSZtr6v5Oer5LHFZ9XVAVUPOSqd3LCAKrGHLsbMPQ717YdW/Gvgo3gT5HLoBBTora3zujZEoDu6nbrRaOfhHMlIGQs1+jZqusyQL3tXEZlZdErLtSnQ5ZbWOmZ9Rs+8ZOOEQ001YdkJ3Kwt/5ds2oQ+Nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744092883; 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=rfxzveTaXJtWwFKEeVvLZ0x0ccZfdKdEW4mEoLLWsSA=; b=Trv3lelIEs+w5SIpbqINir6P7SfYIRcC/+kXQN+YOFW/bzYZMNTBSXyIpZTbLIGNwIAnJdneaacsmdlRmtrPOwS178DC0t+wbsBCtPE7qoadN2J5oZEad/KS5Nw6gx4Y7YkZah7i5pwTDirLMwDVIJH2/dP2ZOQGf+7j/L6g4rM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1744092883931771.6733451318918; Mon, 7 Apr 2025 23:14:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u22Df-0007Ew-A4; Tue, 08 Apr 2025 02:13:59 -0400 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 1u22DY-0007CG-R4 for qemu-devel@nongnu.org; Tue, 08 Apr 2025 02:13:52 -0400 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 1u22DX-0001wa-As for qemu-devel@nongnu.org; Tue, 08 Apr 2025 02:13:52 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-669-KFaZtCBIOtSX9-zSRxHXSw-1; Tue, 08 Apr 2025 02:13:47 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 19A57180025A for ; Tue, 8 Apr 2025 06:13:47 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.41]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4FC75180B486; Tue, 8 Apr 2025 06:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744092829; 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=rfxzveTaXJtWwFKEeVvLZ0x0ccZfdKdEW4mEoLLWsSA=; b=Tmb8tn/mHTinfoZd/uHVZTe0PuEeaKm9kFjgEjMZjj4095OdC0QmJF+EP3tGViiUDeqHCM 2h7IAc3Y2Zsr0QR/4+GCCmQ5jP/JZTmn5gGoUU7/W+C8esv9Pmac0cWCUc3rOHgQN8aEZ3 pi1jzB/2zBRcLyxt6Uc6USFsQXQ1I0s= X-MC-Unique: KFaZtCBIOtSX9-zSRxHXSw-1 X-Mimecast-MFC-AGG-ID: KFaZtCBIOtSX9-zSRxHXSw_1744092827 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v6 3/4] virtio_net: Add second acceptable configuration for MAC setup Date: Tue, 8 Apr 2025 14:12:45 +0800 Message-ID: <20250408061327.2590372-4-lulu@redhat.com> In-Reply-To: <20250408061327.2590372-1-lulu@redhat.com> References: <20250408061327.2590372-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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.32, 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_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: 1744092884947019000 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 94ee21d1fc..45b63eb9de 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3769,6 +3769,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, we use the hardware MAC address overwrite + * the QEMU command line address saved in VirtIONet->mac[0]. + * In the following process, QEMU will use this MAC address + * in VirtIONet to complete the initialization. + */ + 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; + } } error_setg(errp, "vDPA device's MAC address %02x:%02x:%02x:%02x:%02x:%02x " --=20 2.45.0 From nobody Mon Feb 9 15:53:04 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1744092897; cv=none; d=zohomail.com; s=zohoarc; b=YB9EEXFoNmTS6ETb0rlWlVzv5NsrLsQhvb8J3gdOV48MIg8qSmjnI2AwfQ1EkyAHe8v0zUelidcJPTIULGQzdlp+Qza1neLEr4m5YQ/COoE+4UBtHDSZ6rOB82xAP3ful40rNp2r2ZCbnDoctS2L1R5z52ihGZWK0hER5dE6Nuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744092897; 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=cPR42kA0dDxhaaC2cfyBVWCZvGqQEyUACJjLYf9+oxA=; b=JJgx/0omNZFAXE9ff/vrej2ZLVouuZK468MmBX/iY+IyjrDZIuOnU+9w+Bw7+ViWrfNuZUvLkTIvHcCJVo0DZMOdbWlxR9UdVEHf00+ZmmdxHHsuHyEnJ3XRCxzHuh6zWCa4MKn9OjkT9cOYlKuR01OKbXCq2nnX1r5PVE7so/I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17440928973321006.7494534288813; Mon, 7 Apr 2025 23:14:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u22EE-0007kt-UL; Tue, 08 Apr 2025 02:14:34 -0400 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 1u22Dy-0007WV-QE for qemu-devel@nongnu.org; Tue, 08 Apr 2025 02:14:23 -0400 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 1u22Dx-0001yV-4N for qemu-devel@nongnu.org; Tue, 08 Apr 2025 02:14:18 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-JIc2fgVPMB2AMgcHB-U2DQ-1; Tue, 08 Apr 2025 02:14:13 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A4112180035E for ; Tue, 8 Apr 2025 06:14:12 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.41]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BAA0A180AF7C; Tue, 8 Apr 2025 06:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744092854; 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=cPR42kA0dDxhaaC2cfyBVWCZvGqQEyUACJjLYf9+oxA=; b=QNROP2lGHHyTzBinel9zcBQATxYVwXnyPtINMhFOlzej8ayUfUByFCKIFObU3cMaOfxxBk yKtHr/HhcTm98IHi9o8JdqLcHbZpX1jBmoNFvFAjygaYUHhjCjoI3wZu+iSTTTth9qfhcr pTbrO66wZCfrRxBFWF19+i7TaJ72GtY= X-MC-Unique: JIc2fgVPMB2AMgcHB-U2DQ-1 X-Mimecast-MFC-AGG-ID: JIc2fgVPMB2AMgcHB-U2DQ_1744092852 From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH v6 4/4] virtio_net: Add third acceptable configuration for MAC setup. Date: Tue, 8 Apr 2025 14:12:46 +0800 Message-ID: <20250408061327.2590372-5-lulu@redhat.com> In-Reply-To: <20250408061327.2590372-1-lulu@redhat.com> References: <20250408061327.2590372-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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.32, 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_H5=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: 1744092898801019000 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 45b63eb9de..6c6bd116f7 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3784,6 +3784,18 @@ 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 generates a random MAC address and + * uses CVQ/set_config to assign it to the 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; + } error_setg(errp, "vDPA device's MAC address %02x:%02x:%02x:%02x:%02x:%02x " "is not the same as the QEMU command line MAC address " --=20 2.45.0