From nobody Sun Feb 8 05:28:36 2026 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=1584127581; cv=none; d=zohomail.com; s=zohoarc; b=CAcyeoZLYlE5EPqwIXNur9KSQSLOA5IDiLI2euZHlZZmrlRYcL8W8UfotA9YAQ+AbWMip5t6rYN5RIjvU9DZKPWQrDXdfbqKRrwXFrxI1KcolD0a5QjhBba/fLBT7zasp8udyl7aBS2ADBw2fQF71+wxNPpSKMg7zftL7yFO58U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584127581; 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=qSDicR3yMLkqrrC28k6U5cvWZKz80/fZbcKEhyTx4ds=; b=Idzy6pyl10K94m+hUkmn8jDTZwwF0TiziaI4r9mQsu0vwabaEisWGpbGOSsIuMrqmKGL4UYpuoCatOTnNn8WebNH64fSZpNeSP86DbnlqZ8DTsiHf9y0PDBMEO1RUpTnt91Ec75cRKvW2yZZAW1r3RAfc28ZGgD9d59bQxO5k4c= 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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1584127581063985.9605696980938; Fri, 13 Mar 2020 12:26:21 -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-360-eZ4oSHxYNAaPvFyfOhRknQ-1; Fri, 13 Mar 2020 15:26:17 -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 D5B5A1005512; Fri, 13 Mar 2020 19:26:11 +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 167AC91D77; Fri, 13 Mar 2020 19:26:11 +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 EE3301803C32; Fri, 13 Mar 2020 19:26:08 +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 02DJQ7s2016051 for ; Fri, 13 Mar 2020 15:26:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 927A62166B30; Fri, 13 Mar 2020 19:26:07 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C7402166B31 for ; Fri, 13 Mar 2020 19:26:05 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 F1D8B185A78F for ; Fri, 13 Mar 2020 19:26:04 +0000 (UTC) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-331-ETmeidEJP4u5XcmWfjYJFg-1; Fri, 13 Mar 2020 15:26:02 -0400 Received: by mail-pf1-f196.google.com with SMTP id 2so5810422pfg.12 for ; Fri, 13 Mar 2020 12:26:02 -0700 (PDT) Received: from localhost.localdomain ([103.57.87.164]) by smtp.gmail.com with ESMTPSA id f3sm49797969pgg.46.2020.03.13.12.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2020 12:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584127579; 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=qSDicR3yMLkqrrC28k6U5cvWZKz80/fZbcKEhyTx4ds=; b=e6AoBYfKxaCTggyS5QO/eaGUgrTMkhQxDzVOKq27+sqOJSouXSMGMX54cW9qd0znxzAa7M qUAcPke9k/SChM4sXhV0NyCjNtAJuiCPDY6LVimVANnnhSwuAEL62aMPStU7qhUWZHnJLd uudOkBHa6MNbD/h6YZHZKZ01hYPk2KQ= X-MC-Unique: eZ4oSHxYNAaPvFyfOhRknQ-1 X-MC-Unique: ETmeidEJP4u5XcmWfjYJFg-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=xz14wDHpIku64Qd/THqVzeiqXrDSaqJxMmHtC8Lx55U=; b=Un20Bda7G/vIREyHqKpWMhun1UTIRVqlJNMzTWPVEBTyfVdIlpgMwpp+DGMgxvEkMF 25xjnEmDpEXYpRONtAENQIZxbw/WBZQYgI1jVacrrHBBploOesEV3kOsqic/i3/MiQX8 ZWIdH+Pi5U3Hp4hFZTDjfIBbj3GplmMiD6K7OCsLY63GlWMMQaWKRAkGUD2Idh6nNzFn gX7OTS3BR7VeeyI1cb8wy02gV7h3z6HLveAKf45g4HXyvnGrmTwp3kt04TzdrRp4W1Zn QIZYbMZ/jAGZmPI8RZUYAMgWKiUlqQwL46vDoOl6U856e7drvcZXWAs0M91krJZcRpvp AeAA== X-Gm-Message-State: ANhLgQ3xdoPCzerxHImxjWwbzYaDQu3zQb/qdmiprpuDL2p33mvDncYj zEsUGVMPQQCN3D8mTj0R3xvwVMf5yQU= X-Google-Smtp-Source: ADFU+vs9Mt5bqnz0BAlqIVFXY6mF4/pF1tKo9dv1t8a4C9ehbJ17JUVZsWYKOUMtUS/xU/aK/QYUQw== X-Received: by 2002:a63:9d04:: with SMTP id i4mr14446100pgd.294.1584127560663; Fri, 13 Mar 2020 12:26:00 -0700 (PDT) From: Gaurav Agrawal To: libvir-list@redhat.com Subject: [PATCH] qemu: convert DomainLogContext class to use GObject Date: Sat, 14 Mar 2020 00:55:43 +0530 Message-Id: <20200313192543.69066-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 02DJQ7s2016051 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" 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 4b467afa81..b91364b1a8 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_clear_object(&ctxt); return NULL; } =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 099ee59772..ab4206177c 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