From nobody Mon Feb 9 17:57:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1634735106; cv=none; d=zohomail.com; s=zohoarc; b=gi4DzsHglxNQ5Z5DWaaiBEgiHlwXH3oQir0YDiRfXsa1TM8yOrkMH5B+YBqliMTSdJb748CacOeqUnUAgAHKjJmbAEcFxNTOD22DkgufNEjQju6QbbDf91LXarXnqrb11BmeW5L53fvD8BBF2cjiVFNSqJhbmu0Woliy1FnyL5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634735106; 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=TlLSdr7sIUNaAfyI/fP3KdKVH6o+FL2jvNWiZiwGYQk=; b=YVUW4bDYbGflahNKUmlJe6JQxMYdRO3tjlJyPHTfCvmDgvKMqbUwujh0YG7bVe61//FE2Z8qOg7s6qXaEdgVH/YV2n+ihQ2RDjSCPghLQoJF3/ZjoxYaP4/jNkiMIbd4U7s+SFy4/OP11fCZbQN+SI5l4gkdj08g563wkhG0QtI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1634735106568125.31848342045487; Wed, 20 Oct 2021 06:05:06 -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-121-ahsg2z1uMA2KruaMwhzPhA-1; Wed, 20 Oct 2021 09:03:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1CC441054F9E; Wed, 20 Oct 2021 13:03:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EAC406418A; Wed, 20 Oct 2021 13:03:53 +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 B7E231832DF7; Wed, 20 Oct 2021 13:03:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19KD3nZ4029896 for ; Wed, 20 Oct 2021 09:03:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 57AB71981F; Wed, 20 Oct 2021 13:03:49 +0000 (UTC) Received: from kinshicho.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.195.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 90EA21980E for ; Wed, 20 Oct 2021 13:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634735105; 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=TlLSdr7sIUNaAfyI/fP3KdKVH6o+FL2jvNWiZiwGYQk=; b=QaEws9cp2NtH9oicORxvRA/skJ11ZPxSwejPxy7ikHTxAVt2yEgEQplJQpMI4i/yI92Eok 2CxdcslJYc+SZwBmLAJ9wraHUUH9Fkpp/Sz2ORdl1oe+fOoDTNOMc4JxBjny0W7g+PE9l3 OzqUbRWtbQ9uG+EeS47eyv0yfwYBXy4= X-MC-Unique: ahsg2z1uMA2KruaMwhzPhA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v2 16/22] conf: Add virDomainDeviceInfo to virDomainIOMMUDef Date: Wed, 20 Oct 2021 15:02:51 +0200 Message-Id: <20211020130257.534296-17-abologna@redhat.com> In-Reply-To: <20211020130257.534296-1-abologna@redhat.com> References: <20211020130257.534296-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.15 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: 1634735111186100001 Content-Type: text/plain; charset="utf-8" This is needed so that IOMMU devices can have addresses. Existing IOMMU devices (intel-iommu and SMMUv3) are system devices and as such don't have an address associated to them, but virtio-iommu is a PCI device and needs one. Signed-off-by: Andrea Bolognani --- docs/schemas/domaincommon.rng | 63 +++++++++++++++++++---------------- src/conf/domain_conf.c | 37 +++++++++++++------- src/conf/domain_conf.h | 1 + 3 files changed, 60 insertions(+), 41 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 4d6bf906fb..f19c4eeb21 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5418,35 +5418,40 @@ virtio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5102857d5e..146c11bb47 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2552,6 +2552,7 @@ virDomainIOMMUDefFree(virDomainIOMMUDef *iommu) if (!iommu) return; =20 + virDomainDeviceInfoClear(&iommu->info); g_free(iommu); } =20 @@ -4241,13 +4242,14 @@ virDomainDeviceGetInfo(const virDomainDeviceDef *de= vice) return &device->data.panic->info; case VIR_DOMAIN_DEVICE_MEMORY: return &device->data.memory->info; + case VIR_DOMAIN_DEVICE_IOMMU: + return &device->data.iommu->info; case VIR_DOMAIN_DEVICE_VSOCK: return &device->data.vsock->info; =20 /* The following devices do not contain virDomainDeviceInfo */ case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_GRAPHICS: - case VIR_DOMAIN_DEVICE_IOMMU: case VIR_DOMAIN_DEVICE_AUDIO: case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_NONE: @@ -4543,6 +4545,13 @@ virDomainDeviceInfoIterateFlags(virDomainDef *def, return rc; } =20 + device.type =3D VIR_DOMAIN_DEVICE_IOMMU; + if (def->iommu) { + device.data.iommu =3D def->iommu; + if ((rc =3D cb(def, &device, &def->iommu->info, opaque)) !=3D 0) + return rc; + } + device.type =3D VIR_DOMAIN_DEVICE_VSOCK; if (def->vsock) { device.data.vsock =3D def->vsock; @@ -4570,12 +4579,6 @@ virDomainDeviceInfoIterateFlags(virDomainDef *def, if ((rc =3D cb(def, &device, NULL, opaque)) !=3D 0) return rc; } - device.type =3D VIR_DOMAIN_DEVICE_IOMMU; - if (def->iommu) { - device.data.iommu =3D def->iommu; - if ((rc =3D cb(def, &device, NULL, opaque)) !=3D 0) - return rc; - } } =20 /* Coverity is not very happy with this - all dead_error_condition */ @@ -14940,8 +14943,10 @@ virDomainMemoryDefParseXML(virDomainXMLOption *xml= opt, =20 =20 static virDomainIOMMUDef * -virDomainIOMMUDefParseXML(xmlNodePtr node, - xmlXPathContextPtr ctxt) +virDomainIOMMUDefParseXML(virDomainXMLOption *xmlopt, + xmlNodePtr node, + xmlXPathContextPtr ctxt, + unsigned int flags) { VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr driver; @@ -14977,6 +14982,10 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, return NULL; } =20 + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, + &iommu->info, flags) < 0) + return NULL; + return g_steal_pointer(&iommu); } =20 @@ -15174,7 +15183,8 @@ virDomainDeviceDefParse(const char *xmlStr, return NULL; break; case VIR_DOMAIN_DEVICE_IOMMU: - if (!(dev->data.iommu =3D virDomainIOMMUDefParseXML(node, ctxt))) + if (!(dev->data.iommu =3D virDomainIOMMUDefParseXML(xmlopt, node, + ctxt, flags))) return NULL; break; case VIR_DOMAIN_DEVICE_VSOCK: @@ -20325,7 +20335,8 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt, } =20 if (n > 0) { - if (!(def->iommu =3D virDomainIOMMUDefParseXML(nodes[0], ctxt))) + if (!(def->iommu =3D virDomainIOMMUDefParseXML(xmlopt, nodes[0], + ctxt, flags))) return NULL; } VIR_FREE(nodes); @@ -22179,7 +22190,7 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDe= f *src, return false; } =20 - return true; + return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); } =20 =20 @@ -27566,6 +27577,8 @@ virDomainIOMMUDefFormat(virBuffer *buf, =20 virXMLFormatElement(&childBuf, "driver", &driverAttrBuf, NULL); =20 + virDomainDeviceInfoFormat(&childBuf, &iommu->info, 0); + virBufferAsprintf(&attrBuf, " model=3D'%s'", virDomainIOMMUModelTypeToString(iommu->model)); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 486f2f7a2e..d8621e2d4f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2715,6 +2715,7 @@ struct _virDomainIOMMUDef { virTristateSwitch eim; virTristateSwitch iotlb; unsigned int aw_bits; + virDomainDeviceInfo info; }; =20 typedef enum { --=20 2.31.1