mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
util: hostmem: Make parameters for 'virHostMemSetParameters' introspectable
Refactor the validation using 'virTypedParamsValidateTemplate' and export the template so that 'qemuNodeSetMemoryParameters' can expose them via introspection. In addition since 'virHostMemSetParameters' is conditionally compiled, platforms which don't support it will not expose given params. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
1 parent
ccb62a313f
commit
3281beb957
4 files changed
+23
-8
No files matched your search
@@ -2607,6 +2607,7 @@ virHostMemGetParameters;
|
||||
virHostMemGetStats;
|
||||
virHostMemGetTHPSize;
|
||||
virHostMemSetParameters;
|
||||
virHostMemSetParametersValidation;
|
||||
|
||||
|
||||
# util/virhostuptime.h
|
||||
|
||||
@@ -16507,6 +16507,10 @@ qemuNodeSetMemoryParameters(virConnectPtr conn,
|
||||
{
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (virTypedParamsValidateTemplate(params, nparams,
|
||||
virHostMemSetParametersValidation) < 0)
|
||||
return -1;
|
||||
|
||||
if (virNodeSetMemoryParametersEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
|
||||
+16
-8
@@ -351,21 +351,24 @@ virHostMemParametersAreAllSupported(virTypedParameterPtr params,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
const virTypedParamValidationTemplate virHostMemSetParametersValidation[] =
|
||||
{
|
||||
{ VIR_NODE_MEMORY_SHARED_PAGES_TO_SCAN, VIR_TYPED_PARAM_UINT },
|
||||
{ VIR_NODE_MEMORY_SHARED_SLEEP_MILLISECS, VIR_TYPED_PARAM_UINT },
|
||||
{ VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES, VIR_TYPED_PARAM_UINT },
|
||||
{ "", 0 }
|
||||
};
|
||||
|
||||
int
|
||||
virHostMemSetParameters(virTypedParameterPtr params,
|
||||
int nparams)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (virTypedParamsValidate(params, nparams,
|
||||
VIR_NODE_MEMORY_SHARED_PAGES_TO_SCAN,
|
||||
VIR_TYPED_PARAM_UINT,
|
||||
VIR_NODE_MEMORY_SHARED_SLEEP_MILLISECS,
|
||||
VIR_TYPED_PARAM_UINT,
|
||||
VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES,
|
||||
VIR_TYPED_PARAM_UINT,
|
||||
NULL) < 0)
|
||||
if (virTypedParamsValidateTemplate(params, nparams,
|
||||
virHostMemSetParametersValidation) < 0)
|
||||
return -1;
|
||||
|
||||
if (!virHostMemParametersAreAllSupported(params, nparams))
|
||||
@@ -379,6 +382,11 @@ virHostMemSetParameters(virTypedParameterPtr params,
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
const virTypedParamValidationTemplate virHostMemSetParametersValidation[] =
|
||||
{
|
||||
{ "", 0 }
|
||||
};
|
||||
|
||||
int
|
||||
virHostMemSetParameters(virTypedParameterPtr params G_GNUC_UNUSED,
|
||||
int nparams G_GNUC_UNUSED)
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "internal.h"
|
||||
#include "virtypedparam.h"
|
||||
|
||||
int virHostMemGetStats(int cellNum,
|
||||
virNodeMemoryStatsPtr params,
|
||||
@@ -35,6 +36,7 @@ int virHostMemGetInfo(unsigned long long *mem,
|
||||
int virHostMemGetParameters(virTypedParameterPtr params,
|
||||
int *nparams);
|
||||
|
||||
extern const virTypedParamValidationTemplate virHostMemSetParametersValidation[];
|
||||
int virHostMemSetParameters(virTypedParameterPtr params,
|
||||
int nparams);
|
||||
|
||||
|
||||
Reference in new issue
Block a user