Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- 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 df91108..3aae9fe 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -248,6 +248,13 @@ <arg name="network" type="o"/> <arg name="event" type="u"/> </signal> + <signal name="SecretEvent"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-secret.html#virConnectSecretEventLifecycleCallback"/> + <arg name="secret" type="o"/> + <arg name="event" type="u"/> + <arg name="detail" type="u"/> + </signal> <signal name="StoragePoolEvent"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virConnectStoragePoolEventLifecycleCallback"/> diff --git a/src/connect.c b/src/connect.c index 5732d8a..6b96888 100644 --- a/src/connect.c +++ b/src/connect.c @@ -61,6 +61,16 @@ virtDBusConnectClose(virtDBusConnect *connect, } } + for (gint i = 0; i < VIR_SECRET_EVENT_ID_LAST; i++) { + if (connect->secretCallbackIds[i] >= 0) { + if (deregisterEvents) { + virConnectSecretEventDeregisterAny(connect->connection, + connect->secretCallbackIds[i]); + } + connect->secretCallbackIds[i] = -1; + } + } + for (gint i = 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) { if (connect->storagePoolCallbackIds[i] >= 0) { if (deregisterEvents) { @@ -1287,6 +1297,9 @@ virtDBusConnectNew(virtDBusConnect **connectp, for (gint i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i++) connect->networkCallbackIds[i] = -1; + for (gint i = 0; i < VIR_SECRET_EVENT_ID_LAST; i++) + connect->secretCallbackIds[i] = -1; + for (gint i = 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) connect->storagePoolCallbackIds[i] = -1; diff --git a/src/connect.h b/src/connect.h index 5c83cc6..08e1b68 100644 --- a/src/connect.h +++ b/src/connect.h @@ -21,6 +21,7 @@ struct virtDBusConnect { gint domainCallbackIds[VIR_DOMAIN_EVENT_ID_LAST]; gint networkCallbackIds[VIR_NETWORK_EVENT_ID_LAST]; + gint secretCallbackIds[VIR_SECRET_EVENT_ID_LAST]; gint storagePoolCallbackIds[VIR_STORAGE_POOL_EVENT_ID_LAST]; }; typedef struct virtDBusConnect virtDBusConnect; diff --git a/src/events.c b/src/events.c index 04967c2..53cd725 100644 --- a/src/events.c +++ b/src/events.c @@ -143,6 +143,29 @@ virtDBusEventsNetworkLifecycle(virConnectPtr connection G_GNUC_UNUSED, return 0; } +static gint +virtDBusEventsSecretLifecycle(virConnectPtr connection G_GNUC_UNUSED, + virSecretPtr secret, + gint event, + gint detail, + gpointer opaque) +{ + virtDBusConnect *connect = opaque; + g_autofree gchar *path = NULL; + + path = virtDBusUtilBusPathForVirSecret(secret, connect->secretPath); + + g_dbus_connection_emit_signal(connect->bus, + NULL, + connect->connectPath, + VIRT_DBUS_CONNECT_INTERFACE, + "SecretEvent", + g_variant_new("(ouu)", path, event, detail), + NULL); + + return 0; +} + static gint virtDBusEventsStoragePoolLifecycle(virConnectPtr connection G_GNUC_UNUSED, virStoragePoolPtr storagePool, @@ -197,6 +220,21 @@ virtDBusEventsRegisterNetworkEvent(virtDBusConnect *connect, NULL); } +static void +virtDBusEventsRegisterSecretEvent(virtDBusConnect *connect, + gint id, + virConnectSecretEventGenericCallback callback) +{ + g_assert(connect->secretCallbackIds[id] == -1); + + connect->secretCallbackIds[id] = virConnectSecretEventRegisterAny(connect->connection, + NULL, + id, + VIR_SECRET_EVENT_CALLBACK(callback), + connect, + NULL); +} + static void virtDBusEventsRegisterStoragePoolEvent(virtDBusConnect *connect, gint id, @@ -239,6 +277,10 @@ virtDBusEventsRegister(virtDBusConnect *connect) VIR_NETWORK_EVENT_ID_LIFECYCLE, VIR_NETWORK_EVENT_CALLBACK(virtDBusEventsNetworkLifecycle)); + virtDBusEventsRegisterSecretEvent(connect, + VIR_SECRET_EVENT_ID_LIFECYCLE, + VIR_SECRET_EVENT_CALLBACK(virtDBusEventsSecretLifecycle)); + virtDBusEventsRegisterStoragePoolEvent(connect, VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE, VIR_STORAGE_POOL_EVENT_CALLBACK(virtDBusEventsStoragePoolLifecycle)); -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list