From nobody Mon Feb 9 23:00:11 2026 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=1633712000; cv=none; d=zohomail.com; s=zohoarc; b=dNeQiMVihUpJoHiyVt1D/uGbJCwhhz++Ov+1nWWdRTePciCyT5aJvkJRl5BgGDBb2ox6lxX4Vr95CdMWOZ3b8yOwqR3ZE/Vyunev46DqZsRZvmMPO4oVJLXxyYLe0SJSmVi949mvyLg3YTrE+sqCSO8600QeiZA/uqSrtHbYMMM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633712000; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j5JJ1Y61pitcuy0giDm6c5MEl4mJ1p1Z0XuHD9aFizs=; b=JUGoSey3vk5v4/wAHoA3oyeYUzxTwa8JebbVNIXowrzd6b81WQYPBLKdPHK0ANVtI8QxwblgrecDNBJ7tUfMFG89CcOkD2Ye7kW6c2I2Rg9zqGclxTHH4OZL/fhsIIJ+BpLOgXGhBd5eqs+SyCfyzJikER4L1qGeV9GQXijCzZQ= 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 1633711999948526.7228874993951; Fri, 8 Oct 2021 09:53:19 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-376-4wn69C6dMDyPZzKVS5iRNQ-1; Fri, 08 Oct 2021 12:53:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86AB6801AB0; Fri, 8 Oct 2021 16:53:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A7BF5DA61; Fri, 8 Oct 2021 16:53:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 36F774EA46; Fri, 8 Oct 2021 16:53:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 198Gr96l013606 for ; Fri, 8 Oct 2021 12:53:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7CA7C5F4F1; Fri, 8 Oct 2021 16:53:09 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.195.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB5D85F4E3 for ; Fri, 8 Oct 2021 16:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633711998; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=j5JJ1Y61pitcuy0giDm6c5MEl4mJ1p1Z0XuHD9aFizs=; b=TdwjN9ENRbbmTl3z3Kawfzb4Wo94kQS5sZBUGG+3tlmbWlrI0NfN6SEgYmxADnmddWYthm zZ2kKGEBqMZuucMVvobceeXUP9w3cZ8vLy75pZ/ioQKd8SEnI2fFjHTBKP1Dqx4nZsQR3X fB3e5WTlc1N82RTOrfXvCPPU/K/8wIs= X-MC-Unique: 4wn69C6dMDyPZzKVS5iRNQ-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 12/21] qemu: Validate machine type used with virtio-iommu Date: Fri, 8 Oct 2021 18:51:47 +0200 Message-Id: <20211008165156.405216-13-abologna@redhat.com> In-Reply-To: <20211008165156.405216-1-abologna@redhat.com> References: <20211008165156.405216-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1633712001584100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Andrea Bolognani --- src/qemu/qemu_validate.c | 8 ++++++++ ...irtio-iommu-wrong-machine.x86_64-latest.err | 1 + .../virtio-iommu-wrong-machine.xml | 18 ++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 4 files changed, 28 insertions(+) create mode 100644 tests/qemuxml2argvdata/virtio-iommu-wrong-machine.x86_6= 4-latest.err create mode 100644 tests/qemuxml2argvdata/virtio-iommu-wrong-machine.xml diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 4646cd2af3..073f7bce58 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4798,6 +4798,14 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMM= UDef *iommu, break; =20 case VIR_DOMAIN_IOMMU_MODEL_VIRTIO: + if (!qemuDomainIsARMVirt(def) && + !qemuDomainIsQ35(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("IOMMU device: '%s' is only supported with " + "Q35 and ARM Virt machines"), + virDomainIOMMUModelTypeToString(iommu->model)); + return -1; + } break; =20 case VIR_DOMAIN_IOMMU_MODEL_LAST: diff --git a/tests/qemuxml2argvdata/virtio-iommu-wrong-machine.x86_64-lates= t.err b/tests/qemuxml2argvdata/virtio-iommu-wrong-machine.x86_64-latest.err new file mode 100644 index 0000000000..8d1cd19170 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-iommu-wrong-machine.x86_64-latest.err @@ -0,0 +1 @@ +unsupported configuration: IOMMU device: 'virtio' is only supported with Q= 35 and ARM Virt machines diff --git a/tests/qemuxml2argvdata/virtio-iommu-wrong-machine.xml b/tests/= qemuxml2argvdata/virtio-iommu-wrong-machine.xml new file mode 100644 index 0000000000..ad2a516b3a --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-iommu-wrong-machine.xml @@ -0,0 +1,18 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 1 + + hvm + + + + + + /usr/bin/qemu-system-x86_64 + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5f07c09d57..72ffac5de3 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3240,6 +3240,7 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64"); DO_TEST_CAPS_LATEST("virtio-iommu-x86_64"); DO_TEST_CAPS_ARCH_LATEST("virtio-iommu-aarch64", "aarch64"); + DO_TEST_CAPS_LATEST_PARSE_ERROR("virtio-iommu-wrong-machine"); =20 DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS); DO_TEST_PARSE_ERROR("cpu-hotplug-granularity", --=20 2.31.1