log: daemon: Add remote protocol handling for the log appending API

Implement the RPC dispatcher and caller for the new API.
This commit is contained in:
Peter Krempa 2016-06-07 16:15:22 +02:00
parent 5e6143fbcc
commit 78b9b85c06
5 changed files with 88 additions and 1 deletions

View File

@ -1048,6 +1048,7 @@ virLockManagerRelease;
# logging/log_manager.h
virLogManagerDomainAppendMessage;
virLogManagerDomainGetLogFilePosition;
virLogManagerDomainOpenLogFile;
virLogManagerDomainReadLogFile;

View File

@ -143,3 +143,29 @@ virLogManagerProtocolDispatchDomainReadLogFile(virNetServerPtr server ATTRIBUTE_
virNetMessageSaveError(rerr);
return rv;
}
static int
virLogManagerProtocolDispatchDomainAppendLogFile(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client ATTRIBUTE_UNUSED,
virNetMessagePtr msg ATTRIBUTE_UNUSED,
virNetMessageErrorPtr rerr,
virLogManagerProtocolDomainAppendLogFileArgs *args,
virLogManagerProtocolDomainAppendLogFileRet *ret)
{
int rv;
if ((rv = virLogHandlerDomainAppendLogFile(virLogDaemonGetHandler(logDaemon),
args->driver,
(unsigned char *)args->dom.uuid,
args->dom.name,
args->path,
args->message,
args->flags)) < 0) {
virNetMessageSaveError(rerr);
return -1;
}
ret->ret = rv;
return 0;
}

View File

@ -282,3 +282,37 @@ virLogManagerDomainReadLogFile(virLogManagerPtr mgr,
cleanup:
return rv;
}
int
virLogManagerDomainAppendMessage(virLogManagerPtr mgr,
const char *driver,
const unsigned char *domuuid,
const char *domname,
const char *path,
const char *message,
unsigned int flags)
{
struct virLogManagerProtocolDomainAppendLogFileArgs args;
struct virLogManagerProtocolDomainAppendLogFileRet ret;
memset(&args, 0, sizeof(args));
args.driver = (char *)driver;
memcpy(args.dom.uuid, domuuid, VIR_UUID_BUFLEN);
args.dom.name = (char *)domname;
args.path = (char *)path;
args.message = (char *)message;
args.flags = flags;
if (virNetClientProgramCall(mgr->program,
mgr->client,
mgr->serial++,
VIR_LOG_MANAGER_PROTOCOL_PROC_DOMAIN_APPEND_LOG_FILE,
0, NULL, NULL, NULL,
(xdrproc_t)xdr_virLogManagerProtocolDomainAppendLogFileArgs, &args,
(xdrproc_t)xdr_virLogManagerProtocolDomainAppendLogFileRet, &ret) < 0)
return -1;
return ret.ret;
}

View File

@ -57,4 +57,12 @@ char *virLogManagerDomainReadLogFile(virLogManagerPtr mgr,
size_t maxlen,
unsigned int flags);
int virLogManagerDomainAppendMessage(virLogManagerPtr mgr,
const char *driver,
const unsigned char *domuuid,
const char *domname,
const char *path,
const char *message,
unsigned int flags);
#endif /* __VIR_LOG_MANAGER_H__ */

View File

@ -68,6 +68,18 @@ struct virLogManagerProtocolDomainReadLogFileRet {
virLogManagerProtocolNonNullString data;
};
struct virLogManagerProtocolDomainAppendLogFileArgs {
virLogManagerProtocolNonNullString driver;
virLogManagerProtocolDomain dom;
virLogManagerProtocolNonNullString path;
virLogManagerProtocolNonNullString message;
unsigned int flags;
};
struct virLogManagerProtocolDomainAppendLogFileRet {
int ret;
};
/* Define the program number, protocol version and procedure numbers here. */
const VIR_LOG_MANAGER_PROTOCOL_PROGRAM = 0x87539319;
const VIR_LOG_MANAGER_PROTOCOL_PROGRAM_VERSION = 1;
@ -115,5 +127,11 @@ enum virLogManagerProtocolProcedure {
* @generate: none
* @acl: none
*/
VIR_LOG_MANAGER_PROTOCOL_PROC_DOMAIN_READ_LOG_FILE = 3
VIR_LOG_MANAGER_PROTOCOL_PROC_DOMAIN_READ_LOG_FILE = 3,
/**
* @generate: none
* @acl: none
*/
VIR_LOG_MANAGER_PROTOCOL_PROC_DOMAIN_APPEND_LOG_FILE = 4
};