git: 31649c585002 - stable/13 - bhyve: Use vm_get_topology to query kernel's maximum vCPU count.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 11 May 2022 18:56:11 UTC
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=31649c58500230531e848ecc77283097668bfda6 commit 31649c58500230531e848ecc77283097668bfda6 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2022-03-09 23:39:23 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2022-05-11 18:53:12 +0000 bhyve: Use vm_get_topology to query kernel's maximum vCPU count. Reviewed by: grehan Differential Revision: https://reviews.freebsd.org/D34493 (cherry picked from commit c76e4b89d9b87b2450107b29f229d374dc156352) --- usr.sbin/bhyve/bhyverun.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 3a474fcdf270..3a2b91c760e4 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -1000,16 +1000,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); }