From nobody Mon Feb 9 17:23:30 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=1647621671; cv=none; d=zohomail.com; s=zohoarc; b=S5bW601au/cTLA8gEzD4oU1YSBhemc4q8ra5UxrAi5/daDo0d7jXwzACaNMPp71Kuob7M5HDjmMlaFZsltTkJ5Z6BHDw073cYBWVDohTi8+f53O6LbTFqpSJ2fJ75JxkQG9CDJdkYw3WrXpEZiEpjcTMHqTK15LhQ68ebXGu9KE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647621671; 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=X1PLPh2VxLVkltZS5m12Eiz4PjvbuWIBvLWAWxJUUFs=; b=RyDYZIXOPDdYdL/5ADSlC/b3E6w8nlBEM66+5bliRVUo/3Xf1Ahb9Sw2fTb/wquOI0U6FO1NxMmXLk/ySYlSuqRdfNeXIzoMd0cw2xVmBd0x7MS8SnjRaXMenmSt2F8hDDZNOmcKw/nkRGUtn0DIuWUfzrAu/Q2RUAGnWlg8CCM= 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 164762167160828.166765809893832; Fri, 18 Mar 2022 09:41:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-226-NFN2i_ZANK-f0fPlotq8iw-1; Fri, 18 Mar 2022 12:40:52 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6003880418A; Fri, 18 Mar 2022 16:40:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BC6A428EF5; Fri, 18 Mar 2022 16:40:46 +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 15F7F1940373; Fri, 18 Mar 2022 16:40:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4A9D71940379 for ; Fri, 18 Mar 2022 16:40:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3D4E8145B979; Fri, 18 Mar 2022 16:40:40 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.195.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF940145B97C for ; Fri, 18 Mar 2022 16:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647621670; 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=X1PLPh2VxLVkltZS5m12Eiz4PjvbuWIBvLWAWxJUUFs=; b=JvwAXuLyjrYkIdMjCq+UKD4F8m5fcW7ycf10vTravtT05U6FqXka3hiNGiTd3dxkU7VSlU oFHBttVeNZU36Sqn3zv9duj9a7lBLWl63UE19nAZ+U4JxK+oMDaJSe1OELt+vP6cAU6ZXJ VGS5m0fxptri71n+mz1IC60c6vChChQ= X-MC-Unique: NFN2i_ZANK-f0fPlotq8iw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v2 11/17] conf: Add virDomainDeviceInfo to virDomainIOMMUDef Date: Fri, 18 Mar 2022 17:40:22 +0100 Message-Id: <20220318164028.1185357-12-abologna@redhat.com> In-Reply-To: <20220318164028.1185357-1-abologna@redhat.com> References: <20220318164028.1185357-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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.85 on 10.11.54.9 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1647621673619100005 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 Reviewed-by: J=C3=A1n Tomko --- 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 deef019ded..f8786fe31c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5450,35 +5450,40 @@ virtio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 99e82bc5f9..315feb4b0d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2578,6 +2578,7 @@ virDomainIOMMUDefFree(virDomainIOMMUDef *iommu) if (!iommu) return; =20 + virDomainDeviceInfoClear(&iommu->info); g_free(iommu); } =20 @@ -4273,13 +4274,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: @@ -4575,6 +4577,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; @@ -4602,12 +4611,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 */ @@ -14794,8 +14797,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; @@ -14831,6 +14836,10 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, return NULL; } =20 + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, + &iommu->info, flags) < 0) + return NULL; + return g_steal_pointer(&iommu); } =20 @@ -15028,7 +15037,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: @@ -20156,7 +20166,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); @@ -22020,7 +22031,7 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDe= f *src, return false; } =20 - return true; + return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); } =20 =20 @@ -27422,6 +27433,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 f6ffcf985c..8eafdb0c30 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2765,6 +2765,7 @@ struct _virDomainIOMMUDef { virTristateSwitch eim; virTristateSwitch iotlb; unsigned int aw_bits; + virDomainDeviceInfo info; }; =20 typedef enum { --=20 2.35.1