From nobody Sun Feb 8 13:09:48 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=1612314446; cv=none; d=zohomail.com; s=zohoarc; b=fuKDLPQatqK8ym3I4wdvzWNLRNKaSDr+ORa9wjYr93mmCyShKltnWPV1gdwR7soUwAGTu0weW7awpBv/JehCy6/SPoqDrqWQ2MX1fs4NgpLLcy2w1Gxox0UIMK00fX26gRT8HdxGK3/eQXhUNTK/KJr6hZg+DFQ+zmV3AI0sSk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612314446; 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=y/qWRsMyow/m1RmFEmR0AiSsu+uD+R+UmjW0YN29WuE=; b=i107GsUVARZ4godFqsAX78SVr32nqmbw9PK+YLBwrCYFZU+HyRiKS1mGjqGnrC/6Sfu4ggw7IccEaSW0co3sHbM3+msqQhbvIU/KC+CJYMigR8D4qo3tcMOdhy6FdjKTixc6g9H8SCYB6BnzQq3nKAUWneldOlrrxNXEOIVLzsM= 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 1612314446109968.9772558923914; Tue, 2 Feb 2021 17:07:26 -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-593-FDjf1MKkMnCcbvBweojdMg-1; Tue, 02 Feb 2021 20:07:22 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 84146801ABA; Wed, 3 Feb 2021 01:07:13 +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 5BCE05D9F1; Wed, 3 Feb 2021 01:07:13 +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 231401809C92; Wed, 3 Feb 2021 01:07:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11316wwp010420 for ; Tue, 2 Feb 2021 20:06:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 01358100416A; Wed, 3 Feb 2021 01:06:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EEE2911422D8 for ; Wed, 3 Feb 2021 01:06:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 41A06811E87 for ; Wed, 3 Feb 2021 01:06:57 +0000 (UTC) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-491-naF3OO4QMP27rhHJa_o_Rw-1; Tue, 02 Feb 2021 20:06:53 -0500 Received: by mail-qk1-f181.google.com with SMTP id d85so21883167qkg.5; Tue, 02 Feb 2021 17:06:53 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 17:06:52 -0800 (PST) X-MC-Unique: FDjf1MKkMnCcbvBweojdMg-1 X-MC-Unique: naF3OO4QMP27rhHJa_o_Rw-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=y/qWRsMyow/m1RmFEmR0AiSsu+uD+R+UmjW0YN29WuE=; b=GYIsxHTrFM6Iq3QJXjQJcyIk+ON2iHlq4/eDZo9opuN+TmPlI1WDZwSR29rK8/27Yb rO6c5phYCTtbf9x51nmHsppocrvG1lzTND+9ftDaAGy6c35xzAbvlmZwUr/ZGJuWHDZe kQQZ7b+IYShoYB4MPPFaaf4jNvMEBeWtOn0QsDhBhoqrOeAEEbersyEznPQHSSFmdGI0 DhGg4b+es6GRg5npVE8s0YshBsjXbIFNRKcPqbFfL+42mMqBvEhqqncYVB1hlUQqzK6d 2tlVlf/P54J9gPeeuTQejb6PzmqA0qqSmm2fF9N/zxeR6wbZW9NI55eBLCOIdzTiOWCD 4iew== X-Gm-Message-State: AOAM530XHyvQAQOnuThulLV0tuLxYq05sy8oXJV5l8Kvk2xjd7YCQlVc Of4n8ILUMRps05qMY8wlTQ4cZl2kCus= X-Google-Smtp-Source: ABdhPJzvakcCbt181klVn98MHF+yvKOYJvcUYAa0HhBxMMnjr2Q0ObjXSrS3reyTvIjTmn9qGphb6Q== X-Received: by 2002:a37:8485:: with SMTP id g127mr423773qkd.233.1612314412664; Tue, 02 Feb 2021 17:06:52 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 09/10] domain_driver.c: use g_auto* in virDomainDriverNodeDeviceDetachFlags() Date: Tue, 2 Feb 2021 22:06:24 -0300 Message-Id: <20210203010625.2328911-10-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.3 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.14 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 | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 6ee74d6dff..c08b7d46c5 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -465,57 +465,50 @@ virDomainDriverNodeDeviceDetachFlags(virNodeDevicePtr= dev, virHostdevManagerPtr hostdevMgr, const char *driverName) { - 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 (!driverName) return -1; =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 (virNodeDeviceDetachFlagsEnsureACL(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; + return -1; =20 if (STREQ(driverName, "vfio")) virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_VFIO); else if (STREQ(driverName, "xen")) virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN); =20 - ret =3D virHostdevPCINodeDeviceDetach(hostdevMgr, pci); - cleanup: - virPCIDeviceFree(pci); - virNodeDeviceDefFree(def); - virObjectUnref(nodedev); - virObjectUnref(nodeconn); - return ret; + return virHostdevPCINodeDeviceDetach(hostdevMgr, pci); } --=20 2.26.2