From nobody Fri Oct 18 06:19:40 2024 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 header.i=@cisco.com; 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1720109744; cv=none; d=zohomail.com; s=zohoarc; b=lfSXgTaxBExS1WHvqmZByl6vTJ1sojvAaYNiONlF9rM7Md3cIGzB5sB9ciaVextIzA9Dxl7U+79sfx8rXwTbdSAgowQhfA8bQ/sh9RVI/RzDpgB8M7lP9G7z2rW3ljp4Wawp9kz//zL3vmrjagTFXhBEBUjrS1NBO7/KzbdMq/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720109744; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=7DE3+/4DBZOv730TCiXRmltfEw8+Wfd4mDjZs6C8aR4=; b=deeHQ+Oik2DYhTkmrUzEd49mQb+kI33LZzXdYM86OCbUTNy8hjBAb4N3baB2Ud7C48TnFWrbhO0hOGY9Qi+tS7rsFkiuBOvMoF9jzzeb6TaYAtxHlbivoGRqAuc1Ko4qVT+dI4oaC+/qxra9jVD2juXKFMpMk061aj3XVshKcvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@cisco.com; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720109744162792.6797789838167; Thu, 4 Jul 2024 09:15:44 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 246D712E0; Thu, 4 Jul 2024 12:15:43 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0D98D15BE; Thu, 4 Jul 2024 12:14:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 696D012E0; Thu, 4 Jul 2024 11:48:01 -0400 (EDT) Received: from rcdn-iport-5.cisco.com (rcdn-iport-5.cisco.com [173.37.86.76]) (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 C5C5C12D7 for ; Thu, 4 Jul 2024 11:48:00 -0400 (EDT) Received: from rcdn-core-7.cisco.com ([173.37.93.143]) by rcdn-iport-5.cisco.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2024 15:46:58 +0000 Received: from mirlos-docker.cisco.com (virl-rtp10-labnat-04.cisco.com [10.122.58.60]) by rcdn-core-7.cisco.com (8.15.2/8.15.2) with ESMTP id 464Fkv6s005867; Thu, 4 Jul 2024 15:46:57 GMT X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SPF_HELO_PERMERROR autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=2787; q=dns/txt; s=iport; t=1720108080; x=1721317680; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C8n5ugxAdFbFMssxY02300SmGepPEmqm5dfWJJinqvU=; b=XmzWTpbEZMKXm7Mi3jmBldp/UUAwNXrR1i3X1ri2Zl0R2VrCwONPeA/r 0JQ085x8COEHjgM2oGCqymMnYpTmpg+b4W8Xj7xpKlpxdA/kC6D5b96Kx hqXbX82aB9n9OCemNvm5iw8H8G/pdZvoUz87LBt+BtrRGga75GXCfCWGp c=; X-CSE-ConnectionGUID: gqi/NPQSSUqTpdv2DqM66w== X-CSE-MsgGUID: 7CeoqFKoSkyQYn+lbqCGEA== X-IronPort-AV: E=Sophos;i="6.09,183,1716249600"; d="scan'208";a="227732423" To: devel@lists.libvirt.org Subject: [PATCH 1/1] qemuDomainChangeNet: check virtio options for non-virtio models Date: Thu, 4 Jul 2024 15:44:54 +0000 Message-Id: <20240704154454.3999218-2-mirlos@cisco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240704154454.3999218-1-mirlos@cisco.com> References: <20240704154454.3999218-1-mirlos@cisco.com> MIME-Version: 1.0 X-Outbound-SMTP-Client: 10.122.58.60, virl-rtp10-labnat-04.cisco.com X-Outbound-Node: rcdn-core-7.cisco.com Content-Transfer-Encoding: quoted-printable X-MailFrom: mirlos@cisco.com X-Mailman-Rule-Hits: nonmember-moderation 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 Message-ID-Hash: GSCH7MR5NHRMGK7ZUORYQDZEOLI5MYGV X-Message-ID-Hash: GSCH7MR5NHRMGK7ZUORYQDZEOLI5MYGV X-Mailman-Approved-At: Thu, 04 Jul 2024 16:14:27 -0400 CC: Miroslav Los 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: From: Miroslav Los via Devel Reply-To: Miroslav Los X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1720109744965100001 Content-Type: text/plain; charset="utf-8" In a domain created with an interface with a subelement, the device contains a non-NULL virDomainVirtioOptions struct, even for non-virtio NIC models. The subelement need not be present again after libvirt restarts, or when the interface is passed to clients. When clients such as virsh domif-setlink put back the modified interface XML, the new device's virtio attribute is NULL. This may fail the equality checks for virtio options in qemuDomainChangeNet, depending on whether libvird was restarted since define or not. This patch modifies the check for non-virtio models, to ignore olddev value of virtio (assumed valid), and to allow either NULL or a struct with all values ABSENT in the new virtio options. Signed-off-by: Miroslav Los Reviewed-by: Michal Privoznik --- src/qemu/qemu_hotplug.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2756d2aebd..1f4620d833 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3681,6 +3681,7 @@ qemuDomainChangeNet(virQEMUDriver *driver, bool needVlanUpdate =3D false; bool needIsolatedPortChange =3D false; bool needQueryRxFilter =3D false; + bool isVirtio =3D false; int ret =3D -1; int changeidx =3D -1; g_autoptr(virConnect) conn =3D NULL; @@ -3742,7 +3743,9 @@ qemuDomainChangeNet(virQEMUDriver *driver, goto cleanup; } =20 - if (virDomainNetIsVirtioModel(olddev) && + isVirtio =3D virDomainNetIsVirtioModel(olddev); + + if (isVirtio && (olddev->driver.virtio.name !=3D newdev->driver.virtio.name || olddev->driver.virtio.txmode !=3D newdev->driver.virtio.txmode || olddev->driver.virtio.ioeventfd !=3D newdev->driver.virtio.ioeven= tfd || @@ -3769,12 +3772,18 @@ qemuDomainChangeNet(virQEMUDriver *driver, goto cleanup; } =20 - if (!!olddev->virtio !=3D !!newdev->virtio || - (olddev->virtio && newdev->virtio && - (olddev->virtio->iommu !=3D newdev->virtio->iommu || - olddev->virtio->ats !=3D newdev->virtio->ats || - olddev->virtio->packed !=3D newdev->virtio->packed || - olddev->virtio->page_per_vq !=3D newdev->virtio->page_per_vq))) { + if ((isVirtio && + (!!olddev->virtio !=3D !!newdev->virtio || + (olddev->virtio && newdev->virtio && + (olddev->virtio->iommu !=3D newdev->virtio->iommu || + olddev->virtio->ats !=3D newdev->virtio->ats || + olddev->virtio->packed !=3D newdev->virtio->packed || + olddev->virtio->page_per_vq !=3D newdev->virtio->page_per_vq))= )) || + (!isVirtio && newdev->virtio && + (newdev->virtio->iommu !=3D 0 || + newdev->virtio->ats !=3D 0 || + newdev->virtio->packed !=3D 0 || + newdev->virtio->page_per_vq !=3D 0))) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify virtio network device driver optio= ns")); goto cleanup; --=20 2.25.1