From: Peter Krempa <pkrempa@redhat.com> The utility functions which get memory stats don't actually use the flags. Remove the argument and move the 'virCheckFlags' to driver implementation. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/bhyve/bhyve_driver.c | 12 +++++++++--- src/ch/ch_driver.c | 4 +++- src/lxc/lxc_driver.c | 12 +++++++++--- src/openvz/openvz_driver.c | 4 +++- src/qemu/qemu_driver.c | 12 +++++++++--- src/util/virhostmem.c | 29 +++++++---------------------- src/util/virhostmem.h | 9 +++------ src/vz/vz_driver.c | 4 +++- 8 files changed, 46 insertions(+), 40 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 2718c074f3..8813413037 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1160,10 +1160,12 @@ bhyveNodeGetMemoryStats(virConnectPtr conn, int *nparams, unsigned int flags) { + virCheckFlags(0, -1); + if (virNodeGetMemoryStatsEnsureACL(conn) < 0) return -1; - return virHostMemGetStats(cellNum, params, nparams, flags); + return virHostMemGetStats(cellNum, params, nparams); } static int @@ -1375,10 +1377,12 @@ bhyveNodeGetMemoryParameters(virConnectPtr conn, int *nparams, unsigned int flags) { + virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); + if (virNodeGetMemoryParametersEnsureACL(conn) < 0) return -1; - return virHostMemGetParameters(params, nparams, flags); + return virHostMemGetParameters(params, nparams); } static int @@ -1387,10 +1391,12 @@ bhyveNodeSetMemoryParameters(virConnectPtr conn, int nparams, unsigned int flags) { + virCheckFlags(0, -1); + if (virNodeSetMemoryParametersEnsureACL(conn) < 0) return -1; - return virHostMemSetParameters(params, nparams, flags); + return virHostMemSetParameters(params, nparams); } static char * diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 874fca2193..ff3cb55c69 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -2304,10 +2304,12 @@ chNodeGetMemoryStats(virConnectPtr conn, int *nparams, unsigned int flags) { + virCheckFlags(0, -1); + if (virNodeGetMemoryStatsEnsureACL(conn) < 0) return -1; - return virHostMemGetStats(cellNum, params, nparams, flags); + return virHostMemGetStats(cellNum, params, nparams); } static int diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index db00288900..c51da98777 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4801,10 +4801,12 @@ lxcNodeGetMemoryStats(virConnectPtr conn, int *nparams, unsigned int flags) { + virCheckFlags(0, -1); + if (virNodeGetMemoryStatsEnsureACL(conn) < 0) return -1; - return virHostMemGetStats(cellNum, params, nparams, flags); + return virHostMemGetStats(cellNum, params, nparams); } @@ -4842,10 +4844,12 @@ lxcNodeGetMemoryParameters(virConnectPtr conn, int *nparams, unsigned int flags) { + virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); + if (virNodeGetMemoryParametersEnsureACL(conn) < 0) return -1; - return virHostMemGetParameters(params, nparams, flags); + return virHostMemGetParameters(params, nparams); } @@ -4855,10 +4859,12 @@ lxcNodeSetMemoryParameters(virConnectPtr conn, int nparams, unsigned int flags) { + virCheckFlags(0, -1); + if (virNodeSetMemoryParametersEnsureACL(conn) < 0) return -1; - return virHostMemSetParameters(params, nparams, flags); + return virHostMemSetParameters(params, nparams); } diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 60b8a9534b..173ccfbe6e 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1862,7 +1862,9 @@ openvzNodeGetMemoryStats(virConnectPtr conn G_GNUC_UNUSED, int *nparams, unsigned int flags) { - return virHostMemGetStats(cellNum, params, nparams, flags); + virCheckFlags(0, -1); + + return virHostMemGetStats(cellNum, params, nparams); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 52c6ce2f27..f121a0e788 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16400,10 +16400,12 @@ qemuNodeGetMemoryStats(virConnectPtr conn, int *nparams, unsigned int flags) { + virCheckFlags(0, -1); + if (virNodeGetMemoryStatsEnsureACL(conn) < 0) return -1; - return virHostMemGetStats(cellNum, params, nparams, flags); + return virHostMemGetStats(cellNum, params, nparams); } @@ -16441,10 +16443,12 @@ qemuNodeGetMemoryParameters(virConnectPtr conn, int *nparams, unsigned int flags) { + virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); + if (virNodeGetMemoryParametersEnsureACL(conn) < 0) return -1; - return virHostMemGetParameters(params, nparams, flags); + return virHostMemGetParameters(params, nparams); } @@ -16454,10 +16458,12 @@ qemuNodeSetMemoryParameters(virConnectPtr conn, int nparams, unsigned int flags) { + virCheckFlags(0, -1); + if (virNodeSetMemoryParametersEnsureACL(conn) < 0) return -1; - return virHostMemSetParameters(params, nparams, flags); + return virHostMemSetParameters(params, nparams); } diff --git a/src/util/virhostmem.c b/src/util/virhostmem.c index 09a322fdea..7d7deac34b 100644 --- a/src/util/virhostmem.c +++ b/src/util/virhostmem.c @@ -248,11 +248,8 @@ virHostMemGetStatsLinux(FILE *meminfo, int virHostMemGetStats(int cellNum G_GNUC_UNUSED, virNodeMemoryStatsPtr params G_GNUC_UNUSED, - int *nparams G_GNUC_UNUSED, - unsigned int flags) + int *nparams G_GNUC_UNUSED) { - virCheckFlags(0, -1); - #ifdef __linux__ { int ret; @@ -356,14 +353,11 @@ virHostMemParametersAreAllSupported(virTypedParameterPtr params, #ifdef __linux__ int -virHostMemSetParameters(virTypedParameterPtr params G_GNUC_UNUSED, - int nparams G_GNUC_UNUSED, - unsigned int flags) +virHostMemSetParameters(virTypedParameterPtr params, + int nparams) { size_t i; - virCheckFlags(0, -1); - if (virTypedParamsValidate(params, nparams, VIR_NODE_MEMORY_SHARED_PAGES_TO_SCAN, VIR_TYPED_PARAM_UINT, @@ -387,11 +381,8 @@ virHostMemSetParameters(virTypedParameterPtr params G_GNUC_UNUSED, #else int virHostMemSetParameters(virTypedParameterPtr params G_GNUC_UNUSED, - int nparams G_GNUC_UNUSED, - unsigned int flags) + int nparams G_GNUC_UNUSED) { - virCheckFlags(0, -1); - virReportError(VIR_ERR_NO_SUPPORT, "%s", _("node set memory parameters not implemented on this platform")); return -1; @@ -443,9 +434,8 @@ virHostMemGetParameterValue(const char *field, #define NODE_MEMORY_PARAMETERS_NUM 8 #ifdef __linux__ int -virHostMemGetParameters(virTypedParameterPtr params G_GNUC_UNUSED, - int *nparams G_GNUC_UNUSED, - unsigned int flags) +virHostMemGetParameters(virTypedParameterPtr params, + int *nparams) { unsigned int pages_to_scan; unsigned int sleep_millisecs; @@ -458,8 +448,6 @@ virHostMemGetParameters(virTypedParameterPtr params G_GNUC_UNUSED, size_t i; int ret; - virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); - if ((*nparams) == 0) { *nparams = NODE_MEMORY_PARAMETERS_NUM; return 0; @@ -580,11 +568,8 @@ virHostMemGetParameters(virTypedParameterPtr params G_GNUC_UNUSED, #else int virHostMemGetParameters(virTypedParameterPtr params G_GNUC_UNUSED, - int *nparams G_GNUC_UNUSED, - unsigned int flags) + int *nparams G_GNUC_UNUSED) { - virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); - virReportError(VIR_ERR_NO_SUPPORT, "%s", _("node get memory parameters not implemented on this platform")); return -1; diff --git a/src/util/virhostmem.h b/src/util/virhostmem.h index 5c8d46cfa4..4a0d692402 100644 --- a/src/util/virhostmem.h +++ b/src/util/virhostmem.h @@ -25,8 +25,7 @@ int virHostMemGetStats(int cellNum, virNodeMemoryStatsPtr params, - int *nparams, - unsigned int flags); + int *nparams); int virHostMemGetCellsFree(unsigned long long *freeMems, int startCell, int maxCells); @@ -34,12 +33,10 @@ int virHostMemGetInfo(unsigned long long *mem, unsigned long long *freeMem); int virHostMemGetParameters(virTypedParameterPtr params, - int *nparams, - unsigned int flags); + int *nparams); int virHostMemSetParameters(virTypedParameterPtr params, - int nparams, - unsigned int flags); + int nparams); int virHostMemGetFreePages(unsigned int npages, unsigned int *pages, diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index f8193367c9..3dea4d450d 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1981,10 +1981,12 @@ vzNodeGetMemoryStats(virConnectPtr conn, int *nparams, unsigned int flags) { + virCheckFlags(0, -1); + if (virNodeGetMemoryStatsEnsureACL(conn) < 0) return -1; - return virHostMemGetStats(cellNum, params, nparams, flags); + return virHostMemGetStats(cellNum, params, nparams); } static int -- 2.54.0