Skip to content

Commit

Permalink
OS-6665 Would like mechanism to determine how many vcpus bhyve supports
Browse files Browse the repository at this point in the history
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Mike Gerdts <mike.gerdts@joyent.com>
Approved by: Patrick Mooney <patrick.mooney@joyent.com>
  • Loading branch information
jjelinek committed Mar 15, 2018
1 parent d8aa921 commit 82b4be0
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions usr/src/lib/brand/bhyve/zone/bhhwcompat.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
*/

/*
* Exit 0 if the current hardware is bhyve-compatible, non-zero otherwise.
* A '-v' option can be used to print the incompatibility reason provided by
* the kernel.
* With no option, exit 0 if the current hardware is bhyve-compatible, non-zero
* otherwise. A '-v' option can be used to print the incompatibility reason
* provided by the kernel.
*
* The -c option can be used to print the number of virtual CPUs supported by
* bhyve build.
*/

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/vmm.h>

#include <sys/param.h>
#include <sys/cpuset.h>
Expand All @@ -32,7 +36,7 @@
static void
usage()
{
fprintf(stderr, "bhhwcompat [-v]\n");
fprintf(stderr, "bhhwcompat [-cv]\n");
exit(1);
}

Expand All @@ -41,10 +45,14 @@ main(int argc, char *argv[])
{
int fd, c;
char emsg[128];
boolean_t max_cpu = B_FALSE;
boolean_t verbose = B_FALSE;

while ((c = getopt(argc, argv, "v")) != -1) {
while ((c = getopt(argc, argv, "cv")) != -1) {
switch (c) {
case 'c':
max_cpu = B_TRUE;
break;
case 'v':
verbose = B_TRUE;
break;
Expand All @@ -53,6 +61,10 @@ main(int argc, char *argv[])
}
}

if (max_cpu) {
(void) printf("%d\n", VM_MAXCPU);
}

if ((fd = open(VMM_CTL_DEV, O_RDONLY | O_EXCL)) < 0) {
if (verbose)
fprintf(stderr, "missing %s\n", VMM_CTL_DEV);
Expand Down

0 comments on commit 82b4be0

Please sign in to comment.