Commit bd653d14 authored by Katerina Koukiou's avatar Katerina Koukiou

Register Secret Lifecycle Events

Signed-off-by: default avatarKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Pavel Hrdina's avatarPavel Hrdina <phrdina@redhat.com>
parent 4d38c82b
......@@ -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"/>
......
......@@ -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;
......
......@@ -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;
......
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment