git: c76e4b89d9b8 - main - bhyve: Use vm_get_topology to query kernel's maximum vCPU count.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 09 Mar 2022 23:57:35 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c76e4b89d9b87b2450107b29f229d374dc156352 commit c76e4b89d9b87b2450107b29f229d374dc156352 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2022-03-09 23:39:23 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2022-03-09 23:39:23 +0000 bhyve: Use vm_get_topology to query kernel's maximum vCPU count. Reviewed by: grehan Differential Revision: https://reviews.freebsd.org/D34493 --- 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 4989915791b5..867938af050d 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -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); }