Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.StoragePool.xml | 4 ++++ src/events.c | 27 +++++++++++++++++++++++++++ tests/test_storage.py | 10 ++++++++++ 3 files changed, 41 insertions(+) diff --git a/data/org.libvirt.StoragePool.xml b/data/org.libvirt.StoragePool.xml index f33ed38..01ab39d 100644 --- a/data/org.libvirt.StoragePool.xml +++ b/data/org.libvirt.StoragePool.xml @@ -66,5 +66,9 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolUndefine"/> </method> + <signal name="Refresh"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-storage.html#virConnectStoragePoolEventGenericCallback"/> + </signal> </interface> </node> diff --git a/src/events.c b/src/events.c index 53cd725..5880b1b 100644 --- a/src/events.c +++ b/src/events.c @@ -1,6 +1,7 @@ #include "domain.h" #include "events.h" #include "util.h" +#include "storagepool.h" #include <libvirt/libvirt.h> @@ -190,6 +191,28 @@ virtDBusEventsStoragePoolLifecycle(virConnectPtr connection G_GNUC_UNUSED, return 0; } +static gint +virtDBusEventsStoragePoolRefresh(virConnectPtr connection G_GNUC_UNUSED, + virStoragePoolPtr storagePool, + gpointer opaque) +{ + virtDBusConnect *connect = opaque; + g_autofree gchar *path = NULL; + + path = virtDBusUtilBusPathForVirStoragePool(storagePool, + connect->storagePoolPath); + + g_dbus_connection_emit_signal(connect->bus, + NULL, + path, + VIRT_DBUS_STORAGEPOOL_INTERFACE, + "Refresh", + NULL, + NULL); + + return 0; +} + static void virtDBusEventsRegisterDomainEvent(virtDBusConnect *connect, gint id, @@ -284,4 +307,8 @@ virtDBusEventsRegister(virtDBusConnect *connect) virtDBusEventsRegisterStoragePoolEvent(connect, VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE, VIR_STORAGE_POOL_EVENT_CALLBACK(virtDBusEventsStoragePoolLifecycle)); + + virtDBusEventsRegisterStoragePoolEvent(connect, + VIR_STORAGE_POOL_EVENT_ID_REFRESH, + VIR_STORAGE_POOL_EVENT_CALLBACK(virtDBusEventsStoragePoolRefresh)); } diff --git a/tests/test_storage.py b/tests/test_storage.py index d1d393f..b9e7090 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -108,6 +108,16 @@ class TestStoragePool(libvirttest.BaseTestClass): self.main_loop() + def test_storage_pool_refresh(self): + _, test_storage_pool = self.test_storage_pool() + interface_obj = dbus.Interface(test_storage_pool, + 'org.libvirt.StoragePool') + interface_obj.connect_to_signal('Refresh', + lambda: self.loop.quit()) + interface_obj.Refresh(0) + + self.main_loop() + if __name__ == '__main__': libvirttest.run() -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list