summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: deafbed)
raw | patch | inline | side by side (parent: deafbed)
author | Alan Pevec <apevec@redhat.com> | |
Tue, 11 Aug 2009 22:53:00 +0000 (00:53 +0200) | ||
committer | Florian Forster <octo@noris.net> | |
Wed, 12 Aug 2009 13:12:18 +0000 (15:12 +0200) |
https://bugzilla.redhat.com/show_bug.cgi?id=480997
Signed-off-by: Alan Pevec <apevec@redhat.com>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
Signed-off-by: Alan Pevec <apevec@redhat.com>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/libvirt.c | patch | blob | history |
diff --git a/src/libvirt.c b/src/libvirt.c
index 5acff29a578cd609dff2ba7de65bab1e13c4fc3b..6ba08fbca5ebc28249c5246e7a9030b49b94b242 100644 (file)
--- a/src/libvirt.c
+++ b/src/libvirt.c
/* Connection. */
static virConnectPtr conn = 0;
+static char *conn_string = NULL;
+static int conn_count = 0;
/* Seconds between list refreshes, 0 disables completely. */
static int interval = 60;
il_interface_devices = ignorelist_create (1);
if (strcasecmp (key, "Connection") == 0) {
- if (conn != 0) {
+ if (conn_count++ != 0) {
ERROR ("Connection may only be given once in config file");
return 1;
}
- conn = virConnectOpenReadOnly (value);
- if (!conn) {
- VIRT_ERROR (NULL, "connection failed");
- return 1;
+ conn_string = strdup(value);
+ if (conn_string == NULL) {
+ ERROR ("libvirt plugin: Connection strdup failed.");
+ return -1;
}
return 0;
}
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 = virConnectOpenReadOnly (conn_string);
+ if (conn == NULL) {
+ ERROR ("libvirt plugin: Not connected.");
+ return -1;
+ }
}
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;
}