From nobody Wed Feb 11 06:31:51 2026 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 1529082269238879.4219839993383; Fri, 15 Jun 2018 10:04:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7EF461B9C; Fri, 15 Jun 2018 17:04:27 +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 7172BBC588; Fri, 15 Jun 2018 17:04:27 +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 206C918037F0; Fri, 15 Jun 2018 17:04:27 +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 w5FH3sDE029791 for ; Fri, 15 Jun 2018 13:03:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 66444202660C; Fri, 15 Jun 2018 17:03:54 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A7522026609 for ; Fri, 15 Jun 2018 17:03:53 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:39 +0200 Message-Id: <20180615170350.20851-4-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-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/14] Register NodeDevice 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 15 Jun 2018 17:04:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.Connect.xml | 7 +++++++ src/connect.c | 13 +++++++++++++ src/connect.h | 1 + src/events.c | 42 ++++++++++++++++++++++++++++++++++++++++= ++ 4 files changed, 63 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 137e67b..3828832 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -339,6 +339,13 @@ + + + + + + diff --git a/src/connect.c b/src/connect.c index 919172a..1c27768 100644 --- a/src/connect.c +++ b/src/connect.c @@ -65,6 +65,16 @@ virtDBusConnectClose(virtDBusConnect *connect, } } =20 + for (gint i =3D 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++) { + if (connect->devCallbackIds[i] >=3D 0) { + if (deregisterEvents) { + virConnectNetworkEventDeregisterAny(connect->connection, + connect->devCallbackId= s[i]); + } + connect->devCallbackIds[i] =3D -1; + } + } + for (gint i =3D 0; i < VIR_SECRET_EVENT_ID_LAST; i++) { if (connect->secretCallbackIds[i] >=3D 0) { if (deregisterEvents) { @@ -1744,6 +1754,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_NODE_DEVICE_EVENT_ID_LAST; i++) + connect->devCallbackIds[i] =3D -1; + for (gint i =3D 0; i < VIR_SECRET_EVENT_ID_LAST; i++) connect->secretCallbackIds[i] =3D -1; =20 diff --git a/src/connect.h b/src/connect.h index 3b62edd..a864041 100644 --- a/src/connect.h +++ b/src/connect.h @@ -24,6 +24,7 @@ struct virtDBusConnect { =20 gint domainCallbackIds[VIR_DOMAIN_EVENT_ID_LAST]; gint networkCallbackIds[VIR_NETWORK_EVENT_ID_LAST]; + gint devCallbackIds[VIR_NODE_DEVICE_EVENT_ID_LAST]; gint secretCallbackIds[VIR_SECRET_EVENT_ID_LAST]; gint storagePoolCallbackIds[VIR_STORAGE_POOL_EVENT_ID_LAST]; }; diff --git a/src/events.c b/src/events.c index b51664f..60cbecd 100644 --- a/src/events.c +++ b/src/events.c @@ -567,6 +567,29 @@ virtDBusEventsNetworkEvent(virConnectPtr connection G_= GNUC_UNUSED, return 0; } =20 +static gint +virtDBusEventsNodeDeviceEvent(virConnectPtr connection G_GNUC_UNUSED, + virNodeDevicePtr dev, + gint event, + gint detail, + gpointer opaque) +{ + virtDBusConnect *connect =3D opaque; + g_autofree gchar *path =3D NULL; + + path =3D virtDBusUtilBusPathForVirNodeDevice(dev, connect->devPath); + + g_dbus_connection_emit_signal(connect->bus, + NULL, + connect->connectPath, + VIRT_DBUS_CONNECT_INTERFACE, + "NodeDeviceEvent", + g_variant_new("(oii)", path, event, deta= il), + NULL); + + return 0; +} + static gint virtDBusEventsSecretEvent(virConnectPtr connection G_GNUC_UNUSED, virSecretPtr secret, @@ -666,6 +689,21 @@ virtDBusEventsRegisterNetworkEvent(virtDBusConnect *co= nnect, NU= LL); } =20 +static void +virtDBusEventsRegisterNodeDeviceEvent(virtDBusConnect *connect, + gint id, + virConnectNodeDeviceEventGenericCall= back callback) +{ + g_assert(connect->devCallbackIds[id] =3D=3D -1); + + connect->devCallbackIds[id] =3D virConnectNodeDeviceEventRegisterAny(c= onnect->connection, + NUL= L, + id, + VIR= _NODE_DEVICE_EVENT_CALLBACK(callback), + con= nect, + NUL= L); +} + static void virtDBusEventsRegisterSecretEvent(virtDBusConnect *connect, gint id, @@ -791,6 +829,10 @@ virtDBusEventsRegister(virtDBusConnect *connect) VIR_NETWORK_EVENT_ID_LIFECYCLE, VIR_NETWORK_EVENT_CALLBACK(virtDBus= EventsNetworkEvent)); =20 + virtDBusEventsRegisterNodeDeviceEvent(connect, + VIR_NODE_DEVICE_EVENT_ID_LIFECYC= LE, + VIR_NODE_DEVICE_EVENT_CALLBACK(v= irtDBusEventsNodeDeviceEvent)); + virtDBusEventsRegisterSecretEvent(connect, VIR_SECRET_EVENT_ID_LIFECYCLE, VIR_SECRET_EVENT_CALLBACK(virtDBusEv= entsSecretEvent)); --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list