mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 23:37:42 +00:00
xenapi: Improve error message on session failure
XenAPI session login can fail for a number of reasons, but currently no specific reason is displayed to the user, e.g.: virsh -c XenAPI://citrix-xen.example.com/ Enter username for citrix-xen.example.com: root Enter root's password for citrix-xen.example.com: error: authentication failed: (null) error: failed to connect to the hypervisor This patch displays the session error description on failure.
This commit is contained in:
parent
08a6826a14
commit
006be75ee2
@ -166,7 +166,22 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
|
||||
privP->session = xen_session_login_with_password(call_func, privP, username,
|
||||
password, xen_api_latest_version);
|
||||
|
||||
if (privP->session != NULL && privP->session->ok) {
|
||||
if (privP->session == NULL) {
|
||||
/* From inspection of xen_session_login_with_password in
|
||||
* libxenserver(Version 5.6.100-1), this appears not to be currently
|
||||
* possible. The only way for this to be NULL would be on malloc
|
||||
* failure, except that the code doesn't check for this and would
|
||||
* segfault before returning.
|
||||
*
|
||||
* We don't assume the reason here for a failure in an external library.
|
||||
*/
|
||||
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to allocate xen session"));
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (privP->session->ok) {
|
||||
conn->privateData = privP;
|
||||
|
||||
VIR_FREE(username);
|
||||
@ -175,7 +190,8 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
|
||||
return VIR_DRV_OPEN_SUCCESS;
|
||||
}
|
||||
|
||||
xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, NULL);
|
||||
xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
|
||||
*privP->session->error_description);
|
||||
|
||||
error:
|
||||
VIR_FREE(username);
|
||||
|
Loading…
x
Reference in New Issue
Block a user