From nobody Fri Dec 19 21:49:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1587477042; cv=none; d=zohomail.com; s=zohoarc; b=PqGbXBIsOgThs2QVzkvUwpseQIA/45hqNDI11vVi+23qgrMQyY4DTfZrEISaYayanEBcSM+TNhDuL0n5kRcl5/zNXL/qbceIniwZWSYnDUQ56BKNYThw6V1vy9b7BZTEsFQjHD8VbvZK+2RZRXecLrXhnf5n91g8aKSp3/F1uNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587477042; 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=XiGmkUCG/NMOl7+MzJautMZEKE4buxxEJg+3xIju3zk=; b=G4pbJDdjrL7/Hyg3bzvzzRLk1AaLaJnfNBMnmenuYzsiVlZ2OkrIrOBUX5nlowYNwL+PxFhjudq41BtYm4GO1Dt6p7d3E4NWG9g8zRPsOJTWMCZriKYiLRtMZX5EH0Ndzb9MfmjlPXA7/qQnEhL6cUE7w5xxlyZhyHnr9E3gEMw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1587477042221318.3222870693803; Tue, 21 Apr 2020 06:50:42 -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-230-ybSGMxqIPFuYDk1-j28LJA-1; Tue, 21 Apr 2020 09:50:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 417998017F3; Tue, 21 Apr 2020 13:50:31 +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 13C72B3A7B; Tue, 21 Apr 2020 13:50:31 +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 B71C718089CD; Tue, 21 Apr 2020 13:50:30 +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 03LDoPgp003395 for ; Tue, 21 Apr 2020 09:50:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 92A772166B29; Tue, 21 Apr 2020 13:50:25 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E1E12166B27 for ; Tue, 21 Apr 2020 13:50:25 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.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 6AA91101A55A for ; Tue, 21 Apr 2020 13:50:25 +0000 (UTC) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-455-izOe9LhKMwO13NqI7YLsjQ-1; Tue, 21 Apr 2020 09:50:23 -0400 Received: by mail-wr1-f42.google.com with SMTP id x18so16588264wrq.2 for ; Tue, 21 Apr 2020 06:50:22 -0700 (PDT) Received: from localhost.localdomain (public-gprs377075.centertel.pl. [37.47.104.52]) by smtp.gmail.com with ESMTPSA id q10sm3981826wrv.95.2020.04.21.06.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587477040; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=XiGmkUCG/NMOl7+MzJautMZEKE4buxxEJg+3xIju3zk=; b=B5NjND18/1jiPpaIRos5lFC/AgmfkMau9pRpM/GTgrMpENXAn4DAyfNsJ+uziIuX2reVe4 AZXUVBXrxRh4USusG7WrZo8xs3X+hnA2QQsNZJbJm1IUU2gJVVmMb6eg9byFisLZ+vPv3S b3IKZZ8aGneoUfZma6tSyfYIjLIDmGA= X-MC-Unique: ybSGMxqIPFuYDk1-j28LJA-1 X-MC-Unique: izOe9LhKMwO13NqI7YLsjQ-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=mjJ6yCqKRNHq7m0AsVEouQBbkN3PxGQawPMBAetFWU0=; b=fld6YGZhsFlI9k2jl8SHLAE004x3uhj+5Dt6J6DvPgj17kJKgudlvthSgDD0VHQq66 dQzs3sWM+lno6ZluBxFfqk62l5K1Z0CoSyEupb2kOphIrxOHjbdV5kKydhPpS4B2Fexo Gqvy4HlgtrASj8YraLGasqugu44V5ZRGKsWo4hcP7k6A3NAqlU/QL+x1eYJvNIfHMRSS ex2tNmAwNafRxUXuesaCo8sOKyTG+Aml1PUU8pYKwtYo6mCIWoaEHehyPrOckP1BHFe3 RCoyVoQI/R/5a6nlvbGAP3trGPB+NK741/VwmXnmV2B2FxXRtfucVEikYlhbFEJOlD2A Tpyg== X-Gm-Message-State: AGi0PubrA7D/1zspRHjYgJJiLAlgZsNfH35h1E5KXRLqPU2diKSmjb7Y R16dbPnxONlBM3PJScokxBdzL1btc7Y= X-Google-Smtp-Source: APiQypKNm8s56NkEc68EJLgVI7qOlrU5Q9Jcb0ZYzgnRs2DMHyIuLXWZPKhIkuGG/jFk+Aam9Z16Jg== X-Received: by 2002:adf:fc11:: with SMTP id i17mr26263503wrr.152.1587477020348; Tue, 21 Apr 2020 06:50:20 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH v2 16/40] admin: convert virAdmClient to GObject Date: Tue, 21 Apr 2020 15:48:57 +0200 Message-Id: <20200421134921.3717019-17-r4f4rfs@gmail.com> In-Reply-To: <20200421134921.3717019-1-r4f4rfs@gmail.com> References: <20200421134921.3717019-1-r4f4rfs@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 03LDoPgp003395 X-loop: libvir-list@redhat.com Cc: Rafael Fonseca 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.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Rafael Fonseca --- src/admin/libvirt-admin.c | 2 +- src/admin/libvirt_admin_private.syms | 2 +- src/datatypes.c | 36 ++++++++++++++++++---------- src/datatypes.h | 13 +++++----- src/rpc/gendispatch.pl | 1 + 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/admin/libvirt-admin.c b/src/admin/libvirt-admin.c index eccad1d0fc..56c63ea6e6 100644 --- a/src/admin/libvirt-admin.c +++ b/src/admin/libvirt-admin.c @@ -676,7 +676,7 @@ int virAdmClientFree(virAdmClientPtr client) =20 virCheckAdmClientReturn(client, -1); =20 - virObjectUnref(client); + g_clear_object(&client); return 0; } =20 diff --git a/src/admin/libvirt_admin_private.syms b/src/admin/libvirt_admin= _private.syms index cfdaba330d..e402635872 100644 --- a/src/admin/libvirt_admin_private.syms +++ b/src/admin/libvirt_admin_private.syms @@ -34,8 +34,8 @@ xdr_admin_server_set_threadpool_parameters_args; xdr_admin_server_update_tls_files_args; =20 # datatypes.h +vir_adm_client_get_type; vir_adm_server_get_type; -virAdmClientClass; virAdmConnectClass; virAdmConnectCloseCallbackDataRegister; virAdmConnectCloseCallbackDataReset; diff --git a/src/datatypes.c b/src/datatypes.c index cfdb9f9650..83028708da 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -71,8 +71,21 @@ virClassPtr virAdmConnectCloseCallbackDataClass; static void virAdmConnectDispose(void *obj); static void virAdmConnectCloseCallbackDataDispose(void *obj); =20 -virClassPtr virAdmClientClass; -static void virAdmClientDispose(void *obj); +G_DEFINE_TYPE(virAdmClient, vir_adm_client, G_TYPE_OBJECT); +static void virAdmClientDispose(GObject *obj); + +static void +vir_adm_client_init(virAdmClient *clt G_GNUC_UNUSED) +{ +} + +static void +vir_adm_client_class_init(virAdmClientClass *klass) +{ + GObjectClass *obj =3D G_OBJECT_CLASS(klass); + + obj->dispose =3D virAdmClientDispose; +} =20 G_DEFINE_TYPE(virAdmServer, vir_adm_server, G_TYPE_OBJECT); static void virAdmServerDispose(GObject *obj); @@ -121,7 +134,6 @@ virDataTypesOnceInit(void) =20 DECLARE_CLASS_LOCKABLE(virAdmConnect); DECLARE_CLASS_LOCKABLE(virAdmConnectCloseCallbackData); - DECLARE_CLASS(virAdmClient); =20 #undef DECLARE_CLASS_COMMON #undef DECLARE_CLASS_LOCKABLE @@ -1228,30 +1240,28 @@ virAdmClientPtr virAdmGetClient(virAdmServerPtr srv, const unsigned long long id, unsigned long long timestamp, unsigned int transport) { - virAdmClientPtr ret =3D NULL; + g_autoptr(virAdmClient) ret =3D NULL; =20 if (virDataTypesInitialize() < 0) - goto error; + return NULL; =20 - if (!(ret =3D virObjectNew(virAdmClientClass))) - goto error; + ret =3D VIR_ADM_CLIENT(g_object_new(VIR_TYPE_ADM_CLIENT, NULL)); =20 ret->id =3D id; ret->timestamp =3D timestamp; ret->transport =3D transport; ret->srv =3D g_object_ref(srv); =20 - return ret; - error: - virObjectUnref(ret); - return NULL; + return g_steal_pointer(&ret); } =20 static void -virAdmClientDispose(void *obj) +virAdmClientDispose(GObject *obj) { - virAdmClientPtr clt =3D obj; + virAdmClientPtr clt =3D VIR_ADM_CLIENT(obj); VIR_DEBUG("release client clt=3D%p, id=3D%llu", clt, clt->id); =20 g_clear_object(&clt->srv); + + G_OBJECT_CLASS(vir_adm_client_parent_class)->finalize(obj); } diff --git a/src/datatypes.h b/src/datatypes.h index dee21068b3..482ad0274c 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -46,10 +46,11 @@ extern virClassPtr virStorageVolClass; extern virClassPtr virStoragePoolClass; =20 extern virClassPtr virAdmConnectClass; -extern virClassPtr virAdmClientClass; =20 #define VIR_TYPE_ADM_SERVER vir_adm_server_get_type() G_DECLARE_FINAL_TYPE(virAdmServer, vir_adm_server, VIR, ADM_SERVER, GObjec= t); +#define VIR_TYPE_ADM_CLIENT vir_adm_client_get_type() +G_DECLARE_FINAL_TYPE(virAdmClient, vir_adm_client, VIR, ADM_CLIENT, GObjec= t); =20 #define virCheckConnectReturn(obj, retval) \ do { \ @@ -447,8 +448,8 @@ G_DECLARE_FINAL_TYPE(virAdmServer, vir_adm_server, VIR,= ADM_SERVER, GObject); =20 #define virCheckAdmClientReturn(obj, retval) \ do { \ - virAdmClientPtr _clt =3D (obj); \ - if (!virObjectIsClass(_clt, virAdmClientClass) || \ + virAdmClientPtr _clt =3D VIR_ADM_CLIENT(obj); \ + if (_clt =3D=3D NULL || \ !VIR_IS_ADM_SERVER(_clt->srv) || \ !virObjectIsClass(_clt->srv->conn, virAdmConnectClass)) { \ virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INVALID_CONN, \ @@ -460,8 +461,8 @@ G_DECLARE_FINAL_TYPE(virAdmServer, vir_adm_server, VIR,= ADM_SERVER, GObject); } while (0) #define virCheckAdmClientGoto(obj, label) \ do { \ - virAdmClientPtr _clt =3D (obj); \ - if (!virObjectIsClass(_clt, virAdmClientClass) || \ + virAdmClientPtr _clt =3D VIR_ADM_CLIENT(obj); \ + if (_clt =3D=3D NULL || \ !VIR_IS_ADM_SERVER(_clt->srv) || \ !virObjectIsClass(_clt->srv->conn, virAdmConnectClass)) { \ virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INVALID_CONN, \ @@ -588,7 +589,7 @@ struct _virAdmServer { * Internal structure associated to a client connected to daemon */ struct _virAdmClient { - virObject parent; + GObject parent; virAdmServerPtr srv; /* pointer to the server client is * connected to, which also holds a * reference back to the admin connect= ion diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index a9152198d7..fa5340d5e8 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -194,6 +194,7 @@ sub get_conn_method { } =20 my %gobject_impl =3D ( + virAdmClient =3D> 1, virAdmServer =3D> 1, ); =20 --=20 2.25.3