From nobody Mon Feb 9 19:53:48 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=1634735036; cv=none; d=zohomail.com; s=zohoarc; b=KdND+jeediP0U4HK1nX53FfUQilqqSoA5NkSkn4VGTdoI23vqznR1zvGfYQt2I6hmKCOjKsrVwOCJNmzhTBO0gUinzUklEdFS3U8ZISuilvToMLY5gjgWxC/E70beOawRrTqH0csTONhM7wMnOfmH19bgQeN030X+hwH3JFkqvs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634735036; 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=0e76FcP+RSnyt+0EgTuJL2o0t4fLwzmyO27wM5rzNpk=; b=VzcvqHTDUiG20gIhsO3FsgHGYIPe2Wr2pTYFrsrQK8+UGjESYe3EwTFYar2GAxpXBiTlCheF3iJ465zJOeQ/8ixMLJwroaCrO5RrBETpkDFPgEcMWWiYhlSrFkTMhYoac7fkPAYbX1scHD/seEqTkK2gmEw2XOXbVi7VnwbDHNs= 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 1634735035786630.9011933882521; Wed, 20 Oct 2021 06:03:55 -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-304-oxj1CMBJNfeCKhJtmB0Jhg-1; Wed, 20 Oct 2021 09:03:51 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE5D1879515; Wed, 20 Oct 2021 13:03:45 +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 9D6425FC13; Wed, 20 Oct 2021 13:03:45 +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 66FDB4EA3D; Wed, 20 Oct 2021 13:03:45 +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 19KD3TrV029710 for ; Wed, 20 Oct 2021 09:03:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id A79DD652AC; Wed, 20 Oct 2021 13:03:29 +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 D22BE60657 for ; Wed, 20 Oct 2021 13:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634735034; 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=0e76FcP+RSnyt+0EgTuJL2o0t4fLwzmyO27wM5rzNpk=; b=Z2UOpF0Ppmq4wjSLIbN8kK037clAfjBK2FDx0VmFQHt8ubqMbX/wi70ADpvWgNFM7q6G9x xoGnxZYYBD1O0lQAPqz+PPMi7NZxtuPXbJ8FC9GS6eV8JaxfAfBqwe4O5iMNjWRe4n3NJm OngfLbjhhgmUK28b4G2mpL5KiCBsBCo= X-MC-Unique: oxj1CMBJNfeCKhJtmB0Jhg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v2 06/22] conf: Add new/free functions for virDomainIOMMUDef Date: Wed, 20 Oct 2021 15:02:41 +0200 Message-Id: <20211020130257.534296-7-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.16 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: 1634735050569100011 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 0618343b79..15228d1e38 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2534,6 +2534,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) { @@ -3336,7 +3357,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); @@ -3674,7 +3695,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); @@ -14923,11 +14944,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 1ac802feca..4624bad1f7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3300,6 +3300,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