From 791e20142a10900a8dfff5b86e88554eef2aaff7 Mon Sep 17 00:00:00 2001 From: Ilias Stamatis Date: Fri, 28 Jun 2019 18:15:01 +0200 Subject: [PATCH] test_driver: Implement virDomainGetPerfEvents Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- src/test/test_driver.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index bc93d7acc3..7c58d2c8ce 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3372,6 +3372,49 @@ testDomainGetFSInfo(virDomainPtr dom, } +static int +testDomainGetPerfEvents(virDomainPtr dom, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + virDomainObjPtr vm = NULL; + virDomainDefPtr def = NULL; + virTypedParameterPtr par = NULL; + size_t i; + int maxpar = 0; + int npar = 0; + int ret = -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG | + VIR_TYPED_PARAM_STRING_OKAY, -1); + + if (!(vm = testDomObjFromDomain(dom))) + goto cleanup; + + if (!(def = virDomainObjGetOneDef(vm, flags))) + goto cleanup; + + for (i = 0; i < VIR_PERF_EVENT_LAST; i++) { + if (virTypedParamsAddBoolean(&par, &npar, &maxpar, + virPerfEventTypeToString(i), + def->perf.events[i] == VIR_TRISTATE_BOOL_YES) < 0) + goto cleanup; + } + + VIR_STEAL_PTR(*params, par); + *nparams = npar; + npar = 0; + + ret = 0; + cleanup: + virDomainObjEndAPI(&vm); + virTypedParamsFree(par, npar); + return ret; +} + + static char *testDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, int *nparams) { @@ -7367,6 +7410,7 @@ static virHypervisorDriver testHypervisorDriver = { .domainSetAutostart = testDomainSetAutostart, /* 0.3.2 */ .domainGetDiskErrors = testDomainGetDiskErrors, /* 5.4.0 */ .domainGetFSInfo = testDomainGetFSInfo, /* 5.6.0 */ + .domainGetPerfEvents = testDomainGetPerfEvents, /* 5.6.0 */ .domainGetSchedulerType = testDomainGetSchedulerType, /* 0.3.2 */ .domainGetSchedulerParameters = testDomainGetSchedulerParameters, /* 0.3.2 */ .domainGetSchedulerParametersFlags = testDomainGetSchedulerParametersFlags, /* 0.9.2 */