提交 ec3fa12e 编写于 作者: M Matthias Bolte

phyp: Use actual error code instead of 0

上级 6f5e6332
......@@ -61,6 +61,10 @@
#define VIR_FROM_THIS VIR_FROM_PHYP
#define PHYP_ERROR(conn, code, fmt...) \
virReportErrorHelper(conn, VIR_FROM_PHYP, code, __FILE__, __FUNCTION__, \
__LINE__, fmt)
/*
* URI: phyp://user@[hmc|ivm]/managed_system
* */
......@@ -86,26 +90,17 @@ phypOpen(virConnectPtr conn,
return VIR_DRV_OPEN_DECLINED;
if (conn->uri->server == NULL) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
_("Missing server name in phyp:// URI"));
return VIR_DRV_OPEN_ERROR;
}
if (conn->uri->path == NULL) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
_("Missing managed system name in phyp:// URI"));
return VIR_DRV_OPEN_ERROR;
}
if (conn->uri->path == NULL) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
_("Missing path name in phyp:// URI"));
return VIR_DRV_OPEN_ERROR;
}
if (VIR_ALLOC(phyp_driver) < 0) {
virReportOOMError(conn);
goto failure;
......@@ -148,15 +143,13 @@ phypOpen(virConnectPtr conn,
*char_ptr = '\0';
if (escape_specialcharacters(conn->uri->path, string, len) == -1) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
_("Error parsing 'path'. Invalid characters."));
goto failure;
}
if ((session = openSSHSession(conn, auth, &internal_socket)) == NULL) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
_("Error while opening SSH session."));
goto failure;
}
......@@ -244,8 +237,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
ret = getaddrinfo(hostname, "22", &hints, &ai);
if (ret != 0) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
_("Error while getting %s address info"), hostname);
goto err;
}
......@@ -262,8 +254,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
cur = cur->ai_next;
}
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
_("Failed to connect to %s"), hostname);
freeaddrinfo(ai);
goto err;
......@@ -283,8 +274,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
while ((rc = libssh2_session_startup(session, sock)) ==
LIBSSH2_ERROR_EAGAIN) ;
if (rc) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
_("Failure establishing SSH session."));
goto disconnect;
}
......@@ -307,8 +297,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
};
if (!auth || !auth->cb) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
_("No authentication callback provided."));
goto disconnect;
}
......@@ -319,8 +308,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
}
if (!hasPassphrase) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
_("Required credentials are not supported."));
goto disconnect;
}
......@@ -329,8 +317,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
(auth->cb) (creds, ARRAY_CARDINALITY(creds), auth->cbdata);
if (res < 0) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
_("Unable to fetch credentials."));
goto disconnect;
}
......@@ -338,8 +325,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
if (creds[0].result) {
password = creds[0].result;
} else {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
_("Unable to get password certificates"));
goto disconnect;
}
......@@ -350,8 +336,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
LIBSSH2_ERROR_EAGAIN) ;
if (rc) {
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
_("Authentication failed"));
goto disconnect;
} else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册