From: "Daniel P. Berrange" <berrange(a)redhat.com>
The access control checks in the 'connectOpen' driver method
will require 'conn->driver' to be non-NULL. Set this before
running the 'connectOpen' method and NULL-ify it again on
failure.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/libvirt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index eee67d9..23e2a9a 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1213,6 +1213,7 @@ do_open(const char *name,
}
VIR_DEBUG("trying driver %d (%s) ...", i, virDriverTab[i]->name);
+ ret->driver = virDriverTab[i];
res = virDriverTab[i]->connectOpen(ret, auth, flags);
VIR_DEBUG("driver %d %s returned %s",
i, virDriverTab[i]->name,
@@ -1221,10 +1222,12 @@ do_open(const char *name,
(res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown
status")));
if (res == VIR_DRV_OPEN_SUCCESS) {
- ret->driver = virDriverTab[i];
break;
} else if (res == VIR_DRV_OPEN_ERROR) {
+ ret->driver = NULL;
goto failed;
+ } else {
+ ret->driver = NULL;
}
}
--
1.8.1.4