From: Roman Bogorodskiy Date: Sat, 7 Mar 2026 07:35:37 +0000 (+0000) Subject: util: extend virHostCPUGetInfo() for FreeBSD X-Git-Tag: v12.2.0-rc1~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f25afba55643a1cfe912a0561787f4bc356a45a;p=thirdparty%2Flibvirt.git util: extend virHostCPUGetInfo() for FreeBSD Extend virHostCPUGetInfo() to report more data on FreeBSD, such as: - NUMA domain count - CPU core count - CPU threads per core count Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 113aa6881e..7cecb4b2c8 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1014,6 +1014,22 @@ virHostCPUGetInfo(virArch hostarch G_GNUC_UNUSED, *mhz = cpu_freq / 1000000; # endif +# ifdef __FreeBSD__ +# define FILL_DATA_SYSCTL(var, sysctl, error_msg) \ + do { \ + size_t _len = sizeof(*var); \ + if (sysctlbyname(sysctl, var, &_len, NULL, 0) < 0) { \ + virReportSystemError(errno, "%s", error_msg); \ + return -1; \ + } \ + } while (0) + + FILL_DATA_SYSCTL(nodes, "vm.ndomains", _("cannot obtain NUMA domain count")); + FILL_DATA_SYSCTL(cores, "kern.smp.cores", _("cannot obtain CPU core count")); + FILL_DATA_SYSCTL(threads, "kern.smp.threads_per_core", + _("cannot obtain CPU threads per core")); +# endif /* __FreeBSD__ */ + return 0; #else /* XXX Solaris will need an impl later if they port QEMU driver */