summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 656f77d)
raw | patch | inline | side by side (parent: 656f77d)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 27 Aug 2009 20:58:15 +0000 (22:58 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 27 Aug 2009 21:02:51 +0000 (23:02 +0200) |
This is an upstream patch to let the libvirt plugin re-connect to libvirtd if
connecting fails.
connecting fails.
debian/changelog | patch | blob | history | |
debian/patches/00list | patch | blob | history | |
debian/patches/libvirt-reconnect.dpatch | [new file with mode: 0755] | patch | blob |
diff --git a/debian/changelog b/debian/changelog
index e892a1b0f39a8b00af0603eb50ecdf0daa8af2d1..07301416bf38bb1bd487ef497f1b4d485ebf926d 100644 (file)
--- a/debian/changelog
+++ b/debian/changelog
- 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
- 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 <tokkee@debian.org> Thu, 27 Aug 2009 22:49:24 +0200
+ -- Sebastian Harl <tokkee@debian.org> 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 57edf94ab3c0bc08b15f741d4308428ddc62cc1b..8183f5419a9cce13ef34bc7db2908f5481b8c1e2 100644 (file)
--- a/debian/patches/00list
+++ b/debian/patches/00list
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
--- /dev/null
@@ -0,0 +1,86 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## libvirt-reconnect.dpatch by Alan Pevec <apevec@redhat.com> and
+## Florian Forster <octo@verplant.org>
+##
+## 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 <libvirt/libvirt.h>
+ #include <libvirt/virterror.h>
+@@ -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 <http://libvirt.org/uri.html>");
+- 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;
+ }
+