]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: hostmem: Make parameters for 'virHostMemSetParameters' introspectable
authorPeter Krempa <pkrempa@redhat.com>
Thu, 23 Apr 2026 11:13:52 +0000 (13:13 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 14 May 2026 10:13:10 +0000 (12:13 +0200)
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>
src/libvirt_private.syms
src/qemu/qemu_driver.c
src/util/virhostmem.c
src/util/virhostmem.h

index b1dc6788197cc3fd8ee04b1bb7c926b908830682..1e6890b8a80bd7e521a1c288b82df71c93122903 100644 (file)
@@ -2607,6 +2607,7 @@ virHostMemGetParameters;
 virHostMemGetStats;
 virHostMemGetTHPSize;
 virHostMemSetParameters;
+virHostMemSetParametersValidation;
 
 
 # util/virhostuptime.h
index 521b1b3f948c99fe5b21a2b1bf050a31f09385e5..ac1b4004f9394d5b04399af9f832dadd466bef56 100644 (file)
@@ -16507,6 +16507,10 @@ qemuNodeSetMemoryParameters(virConnectPtr conn,
 {
     virCheckFlags(0, -1);
 
+    if (virTypedParamsValidateTemplate(params, nparams,
+                                       virHostMemSetParametersValidation) < 0)
+        return -1;
+
     if (virNodeSetMemoryParametersEnsureACL(conn) < 0)
         return -1;
 
index 7d7deac34bea18ce3c4fed831abdf19e22c32d82..beff114362b95bea1d70abe0f8af54c994a38aee 100644 (file)
@@ -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)
index 4a0d692402e2be16e74e661d1509b30ec77d6948..ebe7d26f21e3645e92c0f7523a192214f8ecb777 100644 (file)
@@ -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);