From nobody Wed Dec 17 06:01:15 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525704384201425.15439136954535; Mon, 7 May 2018 07:46:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 667EA80469; Mon, 7 May 2018 14:46:21 +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 2124930B4985; Mon, 7 May 2018 14:46:21 +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 AF0A7180BAE5; Mon, 7 May 2018 14:46:20 +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 w47Ef4Pf032362 for ; Mon, 7 May 2018 10:41:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 96C492024CA2; Mon, 7 May 2018 14:41:04 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BCBB2024CA1 for ; Mon, 7 May 2018 14:41:04 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:40:44 +0200 Message-Id: <20180507144100.25045-4-kkoukiou@redhat.com> In-Reply-To: <20180507144100.25045-1-kkoukiou@redhat.com> References: <20180507144100.25045-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 03/19] Register StoragePool Lifecycle Events 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 07 May 2018 14:46:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou --- data/org.libvirt.Connect.xml | 7 +++++++ src/connect.c | 13 +++++++++++++ src/connect.h | 1 + src/events.c | 43 ++++++++++++++++++++++++++++++++++++++++= +++ 4 files changed, 64 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 9207295..6b156d1 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -230,5 +230,12 @@ + + + + + + diff --git a/src/connect.c b/src/connect.c index 858db43..97c4857 100644 --- a/src/connect.c +++ b/src/connect.c @@ -60,6 +60,16 @@ virtDBusConnectClose(virtDBusConnect *connect, } } =20 + for (gint i =3D 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) { + if (connect->storagePoolCallbackIds[i] >=3D 0) { + if (deregisterEvents) { + virConnectStoragePoolEventDeregisterAny(connect->connectio= n, + connect->storagePo= olCallbackIds[i]); + } + connect->storagePoolCallbackIds[i] =3D -1; + } + } + virConnectClose(connect->connection); connect->connection =3D NULL; } @@ -1177,6 +1187,9 @@ virtDBusConnectNew(virtDBusConnect **connectp, for (gint i =3D 0; i < VIR_NETWORK_EVENT_ID_LAST; i++) connect->networkCallbackIds[i] =3D -1; =20 + for (gint i =3D 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) + connect->storagePoolCallbackIds[i] =3D -1; + connect->bus =3D bus; connect->uri =3D uri; connect->connectPath =3D connectPath; diff --git a/src/connect.h b/src/connect.h index d6c3830..b4df048 100644 --- a/src/connect.h +++ b/src/connect.h @@ -20,6 +20,7 @@ struct virtDBusConnect { =20 gint domainCallbackIds[VIR_DOMAIN_EVENT_ID_LAST]; gint networkCallbackIds[VIR_NETWORK_EVENT_ID_LAST]; + gint storagePoolCallbackIds[VIR_STORAGE_POOL_EVENT_ID_LAST]; }; typedef struct virtDBusConnect virtDBusConnect; =20 diff --git a/src/events.c b/src/events.c index ea55180..04967c2 100644 --- a/src/events.c +++ b/src/events.c @@ -143,6 +143,30 @@ virtDBusEventsNetworkLifecycle(virConnectPtr connectio= n G_GNUC_UNUSED, return 0; } =20 +static gint +virtDBusEventsStoragePoolLifecycle(virConnectPtr connection G_GNUC_UNUSED, + virStoragePoolPtr storagePool, + gint event, + gint detail, + gpointer opaque) +{ + virtDBusConnect *connect =3D opaque; + g_autofree gchar *path =3D NULL; + + path =3D virtDBusUtilBusPathForVirStoragePool(storagePool, + connect->storagePoolPath); + + g_dbus_connection_emit_signal(connect->bus, + NULL, + connect->connectPath, + VIRT_DBUS_CONNECT_INTERFACE, + "StoragePoolEvent", + g_variant_new("(ouu)", path, event, deta= il), + NULL); + + return 0; +} + static void virtDBusEventsRegisterDomainEvent(virtDBusConnect *connect, gint id, @@ -173,6 +197,21 @@ virtDBusEventsRegisterNetworkEvent(virtDBusConnect *co= nnect, NU= LL); } =20 +static void +virtDBusEventsRegisterStoragePoolEvent(virtDBusConnect *connect, + gint id, + virConnectStoragePoolEventGenericCa= llback callback) +{ + g_assert(connect->storagePoolCallbackIds[id] =3D=3D -1); + + connect->storagePoolCallbackIds[id] =3D virConnectStoragePoolEventRegi= sterAny(connect->connection, + = NULL, + = id, + = VIR_STORAGE_POOL_EVENT_CALLBACK(callback), + = connect, + = NULL); +} + void virtDBusEventsRegister(virtDBusConnect *connect) { @@ -199,4 +238,8 @@ virtDBusEventsRegister(virtDBusConnect *connect) virtDBusEventsRegisterNetworkEvent(connect, VIR_NETWORK_EVENT_ID_LIFECYCLE, VIR_NETWORK_EVENT_CALLBACK(virtDBus= EventsNetworkLifecycle)); + + virtDBusEventsRegisterStoragePoolEvent(connect, + VIR_STORAGE_POOL_EVENT_ID_LIFEC= YCLE, + VIR_STORAGE_POOL_EVENT_CALLBACK= (virtDBusEventsStoragePoolLifecycle)); } --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list