bhyve: Use vm_get_topology to query kernel's maximum vCPU count.

Reviewed by:	grehan
Differential Revision:	https://reviews.freebsd.org/D34493
This commit is contained in:
John Baldwin 2022-03-09 15:39:23 -08:00
parent fd6f92946f
commit c76e4b89d9

View file

@ -1001,16 +1001,20 @@ vm_loop(struct vmctx *ctx, int vcpu, uint64_t startrip)
static int
num_vcpus_allowed(struct vmctx *ctx)
{
uint16_t sockets, cores, threads, maxcpus;
int tmp, error;
error = vm_get_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, &tmp);
/*
* The guest is allowed to spinup more than one processor only if the
* UNRESTRICTED_GUEST capability is available.
*/
error = vm_get_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, &tmp);
if (error != 0)
return (1);
error = vm_get_topology(ctx, &sockets, &cores, &threads, &maxcpus);
if (error == 0)
return (VM_MAXCPU);
return (maxcpus);
else
return (1);
}