From nobody Fri May 17 06:43:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584360658; cv=none; d=zohomail.com; s=zohoarc; b=eHd/wr9eBZ2i1mtBL0r9Exy6iz00YWHb4kMTO9PpMRDgcDUF5Z1PKhX+WwQ4yIJDgH7vJ0R2wD1u7DM1Hm4XLUazfXlQsJF87abdlj0S5nouMJTnK9xlxscafv46O0gmSIDLD3i/zWz6wc56S1cLgPNNC2gzchaTETSIZcBz1+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584360658; 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=V5St0DquduJJMPxvTKsKKpHh7n525DGASI3fW5NKKkM=; b=B9AkeiDSUh3GyJJ5bPELk8xxqMzCznZpLR7fdcWzkcDLyd7NwEdLCi/yQf1jNY56jn2XF50CCAgqFREwTEftpsF1oHAfBbJmW79T+F7QrZdstFKRA6+n7VnMkxuUP097JUr0SceJgvvf8a0CBt5R+N4UiCSXG5B3u2mLNszw738= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1584360658842877.1573399286044; Mon, 16 Mar 2020 05:10:58 -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-283-vHMCm84KPCCOVhWTyNIT5Q-1; Mon, 16 Mar 2020 08:10:55 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16B2919251BC; Mon, 16 Mar 2020 12:10:50 +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 DA20710016EB; Mon, 16 Mar 2020 12:10:49 +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 7368086A38; Mon, 16 Mar 2020 12:10:49 +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 02GCAldm003097 for ; Mon, 16 Mar 2020 08:10:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C8C410DCF6B; Mon, 16 Mar 2020 12:10:47 +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 57EC71004C6D for ; Mon, 16 Mar 2020 12:10:45 +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 487908F81C3 for ; Mon, 16 Mar 2020 12:10:45 +0000 (UTC) Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-370-EaDZn6qZOW6NYVylat_xWg-1; Mon, 16 Mar 2020 08:10:42 -0400 Received: by mail-pg1-f182.google.com with SMTP id x7so9646150pgh.5 for ; Mon, 16 Mar 2020 05:10:42 -0700 (PDT) Received: from localhost.localdomain ([103.57.87.224]) by smtp.gmail.com with ESMTPSA id x70sm55813032pgd.37.2020.03.16.05.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 05:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584360657; 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=V5St0DquduJJMPxvTKsKKpHh7n525DGASI3fW5NKKkM=; b=cxWCSefLPyk9YfDOZHnnycveo+WFSQ7mzrjZkaiA0zGvShZNTDZzescgoUm06O2NbIwCIQ cXH7v+Ek5qnyjUuPJ1vkGmd88pJ5Ba3X5TegciwlyG/bQCFAoXva7gG1X8kNsfIuYoEh2N KBCsoO7ne9ofzgdAcoYnSt/L3yGXWpQ= X-MC-Unique: vHMCm84KPCCOVhWTyNIT5Q-1 X-MC-Unique: EaDZn6qZOW6NYVylat_xWg-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=aQG3ak1CYz3i4ixf3gBSL38T4I3nM1E2BvR9IFYGKLg=; b=lO6T2HsyAUM6G540iHLNaYqFK0GHidYfyD5GiBOaKAX71Okfz8pbjiQS9N5ijGdRaO NJnD/sfe5/TDRMv/7KZSuCWDxA7L/XZUYM3UHG/hYyvog72BwX0QAN/dbwNt/zynwbO5 0qg2rPxvZnG80EGL0g7P/k7PerZk+BRMDpIP4AZMG4ifbK4Q/GSxkic2H1GKswtBzUpl 5HRfUegyAfyYKCwHWx9xUaxM7+GzrOeNt1ftFX/qgFHqCAytcYqqmHjT8uJSlDnG/bUD HlsHnW3v8/HXKL8MIvAjhpNuAISb5GfiE7+fgydA+aLWeNjH+jFPvZ7Y/dgglAGi2qDu zLbQ== X-Gm-Message-State: ANhLgQ2hnoNK3864QK7180R0XEhK+1Pt2/DGsHIS/UXYDkV0yvASllLB 21B7aAXK4La16YoMDVILAqIJh8DwELRzTQ== X-Google-Smtp-Source: ADFU+vuq0JrUOOYYAT+hkjkCU0IICYRBH5fXIggGu9eaTXnJ0/9zAoBYokU8BpLsONE4gctSXInesw== X-Received: by 2002:aa7:909a:: with SMTP id i26mr28536047pfa.144.1584360641234; Mon, 16 Mar 2020 05:10:41 -0700 (PDT) From: Gaurav Agrawal To: libvir-list@redhat.com Subject: [PATCHv2] qemu: convert DomainLogContext class to use GObject Date: Mon, 16 Mar 2020 17:40:24 +0530 Message-Id: <20200316121024.63152-1-agrawalgaurav@gnome.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02GCAldm003097 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.84 on 10.5.11.22 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: Gaurav Agrawal Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 35 +++++++++++++++++++---------------- src/qemu/qemu_domain.h | 5 +++-- src/qemu/qemu_process.c | 4 ++-- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7c962fb062..86e2ac7e41 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 * @@ -10587,13 +10596,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; @@ -10662,7 +10665,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(vir= QEMUDriverPtr driver, return ctxt; =20 error: - virObjectUnref(ctxt); + g_clear_object(&ctxt); return NULL; } =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 835321f54d..2f8b2f1399 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -21,6 +21,7 @@ =20 #pragma once =20 +#include #include "virthread.h" #include "vircgroup.h" #include "virperf.h" @@ -601,9 +602,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 454db21b31..e8401030a2 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