Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
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 @@
<arg name="network" type="o"/>
<arg name="event" type="u"/>
</signal>
+ <signal name="StoragePoolEvent">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-storage.html#virConnectStoragePo...
+ <arg name="storagePool" type="o"/>
+ <arg name="event" type="u"/>
+ <arg name="detail" type="u"/>
+ </signal>
</interface>
</node>
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,
}
}
+ for (gint i = 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) {
+ if (connect->storagePoolCallbackIds[i] >= 0) {
+ if (deregisterEvents) {
+ virConnectStoragePoolEventDeregisterAny(connect->connection,
+
connect->storagePoolCallbackIds[i]);
+ }
+ connect->storagePoolCallbackIds[i] = -1;
+ }
+ }
+
virConnectClose(connect->connection);
connect->connection = NULL;
}
@@ -1177,6 +1187,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_STORAGE_POOL_EVENT_ID_LAST; i++)
+ connect->storagePoolCallbackIds[i] = -1;
+
connect->bus = bus;
connect->uri = uri;
connect->connectPath = 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 {
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;
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 connection
G_GNUC_UNUSED,
return 0;
}
+static gint
+virtDBusEventsStoragePoolLifecycle(virConnectPtr connection G_GNUC_UNUSED,
+ virStoragePoolPtr storagePool,
+ gint event,
+ gint detail,
+ gpointer opaque)
+{
+ virtDBusConnect *connect = opaque;
+ g_autofree gchar *path = NULL;
+
+ path = 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, detail),
+ NULL);
+
+ return 0;
+}
+
static void
virtDBusEventsRegisterDomainEvent(virtDBusConnect *connect,
gint id,
@@ -173,6 +197,21 @@ virtDBusEventsRegisterNetworkEvent(virtDBusConnect *connect,
NULL);
}
+static void
+virtDBusEventsRegisterStoragePoolEvent(virtDBusConnect *connect,
+ gint id,
+ virConnectStoragePoolEventGenericCallback
callback)
+{
+ g_assert(connect->storagePoolCallbackIds[id] == -1);
+
+ connect->storagePoolCallbackIds[id] =
virConnectStoragePoolEventRegisterAny(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(virtDBusEventsNetworkLifecycle));
+
+ virtDBusEventsRegisterStoragePoolEvent(connect,
+ VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE,
+
VIR_STORAGE_POOL_EVENT_CALLBACK(virtDBusEventsStoragePoolLifecycle));
}
--
2.15.0