mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
bhyve: host API support
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
This commit is contained in:
parent
ba08c5932e
commit
bc93c34ef6
@ -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 */
|
||||
};
|
||||
|
||||
|
||||
|
@ -1699,6 +1699,23 @@ 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 * (unsigned long long)pagesize;
|
||||
|
||||
return freemem;
|
||||
#else
|
||||
double avail = physmem_available();
|
||||
unsigned long long ret;
|
||||
|
||||
@ -1709,6 +1726,7 @@ nodeGetFreeMemoryFake(void)
|
||||
}
|
||||
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* returns 1 on success, 0 if the detection failed and -1 on hard error */
|
||||
|
Loading…
x
Reference in New Issue
Block a user