summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3602864)
raw | patch | inline | side by side (parent: 3602864)
author | Florian Forster <octo@huhu.verplant.org> | |
Wed, 12 Aug 2009 13:08:40 +0000 (15:08 +0200) | ||
committer | Florian Forster <octo@noris.net> | |
Wed, 12 Aug 2009 13:24:39 +0000 (15:24 +0200) |
Use the complaint mechanism for failed connection attempts and handle multiple
`Connection' configuration options like other options in other plugins (i. e.
later options overwrite earlier settings of the same name).
`Connection' configuration options like other options in other plugins (i. e.
later options overwrite earlier settings of the same name).
src/libvirt.c | patch | blob | history |
diff --git a/src/libvirt.c b/src/libvirt.c
index 6ba08fbca5ebc28249c5246e7a9030b49b94b242..6f9e5f126d497b44ef2c42e2cd437cae3f5a1b49 100644 (file)
--- a/src/libvirt.c
+++ b/src/libvirt.c
#include "plugin.h"
#include "configfile.h"
#include "utils_ignorelist.h"
+#include "utils_complain.h"
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
/* Connection. */
static virConnectPtr conn = 0;
static char *conn_string = NULL;
-static int conn_count = 0;
+static c_complain_t conn_complain = C_COMPLAIN_INIT_STATIC;
/* Seconds between list refreshes, 0 disables completely. */
static int interval = 60;
il_interface_devices = ignorelist_create (1);
if (strcasecmp (key, "Connection") == 0) {
- if (conn_count++ != 0) {
- ERROR ("Connection may only be given once in config file");
- return 1;
- }
- conn_string = strdup(value);
- if (conn_string == NULL) {
+ char *tmp = strdup (value);
+ if (tmp == NULL) {
ERROR ("libvirt plugin: Connection strdup failed.");
- return -1;
+ return 1;
}
+ sfree (conn_string);
+ conn_string = tmp;
return 0;
}
int i;
if (conn == NULL) {
+ /* `conn_string == NULL' is acceptable. */
conn = virConnectOpenReadOnly (conn_string);
if (conn == NULL) {
- ERROR ("libvirt plugin: Not connected.");
+ 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);