void RpcVMX_LogV(const char *fmt, va_list args) { int payloadLen; payloadLen = Str_Vsnprintf(RpcVMX.logBuf + RpcVMX.logOffset, sizeof RpcVMX.logBuf - RpcVMX.logOffset, fmt, args); if (payloadLen < 1) { /* * Overflow. We need more space in the buffer. Just set the length to * the buffer size and send the (truncated) log message. */ payloadLen = sizeof RpcVMX.logBuf - RpcVMX.logOffset; } RpcOut_SendOneRaw(RpcVMX.logBuf, RpcVMX.logOffset + payloadLen, NULL, NULL); }
Bool RpcOut_sendOne(char **reply, // OUT: Result size_t *repLen, // OUT: Length of the result char const *reqFmt, // IN: RPCI command ...) // Unspecified { va_list args; Bool status; char *request; size_t reqLen = 0; status = FALSE; /* Format the request string */ va_start(args, reqFmt); request = Str_Vasprintf(&reqLen, reqFmt, args); va_end(args); /* * If Str_Vasprintf failed, write NULL into the reply if the caller wanted * a reply back. */ if (request == NULL) { if (reply) { *reply = NULL; } return FALSE; } /* * If the command doesn't contain a space, add one to the end to maintain * compatibility with old VMXs. * * For a long time, the GuestRpc logic in the VMX was wired to expect a * trailing space in every command, even commands without arguments. That is * no longer true, but we must continue to add a trailing space because we * don't know whether we're talking to an old or new VMX. */ if (strchr(request, ' ') == NULL) { char *tmp; tmp = Str_Asprintf(NULL, "%s ", request); free(request); request = tmp; /* * If Str_Asprintf failed, write NULL into reply if the caller wanted * a reply back. */ if (request == NULL) { if (reply != NULL) { *reply = NULL; } return FALSE; } } status = RpcOut_SendOneRaw(request, reqLen, reply, repLen); free(request); return status; }