diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b1dc678819..1e6890b8a8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2607,6 +2607,7 @@ virHostMemGetParameters; virHostMemGetStats; virHostMemGetTHPSize; virHostMemSetParameters; +virHostMemSetParametersValidation; # util/virhostuptime.h diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 521b1b3f94..ac1b4004f9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16507,6 +16507,10 @@ qemuNodeSetMemoryParameters(virConnectPtr conn, { virCheckFlags(0, -1); + if (virTypedParamsValidateTemplate(params, nparams, + virHostMemSetParametersValidation) < 0) + return -1; + if (virNodeSetMemoryParametersEnsureACL(conn) < 0) return -1; diff --git a/src/util/virhostmem.c b/src/util/virhostmem.c index 7d7deac34b..beff114362 100644 --- a/src/util/virhostmem.c +++ b/src/util/virhostmem.c @@ -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) diff --git a/src/util/virhostmem.h b/src/util/virhostmem.h index 4a0d692402..ebe7d26f21 100644 --- a/src/util/virhostmem.h +++ b/src/util/virhostmem.h @@ -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);