From nobody Sun May 5 08:59:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584037081; cv=none; d=zohomail.com; s=zohoarc; b=hQ0LRRBz+lQlug/ehfKH0/4mvRyVG337G73flFDgO0v2nbGhkc3xWvKw7QR97d6qq3n7LstYH2aqVOP/HuOrI7PqxAkObsn2xH1h5M/jSofy5sg6bXzcrfM/PMiR8RoUGc85Q0u2Er+l8E9SISEipZFdYiqthqa5IRQNmCE07EA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584037081; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=KTY7bQKak3pA5FmeRUJKJ5KbwpLil+Eg+AImWRQ8QB8=; b=KoL5d/xRrw8TvLzWt66oWN3DLvhKHMwtnhNoW+PXz8s/EJnAqsaTrnTjC/vwg1uBRzy2zyMqCpgP9Hyp9bv/lMcyxfq78lwL3EsfgSNB5eVN5zPE+f7B15S2yY25qhi4oQi5ZYex2miiliwDBnrECmCPzfAjpeBY1OWF+MJqGeo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1584037081189126.5312806152051; Thu, 12 Mar 2020 11:18:01 -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-175-nXISO2JDOhqsmPL1aqj7mA-1; Thu, 12 Mar 2020 14:17:57 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE202800D48; Thu, 12 Mar 2020 18:17:49 +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 33CE692D2D; Thu, 12 Mar 2020 18:17:48 +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 3240B85EC1; Thu, 12 Mar 2020 18:17:46 +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 02CIHikk001076 for ; Thu, 12 Mar 2020 14:17:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id EDCDD2166B2A; Thu, 12 Mar 2020 18:17:43 +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 E97622166B29 for ; Thu, 12 Mar 2020 18:17:41 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 CC7E580102D for ; Thu, 12 Mar 2020 18:17:41 +0000 (UTC) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-FJ6f-7-VO5--CVki2chm4g-1; Thu, 12 Mar 2020 14:17:39 -0400 Received: by mail-pf1-f173.google.com with SMTP id 23so3671331pfj.1 for ; Thu, 12 Mar 2020 11:17:38 -0700 (PDT) Received: from localhost.localdomain ([103.212.147.80]) by smtp.gmail.com with ESMTPSA id j23sm4803248pfi.203.2020.03.12.11.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 11:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584037080; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=KTY7bQKak3pA5FmeRUJKJ5KbwpLil+Eg+AImWRQ8QB8=; b=MEgK5SNJJiwlUZOMU/KC5wGekpZEbPYbqFQCI5VBPjgqvDKPwt1QnHLqm2CSSW9gK4n5Yu hlVb14gJ1UM2bXAVHiyngniGe1CdjFOVWcRHNr9ImJ9zYqJGe95KyvTzWLqNiOJBX/6fEy LCW6ijBN7JKudITWVVu1qpWTF6K6TL8= X-MC-Unique: nXISO2JDOhqsmPL1aqj7mA-1 X-MC-Unique: FJ6f-7-VO5--CVki2chm4g-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:mime-version :content-transfer-encoding; bh=66vb47hBAg8bMf638oaOKuplhSeBhFqkiCKmQeX100k=; b=kcFgYTYbfuFJbchPJp2A6POd+bvOG7lhTpevGvicBBh+GdFCvBD1E23wuh3frGTVRw lstzNs0cXRlGphL+m9Ju9suyubPUjP9mp5NJm7Zy7DEhVlojffElwhuCd6PS5kVkw8Yd vrmWV8AgmF1mDwMVjEcqbUAF+E+r7EKXm9J4kAXaj/MTXCLyaomUPkd1mH5OcWTwNbjv 5Wy7FTVJ5HO/k3VbO+lPxYEIpIJ0MbmCgv1VgHbrOGBAzplJDYFPsIx79R1x1RyCvaR0 /IdyAtzP/abBrWpnIOY02AowNE8YwSCRcFnZST9212O0V5jH6RmvHFTRqejOICrmWFWu 4xNQ== X-Gm-Message-State: ANhLgQ0Pc34p3QTO88LfOYBTXYbg6UfOOVrG2LaCB1pWlptBgoT7Ct52 /qAaeqQqPTnSCOR3VHiM6zEZoOvuX8c= X-Google-Smtp-Source: ADFU+vtZf/q4IBxGPymOZQm7V9Idg1332nVwbiSLEEj1cER3CVVst0YuuOnrkzgfBLXzj153kyRHsQ== X-Received: by 2002:a63:4e22:: with SMTP id c34mr9189590pgb.263.1584037056623; Thu, 12 Mar 2020 11:17:36 -0700 (PDT) From: Gaurav Agrawal To: libvir-list@redhat.com Subject: [RFCv2] qemu: convert DomainLogContext class to use GObject Date: Thu, 12 Mar 2020 23:47:25 +0530 Message-Id: <20200312181726.6547-1-agrawalgaurav@gnome.org> 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 02CIHikk001076 X-loop: libvir-list@redhat.com Cc: Gaurav Agrawal 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.13 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" --- src/qemu/qemu_domain.c | 35 +++++++++++++++++++---------------- src/qemu/qemu_domain.h | 6 +++--- src/qemu/qemu_process.c | 4 ++-- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4b467afa81..b3f17b8382 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -151,7 +151,7 @@ qemuDomainObjFromDomain(virDomainPtr domain) =20 =20 struct _qemuDomainLogContext { - virObject parent; + GObject parent; =20 int writefd; int readfd; /* Only used if manager =3D=3D NULL */ @@ -161,37 +161,46 @@ struct _qemuDomainLogContext { virLogManagerPtr manager; }; =20 -static virClassPtr qemuDomainLogContextClass; +G_DEFINE_TYPE(qemuDomainLogContext, qemu_domain_log_context, G_TYPE_OBJECT= ); static virClassPtr qemuDomainSaveCookieClass; =20 -static void qemuDomainLogContextDispose(void *obj); +static void qemuDomainLogContextFinalize(GObject *obj); static void qemuDomainSaveCookieDispose(void *obj); =20 =20 static int qemuDomainOnceInit(void) { - if (!VIR_CLASS_NEW(qemuDomainLogContext, virClassForObject())) - return -1; - if (!VIR_CLASS_NEW(qemuDomainSaveCookie, virClassForObject())) return -1; =20 return 0; } =20 +static void qemu_domain_log_context_init(qemuDomainLogContext *logctxt G_G= NUC_UNUSED) +{ +} + +static void qemu_domain_log_context_class_init(qemuDomainLogContextClass *= klass) +{ + GObjectClass *obj =3D G_OBJECT_CLASS(klass); + + obj->finalize =3D qemuDomainLogContextFinalize; +} + VIR_ONCE_GLOBAL_INIT(qemuDomain); =20 static void -qemuDomainLogContextDispose(void *obj) +qemuDomainLogContextFinalize(GObject *object) { - qemuDomainLogContextPtr ctxt =3D obj; + qemuDomainLogContextPtr ctxt =3D QEMU_DOMAIN_LOG_CONTEXT(object); VIR_DEBUG("ctxt=3D%p", ctxt); =20 virLogManagerFree(ctxt->manager); VIR_FREE(ctxt->path); VIR_FORCE_CLOSE(ctxt->writefd); VIR_FORCE_CLOSE(ctxt->readfd); + G_OBJECT_CLASS(qemu_domain_log_context_parent_class)->finalize(object); } =20 const char * @@ -10591,13 +10600,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(vi= rQEMUDriverPtr driver, qemuDomainLogContextMode m= ode) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - qemuDomainLogContextPtr ctxt =3D NULL; - - if (qemuDomainInitialize() < 0) - return NULL; - - if (!(ctxt =3D virObjectNew(qemuDomainLogContextClass))) - return NULL; + qemuDomainLogContextPtr ctxt =3D QEMU_DOMAIN_LOG_CONTEXT(g_object_new(= QEMU_TYPE_DOMAIN_LOG_CONTEXT, NULL)); =20 VIR_DEBUG("Context new %p stdioLogD=3D%d", ctxt, cfg->stdioLogD); ctxt->writefd =3D -1; @@ -10666,7 +10669,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(vir= QEMUDriverPtr driver, return ctxt; =20 error: - virObjectUnref(ctxt); + g_object_unref(ctxt); return NULL; } =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 099ee59772..9e2cec5779 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -20,7 +20,7 @@ */ =20 #pragma once - +#include #include "virthread.h" #include "vircgroup.h" #include "virperf.h" @@ -601,9 +601,9 @@ struct qemuProcessEvent { =20 void qemuProcessEventFree(struct qemuProcessEvent *event); =20 -typedef struct _qemuDomainLogContext qemuDomainLogContext; +#define QEMU_TYPE_DOMAIN_LOG_CONTEXT qemu_domain_log_context_get_type() +G_DECLARE_FINAL_TYPE(qemuDomainLogContext, qemu_domain_log_context, QEMU, = DOMAIN_LOG_CONTEXT, GObject); typedef qemuDomainLogContext *qemuDomainLogContextPtr; -G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainLogContext, virObjectUnref); =20 typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie; typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 67dad9841a..e7f5991b23 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1929,7 +1929,7 @@ static void qemuProcessMonitorLogFree(void *opaque) { qemuDomainLogContextPtr logCtxt =3D opaque; - virObjectUnref(logCtxt); + g_clear_object(&logCtxt); } =20 =20 @@ -1983,7 +1983,7 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomain= ObjPtr vm, int asyncJob, driver); =20 if (mon && logCtxt) { - virObjectRef(logCtxt); + g_object_ref(logCtxt); qemuMonitorSetDomainLog(mon, qemuProcessMonitorReportLogError, logCtxt, --=20 2.24.1