summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bhyvectl
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2014-08-17 00:52:07 +0000
committergrehan <grehan@FreeBSD.org>2014-08-17 00:52:07 +0000
commite83027edbbda961289c2ed185571fb6272b4f756 (patch)
tree3b7195b83b06e50b75be8a3b3f33487a98019aa8 /usr.sbin/bhyvectl
parentc64921fe8da3adcc50639ba2f5a0a66c6978c44e (diff)
downloadFreeBSD-src-e83027edbbda961289c2ed185571fb6272b4f756.zip
FreeBSD-src-e83027edbbda961289c2ed185571fb6272b4f756.tar.gz
MFC r266933
Activate vcpus from bhyve(8) using the ioctl VM_ACTIVATE_CPU instead of doing it implicitly in vmm.ko.
Diffstat (limited to 'usr.sbin/bhyvectl')
-rw-r--r--usr.sbin/bhyvectl/bhyvectl.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index ceee33a..e77f0d7 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -193,7 +193,9 @@ usage(void)
" [--assert-lapic-lvt=<pin>]\n"
" [--inject-nmi]\n"
" [--force-reset]\n"
- " [--force-poweroff]\n",
+ " [--force-poweroff]\n"
+ " [--get-active-cpus]\n"
+ " [--get-suspended-cpus]\n",
progname);
exit(1);
}
@@ -203,6 +205,7 @@ static int inject_nmi, assert_lapic_lvt;
static int force_reset, force_poweroff;
static const char *capname;
static int create, destroy, get_lowmem, get_highmem;
+static int get_active_cpus, get_suspended_cpus;
static uint64_t memsize;
static int set_cr0, get_cr0, set_cr3, get_cr3, set_cr4, get_cr4;
static int set_efer, get_efer;
@@ -390,6 +393,25 @@ enum {
ASSERT_LAPIC_LVT,
};
+static void
+print_cpus(const char *banner, const cpuset_t *cpus)
+{
+ int i, first;
+
+ first = 1;
+ printf("%s:\t", banner);
+ if (!CPU_EMPTY(cpus)) {
+ for (i = 0; i < CPU_SETSIZE; i++) {
+ if (CPU_ISSET(i, cpus)) {
+ printf("%s%d", first ? " " : ", ", i);
+ first = 0;
+ }
+ }
+ } else
+ printf(" (none)");
+ printf("\n");
+}
+
int
main(int argc, char *argv[])
{
@@ -401,6 +423,7 @@ main(int argc, char *argv[])
uint64_t ctl, eptp, bm, addr, u64, pteval[4], *pte;
struct vmctx *ctx;
int wired;
+ cpuset_t cpus;
uint64_t cr0, cr3, cr4, dr7, rsp, rip, rflags, efer, pat;
uint64_t rax, rbx, rcx, rdx, rsi, rdi, rbp;
@@ -570,6 +593,8 @@ main(int argc, char *argv[])
{ "inject-nmi", NO_ARG, &inject_nmi, 1 },
{ "force-reset", NO_ARG, &force_reset, 1 },
{ "force-poweroff", NO_ARG, &force_poweroff, 1 },
+ { "get-active-cpus", NO_ARG, &get_active_cpus, 1 },
+ { "get-suspended-cpus", NO_ARG, &get_suspended_cpus, 1 },
{ NULL, 0, NULL, 0 }
};
@@ -1529,6 +1554,18 @@ main(int argc, char *argv[])
}
}
+ if (!error && (get_active_cpus || get_all)) {
+ error = vm_active_cpus(ctx, &cpus);
+ if (!error)
+ print_cpus("active cpus", &cpus);
+ }
+
+ if (!error && (get_suspended_cpus || get_all)) {
+ error = vm_suspended_cpus(ctx, &cpus);
+ if (!error)
+ print_cpus("suspended cpus", &cpus);
+ }
+
if (!error && run) {
error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RIP, &rip);
assert(error == 0);
OpenPOWER on IntegriCloud