mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
perf: add new public APIs for perf event
API agreed on in https://www.redhat.com/archives/libvir-list/2015-October/msg00872.html * include/libvirt/libvirt-domain.h (virDomainGetPerfEvents, virDomainSetPerfEvents): New declarations. * src/libvirt_public.syms: Export new symbols. * src/driver-hypervisor.h (virDrvDomainGetPerfEvents, virDrvDomainSetPerfEvents): New typedefs. * src/libvirt-domain.c: Implement virDomainGetPerfEvents and virDomainSetPerfEvents. Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com> Message-id: 1459171833-26416-2-git-send-email-qiaowei.ren@intel.com
This commit is contained in:
parent
6008b065fa
commit
c803b0072b
@ -1834,6 +1834,24 @@ int virDomainListGetStats(virDomainPtr *doms,
|
||||
|
||||
void virDomainStatsRecordListFree(virDomainStatsRecordPtr *stats);
|
||||
|
||||
/*
|
||||
* Perf Event API
|
||||
*/
|
||||
|
||||
/**
|
||||
* VIR_PERF_PARAM_CMT:
|
||||
*
|
||||
* Macro for typed parameter name that represents CMT perf event.
|
||||
*/
|
||||
# define VIR_PERF_PARAM_CMT "cmt"
|
||||
|
||||
int virDomainGetPerfEvents(virDomainPtr dom,
|
||||
virTypedParameterPtr *params,
|
||||
int *nparams);
|
||||
int virDomainSetPerfEvents(virDomainPtr dom,
|
||||
virTypedParameterPtr params,
|
||||
int nparams);
|
||||
|
||||
/*
|
||||
* BlockJob API
|
||||
*/
|
||||
|
@ -961,6 +961,16 @@ typedef int
|
||||
unsigned long long duration,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvDomainGetPerfEvents)(virDomainPtr dom,
|
||||
virTypedParameterPtr *params,
|
||||
int *nparams);
|
||||
|
||||
typedef int
|
||||
(*virDrvDomainSetPerfEvents)(virDomainPtr dom,
|
||||
virTypedParameterPtr params,
|
||||
int nparams);
|
||||
|
||||
typedef int
|
||||
(*virDrvDomainBlockJobAbort)(virDomainPtr dom,
|
||||
const char *path,
|
||||
@ -1427,6 +1437,8 @@ struct _virHypervisorDriver {
|
||||
virDrvConnectSetKeepAlive connectSetKeepAlive;
|
||||
virDrvConnectIsAlive connectIsAlive;
|
||||
virDrvNodeSuspendForDuration nodeSuspendForDuration;
|
||||
virDrvDomainGetPerfEvents domainGetPerfEvents;
|
||||
virDrvDomainSetPerfEvents domainSetPerfEvents;
|
||||
virDrvDomainSetBlockIoTune domainSetBlockIoTune;
|
||||
virDrvDomainGetBlockIoTune domainGetBlockIoTune;
|
||||
virDrvDomainGetCPUStats domainGetCPUStats;
|
||||
|
@ -9690,6 +9690,99 @@ virDomainOpenChannel(virDomainPtr dom,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainGetPerfEvents:
|
||||
* @domain: a domain object
|
||||
* @params: where to store perf events setting
|
||||
* @nparams: number of items in @params
|
||||
*
|
||||
* Get all perf events setting. Possible fields returned in @params are
|
||||
* defined by VIR_DOMAIN_PERF_* macros and new fields will likely be
|
||||
* introduced in the future.
|
||||
*
|
||||
* Returns -1 in case of failure, 0 in case of success.
|
||||
*/
|
||||
int virDomainGetPerfEvents(virDomainPtr domain,
|
||||
virTypedParameterPtr *params,
|
||||
int *nparams)
|
||||
{
|
||||
virConnectPtr conn;
|
||||
|
||||
VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%p",
|
||||
params, nparams);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckDomainReturn(domain, -1);
|
||||
virCheckNonNullArgGoto(params, error);
|
||||
virCheckNonNullArgGoto(nparams, error);
|
||||
|
||||
conn = domain->conn;
|
||||
|
||||
if (conn->driver->domainGetPerfEvents) {
|
||||
int ret;
|
||||
ret = conn->driver->domainGetPerfEvents(domain, params, nparams);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
virReportUnsupportedError();
|
||||
|
||||
error:
|
||||
virDispatchError(domain->conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainSetPerfEvents:
|
||||
* @domain: a domain object
|
||||
* @params: pointer to perf events parameter object
|
||||
* @nparams: number of perf event parameters (this value can be the same
|
||||
* less than the number of parameters supported)
|
||||
*
|
||||
* Enable or disable the particular list of perf events you care about.
|
||||
*
|
||||
* Returns -1 in case of error, 0 in case of success.
|
||||
*/
|
||||
int virDomainSetPerfEvents(virDomainPtr domain,
|
||||
virTypedParameterPtr params,
|
||||
int nparams)
|
||||
{
|
||||
virConnectPtr conn;
|
||||
|
||||
VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%d",
|
||||
params, nparams);
|
||||
VIR_TYPED_PARAMS_DEBUG(params, nparams);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckDomainReturn(domain, -1);
|
||||
conn = domain->conn;
|
||||
|
||||
virCheckReadOnlyGoto(conn->flags, error);
|
||||
virCheckNonNullArgGoto(params, error);
|
||||
virCheckPositiveArgGoto(nparams, error);
|
||||
|
||||
if (virTypedParameterValidateSet(conn, params, nparams) < 0)
|
||||
goto error;
|
||||
|
||||
if (conn->driver->domainSetPerfEvents) {
|
||||
int ret;
|
||||
ret = conn->driver->domainSetPerfEvents(domain, params, nparams);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
virReportUnsupportedError();
|
||||
|
||||
error:
|
||||
virDispatchError(domain->conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainBlockJobAbort:
|
||||
* @dom: pointer to domain object
|
||||
|
@ -728,6 +728,8 @@ LIBVIRT_1.2.19 {
|
||||
LIBVIRT_1.3.3 {
|
||||
global:
|
||||
virDomainMigrateStartPostCopy;
|
||||
virDomainGetPerfEvents;
|
||||
virDomainSetPerfEvents;
|
||||
} LIBVIRT_1.2.19;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
Loading…
Reference in New Issue
Block a user