New functionalities:
- connectGetMaxVcpus - on bhyve hardcode this value to 16
- nodeGetFreeMemory - do not use physmem_get on FreeBSD, since
it might get wrong value on systems with
more than 100GB of RAM
- nodeGetCPUMap - wrapper only for mapping function, currently not
supported by FreeBSD
- nodeSet/GetMemoryParameters - wrapper only for future improvements,
currently not supported by FreeBSD
---
src/bhyve/bhyve_driver.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
src/nodeinfo.c | 19 ++++++++++++++
2 files changed, 85 insertions(+)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index baa3340..2e6a8cb 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -694,6 +694,67 @@ cleanup:
return -1;
}
+static int
+bhyveConnectGetMaxVcpus(virConnectPtr conn ATTRIBUTE_UNUSED,
+ const char *type) {
+ if (virConnectGetMaxVcpusEnsureACL(conn) < 0)
+ return -1;
+
+ /*
+ * Bhyve supports up to 16 VCPUs, but offers no method to check this
+ * value. Hardcode 16...
+ */
+ if (!type || STRCASEEQ(type, "bhyve"))
+ return 16;
+
+ virReportError(VIR_ERR_INVALID_ARG, _("unknown type '%s'"), type);
+ return -1;
+}
+
+static unsigned long long
+bhyveNodeGetFreeMemory(virConnectPtr conn)
+{
+ if (virNodeGetFreeMemoryEnsureACL(conn) < 0)
+ return 0;
+
+ return nodeGetFreeMemory();
+}
+
+static int
+bhyveNodeGetCPUMap(virConnectPtr conn,
+ unsigned char **cpumap,
+ unsigned int *online,
+ unsigned int flags)
+{
+ if (virNodeGetCPUMapEnsureACL(conn) < 0)
+ return -1;
+
+ return nodeGetCPUMap(cpumap, online, flags);
+}
+
+static int
+bhyveNodeGetMemoryParameters(virConnectPtr conn,
+ virTypedParameterPtr params,
+ int *nparams,
+ unsigned int flags)
+{
+ if (virNodeGetMemoryParametersEnsureACL(conn) < 0)
+ return -1;
+
+ return nodeGetMemoryParameters(params, nparams, flags);
+}
+
+static int
+bhyveNodeSetMemoryParameters(virConnectPtr conn,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags)
+{
+ if (virNodeSetMemoryParametersEnsureACL(conn) < 0)
+ return -1;
+
+ return nodeSetMemoryParameters(params, nparams, flags);
+}
static virDriver bhyveDriver = {
.no = VIR_DRV_BHYVE,
@@ -722,6 +783,11 @@ static virDriver bhyveDriver = {
.nodeGetCPUStats = bhyveNodeGetCPUStats, /* 1.2.2 */
.nodeGetMemoryStats = bhyveNodeGetMemoryStats, /* 1.2.2 */
.nodeGetInfo = bhyveNodeGetInfo, /* 1.2.3 */
+ .connectGetMaxVcpus = bhyveConnectGetMaxVcpus, /* 1.2.3 */
+ .nodeGetFreeMemory = bhyveNodeGetFreeMemory, /* 1.2.3 */
+ .nodeGetCPUMap = bhyveNodeGetCPUMap, /* 1.2.3 */
+ .nodeGetMemoryParameters = bhyveNodeGetMemoryParameters, /* 1.2.3 */
+ .nodeSetMemoryParameters = bhyveNodeSetMemoryParameters, /* 1.2.3 */
};
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 6d33f64..7996d55 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -1699,6 +1699,24 @@ nodeGetCellsFreeMemoryFake(unsigned long long *freeMems,
static unsigned long long
nodeGetFreeMemoryFake(void)
{
+#if defined(__FreeBSD__)
+ unsigned long pagesize = getpagesize();
+ u_int value;
+ size_t value_size = sizeof(value);
+ unsigned long long freemem;
+
+ if (sysctlbyname("vm.stats.vm.v_free_count", &value,
+ &value_size, NULL, 0) < 0) {
+ virReportSystemError(errno, "%s",
+ _("sysctl failed for vm.stats.vm.v_free_count"));
+ return 0;
+ }
+
+ freemem = value;
+ freemem = freemem * (unsigned long long)pagesize;
+
+ return freemem;
+#else
double avail = physmem_available();
unsigned long long ret;
@@ -1709,6 +1727,7 @@ nodeGetFreeMemoryFake(void)
}
return ret;
+#endif
}
/* returns 1 on success, 0 if the detection failed and -1 on hard error */
--
1.9.0