On Mon, May 31, 2021 at 10:36:07AM +0200, Michal Privoznik wrote:
Memory on a NUMA node can have a side caches. Configuring these
for a domain was implemented in v6.6.0-rc1~249 and friends.
However, up until now mgmt applications did not really know what
values to pass because we were not exposing caches of the host.
With recent enough kernel these are exposed under sysfs and with
a bit of parsing we can extend our capabilities XML. The sysfs
structure is documented in kernel's
Documentation/admin-guide/mm/numaperf.rst and basically maps in
1:1 fashion to our virNumaCache structure.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
docs/schemas/capability.rng | 4 +
src/conf/capabilities.c | 149 ++++++++++++++++++++++++++++++++-
src/conf/capabilities.h | 4 +-
src/libxl/libxl_capabilities.c | 3 +-
src/test/test_driver.c | 3 +-
tests/testutils.c | 3 +-
6 files changed, 158 insertions(+), 8 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 9332daf6a6..7b60676070 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -1535,6 +1547,129 @@ virCapabilitiesGetNUMAPagesInfo(int node,
}
+static int
+virCapabilitiesGetNodeCacheReadFile(const char *prefix,
+ const char *dir,
+ const char *file,
+ unsigned int *value)
+{
+ g_autofree char *path = gstrdup_printf("%s/%s/%s", prefix, dir, file);
Use g_build_filename() instead.
As a side note, I also wonder if there is an easier and consistent way
that can also handle things like "%s/something%s/%s" etc., but one
temporary autofree variable is probably fine.
+ int rv = virFileReadValueUint(value, "%s", path);
+
This clearly shows that my (pre-glib) ideas for virFileReadValue*()
functions were overcomplicated and the functions should just take path
without a format, especially when we now have g_autofree,
g_build_filename() and others. That's just a thought, unrelated to your
series, though.