From nobody Sun Feb 8 13:09:49 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1612314437; cv=none; d=zohomail.com; s=zohoarc; b=lCNQ52eY4hraCeMSHPcbqgy3y+xJMCxIPaVnimydU9iNsOG7f68qXJuudkwnwtB9rIHxPOu1C37I0K7/WIm43G5KJxci1wFbFPB5ua3rCsgVLIRonioRn2x7BDiFG2ThpNq4hrhoJeGGVJmjW5JioWJa+/mqqci+1fDzqYKvyP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612314437; h=Content-Type:Content-Transfer-Encoding:Cc: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=XudLh34yzCIEWR2IbFoz0zX4B8OlxwBudOMykdp5Tao=; b=D58dRMaEN9cs+7N7BYtM6376kiu+WrKPbh0yafnNFCFfxBWj1Z+EVm1YtNokZGMckMvQbbSanG9WWKSZHYmXacMtFCB0VUgh/5qSEihlZU5gVSSGu7JOs39JSt1MFd6OBjsm9M3X/pEneSj7BmlhkKp9zCNVXCFEzq7wNz7liz8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= 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 161231443708547.923301169444926; Tue, 2 Feb 2021 17:07:17 -0800 (PST) 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-569--lx2ckpLMnSrFGMyxlnL0g-1; Tue, 02 Feb 2021 20:07:13 -0500 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 7E356107ACE4; Wed, 3 Feb 2021 01:07:07 +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 59C8B5FC1D; Wed, 3 Feb 2021 01:07:07 +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 24B7618095CE; Wed, 3 Feb 2021 01:07:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11316odK010350 for ; Tue, 2 Feb 2021 20:06:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 07A612166B27; Wed, 3 Feb 2021 01:06:50 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 022D92166B2A for ; Wed, 3 Feb 2021 01:06:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E1F7882DFE0 for ; Wed, 3 Feb 2021 01:06:49 +0000 (UTC) Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-604-Q00VZdTRMxyk3KTlAey88Q-1; Tue, 02 Feb 2021 20:06:46 -0500 Received: by mail-qk1-f179.google.com with SMTP id d85so21882869qkg.5; Tue, 02 Feb 2021 17:06:45 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:6df1:6267:881f:cc79:a1f7]) by smtp.gmail.com with ESMTPSA id g6sm328813qtr.87.2021.02.02.17.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 17:06:44 -0800 (PST) X-MC-Unique: -lx2ckpLMnSrFGMyxlnL0g-1 X-MC-Unique: Q00VZdTRMxyk3KTlAey88Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XudLh34yzCIEWR2IbFoz0zX4B8OlxwBudOMykdp5Tao=; b=KC2HsKC7yroVC8qXHjmmRucgAHCKyKyIjw9m1CQG4QoS66EV4Au0xmfWEq6CrdNVzS nH2DFwMEQwv2WlVAo0S0909qdSz7JmKPvuWPjtmHGnoPeKUNGmHLt3xgxezsndrxgcKz J+cfkIwYiRNyQuYtfOJ00lyzixj+i75QX2B29lRPvIudpgZBiLRdIGkd/hBicni/oNgv bv0II45GA9olizaZX9ccZrh68YhFNOHNEXTbHTNUpJ8xRSUFBZqELWZ2ZIlQu/LHW5nP 0cDGtP04y+jCLetbAtutbWnadyVlK5e685GpeBYInm8rzz0MmSnqToKMjczft3eM/ox3 0Ryw== X-Gm-Message-State: AOAM530+qJuEykJqFSs03Zdk+JLUX2iuf5KUr6xDUjSxAq+QwBfuTX1j XPxSz3DoKGTZPEcXAuUWGZU+gOwDSeQ= X-Google-Smtp-Source: ABdhPJxb8vFUQCbaM3EoXkBo22+UVTRptBzmkp9j66AA6V2zQZyZOzYa9j5KZkPSKqpwQhs6eBuC7g== X-Received: by 2002:a37:4a82:: with SMTP id x124mr460996qka.458.1612314405385; Tue, 02 Feb 2021 17:06:45 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 05/10] domain_driver.c: use g_auto* in virDomainDriverNodeDeviceReAttach() Date: Tue, 2 Feb 2021 22:06:20 -0300 Message-Id: <20210203010625.2328911-6-danielhb413@gmail.com> In-Reply-To: <20210203010625.2328911-1-danielhb413@gmail.com> References: <20210203010625.2328911-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , =?UTF-8?q?J=C3=A1n=20Tomko?= 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Reviewed-by: J=C3=A1n Tomko Signed-off-by: Daniel Henrique Barboza --- src/hypervisor/domain_driver.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index c559f94348..ea4c3c9466 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -420,50 +420,42 @@ int virDomainDriverNodeDeviceReAttach(virNodeDevicePtr dev, virHostdevManagerPtr hostdevMgr) { - virPCIDevicePtr pci =3D NULL; + g_autoptr(virPCIDevice) pci =3D NULL; virPCIDeviceAddress devAddr; - int ret =3D -1; - virNodeDeviceDefPtr def =3D NULL; + g_autoptr(virNodeDeviceDef) def =3D NULL; g_autofree char *xml =3D NULL; - virConnectPtr nodeconn =3D NULL; - virNodeDevicePtr nodedev =3D NULL; + g_autoptr(virConnect) nodeconn =3D NULL; + g_autoptr(virNodeDevice) nodedev =3D NULL; =20 if (!(nodeconn =3D virGetConnectNodeDev())) - goto cleanup; + return -1; =20 /* 'dev' is associated with virConnectPtr, so for split * daemons, we need to get a copy that is associated with * the virnodedevd daemon. */ if (!(nodedev =3D virNodeDeviceLookupByName( nodeconn, virNodeDeviceGetName(dev)))) - goto cleanup; + return -1; =20 xml =3D virNodeDeviceGetXMLDesc(nodedev, 0); if (!xml) - goto cleanup; + return -1; =20 def =3D virNodeDeviceDefParseString(xml, EXISTING_DEVICE, NULL); if (!def) - goto cleanup; + return -1; =20 /* ACL check must happen against original 'dev', * not the new 'nodedev' we acquired */ if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0) - goto cleanup; + return -1; =20 if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0) - goto cleanup; + return -1; =20 pci =3D virPCIDeviceNew(&devAddr); if (!pci) - goto cleanup; - - ret =3D virHostdevPCINodeDeviceReAttach(hostdevMgr, pci); + return -1; =20 - virPCIDeviceFree(pci); - cleanup: - virNodeDeviceDefFree(def); - virObjectUnref(nodedev); - virObjectUnref(nodeconn); - return ret; + return virHostdevPCINodeDeviceReAttach(hostdevMgr, pci); } --=20 2.26.2