提交 1a28c5e0 编写于 作者: N Nikolay Shirokovskiy 提交者: Maxim Nestratov

vz: factor out converting block stats to params

This action deserves its own function and makes main API call
structure much cleaner.
Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 1b2673e2
......@@ -1619,45 +1619,29 @@ vzDomainBlockStats(virDomainPtr domain,
}
static int
vzDomainBlockStatsFlags(virDomainPtr domain,
const char *path,
vzDomainBlockStatsToParams(virDomainBlockStatsPtr stats,
virTypedParameterPtr params,
int *nparams,
unsigned int flags)
int *nparams)
{
virDomainBlockStatsStruct stats;
virDomainObjPtr dom;
int ret = -1;
size_t i;
virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1);
/* We don't return strings, and thus trivially support this flag. */
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
if (!(dom = vzDomObjFromDomainRef(domain)))
return -1;
if (vzDomainBlockStatsImpl(dom, path, &stats) < 0)
goto cleanup;
if (*nparams == 0) {
#define PARALLELS_COUNT_STATS(VAR, TYPE, NAME) \
if ((stats.VAR) != -1) \
if ((stats->VAR) != -1) \
++*nparams;
PARALLELS_BLOCK_STATS_FOREACH(PARALLELS_COUNT_STATS)
#undef PARALLELS_COUNT_STATS
ret = 0;
goto cleanup;
return 0;
}
i = 0;
#define PARALLELS_BLOCK_STATS_ASSIGN_PARAM(VAR, TYPE, NAME) \
if (i < *nparams && (stats.VAR) != -1) { \
if (i < *nparams && (stats->VAR) != -1) { \
if (virTypedParameterAssign(params + i, TYPE, \
VIR_TYPED_PARAM_LLONG, (stats.VAR)) < 0) \
goto cleanup; \
VIR_TYPED_PARAM_LLONG, (stats->VAR)) < 0) \
return -1; \
i++; \
}
......@@ -1666,6 +1650,33 @@ vzDomainBlockStatsFlags(virDomainPtr domain,
#undef PARALLELS_BLOCK_STATS_ASSIGN_PARAM
*nparams = i;
return 0;
}
static int
vzDomainBlockStatsFlags(virDomainPtr domain,
const char *path,
virTypedParameterPtr params,
int *nparams,
unsigned int flags)
{
virDomainBlockStatsStruct stats;
virDomainObjPtr dom;
int ret = -1;
virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1);
/* We don't return strings, and thus trivially support this flag. */
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
if (!(dom = vzDomObjFromDomainRef(domain)))
return -1;
if (vzDomainBlockStatsImpl(dom, path, &stats) < 0)
goto cleanup;
if (vzDomainBlockStatsToParams(&stats, params, nparams) < 0)
goto cleanup;
ret = 0;
cleanup:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册