---
examples/object-events/event-test.c | 46 ++++++++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
index c1ff4a7..a951230 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -337,6 +337,26 @@ guestAgentLifecycleEventReasonToString(int event)
return "unknown";
}
+static const char *
+storagePoolEventToString(int event)
+{
+ switch ((virStoragePoolEventLifecycleType) event) {
+ case VIR_STORAGE_POOL_EVENT_DEFINED:
+ return "Defined";
+ case VIR_STORAGE_POOL_EVENT_UNDEFINED:
+ return "Undefined";
+ case VIR_STORAGE_POOL_EVENT_STARTED:
+ return "Started";
+ case VIR_STORAGE_POOL_EVENT_STOPPED:
+ return "Stopped";
+ case VIR_STORAGE_POOL_EVENT_REFRESHED:
+ return "Refreshed";
+ case VIR_STORAGE_POOL_EVENT_LAST:
+ break;
+ }
+ return "unknown";
+}
+
static int
myDomainEventCallback1(virConnectPtr conn ATTRIBUTE_UNUSED,
@@ -644,6 +664,20 @@ myNetworkEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
return 0;
}
+static int
+myStoragePoolEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolPtr dom,
+ int event,
+ int detail,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ printf("%s EVENT: Storage pool %s %s %d\n",
+ __func__, virStoragePoolGetName(dom),
+ storagePoolEventToString(event), detail);
+ return 0;
+}
+
+
static void
eventTypedParamsPrint(virTypedParameterPtr params,
int nparams)
@@ -899,6 +933,7 @@ main(int argc, char **argv)
virConnectPtr dconn = NULL;
int callback1ret = -1;
int callback16ret = -1;
+ int callback17ret = -1;
struct sigaction action_stop;
size_t i;
@@ -966,8 +1001,16 @@ main(int argc, char **argv)
VIR_NETWORK_EVENT_CALLBACK(myNetworkEventCallback),
strdup("net callback"),
myFreeFunc);
+ callback17ret = virConnectStoragePoolEventRegisterAny(dconn,
+ NULL,
+
VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE,
+
VIR_STORAGE_POOL_EVENT_CALLBACK(myStoragePoolEventCallback),
+ strdup("storage pool
callback"), myFreeFunc);
+
+
if ((callback1ret == -1) ||
- (callback16ret == -1))
+ (callback16ret == -1) ||
+ (callback17ret == -1))
goto cleanup;
if (virConnectSetKeepAlive(dconn, 5, 3) < 0) {
@@ -986,6 +1029,7 @@ main(int argc, char **argv)
printf("Deregistering event callbacks\n");
virConnectDomainEventDeregister(dconn, myDomainEventCallback1);
virConnectNetworkEventDeregisterAny(dconn, callback16ret);
+ virConnectStoragePoolEventDeregisterAny(dconn, callback17ret);
printf("Deregistering domain event callbacks\n");
--
2.5.5