From nobody Tue May 7 11:37:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583841650; cv=none; d=zohomail.com; s=zohoarc; b=jyLnCWN9lVq7sqLLR/kqs5cVLgTPH2DNtkV40GoOxIXRRexiSknzp5p1FmsvYQVUlI8zWIh6YzjcgiUZfhRNqLOZywhlCdW/fApBN4fJj4Es7V8UraINOln3M2JZfFCqChzyHVAnhzAwy65JcdDBUGi+X/SeMWoCGEG14IjxRaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583841650; 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=G9id36Esz6ebFMldWKqGktbkcIM9pfgcf0Z7zUxNnIE=; b=aGHdEMoYhykR8s6XipQVUHM6cHwve69+QL4Ru6POsOj5t6t3mTzsr1IToWFrlmd1pSQ498DNEijn27Az0MZYozQfoiTXgjeHEyJj8wil0rdpljySDWGm7u2IIEUJIrjN7ikEkl2oGxxGc+oiH/E9mVC/EAB/vzv53XlHLgF6Onc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1583841650049127.5089669483956; Tue, 10 Mar 2020 05:00:50 -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-444--IId9EdZP2-Ut7KkI45stQ-1; Tue, 10 Mar 2020 08:00:45 -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 DDE221005513; Tue, 10 Mar 2020 12:00:37 +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 104C79296D; Tue, 10 Mar 2020 12:00:37 +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 54466865F3; Tue, 10 Mar 2020 12:00:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02AC0Vvw025119 for ; Tue, 10 Mar 2020 08:00:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5540A2028CD2; Tue, 10 Mar 2020 12:00:31 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F9FA2028CD5 for ; Tue, 10 Mar 2020 12:00:29 +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 DA4328BA537 for ; Tue, 10 Mar 2020 12:00:28 +0000 (UTC) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-ayfzBdFQPIinNaZoK9Xvgw-1; Tue, 10 Mar 2020 08:00:26 -0400 Received: by mail-pg1-f172.google.com with SMTP id 37so2035606pgm.11 for ; Tue, 10 Mar 2020 05:00:26 -0700 (PDT) Received: from localhost.localdomain ([103.57.87.111]) by smtp.gmail.com with ESMTPSA id q20sm5006340pfh.89.2020.03.10.05.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 05:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583841647; 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=G9id36Esz6ebFMldWKqGktbkcIM9pfgcf0Z7zUxNnIE=; b=FUvTBAhmbri9RqNb/Owhh6bivPdHukGy0iwGrVnQDhLOAlDrtX8FLaqf6OOeHeLS3jHIY/ rTGJWspf2eMrN0djB1lQ8Kar0UooviXqqJTtMFPOUbeJgrB+fTUEBShB06TwGKibDQiZAn dKDZxdfZ4NOjHlXKplnvCqJ5YtwDMNk= X-MC-Unique: -IId9EdZP2-Ut7KkI45stQ-1 X-MC-Unique: ayfzBdFQPIinNaZoK9Xvgw-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=7h0jrzD80biKMpEU/II+/OWtbh8FPu4hRkLdCzJ/3es=; b=qZ8MBL3rTukLmSWlg1XV/UnDpZ2TwuJVSJ7L8qsdf+EwaiiR5IbvVh0x/m6+D2ZPzs b1AAPetm6dEZvsz46f9jVqbWuczfdRdUzSe5tr9xhZ5RetA7ylM8mYO3eb7fAAJIc9Dw 3yI+zsGflFFvN0wdkn2lFeqnHdyUpV2Tpv+h6k+a14q8EQ5Tv6mYmHlBWB2PGT+fzLw9 XAjWBoO5vpsxLXO/4fQYrSBpSYZ3wxQs8id+adRqZ7zdgEkFUrEbTzpqGSCEjQ/W/9/f pkTfiNUBknATR+T3d2nX+KQk4/Gq8bc1mOKoiEpGz0INy0IyJHmdgzFs+nzvFBtOFCm+ K5CA== X-Gm-Message-State: ANhLgQ1M4YTRI26AHt8NLOXkRKpwkoadfOjZxYWX1RAZ7pohTcOWx6Cz 8VYJh1qgks0gE3wqPwVM0U6dpuwHiZs= X-Google-Smtp-Source: ADFU+vuEBaYsK4jSW9svD8GqfaPRFU6cAHbSqeqGgofF2ip0mk/erPaRkfNi3Xm5yz5jsXCmWliLnA== X-Received: by 2002:a62:a501:: with SMTP id v1mr22223394pfm.7.1583841624833; Tue, 10 Mar 2020 05:00:24 -0700 (PDT) From: Gaurav Agrawal To: libvir-list@redhat.com Subject: [RFC] qemu: convert DomainLogContext class to use GObject Date: Tue, 10 Mar 2020 17:30:01 +0530 Message-Id: <20200310120001.5451-1-agrawalgaurav@gnome.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02AC0Vvw025119 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.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" --- src/qemu/qemu_domain.c | 36 ++++++++++++++++++++---------------- src/qemu/qemu_domain.h | 6 ++++-- src/qemu/qemu_process.c | 4 ++-- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3d3f796d85..0d2edf4dbe 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -150,7 +150,7 @@ qemuDomainObjFromDomain(virDomainPtr domain) =20 =20 struct _qemuDomainLogContext { - virObject parent; + GObject parent; =20 int writefd; int readfd; /* Only used if manager =3D=3D NULL */ @@ -160,37 +160,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 * @@ -10557,13 +10566,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; @@ -10632,7 +10635,8 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(vir= QEMUDriverPtr driver, return ctxt; =20 error: - virObjectUnref(ctxt); + if (ctxt) + g_object_unref(ctxt); return NULL; } =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3929ee9ca1..3c270b87a2 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -37,6 +37,8 @@ #include "virmdev.h" #include "virchrdev.h" #include "virobject.h" +#include "internal.h" +#include #include "logging/log_manager.h" #include "virdomainmomentobjlist.h" #include "virenum.h" @@ -598,9 +600,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 499d39a920..9f7c245c7e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1925,7 +1925,7 @@ static void qemuProcessMonitorLogFree(void *opaque) { qemuDomainLogContextPtr logCtxt =3D opaque; - virObjectUnref(logCtxt); + g_clear_object(&logCtxt); } =20 =20 @@ -1978,7 +1978,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