As per virEventRunDefaultImpl() documentation, this function will block
forever if there are no registered event handlers.
This leads to Collectd is unable to correctly stop event_loop thread
if libvirtd was restarted.
Added empty timeout callback to fix this.
return 0;
}
+static void virt_eventloop_timeout_cb(int timer ATTRIBUTE_UNUSED,
+ void *timer_info) {}
+
static int register_event_impl(void) {
if (virEventRegisterDefaultImpl() < 0) {
virErrorPtr err = virGetLastError();
return -1;
}
+ if (virEventAddTimeout(CDTIME_T_TO_MS(plugin_get_interval()),
+ virt_eventloop_timeout_cb, NULL, NULL) < 0) {
+ virErrorPtr err = virGetLastError();
+ ERROR(PLUGIN_NAME " plugin: virEventAddTimeout failed: %s",
+ err && err->message ? err->message : "Unknown error");
+ return -1;
+ }
+
return 0;
}