From nobody Fri May 17 03:00:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1659973286; cv=none; d=zohomail.com; s=zohoarc; b=frISlwATjgRGTcc/LSyXylfItClMLAhRO+z7vYxERETZcBSiDJZdl32BSJfvflII67H/ayq6tKfQN6XfxZxJwsRjaeA54ccPXkPsbQ77aSmFBKZ+TgNHLTUlModgESW7/CEv31P1jH9+vHf+8tYRPcFCLeJejqIKMku7/LXlc0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659973286; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=MyD5BdX4NDKccMXcGEB3xXS6mYw2UfBZiV++VTkZzlM=; b=TVzHlSlGVFrvlGXhSjhxdsa8k2Duk0MaJhJgq0ooztYdFKSHOi9kCcvb9DlyAIOtlP+RkADcHHTeOqfdof5dm3f5wzSsL3msiMVqnXUnqsKajn/G8TOPlqmjvskQfcFKFtJ+3K7Qj568jJozmw+GeiDmzVXGX5OyHw29sFoKLoc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1659973286611543.1537932619451; Mon, 8 Aug 2022 08:41:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-362-Gzj3oR5iNU6lSmzU8NBR1g-1; Mon, 08 Aug 2022 11:41:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B85C41C05137; Mon, 8 Aug 2022 15:41:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A56E440C1288; Mon, 8 Aug 2022 15:41:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 767631946A4F; Mon, 8 Aug 2022 15:41:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5B8B51946A49 for ; Mon, 8 Aug 2022 15:41:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4B68C492CA2; Mon, 8 Aug 2022 15:41:18 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.194.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3F99492C3B for ; Mon, 8 Aug 2022 15:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659973285; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MyD5BdX4NDKccMXcGEB3xXS6mYw2UfBZiV++VTkZzlM=; b=M8dVmbtKnrC4WDGkkawVUZYZiw9C2D1dkTSGvLbH8cA3EEMvfAPLN/tWqzms3sLIDxsI+K pObv0vGkFISeEFRoYzu19pv+dz4yOcgYSFMww755Ts1ykKcLjVISOZCIRrTwoCB5Qz8Web 08m1BwxqmKHyWMeDe8xUj3FbhZ7RcI4= X-MC-Unique: Gzj3oR5iNU6lSmzU8NBR1g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH] conf: Simplify IOMMU device validation Date: Mon, 8 Aug 2022 17:41:16 +0200 Message-Id: <20220808154116.50924-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659973288150100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Instead of duplicating the list of attributes that are not allowed for some of the IOMMU models, use two separate switch statements: one for the attributes and one for the address. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko Reviewed-by: Pavel Hrdina --- src/conf/domain_validate.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 88205c64e0..1c78a3d31c 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2633,6 +2633,7 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *io= mmu) { switch (iommu->model) { case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: + case VIR_DOMAIN_IOMMU_MODEL_VIRTIO: if (iommu->intremap !=3D VIR_TRISTATE_SWITCH_ABSENT || iommu->caching_mode !=3D VIR_TRISTATE_SWITCH_ABSENT || iommu->eim !=3D VIR_TRISTATE_SWITCH_ABSENT || @@ -2643,8 +2644,15 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *i= ommu) virDomainIOMMUModelTypeToString(iommu->model)); return -1; } - G_GNUC_FALLTHROUGH; + break; =20 + case VIR_DOMAIN_IOMMU_MODEL_INTEL: + case VIR_DOMAIN_IOMMU_MODEL_LAST: + break; + } + + switch (iommu->model) { + case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: case VIR_DOMAIN_IOMMU_MODEL_INTEL: if (iommu->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { virReportError(VIR_ERR_XML_ERROR, @@ -2655,18 +2663,6 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *i= ommu) break; =20 case VIR_DOMAIN_IOMMU_MODEL_VIRTIO: - if (iommu->intremap !=3D VIR_TRISTATE_SWITCH_ABSENT || - iommu->caching_mode !=3D VIR_TRISTATE_SWITCH_ABSENT || - iommu->eim !=3D VIR_TRISTATE_SWITCH_ABSENT || - iommu->iotlb !=3D VIR_TRISTATE_SWITCH_ABSENT || - iommu->aw_bits !=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("iommu model '%s' doesn't support additional = attributes"), - virDomainIOMMUModelTypeToString(iommu->model)); - return -1; - } - break; - case VIR_DOMAIN_IOMMU_MODEL_LAST: break; } --=20 2.37.1