From nobody Mon Feb 9 01:16:32 2026 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; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1589371117; cv=none; d=zohomail.com; s=zohoarc; b=Jwp55tNyuy6H4IngjQSy00ZV2wc8F/UmtCoHWcMzi+LHPbPt3scWsw/MAFtsaAF0qVIXoBucg8MM73ij9IwWs/19oAeXbReUdxHxePcQ8eN1aoaca9Oguv5rmAfK3vmriFAq+FTTLGpH7RUPftYOJdWPe7vrtXARlsC/jGE8FMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589371117; 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=rDikbyxrWBNaUz0LdHSeYqGUSlPZN9D7MoH2zhht9nE=; b=H0lg2FfGPc7+sjCL5eILzPmqGT1Qi7dZrhHoGK1vvY5qd4bwEPwz7xA2eFJBwLrJGFOQhYmtdJB0MHxOA+978mSVTuQ/qbe/PFy8J3GsRtqTnC7hDzHCooVxlVGpqaYFMkaCE04Cp1nZ/mb9j77JZYmnhmocHB4DuvkiSsRht2g= 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; dmarc=fail header.from= (p=none dis=none) header.from= 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 158937111756858.59458201661869; Wed, 13 May 2020 04:58:37 -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-285-wn5aY2VsNTeuS6891R4ZTg-1; Wed, 13 May 2020 07:58:32 -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 BDABE83DB3A; Wed, 13 May 2020 11:58:25 +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 9DE106E710; Wed, 13 May 2020 11:58:25 +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 69C70180599D; Wed, 13 May 2020 11:58:25 +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 04DBwIjA016013 for ; Wed, 13 May 2020 07:58:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id DD0E12028CD3; Wed, 13 May 2020 11:58:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D5F922026FFE for ; Wed, 13 May 2020 11:58:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 B30398007C8 for ; Wed, 13 May 2020 11:58:16 +0000 (UTC) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-328-sOz_z7zYOneX4DjCNwysVA-1; Wed, 13 May 2020 07:58:14 -0400 Received: by mail-wr1-f54.google.com with SMTP id l18so20522691wrn.6 for ; Wed, 13 May 2020 04:58:13 -0700 (PDT) Received: from localhost.localdomain (public-gprs367127.centertel.pl. [37.47.65.88]) by smtp.gmail.com with ESMTPSA id l1sm27838422wrc.24.2020.05.13.04.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 04:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589371116; 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=rDikbyxrWBNaUz0LdHSeYqGUSlPZN9D7MoH2zhht9nE=; b=IOWaRDbv/M0rege++dJ2yAI1C0p22GuGfA5XTnPU/3lVbBxeEE9rsV7MxkueWQ4cOq7hQ/ QhQqW36gprBZ9iGOrRo7t4MDJXlWwOC5HvIUHgVtLP+Ke8pAZAl+6swp3SsKTNnAfgQuKD xjgPoFS+Ny6N5GYOq4VwUytNFZn9DMI= X-MC-Unique: wn5aY2VsNTeuS6891R4ZTg-1 X-MC-Unique: sOz_z7zYOneX4DjCNwysVA-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=rDikbyxrWBNaUz0LdHSeYqGUSlPZN9D7MoH2zhht9nE=; b=SuafI7BSfqkT8AHFQK/CUtryWpFcaZ2+6q2bo/IYc+hg9n468OjDL0jloII+jCOzhI IQkx5ZQUSo1WS/ZS2SLhOVaFoxqVaiSkEBmD8F1oWyxFQGpQMnr3SLgFEGqgbxlNxg1k 6Y/mxRzAsc+8DUUzG9ba0N4+4OzLOpKwhKHqm+xdD2zWAXHDZnuOXL7lAAoMZxskCjiq w+WcNV5alQpBV7/MGH1B/2QyVDuY52a9T3zNpvLhQUVXyj5wWrxKvxvR7S0CRH7FFcCR LvLC4o596+eDG4GP4zB12/Gt7QLVuYupBtWcvy888yzxa8fr0VIzVdrfBiOk67Xyr2lp JMfw== X-Gm-Message-State: AGi0PuZOcdcpey6DfFYOFU5N0OZNcf2vmA+b8tKyyMpLRE5FbnkfEm4D ro0WuBgzxdDNffE+DQtzZcSUTuY9 X-Google-Smtp-Source: APiQypKLxf3lfc7kNd7meKo/8beUYt2EuGaYXqto35Sd2/B1vUgTE39EVSEYhlOIFGScaF26V6Cilg== X-Received: by 2002:adf:9d91:: with SMTP id p17mr23653695wre.119.1589371092669; Wed, 13 May 2020 04:58:12 -0700 (PDT) From: Rafael Fonseca To: libvirt-list@redhat.com Subject: [PATCH 08/40] bhyve: convert bhyveMonitor to GObject Date: Wed, 13 May 2020 13:56:52 +0200 Message-Id: <20200513115724.157687-9-r4f4rfs@gmail.com> In-Reply-To: <20200513115724.157687-1-r4f4rfs@gmail.com> References: <20200513115724.157687-1-r4f4rfs@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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/bhyve/bhyve_monitor.c | 37 ++++++++++++++++++++----------------- src/bhyve/bhyve_monitor.h | 3 ++- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c index e5cd39a086..20633cd320 100644 --- a/src/bhyve/bhyve_monitor.c +++ b/src/bhyve/bhyve_monitor.c @@ -39,7 +39,7 @@ VIR_LOG_INIT("bhyve.bhyve_monitor"); =20 struct _bhyveMonitor { - virObject parent; + GObject parent; =20 bhyveConnPtr driver; virDomainObjPtr vm; @@ -48,44 +48,48 @@ struct _bhyveMonitor { bool reboot; }; =20 -static virClassPtr bhyveMonitorClass; +G_DEFINE_TYPE(bhyveMonitor, bhyve_monitor, G_TYPE_OBJECT); =20 static void -bhyveMonitorDispose(void *obj) +bhyveMonitorFinalize(GObject *obj) { - bhyveMonitorPtr mon =3D obj; + bhyveMonitorPtr mon =3D BHYVE_MONITOR(obj); =20 VIR_FORCE_CLOSE(mon->kq); virObjectUnref(mon->vm); + + G_OBJECT_CLASS(bhyve_monitor_parent_class)->finalize(obj); } =20 -static int -bhyveMonitorOnceInit(void) +static void +bhyve_monitor_init(bhyveMonitor *mon G_GNUC_UNUSED) { - if (!VIR_CLASS_NEW(bhyveMonitor, virClassForObject())) - return -1; - - return 0; } =20 -VIR_ONCE_GLOBAL_INIT(bhyveMonitor); +static void +bhyve_monitor_class_init(bhyveMonitorClass *klass) +{ + GObjectClass *obj =3D G_OBJECT_CLASS(klass); + + obj->finalize =3D bhyveMonitorFinalize; +} =20 static void bhyveMonitorIO(int, int, int, void *); =20 static bool bhyveMonitorRegister(bhyveMonitorPtr mon) { - virObjectRef(mon); + g_object_ref(mon); mon->watch =3D virEventAddHandle(mon->kq, VIR_EVENT_HANDLE_READABLE | VIR_EVENT_HANDLE_ERROR | VIR_EVENT_HANDLE_HANGUP, bhyveMonitorIO, mon, - virObjectFreeCallback); + g_object_unref); if (mon->watch < 0) { VIR_DEBUG("failed to add event handle for mon %p", mon); - virObjectUnref(mon); + g_object_unref(mon); return false; } return true; @@ -181,8 +185,7 @@ bhyveMonitorOpenImpl(virDomainObjPtr vm, bhyveConnPtr d= river) if (bhyveMonitorInitialize() < 0) return NULL; =20 - if (!(mon =3D virObjectNew(bhyveMonitorClass))) - return NULL; + mon =3D BHYVE_MONITOR(g_object_new(BHYVE_TYPE_MONITOR, NULL)); =20 mon->driver =3D driver; mon->reboot =3D false; @@ -238,5 +241,5 @@ bhyveMonitorClose(bhyveMonitorPtr mon) VIR_DEBUG("cleaning up bhyveMonitor %p", mon); =20 bhyveMonitorUnregister(mon); - virObjectUnref(mon); + g_clear_object(&mon); } diff --git a/src/bhyve/bhyve_monitor.h b/src/bhyve/bhyve_monitor.h index 175cc87192..dcc6929696 100644 --- a/src/bhyve/bhyve_monitor.h +++ b/src/bhyve/bhyve_monitor.h @@ -24,7 +24,8 @@ #include "domain_conf.h" #include "bhyve_utils.h" =20 -typedef struct _bhyveMonitor bhyveMonitor; +#define BHYVE_TYPE_MONITOR bhyve_monitor_get_type() +G_DECLARE_FINAL_TYPE(bhyveMonitor, bhyve_monitor, BHYVE, MONITOR, GObject); typedef bhyveMonitor *bhyveMonitorPtr; =20 bhyveMonitorPtr bhyveMonitorOpen(virDomainObjPtr vm, bhyveConnPtr driver); --=20 2.26.2