From: Sebastian Harl Date: Thu, 27 Aug 2009 20:58:15 +0000 (+0200) Subject: patches: Added libvirt-reconnect.dpatch. X-Git-Tag: collectd-4.7.2-1~14 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3c2171b985900d0089324397f3298ef5557a1110;p=pkg-collectd.git patches: Added libvirt-reconnect.dpatch. This is an upstream patch to let the libvirt plugin re-connect to libvirtd if connecting fails. --- diff --git a/debian/changelog b/debian/changelog index e892a1b..0730141 100644 --- a/debian/changelog +++ b/debian/changelog @@ -37,6 +37,8 @@ collectd (4.7.2-1) unstable; urgency=low - Removed libcollectdclient_static_sstrerror.dpatch - included upstream. - Added network-fix-cacheflush.dpatch - upstream patch to fix the handling the CacheFlush config option of the network plugin. + - Added libvirt-reconnect.dpatch - upstream patch to let the libvirt + plugin re-connect to libvirtd if connecting fails. * debian/README.Debian: - Removed the note about how to get collectd2html.pl working with version 4 of collectd - the script now supports the --recursive option @@ -54,7 +56,7 @@ collectd (4.7.2-1) unstable; urgency=low - Set the 'apache' plugin's URL according to the default used by Debian's Apache; thanks to Joey Hess for reporting this (Closes: #541888). - -- Sebastian Harl Thu, 27 Aug 2009 22:49:24 +0200 + -- Sebastian Harl Thu, 27 Aug 2009 22:57:05 +0200 collectd (4.6.3-1) unstable; urgency=low diff --git a/debian/patches/00list b/debian/patches/00list index 57edf94..8183f54 100644 --- a/debian/patches/00list +++ b/debian/patches/00list @@ -1,4 +1,5 @@ rrd_filter_path.dpatch collection_conf_path.dpatch network-fix-cacheflush.dpatch +libvirt-reconnect.dpatch diff --git a/debian/patches/libvirt-reconnect.dpatch b/debian/patches/libvirt-reconnect.dpatch new file mode 100755 index 0000000..2069276 --- /dev/null +++ b/debian/patches/libvirt-reconnect.dpatch @@ -0,0 +1,86 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## libvirt-reconnect.dpatch by Alan Pevec and +## Florian Forster +## +## DP: libvirt plugin: Re-connect to libvirtd if connecting fails. +## DP: +## DP: https://bugzilla.redhat.com/show_bug.cgi?id=480997 + +@DPATCH@ + +diff a/src/libvirt.c b/src/libvirt.c +--- a/src/libvirt.c ++++ b/src/libvirt.c +@@ -24,6 +24,7 @@ + #include "plugin.h" + #include "configfile.h" + #include "utils_ignorelist.h" ++#include "utils_complain.h" + + #include + #include +@@ -49,6 +50,8 @@ static const char *config_keys[] = { + + /* Connection. */ + static virConnectPtr conn = 0; ++static char *conn_string = NULL; ++static c_complain_t conn_complain = C_COMPLAIN_INIT_STATIC; + + /* Seconds between list refreshes, 0 disables completely. */ + static int interval = 60; +@@ -153,15 +156,13 @@ lv_config (const char *key, const char *value) + il_interface_devices = ignorelist_create (1); + + if (strcasecmp (key, "Connection") == 0) { +- if (conn != 0) { +- ERROR ("Connection may only be given once in config file"); +- return 1; +- } +- conn = virConnectOpenReadOnly (value); +- if (!conn) { +- VIRT_ERROR (NULL, "connection failed"); ++ char *tmp = strdup (value); ++ if (tmp == NULL) { ++ ERROR ("libvirt plugin: Connection strdup failed."); + return 1; + } ++ sfree (conn_string); ++ conn_string = tmp; + return 0; + } + +@@ -253,19 +254,29 @@ lv_read (void) + int i; + + if (conn == NULL) { +- ERROR ("libvirt plugin: Not connected. Use Connection in " +- "config file to supply connection URI. For more information " +- "see "); +- return -1; ++ /* `conn_string == NULL' is acceptable. */ ++ conn = virConnectOpenReadOnly (conn_string); ++ if (conn == NULL) { ++ c_complain (LOG_ERR, &conn_complain, ++ "libvirt plugin: Unable to connect: " ++ "virConnectOpenReadOnly failed."); ++ return -1; ++ } + } ++ c_release (LOG_NOTICE, &conn_complain, ++ "libvirt plugin: Connection established."); + + time (&t); + + /* Need to refresh domain or device lists? */ + if ((last_refresh == (time_t) 0) || + ((interval > 0) && ((last_refresh + interval) <= t))) { +- if (refresh_lists () != 0) ++ if (refresh_lists () != 0) { ++ if (conn != NULL) ++ virConnectClose (conn); ++ conn = NULL; + return -1; ++ } + last_refresh = t; + } +