From nobody Thu May 2 14:18:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1560858370; cv=none; d=zoho.com; s=zohoarc; b=YsbO93q2LfrmNBgbiLQ0Re+NUypT1bK5POcbaeTVzTyYIUsa7eRFsaIHJlWrx3hT0L2bldbXk+lZtvkzQ3qIPbsNfgdV8J2EWbT7Fc2jfJ/nfWCTgro+bWSmZql8rgi0Cx8xtEO4sqIlshMJrTgOoTld7fkzPnCaCcs3uPNrE0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560858370; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=jX6EbU9UVhAEv+ZTReHQZqxtOtWZV+iF7F9xtwDLwn8=; b=ib5yK7vJYe0ahVy7G3pSHUIFOTzfTWxfMWZSf8HanpVOI39lH3Pyzz9MRR+ZcUuah9WcvM3YUi2umHCeP3MvdBLGWooKhheC5sjyvoxi7rV7IKZJnvDn1/mWturXwPjPFwUXpAQ3puv8VUZujLI3DiH/VNaTdxCE61nlDpljeYk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560858370001704.3850292229441; Tue, 18 Jun 2019 04:46:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 959216378; Tue, 18 Jun 2019 11:45:59 +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 BAE831017E31; Tue, 18 Jun 2019 11:45:46 +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 9C322E161; Tue, 18 Jun 2019 11:45:43 +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 x5IBjebm028130 for ; Tue, 18 Jun 2019 07:45:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 965E898BA; Tue, 18 Jun 2019 11:45:40 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id DACE362926; Tue, 18 Jun 2019 11:45:37 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 18 Jun 2019 12:45:35 +0100 Message-Id: <20190618114535.15676-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] network: add virNetworkPortRef API 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 18 Jun 2019 11:46:07 +0000 (UTC) Normal practice is to provide a Ref API for all objects, but this was forgotten for the virNetworkPortPtr object. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- include/libvirt/libvirt-network.h | 3 +++ src/libvirt-network.c | 32 +++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 3 files changed, 36 insertions(+) diff --git a/include/libvirt/libvirt-network.h b/include/libvirt/libvirt-ne= twork.h index 97eceef754..c9ff0a49ed 100644 --- a/include/libvirt/libvirt-network.h +++ b/include/libvirt/libvirt-network.h @@ -455,4 +455,7 @@ virNetworkListAllPorts(virNetworkPtr network, int virNetworkPortFree(virNetworkPortPtr port); =20 +int +virNetworkPortRef(virNetworkPortPtr port); + #endif /* LIBVIRT_NETWORK_H */ diff --git a/src/libvirt-network.c b/src/libvirt-network.c index 6ed32c8ba2..c182064c0f 100644 --- a/src/libvirt-network.c +++ b/src/libvirt-network.c @@ -1690,3 +1690,35 @@ virNetworkPortFree(virNetworkPortPtr port) virObjectUnref(port); return 0; } + + +/** + * virNetworkPortRef: + * @port: a network port object + * + * Increment the reference count on the network port. For each + * additional call to this method, there shall be a corresponding + * call to virNetworkPortFree to release the reference count, once + * the caller no longer needs the reference to this object. + * + * This method is typically useful for applications where multiple + * threads are using a network port, and it is required that the + * port remain resident until all threads have finished using + * it. ie, each new thread using a network port would increment + * the reference count. + * + * Returns 0 in case of success, -1 in case of failure. + */ +int +virNetworkPortRef(virNetworkPortPtr port) +{ + VIR_DEBUG("port=3D%p refs=3D%d", port, + port ? port->parent.u.s.refs : 0); + + virResetLastError(); + + virCheckNetworkPortReturn(port, -1); + + virObjectRef(port); + return 0; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 46c32a081b..75f7fdfb0c 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -831,6 +831,7 @@ LIBVIRT_5.5.0 { virNetworkPortGetUUIDString; virNetworkPortDelete; virNetworkPortFree; + virNetworkPortRef; virNetworkPortSetParameters; } LIBVIRT_5.2.0; =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list