1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-25 10:03:49 +03:00

Convert all files in src/rpc/ to use virReportError()

This rmoves all the per-file error reporting macros
from the code in src/rpc/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2012-07-18 11:41:47 +01:00
parent f6d4405e3c
commit 7c45ad4ba2
12 changed files with 316 additions and 354 deletions

View File

@ -33,9 +33,6 @@
#include "virkeepalive.h"
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct _virKeepAlive {
int refs;
@ -287,7 +284,7 @@ virKeepAliveStart(virKeepAlivePtr ka,
if (interval > 0) {
if (ka->interval > 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("keepalive interval already set"));
goto cleanup;
}

View File

@ -38,9 +38,6 @@
#include "virterror_internal.h"
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
typedef struct _virNetClientCall virNetClientCall;
typedef virNetClientCall *virNetClientCallPtr;
@ -651,7 +648,7 @@ int virNetClientSetTLSSession(virNetClientPtr client,
goto error;
}
if (len != 1 || buf[0] != '\1') {
virNetError(VIR_ERR_RPC, "%s",
virReportError(VIR_ERR_RPC, "%s",
_("server verification (of our certificate or IP "
"address) failed"));
goto error;
@ -802,7 +799,7 @@ virNetClientCallDispatchReply(virNetClientPtr client)
thecall = thecall->next;
if (!thecall) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("no call waiting for reply with prog %d vers %d serial %d"),
client->msg.header.prog, client->msg.header.vers, client->msg.header.serial);
return -1;
@ -968,7 +965,7 @@ virNetClientCallDispatch(virNetClientPtr client)
return virNetClientCallDispatchStream(client);
default:
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("got unexpected RPC call prog %d vers %d proc %d type %d"),
client->msg.header.prog, client->msg.header.vers,
client->msg.header.proc, client->msg.header.type);
@ -1413,7 +1410,7 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
}
if (fds[0].revents & (POLLHUP | POLLERR)) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("received hangup / error event on socket"));
goto error;
}
@ -1554,7 +1551,7 @@ static int virNetClientIO(virNetClientPtr client,
/* Go to sleep while other thread is working... */
if (virCondWait(&thiscall->cond, &client->lock) < 0) {
virNetClientCallRemove(&client->waitDispatch, thiscall);
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to wait on condition"));
return -1;
}
@ -1673,14 +1670,14 @@ virNetClientCallNew(virNetMessagePtr msg,
if (expectReply &&
(msg->bufferLength != 0) &&
(msg->header.status == VIR_NET_CONTINUE)) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Attempt to send an asynchronous message with"
" a synchronous reply"));
goto error;
}
if (expectReply && nonBlock) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Attempt to send a non-blocking message with"
" a synchronous reply"));
goto error;
@ -1692,7 +1689,7 @@ virNetClientCallNew(virNetMessagePtr msg,
}
if (virCondInit(&call->cond) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot initialize condition variable"));
goto error;
}
@ -1757,7 +1754,7 @@ static int virNetClientSendInternal(virNetClientPtr client,
msg->header.type, msg->header.status, msg->header.serial);
if (!client->sock || client->wantClose) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("client socket is closed"));
return -1;
}

View File

@ -35,9 +35,6 @@
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetClientProgram {
int refs;
@ -336,18 +333,18 @@ int virNetClientProgramCall(virNetClientProgramPtr prog,
*/
if (msg->header.type != VIR_NET_REPLY &&
msg->header.type != VIR_NET_REPLY_WITH_FDS) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected message type %d"), msg->header.type);
goto error;
}
if (msg->header.proc != proc) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected message proc %d != %d"),
msg->header.proc, proc);
goto error;
}
if (msg->header.serial != serial) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected message serial %d != %d"),
msg->header.serial, serial);
goto error;
@ -388,7 +385,7 @@ int virNetClientProgramCall(virNetClientProgramPtr prog,
goto error;
default:
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("Unexpected message status %d"), msg->header.status);
goto error;
}

View File

@ -31,9 +31,6 @@
#include "threads.h"
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetClientStream {
virMutex lock;
@ -147,7 +144,7 @@ virNetClientStreamPtr virNetClientStreamNew(virNetClientProgramPtr prog,
st->serial = serial;
if (virMutexInit(&st->lock) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot initialize mutex"));
VIR_FREE(st);
return NULL;
@ -452,7 +449,7 @@ int virNetClientStreamEventAddCallback(virNetClientStreamPtr st,
virMutexLock(&st->lock);
if (st->cb) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("multiple stream callbacks not supported"));
goto cleanup;
}
@ -488,7 +485,7 @@ int virNetClientStreamEventUpdateCallback(virNetClientStreamPtr st,
virMutexLock(&st->lock);
if (!st->cb) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("no stream callback registered"));
goto cleanup;
}
@ -510,7 +507,7 @@ int virNetClientStreamEventRemoveCallback(virNetClientStreamPtr st)
virMutexLock(&st->lock);
if (!st->cb) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("no stream callback registered"));
goto cleanup;
}

View File

@ -31,9 +31,6 @@
#include "util.h"
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
virNetMessagePtr virNetMessageNew(bool tracked)
{
@ -121,13 +118,13 @@ int virNetMessageDecodeLength(virNetMessagePtr msg)
xdrmem_create(&xdr, msg->buffer,
msg->bufferLength, XDR_DECODE);
if (!xdr_u_int(&xdr, &len)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to decode message length"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to decode message length"));
goto cleanup;
}
msg->bufferOffset = xdr_getpos(&xdr);
if (len < VIR_NET_MESSAGE_LEN_MAX) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("packet %d bytes received from server too small, want %d"),
len, VIR_NET_MESSAGE_LEN_MAX);
goto cleanup;
@ -137,7 +134,7 @@ int virNetMessageDecodeLength(virNetMessagePtr msg)
len -= VIR_NET_MESSAGE_LEN_MAX;
if (len > VIR_NET_MESSAGE_MAX) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("packet %d bytes received from server too large, want %d"),
len, VIR_NET_MESSAGE_MAX);
goto cleanup;
@ -187,7 +184,7 @@ int virNetMessageDecodeHeader(virNetMessagePtr msg)
XDR_DECODE);
if (!xdr_virNetMessageHeader(&xdr, &msg->header)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to decode message header"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to decode message header"));
goto cleanup;
}
@ -233,12 +230,12 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg)
/* The real value is filled in shortly */
if (!xdr_u_int(&xdr, &len)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
goto cleanup;
}
if (!xdr_virNetMessageHeader(&xdr, &msg->header)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message header"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message header"));
goto cleanup;
}
@ -249,7 +246,7 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg)
* if a payload is added
*/
if (!xdr_u_int(&xdr, &len)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to re-encode message length"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to re-encode message length"));
goto cleanup;
}
@ -273,14 +270,14 @@ int virNetMessageEncodeNumFDs(virNetMessagePtr msg)
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
if (numFDs > VIR_NET_MESSAGE_NUM_FDS_MAX) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("Too many FDs to send %d, expected %d maximum"),
numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX);
goto cleanup;
}
if (!xdr_u_int(&xdr, &numFDs)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode number of FDs"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode number of FDs"));
goto cleanup;
}
msg->bufferOffset += xdr_getpos(&xdr);
@ -305,13 +302,13 @@ int virNetMessageDecodeNumFDs(virNetMessagePtr msg)
xdrmem_create(&xdr, msg->buffer + msg->bufferOffset,
msg->bufferLength - msg->bufferOffset, XDR_DECODE);
if (!xdr_u_int(&xdr, &numFDs)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to decode number of FDs"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to decode number of FDs"));
goto cleanup;
}
msg->bufferOffset += xdr_getpos(&xdr);
if (numFDs > VIR_NET_MESSAGE_NUM_FDS_MAX) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("Received too many FDs %d, expected %d maximum"),
numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX);
goto cleanup;
@ -349,7 +346,7 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
if (!(*filter)(&xdr, data)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message payload"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message payload"));
goto error;
}
@ -362,7 +359,7 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
msglen = msg->bufferOffset;
if (!xdr_u_int(&xdr, &msglen)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
goto error;
}
xdr_destroy(&xdr);
@ -390,7 +387,7 @@ int virNetMessageDecodePayload(virNetMessagePtr msg,
msg->bufferLength - msg->bufferOffset, XDR_DECODE);
if (!(*filter)(&xdr, data)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to decode message payload"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to decode message payload"));
goto error;
}
@ -413,7 +410,7 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg,
unsigned int msglen;
if ((msg->bufferLength - msg->bufferOffset) < len) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("Stream data too long to send (%zu bytes needed, %zu bytes available)"),
len, (msg->bufferLength - msg->bufferOffset));
return -1;
@ -427,7 +424,7 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg,
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
msglen = msg->bufferOffset;
if (!xdr_u_int(&xdr, &msglen)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
goto error;
}
xdr_destroy(&xdr);
@ -452,7 +449,7 @@ int virNetMessageEncodePayloadEmpty(virNetMessagePtr msg)
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
msglen = msg->bufferOffset;
if (!xdr_u_int(&xdr, &msglen)) {
virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
goto error;
}
xdr_destroy(&xdr);
@ -508,7 +505,7 @@ int virNetMessageDupFD(virNetMessagePtr msg,
int fd;
if (slot >= msg->nfds) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("No FD available at slot %zu"), slot);
return -1;
}

View File

@ -31,10 +31,6 @@
#include "logging.h"
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetSASLContext {
virMutex lock;
@ -57,7 +53,7 @@ virNetSASLContextPtr virNetSASLContextNewClient(void)
err = sasl_client_init(NULL);
if (err != SASL_OK) {
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("failed to initialize SASL library: %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
return NULL;
@ -69,7 +65,7 @@ virNetSASLContextPtr virNetSASLContextNewClient(void)
}
if (virMutexInit(&ctxt->lock) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to initialized mutex"));
VIR_FREE(ctxt);
return NULL;
@ -87,7 +83,7 @@ virNetSASLContextPtr virNetSASLContextNewServer(const char *const*usernameWhitel
err = sasl_server_init(NULL, "libvirt");
if (err != SASL_OK) {
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("failed to initialize SASL library: %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
return NULL;
@ -99,7 +95,7 @@ virNetSASLContextPtr virNetSASLContextNewServer(const char *const*usernameWhitel
}
if (virMutexInit(&ctxt->lock) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to initialized mutex"));
VIR_FREE(ctxt);
return NULL;
@ -133,7 +129,7 @@ int virNetSASLContextCheckIdentity(virNetSASLContextPtr ctxt,
goto cleanup; /* Succesful match */
}
if (rv != FNM_NOMATCH) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Malformed TLS whitelist regular expression '%s'"),
*wildcards);
goto cleanup;
@ -146,7 +142,7 @@ int virNetSASLContextCheckIdentity(virNetSASLContextPtr ctxt,
VIR_ERROR(_("SASL client %s not allowed in whitelist"), identity);
/* This is the most common error: make it informative. */
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
_("Client's username is not on the list of allowed clients"));
ret = 0;
@ -196,7 +192,7 @@ virNetSASLSessionPtr virNetSASLSessionNewClient(virNetSASLContextPtr ctxt ATTRIB
}
if (virMutexInit(&sasl->lock) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to initialized mutex"));
VIR_FREE(sasl);
return NULL;
@ -214,7 +210,7 @@ virNetSASLSessionPtr virNetSASLSessionNewClient(virNetSASLContextPtr ctxt ATTRIB
SASL_SUCCESS_DATA,
&sasl->conn);
if (err != SASL_OK) {
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("Failed to create SASL client context: %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;
@ -241,7 +237,7 @@ virNetSASLSessionPtr virNetSASLSessionNewServer(virNetSASLContextPtr ctxt ATTRIB
}
if (virMutexInit(&sasl->lock) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to initialized mutex"));
VIR_FREE(sasl);
return NULL;
@ -260,7 +256,7 @@ virNetSASLSessionPtr virNetSASLSessionNewServer(virNetSASLContextPtr ctxt ATTRIB
SASL_SUCCESS_DATA,
&sasl->conn);
if (err != SASL_OK) {
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("Failed to create SASL client context: %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;
@ -289,7 +285,7 @@ int virNetSASLSessionExtKeySize(virNetSASLSessionPtr sasl,
err = sasl_setprop(sasl->conn, SASL_SSF_EXTERNAL, &ssf);
if (err != SASL_OK) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot set external SSF %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;
@ -310,14 +306,14 @@ const char *virNetSASLSessionGetIdentity(virNetSASLSessionPtr sasl)
err = sasl_getprop(sasl->conn, SASL_USERNAME, &val);
if (err != SASL_OK) {
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("cannot query SASL username on connection %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
val = NULL;
goto cleanup;
}
if (val == NULL) {
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("no client username was found"));
goto cleanup;
}
@ -338,7 +334,7 @@ int virNetSASLSessionGetKeySize(virNetSASLSessionPtr sasl)
virMutexLock(&sasl->lock);
err = sasl_getprop(sasl->conn, SASL_SSF, &val);
if (err != SASL_OK) {
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("cannot query SASL ssf on connection %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
ssf = -1;
@ -374,7 +370,7 @@ int virNetSASLSessionSecProps(virNetSASLSessionPtr sasl,
err = sasl_setprop(sasl->conn, SASL_SEC_PROPS, &secprops);
if (err != SASL_OK) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot set security props %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;
@ -398,7 +394,7 @@ static int virNetSASLSessionUpdateBufSize(virNetSASLSessionPtr sasl)
err = sasl_getprop(sasl->conn, SASL_MAXOUTBUF, &u.ptr);
if (err != SASL_OK) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot get security props %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
return -1;
@ -426,7 +422,7 @@ char *virNetSASLSessionListMechanisms(virNetSASLSessionPtr sasl)
NULL,
NULL);
if (err != SASL_OK) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot list SASL mechanisms %d (%s)"),
err, sasl_errdetail(sasl->conn));
goto cleanup;
@ -479,7 +475,7 @@ int virNetSASLSessionClientStart(virNetSASLSessionPtr sasl,
ret = VIR_NET_SASL_INTERACT;
break;
default:
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("Failed to start SASL negotiation: %d (%s)"),
err, sasl_errdetail(sasl->conn));
break;
@ -528,7 +524,7 @@ int virNetSASLSessionClientStep(virNetSASLSessionPtr sasl,
ret = VIR_NET_SASL_INTERACT;
break;
default:
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("Failed to step SASL negotiation: %d (%s)"),
err, sasl_errdetail(sasl->conn));
break;
@ -574,7 +570,7 @@ int virNetSASLSessionServerStart(virNetSASLSessionPtr sasl,
ret = VIR_NET_SASL_INTERACT;
break;
default:
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("Failed to start SASL negotiation: %d (%s)"),
err, sasl_errdetail(sasl->conn));
break;
@ -619,7 +615,7 @@ int virNetSASLSessionServerStep(virNetSASLSessionPtr sasl,
ret = VIR_NET_SASL_INTERACT;
break;
default:
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("Failed to start SASL negotiation: %d (%s)"),
err, sasl_errdetail(sasl->conn));
break;
@ -666,7 +662,7 @@ ssize_t virNetSASLSessionEncode(virNetSASLSessionPtr sasl,
*outputlen = outlen;
if (err != SASL_OK) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to encode SASL data: %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;
@ -704,7 +700,7 @@ ssize_t virNetSASLSessionDecode(virNetSASLSessionPtr sasl,
&outlen);
*outputlen = outlen;
if (err != SASL_OK) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to decode SASL data: %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;

View File

@ -45,9 +45,6 @@
#endif
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
typedef struct _virNetServerSignal virNetServerSignal;
typedef virNetServerSignal *virNetServerSignalPtr;
@ -261,7 +258,7 @@ static int virNetServerDispatchNewClient(virNetServerServicePtr svc ATTRIBUTE_UN
virNetServerLock(srv);
if (srv->nclients >= srv->nclients_max) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("Too many active clients (%zu), dropping connection from %s"),
srv->nclients_max, virNetServerClientRemoteAddrString(client));
goto error;
@ -378,7 +375,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
#endif
if (virMutexInit(&srv->lock) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot initialize mutex"));
goto error;
}
@ -507,7 +504,7 @@ virNetServerSignalEvent(int watch,
}
}
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected signal received: %d"), siginfo.si_signo);
cleanup:
@ -531,7 +528,7 @@ static int virNetServerSignalSetup(virNetServerPtr srv)
VIR_EVENT_HANDLE_READABLE,
virNetServerSignalEvent,
srv, NULL)) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to add signal handle watch"));
goto error;
}
@ -707,7 +704,7 @@ void virNetServerRun(virNetServerPtr srv)
(timerid = virEventAddTimeout(-1,
virNetServerAutoShutdownTimer,
srv, NULL)) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to register shutdown timeout"));
goto cleanup;
}

View File

@ -36,9 +36,6 @@
#include "virkeepalive.h"
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Allow for filtering of incoming messages to a custom
* dispatch processing queue, instead of the workers.
@ -775,7 +772,7 @@ static ssize_t virNetServerClientRead(virNetServerClientPtr client)
ssize_t ret;
if (client->rx->bufferLength <= client->rx->bufferOffset) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("unexpected zero/negative length request %lld"),
(long long int)(client->rx->bufferLength - client->rx->bufferOffset));
client->wantClose = true;
@ -953,7 +950,7 @@ static ssize_t virNetServerClientWrite(virNetServerClientPtr client)
ssize_t ret;
if (client->tx->bufferLength < client->tx->bufferOffset) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("unexpected zero/negative length request %lld"),
(long long int)(client->tx->bufferLength - client->tx->bufferOffset));
client->wantClose = true;

View File

@ -46,9 +46,6 @@
#include "logging.h"
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetServerMDNSEntry {
char *type;
@ -285,7 +282,7 @@ static AvahiWatch *virNetServerMDNSWatchNew(const AvahiPoll *api ATTRIBUTE_UNUSE
virNetServerMDNSWatchDispatch,
w,
virNetServerMDNSWatchDofree)) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to add watch for fd %d events %d"), fd, hEvents);
VIR_FREE(w);
return NULL;
@ -367,7 +364,7 @@ static AvahiTimeout *virNetServerMDNSTimeoutNew(const AvahiPoll *api ATTRIBUTE_U
t->userdata = userdata;
if (t->timer < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to add timer with timeout %lld"), timeout);
VIR_FREE(t);
return NULL;
@ -455,7 +452,7 @@ int virNetServerMDNSStart(virNetServerMDNS *mdns)
mdns, &error);
if (!mdns->client) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to create mDNS client: %s"),
avahi_strerror(error));
return -1;

View File

@ -32,9 +32,6 @@
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetServerProgram {
int refs;
@ -218,7 +215,7 @@ int virNetServerProgramUnknownError(virNetServerClientPtr client,
{
virNetMessageError rerr;
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("Cannot find program %d version %d"), req->prog, req->vers);
memset(&rerr, 0, sizeof(rerr));
@ -270,14 +267,14 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
/* Check version, etc. */
if (msg->header.prog != prog->program) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("program mismatch (actual %x, expected %x)"),
msg->header.prog, prog->program);
goto error;
}
if (msg->header.vers != prog->version) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("version mismatch (actual %x, expected %x)"),
msg->header.vers, prog->version);
goto error;
@ -307,7 +304,7 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
break;
default:
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("Unexpected message type %u"),
msg->header.type);
goto error;
@ -363,7 +360,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
memset(&rerr, 0, sizeof(rerr));
if (msg->header.status != VIR_NET_OK) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("Unexpected message status %u"),
msg->header.status);
goto error;
@ -372,7 +369,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
dispatcher = virNetServerProgramGetProc(prog, msg->header.proc);
if (!dispatcher) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("unknown procedure: %d"),
msg->header.proc);
goto error;
@ -386,7 +383,7 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
/* Explicitly *NOT* calling remoteDispatchAuthError() because
we want back-compatibility with libvirt clients which don't
support the VIR_ERR_AUTH_FAILED error code */
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
"%s", _("authentication required"));
goto error;
}

View File

@ -48,10 +48,6 @@
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetSocket {
virMutex lock;
@ -212,7 +208,7 @@ int virNetSocketNewListenTCP(const char *nodename,
int e = getaddrinfo(nodename, service, &hints, &ai);
if (e != 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to resolve address '%s' service '%s': %s"),
nodename, service, gai_strerror(e));
return -1;
@ -409,7 +405,7 @@ int virNetSocketNewConnectTCP(const char *nodename,
int e = getaddrinfo(nodename, service, &hints, &ai);
if (e != 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to resolve address '%s' service '%s': %s"),
nodename, service, gai_strerror (e));
return -1;
@ -485,7 +481,7 @@ int virNetSocketNewConnectUNIX(const char *path,
remoteAddr.len = sizeof(remoteAddr.data.un);
if (spawnDaemon && !binary) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Auto-spawn of daemon requested, but no binary specified"));
return -1;
}
@ -1180,7 +1176,7 @@ int virNetSocketSendFD(virNetSocketPtr sock, int fd)
{
int ret = -1;
if (!virNetSocketHasPassFD(sock)) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Sending file descriptors is not supported on this socket"));
return -1;
}
@ -1214,7 +1210,7 @@ int virNetSocketRecvFD(virNetSocketPtr sock, int *fd)
*fd = -1;
if (!virNetSocketHasPassFD(sock)) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Receiving file descriptors is not supported on this socket"));
return -1;
}

View File

@ -48,9 +48,6 @@
#define LIBVIRT_SERVERCERT LIBVIRT_PKI_DIR "/libvirt/servercert.pem"
#define VIR_FROM_THIS VIR_FROM_RPC
#define virNetError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct _virNetTLSContext {
virMutex lock;
@ -116,7 +113,7 @@ static int virNetTLSContextCheckCertTimes(gnutls_x509_crt_t cert,
}
if (gnutls_x509_crt_get_expiration_time(cert) < now) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
(isCA ?
_("The CA certificate %s has expired") :
(isServer ?
@ -127,7 +124,7 @@ static int virNetTLSContextCheckCertTimes(gnutls_x509_crt_t cert,
}
if (gnutls_x509_crt_get_activation_time(cert) > now) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
(isCA ?
_("The CA certificate %s is not yet active") :
(isServer ?
@ -161,7 +158,7 @@ static int virNetTLSContextCheckCertBasicConstraints(gnutls_x509_crt_t cert,
if (status > 0) { /* It is a CA cert */
if (!isCA) {
virNetError(VIR_ERR_SYSTEM_ERROR, isServer ?
virReportError(VIR_ERR_SYSTEM_ERROR, isServer ?
_("The certificate %s basic constraints show a CA, but we need one for a server") :
_("The certificate %s basic constraints show a CA, but we need one for a client"),
certFile);
@ -169,20 +166,20 @@ static int virNetTLSContextCheckCertBasicConstraints(gnutls_x509_crt_t cert,
}
} else if (status == 0) { /* It is not a CA cert */
if (isCA) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("The certificate %s basic constraints do not show a CA"),
certFile);
return -1;
}
} else if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) { /* Missing basicConstraints */
if (isCA) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("The certificate %s is missing basic constraints for a CA"),
certFile);
return -1;
}
} else { /* General error */
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to query certificate %s basic constraints %s"),
certFile, gnutls_strerror(status));
return -1;
@ -209,7 +206,7 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert,
usage = isCA ? GNUTLS_KEY_KEY_CERT_SIGN :
GNUTLS_KEY_DIGITAL_SIGNATURE|GNUTLS_KEY_KEY_ENCIPHERMENT;
} else {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to query certificate %s key usage %s"),
certFile, gnutls_strerror(status));
return -1;
@ -219,7 +216,7 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert,
if (isCA) {
if (!(usage & GNUTLS_KEY_KEY_CERT_SIGN)) {
if (critical) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Certificate %s usage does not permit certificate signing"),
certFile);
return -1;
@ -231,7 +228,7 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert,
} else {
if (!(usage & GNUTLS_KEY_DIGITAL_SIGNATURE)) {
if (critical) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Certificate %s usage does not permit digital signature"),
certFile);
return -1;
@ -242,7 +239,7 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert,
}
if (!(usage & GNUTLS_KEY_KEY_ENCIPHERMENT)) {
if (critical) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Certificate %s usage does not permit key encipherment"),
certFile);
return -1;
@ -283,7 +280,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
break;
}
if (status != GNUTLS_E_SHORT_MEMORY_BUFFER) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to query certificate %s key purpose %s"),
certFile, gnutls_strerror(status));
return -1;
@ -297,7 +294,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer, &size, &purposeCritical);
if (status < 0) {
VIR_FREE(buffer);
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to query certificate %s key purpose %s"),
certFile, gnutls_strerror(status));
return -1;
@ -320,7 +317,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
if (isServer) {
if (!allowServer) {
if (critical) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Certificate %s purpose does not allow use for with a TLS server"),
certFile);
return -1;
@ -332,7 +329,7 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
} else {
if (!allowClient) {
if (critical) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Certificate %s purpose does not allow use for with a TLS client"),
certFile);
return -1;
@ -356,7 +353,7 @@ virNetTLSContextCheckCertDNWhitelist(const char *dname,
if (ret == 0) /* Succesful match */
return 1;
if (ret != FNM_NOMATCH) {
virNetError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Malformed TLS whitelist regular expression '%s'"),
*wildcards);
return -1;
@ -369,7 +366,7 @@ virNetTLSContextCheckCertDNWhitelist(const char *dname,
VIR_DEBUG("Failed whitelist check for client DN '%s'", dname);
/* This is the most common error: make it informative. */
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
_("Client's Distinguished Name is not on the list "
"of allowed clients (tls_allowed_dn_list). Use "
"'certtool -i --infile clientcert.pem' to view the"
@ -392,7 +389,7 @@ virNetTLSContextCheckCertDN(gnutls_x509_crt_t cert,
if (hostname &&
!gnutls_x509_crt_check_hostname(cert, hostname)) {
virNetError(VIR_ERR_RPC,
virReportError(VIR_ERR_RPC,
_("Certificate %s owner does not match the hostname %s"),
certFile, hostname);
return -1;
@ -442,7 +439,7 @@ static int virNetTLSContextCheckCertPair(gnutls_x509_crt_t cert,
&cacert, 1,
NULL, 0,
0, &status) < 0) {
virNetError(VIR_ERR_SYSTEM_ERROR, isServer ?
virReportError(VIR_ERR_SYSTEM_ERROR, isServer ?
_("Unable to verify server certificate %s against CA certificate %s") :
_("Unable to verify client certificate %s against CA certificate %s"),
certFile, cacertFile);
@ -466,7 +463,7 @@ static int virNetTLSContextCheckCertPair(gnutls_x509_crt_t cert,
reason = _("The certificate uses an insecure algorithm");
#endif
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Our own certificate %s failed validation against %s: %s"),
certFile, cacertFile, reason);
return -1;
@ -489,7 +486,7 @@ static gnutls_x509_crt_t virNetTLSContextLoadCertFromFile(const char *certFile,
isServer, isCA, certFile);
if (gnutls_x509_crt_init(&cert) < 0) {
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
_("Unable to initialize certificate"));
goto cleanup;
}
@ -501,7 +498,7 @@ static gnutls_x509_crt_t virNetTLSContextLoadCertFromFile(const char *certFile,
data.size = strlen(buf);
if (gnutls_x509_crt_import(cert, &data, GNUTLS_X509_FMT_PEM) < 0) {
virNetError(VIR_ERR_SYSTEM_ERROR, isServer ?
virReportError(VIR_ERR_SYSTEM_ERROR, isServer ?
_("Unable to import server certificate %s") :
_("Unable to import client certificate %s"),
certFile);
@ -577,7 +574,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
cacert,
GNUTLS_X509_FMT_PEM);
if (err < 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to set x509 CA certificate: %s: %s"),
cacert, gnutls_strerror (err));
goto cleanup;
@ -595,7 +592,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
cacrl,
GNUTLS_X509_FMT_PEM);
if (err < 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to set x509 certificate revocation list: %s: %s"),
cacrl, gnutls_strerror(err));
goto cleanup;
@ -620,7 +617,7 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt,
cert, key,
GNUTLS_X509_FMT_PEM);
if (err < 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to set x509 key and certificate: %s, %s: %s"),
key, cert, gnutls_strerror(err));
goto cleanup;
@ -656,7 +653,7 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
}
if (virMutexInit(&ctxt->lock) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to initialized mutex"));
VIR_FREE(ctxt);
return NULL;
@ -676,7 +673,7 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
err = gnutls_certificate_allocate_credentials(&ctxt->x509cred);
if (err) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to allocate x509 credentials: %s"),
gnutls_strerror(err));
goto error;
@ -697,14 +694,14 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
if (isServer) {
err = gnutls_dh_params_init(&ctxt->dhParams);
if (err < 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to initialize diffie-hellman parameters: %s"),
gnutls_strerror(err));
goto error;
}
err = gnutls_dh_params_generate2(ctxt->dhParams, DH_BITS);
if (err < 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to generate diffie-hellman parameters: %s"),
gnutls_strerror(err));
goto error;
@ -954,7 +951,7 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
memset(dname, 0, dnamesize);
if ((ret = gnutls_certificate_verify_peers2(sess->session, &status)) < 0){
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to verify TLS peer: %s"),
gnutls_strerror(ret));
goto authdeny;
@ -977,20 +974,20 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
reason = _("The certificate uses an insecure algorithm");
#endif
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Certificate failed validation: %s"),
reason);
goto authdeny;
}
if (gnutls_certificate_type_get(sess->session) != GNUTLS_CRT_X509) {
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
_("Only x509 certificates are supported"));
goto authdeny;
}
if (!(certs = gnutls_certificate_get_peers(sess->session, &nCerts))) {
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
_("The certificate has no peers"));
goto authdeny;
}
@ -999,13 +996,13 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
gnutls_x509_crt_t cert;
if (gnutls_x509_crt_init(&cert) < 0) {
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
_("Unable to initialize certificate"));
goto authfail;
}
if (gnutls_x509_crt_import(cert, &certs[i], GNUTLS_X509_FMT_DER) < 0) {
virNetError(VIR_ERR_SYSTEM_ERROR, "%s",
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
_("Unable to load certificate"));
gnutls_x509_crt_deinit(cert);
goto authfail;
@ -1020,7 +1017,7 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
if (i == 0) {
ret = gnutls_x509_crt_get_dn(cert, dname, &dnamesize);
if (ret != 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Failed to get certificate %s distinguished name: %s"),
"[session]", gnutls_strerror(ret));
goto authfail;
@ -1092,7 +1089,7 @@ int virNetTLSContextCheckCertificate(virNetTLSContextPtr ctxt,
virErrorPtr err = virGetLastError();
VIR_WARN("Certificate check failed %s", err && err->message ? err->message : "<unknown>");
if (ctxt->requireValidCert) {
virNetError(VIR_ERR_AUTH_FAILED, "%s",
virReportError(VIR_ERR_AUTH_FAILED, "%s",
_("Failed to verify peer's certificate"));
goto cleanup;
}
@ -1176,7 +1173,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
}
if (virMutexInit(&sess->lock) < 0) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to initialized mutex"));
VIR_FREE(sess);
return NULL;
@ -1191,7 +1188,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
if ((err = gnutls_init(&sess->session,
ctxt->isServer ? GNUTLS_SERVER : GNUTLS_CLIENT)) != 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Failed to initialize TLS session: %s"),
gnutls_strerror(err));
goto error;
@ -1201,7 +1198,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
* are adequate.
*/
if ((err = gnutls_set_default_priority(sess->session)) != 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Failed to set TLS session priority %s"),
gnutls_strerror(err));
goto error;
@ -1210,7 +1207,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
if ((err = gnutls_credentials_set(sess->session,
GNUTLS_CRD_CERTIFICATE,
ctxt->x509cred)) != 0) {
virNetError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Failed set TLS x509 credentials: %s"),
gnutls_strerror(err));
goto error;
@ -1352,7 +1349,7 @@ int virNetTLSSessionHandshake(virNetTLSSessionPtr sess)
virNetServerClientGetFD(client));
#endif
virNetError(VIR_ERR_AUTH_FAILED,
virReportError(VIR_ERR_AUTH_FAILED,
_("TLS handshake failed %s"),
gnutls_strerror(ret));
ret = -1;
@ -1384,7 +1381,7 @@ int virNetTLSSessionGetKeySize(virNetTLSSessionPtr sess)
virMutexLock(&sess->lock);
cipher = gnutls_cipher_get(sess->session);
if (!(ssf = gnutls_cipher_get_key_size(cipher))) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid cipher size for TLS session"));
ssf = -1;
goto cleanup;