Only one virt reader instance should take care of connection
handling (connection/disconnection) to avoid races and plugin
data corruption, potentially crashing collectd.
This bug cannot be triggered with instances=1 (default settings).
Signed-off-by: Francesco Romani <fromani@redhat.com>
return 0;
}
+static void lv_disconnect(void) {
+ if (conn != NULL)
+ virConnectClose(conn);
+ conn = NULL;
+ WARNING(PLUGIN_NAME " plugin: closed connection to libvirt");
+}
+
static int lv_read(user_data_t *ud) {
time_t t;
struct lv_read_instance *inst = NULL;
if ((last_refresh == (time_t)0) ||
((interval > 0) && ((last_refresh + interval) <= t))) {
if (refresh_lists(inst) != 0) {
- if (conn != NULL)
- virConnectClose(conn);
- conn = NULL;
+ if (inst->id == 0)
+ lv_disconnect();
return -1;
}
last_refresh = t;