From nobody Sun Feb 8 18:48:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1648836578; cv=none; d=zohomail.com; s=zohoarc; b=TdvSJ/xLVckY7PnQSsgcEJFLTlXaIgMQPeVVQr1AkAfjAzy0W4rRKVs9bWj5up0R8iekdKoloTH6RD9nu3ylZdQIZ14fWC02RDPJtsloQrjBAr6O/Jr3/T8YxhySQKwJlrXa8Pz7x/qRwMcwdjrd59pTKpt/rSzwBZqxEJdrYuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648836578; 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=Obnd5DKNErJlFGQnbUkXbVirzHxGG7a25ZOGBifQjac=; b=YT2fDsXO+XlMF2u6oIGnsaXUT9GpHjVlnciyUGRndztxRTbeZLIF7c8j0kqoeIymc5cwTXR9DQDzlxJE+tNbrpRiV9AM523YV3L57pIvGMQVT2xjXsf5dQLUHpwcwNkeMEynSRlr7jbw8KRQ9BwPPjfCClsNmNwtFmq54DzFemk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 164883657817636.78061353849921; Fri, 1 Apr 2022 11:09:38 -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-644-Wv8uFlm4Ow-NLBOpUgncZQ-1; Fri, 01 Apr 2022 14:08: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 3ED3728EA70F; Fri, 1 Apr 2022 18:08:49 +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 2B5695E8A74; Fri, 1 Apr 2022 18:08:49 +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 DF8A41940349; Fri, 1 Apr 2022 18:08:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3A0491947BBE for ; Fri, 1 Apr 2022 18:08:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0A547111D7B4; Fri, 1 Apr 2022 18:08:47 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.193.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8511E111CD32 for ; Fri, 1 Apr 2022 18:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648836577; 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=Obnd5DKNErJlFGQnbUkXbVirzHxGG7a25ZOGBifQjac=; b=WrrzHHpDhM0XS8FuolqtoseYKJAdj3YElNu3+IiUfheFxSL7q3dNfVaPHqfWeuOr0AMUM0 AKFXwezse+2jrIB70T69Zn/ka5KmnKn4ylrT1qOSkJF3POG0dQdffemDYhqdBYLluktR8R iboAWgA+nCoTDxS1/kBmY8FYZ4qXV9M= X-MC-Unique: Wv8uFlm4Ow-NLBOpUgncZQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 10/16] conf: Add virDomainDeviceInfo to virDomainIOMMUDef Date: Fri, 1 Apr 2022 20:08:29 +0200 Message-Id: <20220401180835.200444-11-abologna@redhat.com> In-Reply-To: <20220401180835.200444-1-abologna@redhat.com> References: <20220401180835.200444-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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: 1648836581883100001 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 --- src/conf/domain_conf.c | 37 ++++++++++++------ src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 63 +++++++++++++++++-------------- 3 files changed, 60 insertions(+), 41 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2295d73ff2..77671c233f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2581,6 +2581,7 @@ virDomainIOMMUDefFree(virDomainIOMMUDef *iommu) if (!iommu) return; =20 + virDomainDeviceInfoClear(&iommu->info); g_free(iommu); } =20 @@ -4276,13 +4277,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: @@ -4578,6 +4580,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; @@ -4605,12 +4614,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 */ @@ -14797,8 +14800,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; @@ -14834,6 +14839,10 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, return NULL; } =20 + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, + &iommu->info, flags) < 0) + return NULL; + return g_steal_pointer(&iommu); } =20 @@ -15031,7 +15040,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: @@ -20166,7 +20176,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); @@ -22030,7 +22041,7 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDe= f *src, return false; } =20 - return true; + return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); } =20 =20 @@ -27432,6 +27443,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 bad0004b3c..1ef3dc8a2b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2767,6 +2767,7 @@ struct _virDomainIOMMUDef { virTristateSwitch eim; virTristateSwitch iotlb; unsigned int aw_bits; + virDomainDeviceInfo info; }; =20 typedef enum { diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 3951ef3e04..8345976e81 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -5460,35 +5460,40 @@ virtio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =20 --=20 2.35.1