From nobody Tue Jan 21 04:05:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1736647872224651.34281447188; Sat, 11 Jan 2025 18:11:12 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 416C7170C; Sat, 11 Jan 2025 21:11:11 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0837F16BB; Sat, 11 Jan 2025 21:10:48 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6AEC5168E; Sat, 11 Jan 2025 21:10:45 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id D7311168B for ; Sat, 11 Jan 2025 21:10:44 -0500 (EST) 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-683-wVm7MFGBO4yYUp9aiXUEiA-1; Sat, 11 Jan 2025 21:10:42 -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 0777519560A3 for ; Sun, 12 Jan 2025 02:10:42 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.80.69]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8FEA919560A3 for ; Sun, 12 Jan 2025 02:10:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736647844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=umjzeaRyb0Bx2G9n2HP0e+QqzwuH7Imz1o/wb9ACsGM=; b=hkrUI/EXRMWXdzQtFe6OSQ9x+rbXoIHxQ6xmzXVE0mDfyf4Z/zgq8YfnyLI7cy7ntVnOVR 4wzCkhbhkDsz3cUV3u2cnFsB9oF+WA3uNxsC2kSlR0TRlj1Uxsr+qDpF/nfRHdFN+Usx4v xRb6LIfZXNbXul4yB5/n4yUeBh3DzXg= X-MC-Unique: wVm7MFGBO4yYUp9aiXUEiA-1 X-Mimecast-MFC-AGG-ID: wVm7MFGBO4yYUp9aiXUEiA From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH] qemu: support vlan change for linux host bridge during update-device Date: Sat, 11 Jan 2025 21:10:40 -0500 Message-ID: <20250112021040.1551739-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: y_3xDXiOvlkNt4-A3z-J7Z9Q0ycu_pvjnrGHqobi_jk_1736647842 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: L4MCPAYFFAABGTPE3UYEKBT656EDKEJC X-Message-ID-Hash: L4MCPAYFFAABGTPE3UYEKBT656EDKEJC X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1736647873686019100 Content-Type: text/plain; charset="utf-8"; x-default="true" Since we previously only supported vlan tagging for interfaces connected to an OVS bridge [*], the code in qemuChangeNet() (used by the update-device API) assumed an interface with modified vlan config was on an OVS bridge, and would call the OVS-specific virNetDevOpenvswitchUpdateVlan(). Now that we support vlan tagging for interfaces connected to a standard Linux host bridge, we must check the type of connection and only call the OVS function when connected to an OVS bridge *both before and after the update*. Otherwise we just set the flag to re-connect to the bridge, which has the side effect of redoing the vlan setup. ([*] or an SRIOV VF assigned using VFIO, but we don't support *any runtime changes to that type of netdev so it's irrelevant here.) Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- I'm fine with this going in either before or after the 11.0.0 release (would prefer before since it is a bugfix), but if it's going into the release I'd rather it be included with RC2 rather than only in the final release. For that reason, if someone ACKs the patch and agrees that it's safe to go in, please push it for me (since Jiri will almost certainly tag RC2 before I'm conscious on Monday morning) src/qemu/qemu_hotplug.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index de0777d330..5a7e6c3b12 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4144,8 +4144,13 @@ qemuDomainChangeNet(virQEMUDriver *driver, * they don't apply to a particular type. */ =20 - if (!virNetDevVlanEqual(virDomainNetGetActualVlan(olddev), - virDomainNetGetActualVlan(newdev))) { + /* since attaching to a new bridge will re-do the vlan setup, + * we don't need to separately do that in the case that we're + * already switching to a different bridge + */ + if (!(needBridgeChange || + virNetDevVlanEqual(virDomainNetGetActualVlan(olddev), + virDomainNetGetActualVlan(newdev)))) { needVlanUpdate =3D true; } =20 @@ -4215,6 +4220,23 @@ qemuDomainChangeNet(virQEMUDriver *driver, needReplaceDevDef =3D true; } =20 + if (needVlanUpdate) { + if (virDomainNetDefIsOvsport(olddev) && virDomainNetDefIsOvsport(n= ewdev)) { + /* optimization if we're attached to an OVS bridge. This + * will redo vlan setup without needing to re-attach the + * tap device to the bridge + */ + if (virNetDevOpenvswitchUpdateVlan(newdev->ifname, &newdev->vl= an) < 0) + goto cleanup; + } else { + /* vlan setup is done as a part of reconnecting the tap + * device to a new bridge (either OVS or Linux host bridge). + */ + needBridgeChange =3D true; + } + needReplaceDevDef =3D true; + } + if (needBridgeChange) { if (qemuDomainChangeNetBridge(vm, olddev, newdev) < 0) goto cleanup; @@ -4266,12 +4288,6 @@ qemuDomainChangeNet(virQEMUDriver *driver, goto cleanup; } =20 - if (needVlanUpdate) { - if (virNetDevOpenvswitchUpdateVlan(newdev->ifname, &newdev->vlan) = < 0) - goto cleanup; - needReplaceDevDef =3D true; - } - if (needReplaceDevDef) { /* the changes above warrant replacing olddev with newdev in * the domain's nets list. --=20 2.47.1