Set conn->driver before running driver connectOpen method

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@redhat.com>
This commit is contained in:
Daniel P. Berrange 2013-05-02 16:55:52 +01:00
parent a93cd08fd5
commit ba7b867b46

View File

@ -1201,6 +1201,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,
@ -1209,10 +1210,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;
}
}