From nobody Mon Feb 9 16:51:13 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=1633711954; cv=none; d=zohomail.com; s=zohoarc; b=a5Y6m6bKDTaNM3qXpUqqoNSBR4EQJLOpC2m2KJQQbWQqwAwVJjfvwVufKXwqUQhN3lsmDPjX8tOpgxJdAtkKHEGX8rvZdMwRYBKPEDAvPxtcLqYdqlTMNtDdv292SGYPWuZzh4W0wnseMz8uIz37YlmZABLzOCXNRBfM950aMYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633711954; 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=u5RCOtOoRZ/jL1Mq9m4efkmffMDrQyf0noOSh0Dq4hE=; b=ZzUzINy+Ju5mXU96ua1TrqkLwaGGISATrRRbG776qf7xJE6cS1NgGbu+AgvOAcecfbE+7+aiWT6/f+ViqoxuP0v8AX5tRIU7wggeHGdmbDFbaEbhmnsRNoBAGnBf/PAXWpk10ccNOQ59lr4GaYgYP0vc7qV4u+UJyA4nC5jDL40= 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 1633711954006494.48990705333597; Fri, 8 Oct 2021 09:52:34 -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-399-Dy9-PGB9M3u7xLCV_qi1fg-1; Fri, 08 Oct 2021 12:52:30 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB8D1835DF6; Fri, 8 Oct 2021 16:52:25 +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 7FA751972D; Fri, 8 Oct 2021 16:52:25 +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 20F801806D02; Fri, 8 Oct 2021 16:52:25 +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 198GqLhR013314 for ; Fri, 8 Oct 2021 12:52:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A9D65F4EE; Fri, 8 Oct 2021 16:52:21 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.195.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A52F65F4E3 for ; Fri, 8 Oct 2021 16:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633711953; 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=u5RCOtOoRZ/jL1Mq9m4efkmffMDrQyf0noOSh0Dq4hE=; b=h5TH8bYNZ7nGBOaXOeoqiGB0AQw1FB8SrpYvu64Ulf+zrAIORwZITO/J8RjRSfSWFaAKdi snjaUewbPdhDOq+YwnCe0iWc42Hyzj0M3YjIprsFZiHQUKBW26YFYsGrSb5kCLqN9DXhOb C52+C6W2t6xlaFzAil+8Qc1YpqNeaB4= X-MC-Unique: Dy9-PGB9M3u7xLCV_qi1fg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 06/21] conf: Add new/free functions for virDomainIOMMUDef Date: Fri, 8 Oct 2021 18:51:41 +0200 Message-Id: <20211008165156.405216-7-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.84 on 10.5.11.23 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: 1633711955863100001 Content-Type: text/plain; charset="utf-8" This will make it possible to limit changes to a single spot later on, and is also just an overall nicer way to create and destroy objects. Signed-off-by: Andrea Bolognani --- src/conf/domain_conf.c | 29 +++++++++++++++++++++++++---- src/conf/domain_conf.h | 3 +++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 60f2b1129f..6df981ad47 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2524,6 +2524,27 @@ virDomainVsockDefFree(virDomainVsockDef *vsock) } =20 =20 +virDomainIOMMUDef * +virDomainIOMMUDefNew(void) +{ + g_autoptr(virDomainIOMMUDef) iommu =3D NULL; + + iommu =3D g_new0(virDomainIOMMUDef, 1); + + return g_steal_pointer(&iommu); +} + + +void +virDomainIOMMUDefFree(virDomainIOMMUDef *iommu) +{ + if (!iommu) + return; + + g_free(iommu); +} + + void virDomainNetTeamingInfoFree(virDomainNetTeamingInfo *teaming) { @@ -3325,7 +3346,7 @@ void virDomainDeviceDefFree(virDomainDeviceDef *def) virDomainMemoryDefFree(def->data.memory); break; case VIR_DOMAIN_DEVICE_IOMMU: - g_free(def->data.iommu); + virDomainIOMMUDefFree(def->data.iommu); break; case VIR_DOMAIN_DEVICE_VSOCK: virDomainVsockDefFree(def->data.vsock); @@ -3663,7 +3684,7 @@ void virDomainDefFree(virDomainDef *def) virDomainPanicDefFree(def->panics[i]); g_free(def->panics); =20 - g_free(def->iommu); + virDomainIOMMUDefFree(def->iommu); =20 g_free(def->idmap.uidmap); g_free(def->idmap.gidmap); @@ -14916,11 +14937,11 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, { VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr driver; - g_autofree virDomainIOMMUDef *iommu =3D NULL; + g_autoptr(virDomainIOMMUDef) iommu =3D NULL; =20 ctxt->node =3D node; =20 - iommu =3D g_new0(virDomainIOMMUDef, 1); + iommu =3D virDomainIOMMUDefNew(); =20 if (virXMLPropEnum(node, "model", virDomainIOMMUModelTypeFromString, VIR_XML_PROP_REQUIRED, &iommu->model) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c23c233184..72db861105 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3291,6 +3291,9 @@ bool virDomainControllerIsPSeriesPHB(const virDomainC= ontrollerDef *cont); virDomainFSDef *virDomainFSDefNew(virDomainXMLOption *xmlopt); void virDomainFSDefFree(virDomainFSDef *def); void virDomainActualNetDefFree(virDomainActualNetDef *def); +virDomainIOMMUDef *virDomainIOMMUDefNew(void); +void virDomainIOMMUDefFree(virDomainIOMMUDef *iommu); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainIOMMUDef, virDomainIOMMUDefFree); virDomainVsockDef *virDomainVsockDefNew(virDomainXMLOption *xmlopt); void virDomainVsockDefFree(virDomainVsockDef *vsock); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainVsockDef, virDomainVsockDefFree); --=20 2.31.1